From 43e40fdfe10dc302814034550b023d49ce3850ba Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 17 May 2017 16:21:33 -0400 Subject: [PATCH] pimd: Create the pimreg per vrf --- pimd/pim_cmd.c | 5 ++++- pimd/pim_iface.c | 17 +++++++---------- pimd/pim_iface.h | 3 +-- pimd/pim_ifchannel.c | 11 +++++++---- pimd/pim_register.c | 4 ++-- pimd/pim_upstream.c | 16 ++++++++-------- pimd/pimd.h | 2 ++ 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index ff0167de30..1faf1114fb 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -5495,13 +5495,16 @@ DEFUN (interface_ip_pim_sm, PIM_STR IFACE_PIM_SM_STR) { + struct pim_interface *pim_ifp; + VTY_DECLVAR_CONTEXT(interface, ifp); if (!pim_cmd_interface_add(ifp)) { vty_out(vty, "Could not enable PIM SM on interface\n"); return CMD_WARNING_CONFIG_FAILED; } - pim_if_create_pimreg(); + pim_ifp = ifp->info; + pim_if_create_pimreg(pim_ifp->pim); return CMD_SUCCESS; } diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index a6b25511c8..70d013e5e7 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -44,7 +44,6 @@ #include "pim_rp.h" #include "pim_nht.h" -struct interface *pim_regiface = NULL; struct list *pim_ifchannel_list = NULL; static int pim_iface_vif_index[MAXVIFS]; @@ -1084,9 +1083,6 @@ struct interface *pim_if_find_by_vif_index(ifindex_t vif_index) struct listnode *ifnode; struct interface *ifp; - if (vif_index == 0) - return if_lookup_by_name("pimreg", pimg->vrf_id); - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(pimg->vrf_id), ifnode, ifp)) { if (ifp->info) { struct pim_interface *pim_ifp; @@ -1563,14 +1559,15 @@ void pim_if_update_assert_tracking_desired(struct interface *ifp) * The pimreg is a special interface that we have that is not * quite an inteface but a VIF is created for it. */ -void pim_if_create_pimreg(void) +void pim_if_create_pimreg(struct pim_instance *pim) { - if (!pim_regiface) { - pim_regiface = - if_create("pimreg", strlen("pimreg"), pimg->vrf_id); - pim_regiface->ifindex = PIM_OIF_PIM_REGISTER_VIF; - pim_if_new(pim_regiface, 0, 0); + if (!pim->regiface) { + pim->regiface = + if_create("pimreg", strlen("pimreg"), pim->vrf_id); + pim->regiface->ifindex = PIM_OIF_PIM_REGISTER_VIF; + + pim_if_new(pim->regiface, 0, 0); } } diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h index 9aab43ed93..16e62f6da9 100644 --- a/pimd/pim_iface.h +++ b/pimd/pim_iface.h @@ -140,7 +140,6 @@ struct pim_interface { struct bfd_info *bfd_info; }; -extern struct interface *pim_regiface; extern struct list *pim_ifchannel_list; /* if default_holdtime is set (>= 0), use it; @@ -203,7 +202,7 @@ void pim_if_update_join_desired(struct pim_interface *pim_ifp); void pim_if_update_assert_tracking_desired(struct interface *ifp); -void pim_if_create_pimreg(void); +void pim_if_create_pimreg(struct pim_instance *pim); int pim_if_connected_to_source(struct interface *ifp, struct in_addr src); int pim_update_source_set(struct interface *ifp, struct in_addr source); diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index 058f99ca4d..099c7eef72 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -998,6 +998,7 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, { struct pim_ifchannel *ch, *starch; struct pim_interface *pim_ifp; + struct pim_instance *pim; /* PIM enabled on interface? */ pim_ifp = ifp->info; @@ -1006,6 +1007,8 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, if (!PIM_IF_TEST_PIM(pim_ifp->options)) return 0; + pim = pim_ifp->pim; + /* skip (*,G) ch creation if G is of type SSM */ if (sg->src.s_addr == INADDR_ANY) { if (pim_is_grp_ssm(sg->grp)) { @@ -1048,10 +1051,10 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, } } - if (pimg->spt.switchover == PIM_SPT_INFINITY) { + if (pim->spt.switchover == PIM_SPT_INFINITY) { if (pimg->spt.plist) { struct prefix_list *plist = prefix_list_lookup( - AFI_IP, pimg->spt.plist); + AFI_IP, pim->spt.plist); struct prefix g; g.family = AF_INET; g.prefixlen = IPV4_MAX_PREFIXLEN; @@ -1060,12 +1063,12 @@ int pim_ifchannel_local_membership_add(struct interface *ifp, if (prefix_list_apply(plist, &g) == PREFIX_DENY) { pim_channel_add_oif( - up->channel_oil, pim_regiface, + up->channel_oil, pim->regiface, PIM_OIF_FLAG_PROTO_IGMP); } } } else - pim_channel_add_oif(up->channel_oil, pim_regiface, + pim_channel_add_oif(up->channel_oil, pim->regiface, PIM_OIF_FLAG_PROTO_IGMP); } diff --git a/pimd/pim_register.c b/pimd/pim_register.c index 1cbe1dcf7f..3d783923de 100644 --- a/pimd/pim_register.c +++ b/pimd/pim_register.c @@ -55,7 +55,7 @@ void pim_register_join(struct pim_upstream *up) return; } - pim_channel_add_oif(up->channel_oil, pim_regiface, + pim_channel_add_oif(up->channel_oil, pimg->regiface, PIM_OIF_FLAG_PROTO_PIM); up->reg_state = PIM_REG_JOIN; } @@ -138,7 +138,7 @@ int pim_register_stop_recv(uint8_t *buf, int buf_size) break; case PIM_REG_JOIN: upstream->reg_state = PIM_REG_PRUNE; - pim_channel_del_oif(upstream->channel_oil, pim_regiface, + pim_channel_del_oif(upstream->channel_oil, pimg->regiface, PIM_OIF_FLAG_PROTO_PIM); pim_upstream_start_register_stop_timer(upstream, 0); break; diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 735f5ef404..e77b026cbf 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -491,7 +491,7 @@ void pim_upstream_register_reevaluate(void) up->sg_str); /* remove regiface from the OIL if it is there*/ pim_channel_del_oif(up->channel_oil, - pim_regiface, + pimg->regiface, PIM_OIF_FLAG_PROTO_PIM); up->reg_state = PIM_REG_NOINFO; } @@ -503,7 +503,7 @@ void pim_upstream_register_reevaluate(void) "Register %s as G is now ASM", up->sg_str); pim_channel_add_oif(up->channel_oil, - pim_regiface, + pimg->regiface, PIM_OIF_FLAG_PROTO_PIM); up->reg_state = PIM_REG_JOIN; } @@ -1032,7 +1032,7 @@ static void pim_upstream_fhr_kat_expiry(struct pim_upstream *up) /* stop reg-stop timer */ THREAD_OFF(up->t_rs_timer); /* remove regiface from the OIL if it is there*/ - pim_channel_del_oif(up->channel_oil, pim_regiface, + pim_channel_del_oif(up->channel_oil, pimg->regiface, PIM_OIF_FLAG_PROTO_PIM); /* clear the register state */ up->reg_state = PIM_REG_NOINFO; @@ -1310,7 +1310,7 @@ static int pim_upstream_register_stop_timer(struct thread *t) switch (up->reg_state) { case PIM_REG_JOIN_PENDING: up->reg_state = PIM_REG_JOIN; - pim_channel_add_oif(up->channel_oil, pim_regiface, + pim_channel_add_oif(up->channel_oil, pimg->regiface, PIM_OIF_FLAG_PROTO_PIM); break; case PIM_REG_JOIN: @@ -1650,7 +1650,7 @@ void pim_upstream_add_lhr_star_pimreg(void) if (!PIM_UPSTREAM_FLAG_TEST_SRC_IGMP(up->flags)) continue; - pim_channel_add_oif(up->channel_oil, pim_regiface, + pim_channel_add_oif(up->channel_oil, pimg->regiface, PIM_OIF_FLAG_PROTO_IGMP); } } @@ -1697,17 +1697,17 @@ void pim_upstream_remove_lhr_star_pimreg(const char *nlist) continue; if (!nlist) { - pim_channel_del_oif(up->channel_oil, pim_regiface, + pim_channel_del_oif(up->channel_oil, pimg->regiface, PIM_OIF_FLAG_PROTO_IGMP); continue; } g.u.prefix4 = up->sg.grp; apply_new = prefix_list_apply(np, &g); if (apply_new == PREFIX_DENY) - pim_channel_add_oif(up->channel_oil, pim_regiface, + pim_channel_add_oif(up->channel_oil, pimg->regiface, PIM_OIF_FLAG_PROTO_IGMP); else - pim_channel_del_oif(up->channel_oil, pim_regiface, + pim_channel_del_oif(up->channel_oil, pimg->regiface, PIM_OIF_FLAG_PROTO_IGMP); } } diff --git a/pimd/pimd.h b/pimd/pimd.h index 06ca4343f6..57be41154b 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -258,6 +258,8 @@ struct pim_instance { int64_t mroute_add_last; int64_t mroute_del_events; int64_t mroute_del_last; + + struct interface *regiface; }; extern struct pim_instance *pimg; // Pim Global Instance -- 2.39.5