forked from Mirror/frr
pimd: add a workaround for *BSD
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>
This commit is contained in:
parent
2bb913f5e7
commit
b3f2bf7cbe
45
configure.ac
45
configure.ac
|
@ -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>
|
||||
|
|
|
@ -41,19 +41,6 @@
|
|||
#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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue