diff --git a/pkg/server/server.go b/pkg/server/server.go index 69e2c837b..65f1b26bb 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -21,6 +21,7 @@ import ( "errors" "fmt" "net" + "net/netip" "reflect" "strconv" "sync" @@ -879,7 +880,7 @@ func (s *BgpServer) toConfig(peer *peer, getAdvertised bool) *oc.Neighbor { if state == bgp.BGP_FSM_ESTABLISHED { peer.fsm.lock.RLock() conf.Transport.State.LocalAddress, conf.Transport.State.LocalPort = peer.fsm.LocalHostPort() - if conf.Transport.Config.LocalAddress != "0.0.0.0" { + if conf.Transport.Config.LocalAddress != netip.IPv4Unspecified().String() { conf.Transport.State.LocalAddress = conf.Transport.Config.LocalAddress } _, conf.Transport.State.RemotePort = peer.fsm.RemoteHostPort() @@ -1619,7 +1620,7 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) { // exclude zone info ipaddr, _ := net.ResolveIPAddr("ip", laddr) peer.fsm.peerInfo.LocalAddress = ipaddr.IP - if peer.fsm.pConf.Transport.Config.LocalAddress != "0.0.0.0" { + if peer.fsm.pConf.Transport.Config.LocalAddress != netip.IPv4Unspecified().String() { peer.fsm.peerInfo.LocalAddress = net.ParseIP(peer.fsm.pConf.Transport.Config.LocalAddress) peer.fsm.pConf.Transport.State.LocalAddress = peer.fsm.pConf.Transport.Config.LocalAddress }