From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 2F8A74CEF8 for ; Mon, 11 Aug 2025 22:34:31 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 419AB68CC19; Tue, 12 Aug 2025 01:34:28 +0300 (EEST) Received: from relay16.mail.gandi.net (relay16.mail.gandi.net [217.70.178.236]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id A3514688FD7 for ; Tue, 12 Aug 2025 01:34:21 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id D14C143892 for ; Mon, 11 Aug 2025 22:34:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1754951661; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sTOj+mhOGaif8JKH9TyW+gfzpxhJ70SDsLfsKWqccu0=; b=RGtBZQO9s3pnQDmj36uk2YvG65ghZP3wVUH4H99JvBtC1kWUAHzHCgYmZTx6J5kcovb6M0 Gi5lht0pxFJe+jMxrRFf0+oznSfK+iCurYUP1DJKyMzCcVLkM305kbQ3dNo77KA4HiWV9C Y3HqZav4Hk3udmTm17F9skdm3NH2nx8qE+mIvl88LCBVULNNtGmPxfwJruWeuvkZaWN0lQ aaBMNwlbymnb1LHa/yX3VkRuWeAGDX3PHs3diZTsFaUw8rdECSJLrqvB+JFMTZB91UmwD3 qMSV4XeoT2oP+O92Cs7Z1V8+0wrOnB4oCAfCx8vDDJQDoVcUlOTj+k+Palk/fw== Date: Tue, 12 Aug 2025 00:34:19 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20250811223419.GF29660@pb2> References: <20250808072735.1812024-1-peterend@axis.com> <20250808072735.1812024-3-peterend@axis.com> MIME-Version: 1.0 In-Reply-To: <20250808072735.1812024-3-peterend@axis.com> X-GND-State: clean X-GND-Score: -85 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddufeefieejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlhcuvffnffculdduhedmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfpihgvuggvrhhmrgihvghruceomhhitghhrggvlhesnhhivgguvghrmhgrhigvrhdrtggtqeenucggtffrrghtthgvrhhnpeeigeektdejudffjefhteegjedtgeettefggedthfejgfevhfetgeekjedtvdfhveenucfkphepgedurdeiiedrieehrddujeeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepgedurdeiiedrieehrddujeeipdhhvghloheplhhotggrlhhhohhsthdpmhgrihhlfhhrohhmpehmihgthhgrvghlsehnihgvuggvrhhmrgihvghrrdgttgdpnhgspghrtghpthhtohepuddprhgtphhtthhopehffhhmphgvghdquggvvhgvlhesfhhfmhhpvghgrdhorhhg Subject: Re: [FFmpeg-devel] [PATCH v2.1 2/2] avformat/udp: Select output interfaces for ipv6 multicast X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============1648877596431710540==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1648877596431710540== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="wrbFNsNR66+2T2/E" Content-Disposition: inline --wrbFNsNR66+2T2/E Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Peter On Fri, Aug 08, 2025 at 09:27:35AM +0200, Peter Enderborg wrote: > This fixes two old TODO's in ipv6 multicast handling. > If the system as SIOCGIFINDEX ioctl a helper function to iterate over > all interfaces added to join the multicast group on interface if approper= ite. >=20 > The default value is IN6ADDR_ANY (::) and it then joins all interfaces > that are up and have multicast support. Local address can be > specified and then it join ALL interfaces that use that specific > local address. >=20 > Limitations (TODO's) > Handling when network configuration is changed. if up/down etc. >=20 > Signed-off-by: Peter Enderborg > --- > libavformat/udp.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 96 insertions(+), 2 deletions(-) >=20 > diff --git a/libavformat/udp.c b/libavformat/udp.c > index 84f9d3e62e..a0482c122f 100644 > --- a/libavformat/udp.c > +++ b/libavformat/udp.c > @@ -68,6 +68,13 @@ > #include "libavutil/thread.h" > #endif > =20 > +#if HAVE_STRUCT_IPV6_MREQ && HAVE_IOCTL_GIFINDEX && defined(IPPROTO_IPV6) > +#include > +#include > +#include > +#include > +#endif > + > #ifndef IPV6_ADD_MEMBERSHIP > #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP > #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP > @@ -205,6 +212,79 @@ static int udp_set_multicast_ttl(int sockfd, int mca= stTTL, > =20 > return 0; > } > +#if HAVE_STRUCT_IPV6_MREQ && HAVE_IOCTL_GIFINDEX && defined(IPPROTO_IPV6) > +static int udp_ipv6_multicast_iterate(int sockfd, struct sockaddr_in6 *a= ddr, > + struct sockaddr_in6 *local_addr, i= nt mop, void *logctx) > +{ > + struct in6_addr anyipv6 =3D IN6ADDR_ANY_INIT; > + struct ifaddrs *ifal=3DNULL,*ife=3DNULL; > + int iindex_fd =3D socket(AF_INET, SOCK_STREAM, IPPROTO_IP); > + int membership_changed =3D 0; > + > + if (iindex_fd >=3D 0 && !getifaddrs(&ifal)) { > + for(ife=3Difal; ife!=3DNULL; ife=3Dife->ifa_next) { > + if (ife->ifa_addr && > + (ife->ifa_addr->sa_family =3D=3D AF_INET6) && > + (ife->ifa_flags & IFF_MULTICAST) && > + (ife->ifa_flags & IFF_UP)) { > + if ((!memcmp(&local_addr->sin6_addr, &anyipv6, sizeof(st= ruct in6_addr))) || > + (!memcmp(&local_addr->sin6_addr, &((struct sockaddr_= in6 *)ife->ifa_addr)->sin6_addr, sizeof(struct in6_addr)))) { > + struct ifreq if_req; > + strncpy(if_req.ifr_name, ife->ifa_name, IFNAMSIZ); > + if (ioctl(iindex_fd, SIOCGIFINDEX, &if_req) !=3D -1)= { > + struct ipv6_mreq mreq6; > + memcpy(&mreq6.ipv6mr_multiaddr, &addr->sin6_addr= , sizeof(struct in6_addr)); > + mreq6.ipv6mr_interface =3D if_req.ifr_ifindex; > + switch (mop) { > + case IPV6_JOIN_GROUP: > + if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_AD= D_MEMBERSHIP, &mreq6, sizeof(mreq6)) =3D=3D 0) { > + membership_changed =3D 1; > + } else { > + /* Subscribe for all ipv6 addresses belo= ng to a > + interface.It can generate EADDRINUSE but > + is accaptable. */ > + if (errno !=3D EADDRINUSE) { > + ff_log_net_error(logctx, AV_LOG_ERRO= R, "setsockopt(IPV6_ADD_MEMBERSHIP)"); > + goto error; the patch mixes tabs and spaces, we use only spaces in C files for indentio= n. I will leave the review of teh actual changes to others as I am sure you know much more about ipv6 multicast than i do thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Does the universe only have a finite lifespan? No, its going to go on forever, its just that you wont like living in it. -- Hiranya Peiri --wrbFNsNR66+2T2/E Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCaJpv6wAKCRBhHseHBAsP qz7UAJ43vv9NAqixA3EgKrq0hi6eoiVhhACeP4/kun3JFJAbeNUxSWtEXQMpLcE= =V/Vm -----END PGP SIGNATURE----- --wrbFNsNR66+2T2/E-- --===============1648877596431710540== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============1648877596431710540==--