Skip to content

Commit 18cc44d

Browse files
eddie-barlevfujita
authored andcommitted
replacing hardcoded IP 0.0.0.0 with netip.IPv4Unspecified() call
1 parent 832b2d9 commit 18cc44d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/server/server.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"net"
24+
"net/netip"
2425
"reflect"
2526
"strconv"
2627
"sync"
@@ -879,7 +880,7 @@ func (s *BgpServer) toConfig(peer *peer, getAdvertised bool) *oc.Neighbor {
879880
if state == bgp.BGP_FSM_ESTABLISHED {
880881
peer.fsm.lock.RLock()
881882
conf.Transport.State.LocalAddress, conf.Transport.State.LocalPort = peer.fsm.LocalHostPort()
882-
if conf.Transport.Config.LocalAddress != "0.0.0.0" {
883+
if conf.Transport.Config.LocalAddress != netip.IPv4Unspecified().String() {
883884
conf.Transport.State.LocalAddress = conf.Transport.Config.LocalAddress
884885
}
885886
_, conf.Transport.State.RemotePort = peer.fsm.RemoteHostPort()
@@ -1619,7 +1620,7 @@ func (s *BgpServer) handleFSMMessage(peer *peer, e *fsmMsg) {
16191620
// exclude zone info
16201621
ipaddr, _ := net.ResolveIPAddr("ip", laddr)
16211622
peer.fsm.peerInfo.LocalAddress = ipaddr.IP
1622-
if peer.fsm.pConf.Transport.Config.LocalAddress != "0.0.0.0" {
1623+
if peer.fsm.pConf.Transport.Config.LocalAddress != netip.IPv4Unspecified().String() {
16231624
peer.fsm.peerInfo.LocalAddress = net.ParseIP(peer.fsm.pConf.Transport.Config.LocalAddress)
16241625
peer.fsm.pConf.Transport.State.LocalAddress = peer.fsm.pConf.Transport.Config.LocalAddress
16251626
}

0 commit comments

Comments
 (0)