]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Separate pim vif index spot from ifindex
authorDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 18 Jun 2016 00:43:21 +0000 (20:43 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Sat, 18 Jun 2016 00:43:21 +0000 (20:43 -0400)
Allow pim to separate out the pim vif index from the ifindex.
This change will allow pim to work with up to 255(MAXVIFS)
interfaces, while also allowing the interface ifindex to
be whatever number it needs to be.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
18 files changed:
pimd/pim_assert.c
pimd/pim_br.c
pimd/pim_hello.c
pimd/pim_iface.c
pimd/pim_ifchannel.c
pimd/pim_igmpv3.c
pimd/pim_join.c
pimd/pim_mroute.c
pimd/pim_mroute.h
pimd/pim_msg.c
pimd/pim_neighbor.c
pimd/pim_oil.c
pimd/pim_pim.c
pimd/pim_routemap.c
pimd/pim_rp.c
pimd/pim_rpf.c
pimd/pim_static.c
pimd/pim_tlv.c

index 5dae6757164a724cc799e55129ec9f70be4930a8..9f9c9e66f0cbc62d473d2215fe72b7d1992a99bd 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "log.h"
 #include "prefix.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_str.h"
index 6958ad545db42d3cd0981df717c0cf81b72694dc..121a45fd16018f26079402d493b5362e964ade81 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "memory.h"
 #include "log.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_str.h"
index bfc128b97aa25522e7dae3eac1d2170debb0c674..21d0e5b85ce2739c52114d3a87cdfc4d90a1b084 100644 (file)
@@ -23,6 +23,7 @@
 #include <zebra.h>
 
 #include "log.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_pim.h"
index 1f818ccf51eda74acf61223781fd3a9cc15471f3..8357a26a3e4bf36499bcc819d023ebf8cf48046f 100644 (file)
@@ -607,6 +607,22 @@ struct in_addr pim_find_primary_addr(struct interface *ifp)
   return find_first_nonsec_addr(ifp);
 }
 
+static pim_iface_vif_index = 0;
+
+int
+pim_iface_next_vif_index (struct interface *ifp)
+{
+  /*
+   * The pimreg vif is always going to be in index 0
+   * of the table.
+   */
+  if (ifp->ifindex == PIM_OIF_PIM_REGISTER_VIF)
+    return 0;
+
+  pim_iface_vif_index++;
+  return pim_iface_vif_index;
+}
+
 /*
   pim_if_add_vif() uses ifindex as vif_index
 
@@ -634,13 +650,6 @@ int pim_if_add_vif(struct interface *ifp)
     return -2;
   }
 
-  if (ifp->ifindex >= MAXVIFS) {
-    zlog_warn("%s: ifindex=%d >= MAXVIFS=%d on interface %s",
-             __PRETTY_FUNCTION__,
-             ifp->ifindex, MAXVIFS, ifp->name);
-    return -3;
-  }
-
   ifaddr = pim_ifp->primary_address;
   if (ifp->ifindex != PIM_OIF_PIM_REGISTER_VIF && PIM_INADDR_IS_ANY(ifaddr)) {
     zlog_warn("%s: could not get address for interface %s ifindex=%d",
@@ -649,14 +658,23 @@ int pim_if_add_vif(struct interface *ifp)
     return -4;
   }
 
-  flags = (ifp->ifindex == PIM_OIF_PIM_REGISTER_VIF) ? VIFF_REGISTER : VIFF_USE_IFINDEX;
-  if (pim_mroute_add_vif(ifp->ifindex, ifaddr, flags)) {
+  pim_ifp->mroute_vif_index = pim_iface_next_vif_index (ifp);
+
+  if (pim_ifp->mroute_vif_index >= MAXVIFS)
+    {
+      zlog_warn("%s: Attempting to configure more than MAXVIFS=%d on pim enabled interface %s",
+               __PRETTY_FUNCTION__,
+               MAXVIFS, ifp->name);
+      return -3;
+    }
+
+  flags = (ifp->ifindex == PIM_OIF_PIM_REGISTER_VIF) ?
+    VIFF_REGISTER : VIFF_USE_IFINDEX;
+  if (pim_mroute_add_vif(ifp, ifaddr, flags)) {
     /* pim_mroute_add_vif reported error */
     return -5;
   }
 
-  pim_ifp->mroute_vif_index = ifp->ifindex;
-
   /*
     Update highest vif_index
    */
index 5271d412d1d9e7ed45838575d28c083f126258e9..abfa5cc2b7bf844c9974cd171f3c1605bdb905b9 100644 (file)
@@ -25,6 +25,7 @@
 #include "linklist.h"
 #include "thread.h"
 #include "memory.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_str.h"
index 180de9d71e2b8953d15e3dd68e827e4f16264055..7c00204c51491ce4b3705252345936aa5c179e84 100644 (file)
@@ -23,6 +23,7 @@
 #include <zebra.h>
 #include "log.h"
 #include "memory.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_iface.h"
index 9d8e0012e4e262d67acc4437f92a5b681f7de6bd..f3b5e78ada0f27b14de6008423bd3cd35eb4882f 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "log.h"
 #include "prefix.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_str.h"
