Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tamird opened this issue Oct 7, 2020 · 3 comments
Open

Comments

@tamird
Copy link
Contributor

@tamird tamird commented Oct 7, 2020

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

@gopherbot gopherbot added this to the Unreleased milestone Oct 7, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 8, 2020

Change https://golang.org/cl/260680 mentions this issue: ipv4: Correctly MulticastInterface on Linux

@networkimprov
Copy link

@networkimprov networkimprov commented Oct 8, 2020

@dmitshur
Copy link
Member

@dmitshur dmitshur commented Oct 13, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.