summaryrefslogtreecommitdiff
path: root/pimd/pim_iface.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-06-17 20:43:21 -0400
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-06-17 20:43:21 -0400
commit744d91b3c6bfec40f78f97be34a2301dc9a5fbf5 (patch)
treed619170c1168861ff128710160100e412f6fe5cf /pimd/pim_iface.c
parent515b39d7042d129238a313ea0aba37ee4b0742c7 (diff)
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>
Diffstat (limited to 'pimd/pim_iface.c')
-rw-r--r--pimd/pim_iface.c40
1 files changed, 29 insertions, 11 deletions
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c
index 1f818ccf51..8357a26a3e 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
*/