summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-08-04 15:07:26 +0200
committerDonald Sharp <sharpd@cumulusnetwroks.com>2016-08-08 03:05:26 +0200
commit4a3867d0d331ab64311f517bfb39bddfc933c9ee (patch)
treebbfb0e3efa099b216058d16937ec442d1d085a37 /ripd
parentospf6d: fix sendmsg on OpenBSD (diff)
downloadfrr-4a3867d0d331ab64311f517bfb39bddfc933c9ee.tar.xz
frr-4a3867d0d331ab64311f517bfb39bddfc933c9ee.zip
lib: fix setting of IPv4 multicast sockopts on OpenBSD
OpenBSD doesn't support the "ifindex hack" derived from RFC 1724 which allows an ifindex to be encoded in the imr_interface field (in_addr) of the ip_mreq structure. OpenBSD also doesn't support the RFC3678 Protocol-Independent socket API extensions, which allows an interface to be specified by its ifindex. With that said, in OpenBSD we still need to specify an interface by its IP address. This patch adds an exception in the multicast sockopt functions to handle this case. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_interface.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 6748e197d..4499966ad 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -80,6 +80,7 @@ ipv4_multicast_join (int sock,
ret = setsockopt_ipv4_multicast (sock,
IP_ADD_MEMBERSHIP,
+ ifa,
group.s_addr,
ifindex);
@@ -101,6 +102,7 @@ ipv4_multicast_leave (int sock,
ret = setsockopt_ipv4_multicast (sock,
IP_DROP_MEMBERSHIP,
+ ifa,
group.s_addr,
ifindex);
@@ -136,9 +138,13 @@ rip_interface_new (void)
void
rip_interface_multicast_set (int sock, struct connected *connected)
{
+ struct in_addr addr;
+
assert (connected != NULL);
-
- if (setsockopt_ipv4_multicast_if (sock, connected->ifp->ifindex) < 0)
+
+ addr = CONNECTED_ID(connected)->u.prefix4;
+
+ if (setsockopt_ipv4_multicast_if (sock, addr, connected->ifp->ifindex) < 0)
{
zlog_warn ("Can't setsockopt IP_MULTICAST_IF on fd %d to "
"ifindex %d for interface %s",