PR #21439 opened by arf20 URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21439 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21439.patch
Implement `//TODO: Interface index should be looked up from local_addr` at libavformat/udp.c Previously the multicast join request used 0 (default interface) as mreq6.ipv6mr_interface when joining Link-Local scoped IPv6 multicast groups. This lets the kernel choose whatever interface it deems fit. This, as described in the TODO comment, is not good behaviour, it was unexpected for users (me). Now the group will be joined to the same interface it is bound to as per parameter localaddr at the field sin6_scope_id of the sockaddr_in6 local_addr. If localaddr is not a Link-Local scoped (i.e. does not have a %<if> interface designator) getaddrinfo(3) will set this to 0, which the kernel will correctly handle for globally routable address with the routing table. >From d8ca5711deca795fb5d8b2c64414fa28de3c36c8 Mon Sep 17 00:00:00 2001 From: arf20 <[email protected]> Date: Mon, 12 Jan 2026 20:36:46 +0100 Subject: [PATCH] Join multicast group in local_addr interface --- libavformat/udp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/udp.c b/libavformat/udp.c index 61e80c86c5..ba52621673 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -232,8 +232,10 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr, struct ipv6_mreq mreq6; memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); - //TODO: Interface index should be looked up from local_addr - mreq6.ipv6mr_interface = 0; + if (local_addr) + mreq6.ipv6mr_interface = ((struct sockaddr_in6*)local_addr)->sin6_scope_id; + else + mreq6.ipv6mr_interface = 0; if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { ff_log_net_error(logctx, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)"); return ff_neterrno(); -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