index 6f5fe480f248bf5bd572e76b0772bbf4cf376a96..f85f422298117d0a54e03ed9f876b24cb79f0a9f 100644 (file)
@@ -23,6 +23,7 @@
 #include <zebra.h>
 #include "log.h"
 #include "privs.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_mroute.h"
@@ -449,8 +450,9 @@ int pim_mroute_socket_disable()
   would be used for multicast forwarding, a corresponding multicast
   interface must be added to the kernel.
  */
-int pim_mroute_add_vif(int vif_index, struct in_addr ifaddr, unsigned char flags)
+int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr, unsigned char flags)
 {
+  struct pim_interface *pim_ifp = ifp->info;
   struct vifctl vc;
   int err;
 
@@ -461,8 +463,8 @@ int pim_mroute_add_vif(int vif_index, struct in_addr ifaddr, unsigned char flags
   }
 
   memset(&vc, 0, sizeof(vc));
-  vc.vifc_vifi = vif_index;
-  vc.vifc_lcl_ifindex = vif_index;
+  vc.vifc_vifi = pim_ifp->mroute_vif_index;
+  vc.vifc_lcl_ifindex = ifp->ifindex;
   vc.vifc_flags = flags;
   vc.vifc_threshold = PIM_MROUTE_MIN_TTL;
   vc.vifc_rate_limit = 0;
@@ -482,7 +484,7 @@ int pim_mroute_add_vif(int vif_index, struct in_addr ifaddr, unsigned char flags
 
     zlog_warn("%s %s: failure: setsockopt(fd=%d,IPPROTO_IP,MRT_ADD_VIF,vif_index=%d,ifaddr=%s,flag=%d): errno=%d: %s",
              __FILE__, __PRETTY_FUNCTION__,
-             qpim_mroute_socket_fd, vif_index, ifaddr_str, flags,
+             qpim_mroute_socket_fd, ifp->ifindex, ifaddr_str, flags,
              e, safe_strerror(e));
     errno = e;
     return -2;
index a32c792d7875f769776b56969048ec26e50a709d..c1ce012e2dfcd4c3d75ef6de3caa766ad3ac92b0 100644 (file)
@@ -166,7 +166,7 @@ struct igmpmsg
 int pim_mroute_socket_enable(void);
 int pim_mroute_socket_disable(void);
 
-int pim_mroute_add_vif(int vif_index, struct in_addr ifaddr, unsigned char flags);
+int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr, unsigned char flags);
 int pim_mroute_del_vif(int vif_index);
 
 int pim_mroute_add(struct mfcctl *mc);
index 8ead7ce6435ef037807fe13d9686ca9d2cd39622..aa0433a2e2b0fbda20bd3a729168c47cbf1015e1 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <zebra.h>
 
+#include "if.h"
+
 #include "pimd.h"
 #include "pim_pim.h"
 #include "pim_msg.h"
index 8932dc324c9764c107bb3ab4b885baba1dda6ca6..cb41209238299a82f6bc27bc0adf93feaf801d81 100644 (file)
@@ -25,6 +25,7 @@
 #include "log.h"
 #include "prefix.h"
 #include "memory.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_neighbor.h"
index 7c03370fc43325bd2d145f6d47ffb3e813525509..5e7f1786d7e19fda104910ef9fa35912a9925169 100644 (file)
@@ -25,6 +25,7 @@
 #include "log.h"
 #include "memory.h"
 #include "linklist.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_oil.h"
index 2ff062bd67a162890be4f25edaafe0aef9d634da..959663433d1a9b6e28847b042c963e083e5bca1d 100644 (file)
@@ -25,6 +25,7 @@
 #include "log.h"
 #include "thread.h"
 #include "memory.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_pim.h"
index 56868ae0933f37041e070051ac27be04279222ee..ced7c8748444ab35b62bb823dcfe6627801ce90b 100644 (file)
@@ -21,6 +21,7 @@
  */
 #include <zebra.h>
 
+#include "if.h"
 #include "routemap.h"
 
 #include "pimd.h"
index 747f3d48e4b1893c6ab837545869e82c66e55945..26d108bcaac5ad004dec478c41a5829d05f1d270 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "log.h"
 #include "network.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_str.h"
index 354fd664c068c36e49d793d305f1f2f82d2f00b1..11d8464486892b787c62599bc8b22d2b007f4881 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <zebra.h>
 
+#include "if.h"
+
 #include "log.h"
 #include "prefix.h"
 #include "memory.h"
index 5114901dad1ea1f61a09e434454f91ab6760e2a4..47a34daf4836a2d9cf327ef6fd71834f552c075d 100644 (file)
@@ -23,6 +23,7 @@
 #include <zebra.h>
 
 #include "vty.h"
+#include "if.h"
 
 #include "pim_static.h"
 #include "pim_time.h"
index ed4dbba2e5bd7a92a79fa96cbc0117794b376ea9..6e889900580d040a6e7383cb46cb261253463267 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "log.h"
 #include "prefix.h"
+#include "if.h"
 
 #include "pimd.h"
 #include "pim_int.h"