Skip to content

pkg/packet/mrt: use netip for BGP4MPHeader and GeoPeer #3078

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fujita
Copy link
Member

@fujita fujita commented Aug 6, 2025

Replace net.IP with netip.Addr for BGP4MPHeader, GeoPeer, and GeoPeerTable.

Replace net.IP with netip.Addr for BGP4MPHeader, GeoPeer, and GeoPeerTable.

Signed-off-by: FUJITA Tomonori <[email protected]>
binary.BigEndian.PutUint32(buf[5:9], math.Float32bits(p.Latitude))
binary.BigEndian.PutUint32(buf[9:13], math.Float32bits(p.Longitude))
return buf, nil
}

func NewGeoPeer(bgpid string, latitude float32, longitude float32) *GeoPeer {
func NewGeoPeer(bgpid netip.Addr, latitude float32, longitude float32) (*GeoPeer, error) {
if !bgpid.Is4() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we enforce && !bgpid.IsUnspecified() ? (line 703 as well)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a serialization/deserialization library, so I think that it’s better if users can construct whatever binary they want — as long as the values don’t cause GoBGP or the library to crash.

laddr := net.ParseIP(localip).To4()
if paddr != nil && laddr != nil {

if !peerip.IsValid() || !localip.IsValid() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

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

Successfully merging this pull request may close these issues.

2 participants