Skip to content

Commit

Permalink
Fix issue #5: Conditionalize Linux anachronism
Browse files Browse the repository at this point in the history
The IPv6 multicast routing proc setting does not exist outside Linux,
conditionalize it using #ifdef __linux__ (compiler built-in define).

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
  • Loading branch information
troglobit committed Sep 28, 2014
1 parent abea395 commit b0c3b36
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mroute-api.c
Expand Up @@ -400,6 +400,7 @@ int mroute4_del(mroute4_t *route)
}

#ifdef HAVE_IPV6_MULTICAST_ROUTING
#ifdef __linux__
#define IPV6_ALL_MC_FORWARD "/proc/sys/net/ipv6/conf/all/mc_forwarding"

static int proc_set_val(char *file, int val)
Expand All @@ -417,6 +418,7 @@ static int proc_set_val(char *file, int val)

return result;
}
#endif /* Linux only */
#endif /* HAVE_IPV6_MULTICAST_ROUTING */

/**
Expand Down Expand Up @@ -463,13 +465,14 @@ int mroute6_enable(void)
/* Initialize virtual interface table */
memset(&mif_list, 0, sizeof(mif_list));

#ifdef __linux__
/* On Linux pre 2.6.29 kernels net.ipv6.conf.all.mc_forwarding
* is not set on MRT6_INIT so we have to do this manually */
if (proc_set_val(IPV6_ALL_MC_FORWARD, 1)) {
if (errno != EACCES)
smclog(LOG_ERR, errno, "Failed enabling IPv6 multicast forwarding");
}

#endif
/* Create virtual interfaces, IPv6 MIFs, for all non-loopback interfaces */
for (i = 0; (iface = iface_find_by_index(i)); i++) {
if (iface->flags & IFF_LOOPBACK) {
Expand Down

0 comments on commit b0c3b36

Please sign in to comment.