[FFmpeg-devel] [PATCH] avformat: enable UDP IPv6 multicast interface selection

Ignjatović, Lazar (RS) Lazar.Ignjatovic at cubic.com
Tue Mar 19 11:40:22 EET 2024



This message has been marked as Public on 03/19/2024 09:40Z.
On Friday, March 15, 2024 5:27 PM Rémi Denis-Courmont wrote:

>>
>> localaddr option now properly works with IPv6 addresses. Properly
>> resolved interface index in places where default 0 interface index is
>> used (marked with TODO: within udp.c). Added SO_BINDTODEVICE for mcast
>> sockets that are used for reading from the network.
>
> AFAIK, that is privileged, and is not intended for the purpose of scoping multicast.Where the need arises to specify an interface for multicast, there is typically a dedicated ioctl or field of an ioctl.

I agree, although it gets the job done, in this case it is more acceptable to modify `sin6_scope_id` field to point to the desired interface.
Will change within V2 of the patch.

>> +    /* Special case for link-local addresses, relevant interface is
>> + stored
>> in sin6_scope_id */ +#if HAVE_STRUCT_SOCKADDR_IN6 &&
>> defined(IN6_IS_ADDR_LINKLOCAL)
>> +    if (local_addr->ss_family == AF_INET6 &&
>> IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6*)local_addr)->sin6_addr))
>> {
>
> Invalid cast, breaks aliasing, AFAICT.

AFAIK the primary purpose of `sockaddr_storage` is to store sockaddr regardles of address family. In this case it is used to store local addr, wether it is V4 or V6.
With checking that the `ss_family` is in fact `AF_INET6`, `sockaddr_storage` can be safely cast into `sockaddr_in6`.

Maybe I'm missing something here. Would you mind further elaborating your comment?

Thank you for your time!

Sincirely,
Lazar Ignjatović
Associate Software Engineer

Cubic Defense
cubic.com


More information about the ffmpeg-devel mailing list