]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Create the pimreg per vrf
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 17 May 2017 20:21:33 +0000 (16:21 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 24 Jul 2017 17:51:34 +0000 (13:51 -0400)
pimd/pim_cmd.c
pimd/pim_iface.c
pimd/pim_iface.h
pimd/pim_ifchannel.c
pimd/pim_register.c
pimd/pim_upstream.c
pimd/pimd.h

index ff0167de30692363f1e6ac88056802a8d7787efd..1faf1114fb8e022ea3258d7ba4e59f8f2f865f28 100644 (file)
@@ -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;
 }
index a6b25511c84e610eb902dffa130ae3e968b95e9c..70d013e5e7ff831c072fcf256e44f912aebb3a6b 100644 (file)
@@ -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);
        }
 }
 
index 9aab43ed93a899f374621f34469b4624bdb42a15..16e62f6da9afa724718aab3cd0c4215f89910b8a 100644 (file)
@@ -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);
index 058f99ca4d807f1c196fb1fde08fc72631311e84..099c7eef727dd5fd8c082f6d820cd41e1cf3ed7d 100644 (file)
@@ -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);
        }
 
index 1cbe1dcf7ff00e78ccf866ccc639f838a36f6ed3..3d783923de059492fa7677314edc4858f4f3d7c6 100644 (file)
@@ -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;
index 735f5ef404af7a460235f7e390f537ceb5723de7..e77b026cbfa376754ccbd2943da44fb3943d5a58 100644 (file)
@@ -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);
        }
 }
index 06ca4343f6a373eea1683cb8f546d0d9a42e3e32..57be41154b3dd4a73b661211cc6299abf890b013 100644 (file)
@@ -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