]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: add a workaround for *BSD
authorRenato Westphal <renato@opensourcerouting.org>
Thu, 4 Aug 2016 13:07:30 +0000 (10:07 -0300)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Mon, 8 Aug 2016 01:05:26 +0000 (21:05 -0400)
VIFF_USE_IFINDEX is not available on BSDs and other UNIX systems. In
order to build pimd on these platforms, use 'vifc_lcl_addr' instead of
'vifc_lcl_ifindex' to specify the interfaces we want to enable forwarding
of multicast traffic. In the case of unnumbered interfaces, print an
error and return.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
configure.ac
pimd/pim_iface.c
pimd/pim_mroute.c

index 6f07f10cd018d002bb75f2bfe39736d59d3ff5e6..50918227e9ce61fa0b294dccf2db8b4ff6fce12d 100755 (executable)
@@ -996,11 +996,46 @@ dnl figure out how to specify an interface in multicast sockets API
 dnl ---------------------------------------------------------------
 AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], QUAGGA_INCLUDES)
 
-AC_CHECK_HEADERS([linux/mroute.h], [], [],
-[
-#if HAVE_NETINET_IN_H
-#include<netinet/in.h>
-#endif])
+AC_CHECK_HEADERS([linux/mroute.h], [], [],[
+       #ifdef HAVE_SYS_SOCKET_H
+       # include <sys/socket.h>
+       #endif
+       #ifdef HAVE_NETINET_IN_H
+       # include <netinet/in.h>
+       #endif
+       #define _LINUX_IN_H             /* For Linux <= 2.6.25 */
+       #include <linux/types.h>
+])
+
+m4_define([QUAGGA_INCLUDES],
+QUAGGA_INCLUDES
+[#if HAVE_LINUX_MROUTE_H
+# include <linux/mroute.h>
+#endif
+])dnl
+
+AC_CHECK_HEADERS([netinet/ip_mroute.h], [], [],[
+       #ifdef HAVE_SYS_SOCKET_H
+       # include <sys/socket.h>
+       #endif
+       #ifdef HAVE_SYS_TYPES_H
+       # include <sys/types.h>
+       #endif
+       #ifdef HAVE_NETINET_IN_H
+       # include <netinet/in.h>
+       #endif
+       #ifdef HAVE_NET_ROUTE_H
+       # include <net/route.h>
+       #endif
+])
+
+m4_define([QUAGGA_INCLUDES],
+QUAGGA_INCLUDES
+[#if HAVE_NETINET_IP_MROUTE_H
+# include <netinet/ip_mroute.h>
+#endif
+])dnl
+
 AC_MSG_CHECKING([for BSD struct ip_mreq hack])
 AC_TRY_COMPILE([#ifdef HAVE_SYS_PARAM_H
 #include <sys/param.h>
index 14c8c7262e84af687599da760534057ec56835d5..3c602750274e65081788c1873d293ed6ce1211b1 100644 (file)
 #include "pim_time.h"
 #include "pim_ssmpingd.h"
 
-#ifndef VIFF_USE_IFINDEX
-# ifdef linux
-/* make it work compile-time - whether it works runtime depends on the user
- * having 2.6.32 or newer */
-#  define VIFF_USE_IFINDEX        0x8
-# else
-#  error no VIFF_USE_IFINDEX on this system, code needs porting
-/* NB: without VIFF_USE_IFINDEX, the local IP address is used to identify
- * interfaces, which means it's impossible to support multiple interfaces that
- * have the same or no IP address (e.g. unnumbered) */
-# endif
-#endif
-
 struct interface *pim_regiface = NULL;
 
 static void pim_if_igmp_join_del_all(struct interface *ifp);
@@ -645,7 +632,7 @@ int pim_if_add_vif(struct interface *ifp)
 {
   struct pim_interface *pim_ifp = ifp->info;
   struct in_addr ifaddr;
-  unsigned char flags;
+  unsigned char flags = 0;
 
   zassert(pim_ifp);
 
@@ -681,8 +668,13 @@ int pim_if_add_vif(struct interface *ifp)
       return -3;
     }
 
-  flags = (ifp->ifindex == PIM_OIF_PIM_REGISTER_VIF) ?
-    VIFF_REGISTER : VIFF_USE_IFINDEX;
+  if (ifp->ifindex == PIM_OIF_PIM_REGISTER_VIF)
+    flags = VIFF_REGISTER;
+#ifdef VIFF_USE_IFINDEX
+  else
+    flags = VIFF_USE_IFINDEX;
+#endif
+
   if (pim_mroute_add_vif(ifp, ifaddr, flags)) {
     /* pim_mroute_add_vif reported error */
     return -5;
index ab3742438de9b7cf7b3233db9707e524ef9b8577..56f49d62f5785c6edb7a5ba1b4b1243678d925c0 100644 (file)
@@ -501,7 +501,16 @@ int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr, unsigned ch
 
   memset(&vc, 0, sizeof(vc));
   vc.vifc_vifi = pim_ifp->mroute_vif_index;
+#ifdef VIFF_USE_IFINDEX
   vc.vifc_lcl_ifindex = ifp->ifindex;
+#else
+  if (ifaddr.s_addr == INADDR_ANY) {
+    zlog_warn("%s: unnumbered interfaces are not supported on this platform",
+             __PRETTY_FUNCTION__);
+    return -1;
+  }
+  memcpy(&vc.vifc_lcl_addr, &ifaddr, sizeof(vc.vifc_lcl_addr));
+#endif
   vc.vifc_flags = flags;
   vc.vifc_threshold = PIM_MROUTE_MIN_TTL;
   vc.vifc_rate_limit = 0;