Date: Sun, 31 Jul 2022 19:29:36 +0000 From: bugzilla-noreply@freebsd.org To: net@FreeBSD.org Subject: [Bug 265540] EADDRNOTAVAIL when leaving IPv6 multicast group and ipv6_mreq.ipv6mr_interface=0 Message-ID: <bug-265540-7501@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D265540 Bug ID: 265540 Summary: EADDRNOTAVAIL when leaving IPv6 multicast group and ipv6_mreq.ipv6mr_interface=3D0 Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: net@FreeBSD.org Reporter: dmgk@freebsd.org Created attachment 235586 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D235586&action= =3Dedit mcast.c When porting some Linux code, I noticed that when ipv6_mreq.ipv6mr_interfac= e=3D0, it is possible to join an IPv6 multicast group, but setsockopts() returns EADDRNOTAVAIL when leaving. Running attached mcast.c on 14.0-CURRENT: $ ./mcast mcast: addr: ff02::42 mcast: setsockopt: join ok mcast: setsockopt: IPV6_LEAVE_GROUP: Can't assign requested address I'm not sure whether this is a correct fix, but I think the lookup code in in6p_leave_group() is missing an in6_setscope() call: --- a/sys/netinet6/in6_mcast.c +++ b/sys/netinet6/in6_mcast.c @@ -2312,6 +2312,9 @@ in6p_leave_group(struct inpcb *inp, struct sockopt *s= opt) "ifp for group %s.", __func__, ip6_sprintf(ip6tbuf, &gsa->sin6.sin6_addr)); ifp =3D in6p_lookup_mcast_ifp(inp, &gsa->sin6); + if (ifp =3D=3D NULL) + return (EADDRNOTAVAIL); + (void)in6_setscope(&gsa->sin6.sin6_addr, ifp, NULL); } else { NET_EPOCH_ENTER(et); ifp =3D ifnet_byindex(ifindex); in6p_join_group() calls in6_setscope() in in6_mcast.c:1996, but the lookup = by im6o_match_group() in in6_mcast.c:2336 is performed using unscoped address. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-265540-7501>