summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-06-18 02:43:21 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-06-18 02:43:21 +0200
commit744d91b3c6bfec40f78f97be34a2301dc9a5fbf5 (patch)
treed619170c1168861ff128710160100e412f6fe5cf
parentpimd: Remove unneeded shell scripts (diff)
downloadfrr-744d91b3c6bfec40f78f97be34a2301dc9a5fbf5.tar.xz
frr-744d91b3c6bfec40f78f97be34a2301dc9a5fbf5.zip
pimd: Separate pim vif index spot from ifindex
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>
-rw-r--r--pimd/pim_assert.c1
-rw-r--r--pimd/pim_br.c1
-rw-r--r--pimd/pim_hello.c1
-rw-r--r--pimd/pim_iface.c40
-rw-r--r--pimd/pim_ifchannel.c1
-rw-r--r--pimd/pim_igmpv3.c1
-rw-r--r--pimd/pim_join.c1
-rw-r--r--pimd/pim_mroute.c10
-rw-r--r--pimd/pim_mroute.h2
-rw-r--r--pimd/pim_msg.c2
-rw-r--r--pimd/pim_neighbor.c1
-rw-r--r--pimd/pim_oil.c1
-rw-r--r--pimd/pim_pim.c1
-rw-r--r--pimd/pim_routemap.c1
-rw-r--r--pimd/pim_rp.c1
-rw-r--r--pimd/pim_rpf.c2
-rw-r--r--pimd/pim_static.c1
-rw-r--r--pimd/pim_tlv.c1
18 files changed, 53 insertions, 16 deletions
diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c
index 5dae67571..9f9c9e66f 100644
--- a/pimd/pim_assert.c
+++ b/pimd/pim_assert.c
@@ -24,6 +24,7 @@
#include "log.h"
#include "prefix.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
diff --git a/pimd/pim_br.c b/pimd/pim_br.c
index 6958ad545..121a45fd1 100644
--- a/pimd/pim_br.c
+++ b/pimd/pim_br.c
@@ -22,6 +22,7 @@
#include "memory.h"
#include "log.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
diff --git a/pimd/pim_hello.c b/pimd/pim_hello.c
index bfc128b97..21d0e5b85 100644
--- a/pimd/pim_hello.c
+++ b/pimd/pim_hello.c
@@ -23,6 +23,7 @@
#include <zebra.h>
#include "log.h"
+#include "if.h"
#include "pimd.h"
#include "pim_pim.h"
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 1f818ccf5..8357a26a3 100644
--- a/pimd/pim_iface.c
+++ b/pimd/pim_iface.c
@@ -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
*/
diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c
index 5271d412d..abfa5cc2b 100644
--- a/pimd/pim_ifchannel.c
+++ b/pimd/pim_ifchannel.c
@@ -25,6 +25,7 @@
#include "linklist.h"
#include "thread.h"
#include "memory.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c
index 180de9d71..7c00204c5 100644
--- a/pimd/pim_igmpv3.c
+++ b/pimd/pim_igmpv3.c
@@ -23,6 +23,7 @@
#include <zebra.h>
#include "log.h"
#include "memory.h"
+#include "if.h"
#include "pimd.h"
#include "pim_iface.h"
diff --git a/pimd/pim_join.c b/pimd/pim_join.c
index 9d8e0012e..f3b5e78ad 100644
--- a/pimd/pim_join.c
+++ b/pimd/pim_join.c
@@ -24,6 +24,7 @@
#include "log.h"
#include "prefix.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c
index 6f5fe480f..f85f42229 100644
--- a/pimd/pim_mroute.c
+++ b/pimd/pim_mroute.c
@@ -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;
diff --git a/pimd/pim_mroute.h b/pimd/pim_mroute.h
index a32c792d7..c1ce012e2 100644
--- a/pimd/pim_mroute.h
+++ b/pimd/pim_mroute.h
@@ -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);
diff --git a/pimd/pim_msg.c b/pimd/pim_msg.c
index 8ead7ce64..aa0433a2e 100644
--- a/pimd/pim_msg.c
+++ b/pimd/pim_msg.c
@@ -22,6 +22,8 @@
#include <zebra.h>
+#include "if.h"
+
#include "pimd.h"
#include "pim_pim.h"
#include "pim_msg.h"
diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c
index 8932dc324..cb4120923 100644
--- a/pimd/pim_neighbor.c
+++ b/pimd/pim_neighbor.c
@@ -25,6 +25,7 @@
#include "log.h"
#include "prefix.h"
#include "memory.h"
+#include "if.h"
#include "pimd.h"
#include "pim_neighbor.h"
diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c
index 7c03370fc..5e7f1786d 100644
--- a/pimd/pim_oil.c
+++ b/pimd/pim_oil.c
@@ -25,6 +25,7 @@
#include "log.h"
#include "memory.h"
#include "linklist.h"
+#include "if.h"
#include "pimd.h"
#include "pim_oil.h"
diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c
index 2ff062bd6..959663433 100644
--- a/pimd/pim_pim.c
+++ b/pimd/pim_pim.c
@@ -25,6 +25,7 @@
#include "log.h"
#include "thread.h"
#include "memory.h"
+#include "if.h"
#include "pimd.h"
#include "pim_pim.h"
diff --git a/pimd/pim_routemap.c b/pimd/pim_routemap.c
index 56868ae09..ced7c8748 100644
--- a/pimd/pim_routemap.c
+++ b/pimd/pim_routemap.c
@@ -21,6 +21,7 @@
*/
#include <zebra.h>
+#include "if.h"
#include "routemap.h"
#include "pimd.h"
diff --git a/pimd/pim_rp.c b/pimd/pim_rp.c
index 747f3d48e..26d108bca 100644
--- a/pimd/pim_rp.c
+++ b/pimd/pim_rp.c
@@ -22,6 +22,7 @@
#include "log.h"
#include "network.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c
index 354fd664c..11d846448 100644
--- a/pimd/pim_rpf.c
+++ b/pimd/pim_rpf.c
@@ -22,6 +22,8 @@
#include <zebra.h>
+#include "if.h"
+
#include "log.h"
#include "prefix.h"
#include "memory.h"
diff --git a/pimd/pim_static.c b/pimd/pim_static.c
index 5114901da..47a34daf4 100644
--- a/pimd/pim_static.c
+++ b/pimd/pim_static.c
@@ -23,6 +23,7 @@
#include <zebra.h>
#include "vty.h"
+#include "if.h"
#include "pim_static.h"
#include "pim_time.h"
diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c
index ed4dbba2e..6e8899005 100644
--- a/pimd/pim_tlv.c
+++ b/pimd/pim_tlv.c
@@ -24,6 +24,7 @@
#include "log.h"
#include "prefix.h"
+#include "if.h"
#include "pimd.h"
#include "pim_int.h"