diff options
author | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-04-22 20:10:07 +0200 |
---|---|---|
committer | Rafael Zalamena <rzalamena@opensourcerouting.org> | 2021-06-25 20:06:20 +0200 |
commit | 56697b3e0affbab3d7b89af44c8b9ccec28d91c4 (patch) | |
tree | 51bfc1172b8ab6cfef762b4e65773406e997f808 /pimd/pim_nb_config.c | |
parent | yang: simplify MSDP peer handling (diff) | |
download | frr-56697b3e0affbab3d7b89af44c8b9ccec28d91c4.tar.xz frr-56697b3e0affbab3d7b89af44c8b9ccec28d91c4.zip |
pimd: rework MSDP northbound integration
Simplify the MSDP handling functions and allow source changes.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
Diffstat (limited to 'pimd/pim_nb_config.c')
-rw-r--r-- | pimd/pim_nb_config.c | 143 |
1 files changed, 21 insertions, 122 deletions
diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index b70656ea7..d91aa61e7 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -243,65 +243,6 @@ static int pim_ssm_cmd_worker(struct pim_instance *pim, const char *plist, return ret; } -static int ip_msdp_peer_cmd_worker(struct pim_instance *pim, - struct in_addr peer_addr, - struct in_addr local_addr, - char *errmsg, size_t errmsg_len) -{ - enum pim_msdp_err result; - int ret = NB_OK; - - result = pim_msdp_peer_add(pim, peer_addr, local_addr, "default", - NULL /* mp_p */); - switch (result) { - case PIM_MSDP_ERR_NONE: - break; - case PIM_MSDP_ERR_OOM: - ret = NB_ERR; - snprintf(errmsg, errmsg_len, - "%% Out of memory"); - break; - case PIM_MSDP_ERR_PEER_EXISTS: - ret = NB_ERR; - snprintf(errmsg, errmsg_len, - "%% Peer exists"); - break; - case PIM_MSDP_ERR_MAX_MESH_GROUPS: - ret = NB_ERR; - snprintf(errmsg, errmsg_len, - "%% Only one mesh-group allowed currently"); - break; - default: - ret = NB_ERR; - snprintf(errmsg, errmsg_len, - "%% peer add failed"); - } - - return ret; -} - -static int ip_no_msdp_peer_cmd_worker(struct pim_instance *pim, - struct in_addr peer_addr, - char *errmsg, size_t errmsg_len) -{ - enum pim_msdp_err result; - - result = pim_msdp_peer_del(pim, peer_addr); - switch (result) { - case PIM_MSDP_ERR_NONE: - break; - case PIM_MSDP_ERR_NO_PEER: - snprintf(errmsg, errmsg_len, - "%% Peer does not exist"); - break; - default: - snprintf(errmsg, errmsg_len, - "%% peer del failed"); - } - - return result ? NB_ERR : NB_OK; -} - static int pim_rp_cmd_worker(struct pim_instance *pim, struct in_addr rp_addr, struct prefix group, const char *plist, @@ -1163,11 +1104,26 @@ int pim_msdp_mesh_group_members_destroy(struct nb_cb_destroy_args *args) int routing_control_plane_protocols_control_plane_protocol_pim_address_family_msdp_peer_create( struct nb_cb_create_args *args) { + struct pim_msdp_peer *mp; + struct pim_instance *pim; + struct vrf *vrf; + struct ipaddr peer_ip; + struct ipaddr source_ip; + switch (args->event) { case NB_EV_VALIDATE: case NB_EV_PREPARE: case NB_EV_ABORT: + break; case NB_EV_APPLY: + vrf = nb_running_get_entry(args->dnode, NULL, true); + pim = vrf->info; + yang_dnode_get_ip(&peer_ip, args->dnode, "./peer-ip"); + yang_dnode_get_ip(&source_ip, args->dnode, "./source-ip"); + mp = pim_msdp_peer_new(pim, &peer_ip.ipaddr_v4, + &source_ip.ipaddr_v4, + MSDP_SOLO_PEER_GROUP_NAME); + nb_running_set_entry(args->dnode, mp); break; } @@ -1177,10 +1133,7 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ms int routing_control_plane_protocols_control_plane_protocol_pim_address_family_msdp_peer_destroy( struct nb_cb_destroy_args *args) { - int result; - struct pim_instance *pim; - struct ipaddr peer_ip; - struct vrf *vrf; + struct pim_msdp_peer *mp; switch (args->event) { case NB_EV_VALIDATE: @@ -1188,16 +1141,8 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ms case NB_EV_ABORT: break; case NB_EV_APPLY: - vrf = nb_running_get_entry(args->dnode, NULL, true); - pim = vrf->info; - yang_dnode_get_ip(&peer_ip, args->dnode, "./peer-ip"); - result = ip_no_msdp_peer_cmd_worker(pim, peer_ip.ip._v4_addr, - args->errmsg, - args->errmsg_len); - - if (result) - return NB_ERR_INCONSISTENCY; - + mp = nb_running_unset_entry(args->dnode); + pim_msdp_peer_do_del(&mp); break; } @@ -1210,64 +1155,18 @@ int routing_control_plane_protocols_control_plane_protocol_pim_address_family_ms int routing_control_plane_protocols_control_plane_protocol_pim_address_family_msdp_peer_source_ip_modify( struct nb_cb_modify_args *args) { - int result; - struct vrf *vrf; - struct pim_instance *pim; - struct ipaddr peer_ip; + struct pim_msdp_peer *mp; struct ipaddr source_ip; - const struct lyd_node *mesh_group_name_dnode; - const char *mesh_group_name; switch (args->event) { case NB_EV_VALIDATE: - mesh_group_name_dnode = - yang_dnode_get(args->dnode, - "../../msdp-mesh-group/mesh-group-name"); - if (mesh_group_name_dnode) { - mesh_group_name = - yang_dnode_get_string(mesh_group_name_dnode, - "."); - if (strcmp(mesh_group_name, "default")) { - /* currently only one mesh-group can exist at a - * time - */ - snprintf(args->errmsg, args->errmsg_len, - "%% Only one mesh-group allowed currently"); - return NB_ERR_VALIDATION; - } - } - break; case NB_EV_PREPARE: case NB_EV_ABORT: break; case NB_EV_APPLY: - vrf = nb_running_get_entry(args->dnode, NULL, true); - pim = vrf->info; - yang_dnode_get_ip(&peer_ip, args->dnode, "../peer-ip"); + mp = nb_running_get_entry(args->dnode, NULL, true); yang_dnode_get_ip(&source_ip, args->dnode, NULL); - - result = ip_msdp_peer_cmd_worker(pim, peer_ip.ip._v4_addr, - source_ip.ip._v4_addr, - args->errmsg, - args->errmsg_len); - - if (result) - return NB_ERR_INCONSISTENCY; - - break; - } - - return NB_OK; -} - -int routing_control_plane_protocols_control_plane_protocol_pim_address_family_msdp_peer_source_ip_destroy( - struct nb_cb_destroy_args *args) -{ - switch (args->event) { - case NB_EV_VALIDATE: - case NB_EV_PREPARE: - case NB_EV_ABORT: - case NB_EV_APPLY: + pim_msdp_peer_change_source(mp, &source_ip.ipaddr_v4); break; } |