From: Lennart Poettering Date: Fri, 10 Feb 2006 01:45:09 +0000 (+0000) Subject: add membership hack for IPv6, too X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=bf1d0d3886c2236d51f0e90c90bfe52365be4a99;p=catta add membership hack for IPv6, too git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1132 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-core/socket.c b/avahi-core/socket.c index 444be6e..82622d3 100644 --- a/avahi-core/socket.c +++ b/avahi-core/socket.c @@ -125,8 +125,11 @@ int avahi_mdns_mcast_join_ipv4(int fd, const AvahiIPv4Address *a, int idx, int j mdns_mcast_group_ipv4(&sa); mreq.imr_multiaddr = sa.sin_addr; + /* Some network drivers have issues with dropping membership of + * mcast groups when the iface is down, but don't allow rejoining + * when it comes back up. This is an ugly workaround */ if (join) - setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); + setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)); if (setsockopt(fd, IPPROTO_IP, join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) { avahi_log_warn("%s failed: %s", join ? "IP_ADD_MEMBERSHIP" : "IP_DROP_MEMBERSHIP", strerror(errno)); @@ -149,6 +152,9 @@ int avahi_mdns_mcast_join_ipv6(int fd, const AvahiIPv6Address *a, int idx, int j mreq6.ipv6mr_multiaddr = sa6.sin6_addr; mreq6.ipv6mr_interface = idx; + if (join) + setsockopt(fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)); + if (setsockopt(fd, IPPROTO_IPV6, join ? IPV6_ADD_MEMBERSHIP : IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { avahi_log_warn("%s failed: %s", join ? "IPV6_ADD_MEMBERSHIP" : "IPV6_DROP_MEMBERSHIP", strerror(errno)); return -1;