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>
#include "log.h"
#include "prefix.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
#include "memory.h"
#include "log.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
#include <zebra.h>
#include "log.h"
+#include "if.h"
#include "pimd.h"
#include "pim_pim.h"
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
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",
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
*/
#include "linklist.h"
#include "thread.h"
#include "memory.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
#include <zebra.h>
#include "log.h"
#include "memory.h"
+#include "if.h"
#include "pimd.h"
#include "pim_iface.h"
#include "log.h"
#include "prefix.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
#include <zebra.h>
#include "log.h"
#include "privs.h"
+#include "if.h"
#include "pimd.h"
#include "pim_mroute.h"
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;
}
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;
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;
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);
#include <zebra.h>
+#include "if.h"
+
#include "pimd.h"
#include "pim_pim.h"
#include "pim_msg.h"
#include "log.h"
#include "prefix.h"
#include "memory.h"
+#include "if.h"
#include "pimd.h"
#include "pim_neighbor.h"
#include "log.h"
#include "memory.h"
#include "linklist.h"
+#include "if.h"
#include "pimd.h"
#include "pim_oil.h"
#include "log.h"
#include "thread.h"
#include "memory.h"
+#include "if.h"
#include "pimd.h"
#include "pim_pim.h"
*/
#include <zebra.h>
+#include "if.h"
#include "routemap.h"
#include "pimd.h"
#include "log.h"
#include "network.h"
+#include "if.h"
#include "pimd.h"
#include "pim_str.h"
#include <zebra.h>
+#include "if.h"
+
#include "log.h"
#include "prefix.h"
#include "memory.h"
#include <zebra.h>
#include "vty.h"
+#include "if.h"
#include "pim_static.h"
#include "pim_time.h"
#include "log.h"
#include "prefix.h"
+#include "if.h"
#include "pimd.h"
#include "pim_int.h"