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

net/netip: add IPv6LinkLocalAllRouters #51766

Closed
mdlayher opened this issue Mar 17, 2022 · 7 comments
Closed

net/netip: add IPv6LinkLocalAllRouters #51766

mdlayher opened this issue Mar 17, 2022 · 7 comments

Comments

@mdlayher
Copy link
Member

mdlayher commented Mar 17, 2022

I'm working on porting some of my networking packages to Go 1.18's net/netip, but it seems that I had forgotten about my uses of net.IPv6linklocalallrouters when I was making regular additions to inet.af/netaddr.

I'd like to suggest adding exactly the following to net/netip, akin to what already exists as netip.IPv6LinkLocalAllNodes:

// IPv6LinkLocalAllRouters returns the IPv6 link-local all routers multicast
// address ff02::2.
func IPv6LinkLocalAllRouters() Addr { return AddrFrom16([16]byte{0: 0xff, 1: 0x02, 15: 0x02}) }

Along with link-local all nodes, this is one of the most fundamental IPv6 multicast group addresses. Package net exposes it today as a variable: https://pkg.go.dev/net#pkg-variables

Thanks!

/cc @bradfitz @danderson @josharian

@gopherbot gopherbot added this to the Proposal milestone Mar 17, 2022
@mvdan
Copy link
Member

mvdan commented Mar 17, 2022

Out of curiosity, why a func rather than a var?

@DasSkelett
Copy link

Out of curiosity, why a func rather than a var?

I don't know the original motivation for this, but that's how all the other "constants" are implemented in netip as well:

// IPv6LinkLocalAllNodes returns the IPv6 link-local all nodes multicast
// address ff02::1.
func IPv6LinkLocalAllNodes() Addr { return AddrFrom16([16]byte{0: 0xff, 1: 0x02, 15: 0x01}) }
// IPv6Unspecified returns the IPv6 unspecified address "::".
func IPv6Unspecified() Addr { return Addr{z: z6noz} }
// IPv4Unspecified returns the IPv4 unspecified address "0.0.0.0".
func IPv4Unspecified() Addr { return AddrFrom4([4]byte{}) }

For consistency's sake it would make sense to stick to this design.

@mdlayher
Copy link
Member Author

I seem to remember some discussion around avoiding package level allocation and that these calls would be inlined anyway. The immutability is an added bonus.

@rsc
Copy link
Contributor

rsc commented Jun 1, 2022

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals (old) Jun 1, 2022
@rsc
Copy link
Contributor

rsc commented Jun 8, 2022

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

@rsc rsc moved this from Active to Likely Accept in Proposals (old) Jun 8, 2022
@rsc rsc moved this from Likely Accept to Accepted in Proposals (old) Jun 15, 2022
@rsc
Copy link
Contributor

rsc commented Jun 15, 2022

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

@rsc rsc changed the title proposal: net/netip: add IPv6LinkLocalAllRouters net/netip: add IPv6LinkLocalAllRouters Jun 15, 2022
@rsc rsc modified the milestones: Proposal, Backlog Jun 15, 2022
@mdlayher mdlayher self-assigned this Jun 15, 2022
@gopherbot
Copy link

Change https://go.dev/cl/412475 mentions this issue: net/netip: add IPv6LinkLocalAllRouters and IPv6Loopback

romaindoumenc pushed a commit to TroutSoftware/go that referenced this issue Nov 3, 2022
Fixes golang#51766
Fixes golang#51777

Change-Id: I0510175c20c06442d78b2581cfe218e66be1c35b
Reviewed-on: https://go-review.googlesource.com/c/go/+/412475
Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
@golang golang locked and limited conversation to collaborators Oct 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

5 participants