summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pimd/pim_bsm.c126
-rw-r--r--pimd/pim_bsm.h6
-rw-r--r--pimd/pim_cmd.c119
3 files changed, 123 insertions, 128 deletions
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index b7207aa21..2078a859e 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -70,7 +70,7 @@ static void pim_bsm_rpinfo_free(struct bsm_rpinfo *bsrp_info)
XFREE(MTYPE_PIM_BSRP_INFO, bsrp_info);
}
-void pim_bsm_rpinfos_free(struct bsm_rpinfos_head *head)
+static void pim_bsm_rpinfos_free(struct bsm_rpinfos_head *head)
{
struct bsm_rpinfo *bsrp_info;
@@ -78,14 +78,14 @@ void pim_bsm_rpinfos_free(struct bsm_rpinfos_head *head)
pim_bsm_rpinfo_free(bsrp_info);
}
-void pim_free_bsgrp_data(struct bsgrp_node *bsgrp_node)
+static void pim_free_bsgrp_data(struct bsgrp_node *bsgrp_node)
{
pim_bsm_rpinfos_free(bsgrp_node->bsrp_list);
pim_bsm_rpinfos_free(bsgrp_node->partial_bsrp_list);
XFREE(MTYPE_PIM_BSGRP_NODE, bsgrp_node);
}
-void pim_free_bsgrp_node(struct route_table *rt, struct prefix *grp)
+static void pim_free_bsgrp_node(struct route_table *rt, struct prefix *grp)
{
struct route_node *rn;
@@ -102,7 +102,7 @@ static void pim_bsm_frag_free(struct bsm_frag *bsfrag)
XFREE(MTYPE_PIM_BSM_FRAG, bsfrag);
}
-void pim_bsm_frags_free(struct bsm_scope *scope)
+static void pim_bsm_frags_free(struct bsm_scope *scope)
{
struct bsm_frag *bsfrag;
@@ -202,7 +202,7 @@ static int pim_on_bs_timer(struct thread *t)
return 0;
}
-void pim_bs_timer_stop(struct bsm_scope *scope)
+static void pim_bs_timer_stop(struct bsm_scope *scope)
{
if (PIM_DEBUG_BSM)
zlog_debug("%s : BS timer being stopped of sz: %d", __func__,
@@ -569,6 +569,122 @@ static void pim_bsm_update(struct pim_instance *pim, struct in_addr bsr,
pim->global_scope.current_bsr_last_ts = pim_time_monotonic_sec();
}
+void pim_bsm_clear(struct pim_instance *pim)
+{
+ struct route_node *rn;
+ struct route_node *rpnode;
+ struct bsgrp_node *bsgrp;
+ struct prefix nht_p;
+ struct prefix g_all;
+ struct rp_info *rp_all;
+ struct pim_upstream *up;
+ struct rp_info *rp_info;
+
+ if (pim->global_scope.current_bsr.s_addr)
+ pim_nht_bsr_del(pim, pim->global_scope.current_bsr);
+
+ /* Reset scope zone data */
+ pim->global_scope.accept_nofwd_bsm = false;
+ pim->global_scope.state = ACCEPT_ANY;
+ pim->global_scope.current_bsr.s_addr = INADDR_ANY;
+ pim->global_scope.current_bsr_prio = 0;
+ pim->global_scope.current_bsr_first_ts = 0;
+ pim->global_scope.current_bsr_last_ts = 0;
+ pim->global_scope.bsm_frag_tag = 0;
+ pim_bsm_frags_free(&pim->global_scope);
+
+ pim_bs_timer_stop(&pim->global_scope);
+
+ for (rn = route_top(pim->global_scope.bsrp_table); rn;
+ rn = route_next(rn)) {
+ bsgrp = rn->info;
+ if (!bsgrp)
+ continue;
+
+ rpnode = route_node_lookup(pim->rp_table, &bsgrp->group);
+
+ if (!rpnode) {
+ pim_free_bsgrp_node(bsgrp->scope->bsrp_table,
+ &bsgrp->group);
+ pim_free_bsgrp_data(bsgrp);
+ continue;
+ }
+
+ rp_info = (struct rp_info *)rpnode->info;
+
+ if ((!rp_info) || (rp_info->rp_src != RP_SRC_BSR)) {
+ pim_free_bsgrp_node(bsgrp->scope->bsrp_table,
+ &bsgrp->group);
+ pim_free_bsgrp_data(bsgrp);
+ continue;
+ }
+
+ /* Deregister addr with Zebra NHT */
+ nht_p.family = AF_INET;
+ nht_p.prefixlen = IPV4_MAX_BITLEN;
+ nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4;
+
+ if (PIM_DEBUG_PIM_NHT_RP) {
+ zlog_debug("%s: Deregister RP addr %pFX with Zebra ",
+ __func__, &nht_p);
+ }
+
+ pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info);
+
+ if (!str2prefix("224.0.0.0/4", &g_all))
+ return;
+
+ rp_all = pim_rp_find_match_group(pim, &g_all);
+
+ if (rp_all == rp_info) {
+ rp_all->rp.rpf_addr.family = AF_INET;
+ rp_all->rp.rpf_addr.u.prefix4.s_addr = INADDR_NONE;
+ rp_all->i_am_rp = 0;
+ } else {
+ /* Delete the rp_info from rp-list */
+ listnode_delete(pim->rp_list, rp_info);
+
+ /* Delete the rp node from rp_table */
+ rpnode->info = NULL;
+ route_unlock_node(rpnode);
+ route_unlock_node(rpnode);
+ XFREE(MTYPE_PIM_RP, rp_info);
+ }
+
+ pim_free_bsgrp_node(bsgrp->scope->bsrp_table, &bsgrp->group);
+ pim_free_bsgrp_data(bsgrp);
+ }
+ pim_rp_refresh_group_to_rp_mapping(pim);
+
+
+ frr_each (rb_pim_upstream, &pim->upstream_head, up) {
+ /* Find the upstream (*, G) whose upstream address is same as
+ * the RP
+ */
+ if (up->sg.src.s_addr != INADDR_ANY)
+ continue;
+
+ struct prefix grp;
+ struct rp_info *trp_info;
+
+ grp.family = AF_INET;
+ grp.prefixlen = IPV4_MAX_BITLEN;
+ grp.u.prefix4 = up->sg.grp;
+
+ trp_info = pim_rp_find_match_group(pim, &grp);
+
+ /* RP not found for the group grp */
+ if (pim_rpf_addr_is_inaddr_none(&trp_info->rp)) {
+ pim_upstream_rpf_clear(pim, up);
+ pim_rp_set_upstream_addr(pim, &up->upstream_addr,
+ up->sg.src, up->sg.grp);
+ } else {
+ /* RP found for the group grp */
+ pim_upstream_update(pim, up);
+ }
+ }
+}
+
static bool pim_bsm_send_intf(uint8_t *buf, int len, struct interface *ifp,
struct in_addr dst_addr)
{
diff --git a/pimd/pim_bsm.h b/pimd/pim_bsm.h
index dbfeeceec..a536b5068 100644
--- a/pimd/pim_bsm.h
+++ b/pimd/pim_bsm.h
@@ -205,6 +205,7 @@ struct bsmmsg_rpinfo {
/* API */
void pim_bsm_proc_init(struct pim_instance *pim);
void pim_bsm_proc_free(struct pim_instance *pim);
+void pim_bsm_clear(struct pim_instance *pim);
void pim_bsm_write_config(struct vty *vty, struct interface *ifp);
int pim_bsm_process(struct interface *ifp,
struct ip *ip_hdr,
@@ -214,9 +215,4 @@ int pim_bsm_process(struct interface *ifp,
bool pim_bsm_new_nbr_fwd(struct pim_neighbor *neigh, struct interface *ifp);
struct bsgrp_node *pim_bsm_get_bsgrp_node(struct bsm_scope *scope,
struct prefix *grp);
-void pim_bs_timer_stop(struct bsm_scope *scope);
-void pim_bsm_frags_free(struct bsm_scope *scope);
-void pim_bsm_rpinfos_free(struct bsm_rpinfos_head *head);
-void pim_free_bsgrp_data(struct bsgrp_node *bsgrp_node);
-void pim_free_bsgrp_node(struct route_table *rt, struct prefix *grp);
#endif
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 518fcb00e..82627e5e8 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -4051,123 +4051,6 @@ DEFUN (clear_ip_pim_oil,
return CMD_SUCCESS;
}
-static void clear_pim_bsr_db(struct pim_instance *pim)
-{
- struct route_node *rn;
- struct route_node *rpnode;
- struct bsgrp_node *bsgrp;
- struct prefix nht_p;
- struct prefix g_all;
- struct rp_info *rp_all;
- struct pim_upstream *up;
- struct rp_info *rp_info;
-
- if (pim->global_scope.current_bsr.s_addr)
- pim_nht_bsr_del(pim, pim->global_scope.current_bsr);
-
- /* Reset scope zone data */
- pim->global_scope.accept_nofwd_bsm = false;
- pim->global_scope.state = ACCEPT_ANY;
- pim->global_scope.current_bsr.s_addr = INADDR_ANY;
- pim->global_scope.current_bsr_prio = 0;
- pim->global_scope.current_bsr_first_ts = 0;
- pim->global_scope.current_bsr_last_ts = 0;
- pim->global_scope.bsm_frag_tag = 0;
- pim_bsm_frags_free(&pim->global_scope);
-
- pim_bs_timer_stop(&pim->global_scope);
-
- for (rn = route_top(pim->global_scope.bsrp_table); rn;
- rn = route_next(rn)) {
- bsgrp = rn->info;
- if (!bsgrp)
- continue;
-
- rpnode = route_node_lookup(pim->rp_table, &bsgrp->group);
-
- if (!rpnode) {
- pim_free_bsgrp_node(bsgrp->scope->bsrp_table,
- &bsgrp->group);
- pim_free_bsgrp_data(bsgrp);
- continue;
- }
-
- rp_info = (struct rp_info *)rpnode->info;
-
- if ((!rp_info) || (rp_info->rp_src != RP_SRC_BSR)) {
- pim_free_bsgrp_node(bsgrp->scope->bsrp_table,
- &bsgrp->group);
- pim_free_bsgrp_data(bsgrp);
- continue;
- }
-
- /* Deregister addr with Zebra NHT */
- nht_p.family = AF_INET;
- nht_p.prefixlen = IPV4_MAX_BITLEN;
- nht_p.u.prefix4 = rp_info->rp.rpf_addr.u.prefix4;
-
- if (PIM_DEBUG_PIM_NHT_RP) {
- zlog_debug("%s: Deregister RP addr %pFX with Zebra ",
- __func__, &nht_p);
- }
-
- pim_delete_tracked_nexthop(pim, &nht_p, NULL, rp_info);
-
- if (!str2prefix("224.0.0.0/4", &g_all))
- return;
-
- rp_all = pim_rp_find_match_group(pim, &g_all);
-
- if (rp_all == rp_info) {
- rp_all->rp.rpf_addr.family = AF_INET;
- rp_all->rp.rpf_addr.u.prefix4.s_addr = INADDR_NONE;
- rp_all->i_am_rp = 0;
- } else {
- /* Delete the rp_info from rp-list */
- listnode_delete(pim->rp_list, rp_info);
-
- /* Delete the rp node from rp_table */
- rpnode->info = NULL;
- route_unlock_node(rpnode);
- route_unlock_node(rpnode);
- XFREE(MTYPE_PIM_RP, rp_info);
- }
-
- pim_free_bsgrp_node(bsgrp->scope->bsrp_table, &bsgrp->group);
- pim_free_bsgrp_data(bsgrp);
- }
- pim_rp_refresh_group_to_rp_mapping(pim);
-
-
- frr_each (rb_pim_upstream, &pim->upstream_head, up) {
- /* Find the upstream (*, G) whose upstream address is same as
- * the RP
- */
- if (up->sg.src.s_addr != INADDR_ANY)
- continue;
-
- struct prefix grp;
- struct rp_info *trp_info;
-
- grp.family = AF_INET;
- grp.prefixlen = IPV4_MAX_BITLEN;
- grp.u.prefix4 = up->sg.grp;
-
- trp_info = pim_rp_find_match_group(pim, &grp);
-
- /* RP not found for the group grp */
- if (pim_rpf_addr_is_inaddr_none(&trp_info->rp)) {
- pim_upstream_rpf_clear(pim, up);
- pim_rp_set_upstream_addr(pim, &up->upstream_addr,
- up->sg.src, up->sg.grp);
- } else {
- /* RP found for the group grp */
- pim_upstream_update(pim, up);
- }
- }
-}
-
-
DEFUN (clear_ip_pim_bsr_db,
clear_ip_pim_bsr_db_cmd,
"clear ip pim [vrf NAME] bsr-data",
@@ -4183,7 +4066,7 @@ DEFUN (clear_ip_pim_bsr_db,
if (!vrf)
return CMD_WARNING;
- clear_pim_bsr_db(vrf->info);
+ pim_bsm_clear(vrf->info);
return CMD_SUCCESS;
}