From: arf20 via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: arf20 <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] UDP: Join multicast group in local_addr interface (PR #21439)
Date: Mon, 12 Jan 2026 19:41:56 -0000
Message-ID: <176824691725.25.4157081523663418539@4457048688e7> (raw)
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 <aruizfernandez05@gmail.com>
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 -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
reply other threads:[~2026-01-12 19:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=176824691725.25.4157081523663418539@4457048688e7 \
--to=ffmpeg-devel@ffmpeg.org \
--cc=code@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git