Skip to content

x/net/ipv4: PacketConn.MulticastInterface is implemented incorrectly on Linux #41854

@tamird

Description

@tamird

Per the man page:

       IP_MULTICAST_IF (since Linux 1.2)
              Set the local device for a multicast socket.  The argument for
              setsockopt(2) is an ip_mreqn or (since Linux 3.5) ip_mreq
              structure similar to IP_ADD_MEMBERSHIP, or an in_addr struc‐
              ture.  (The kernel determines which structure is being passed
              based on the size passed in optlen.)  For getsockopt(2), the
              argument is an in_addr structure.

However, the implementation uses the wrong type for retrieval:

https://github.com/golang/net/blob/a7d1128ccaa05167332a625f69773af1a0c6b39c/ipv4/dgramopt.go#L41

https://github.com/golang/net/blob/a7d1128ccaa05167332a625f69773af1a0c6b39c/ipv4/sys_linux.go#L27

https://github.com/golang/net/blob/a7d1128ccaa05167332a625f69773af1a0c6b39c/ipv4/sockopt_posix.go#L17

Oddly, the default case in getMulticastInterface would do the right thing.

This looks to have been broken in golang/net@353547e

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions