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

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

net/netip: add IPv6LinkLocalAllRouters #51766

mdlayher opened this issue Mar 17, 2022 · 7 comments

Comments

@mdlayher
Copy link
Member

@mdlayher 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 mvdan commented Mar 17, 2022

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

@DasSkelett
Copy link

@DasSkelett DasSkelett commented Mar 17, 2022

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

@mdlayher mdlayher commented Mar 17, 2022

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 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 Jun 1, 2022
@rsc
Copy link
Contributor

@rsc 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 Jun 8, 2022
@rsc rsc moved this from Likely Accept to Accepted in Proposals Jun 15, 2022
@rsc
Copy link
Contributor

@rsc 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

@gopherbot gopherbot commented Jun 15, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Proposals
Accepted
Development

No branches or pull requests

5 participants