Skip to content

Commit

Permalink
replacing hardcoded IP 0.0.0.0 with netip.IPv4Unspecified() call
Browse files Browse the repository at this point in the history
  • Loading branch information
eddie-barlev authored and fujita committed Sep 30, 2024
1 parent 832b2d9 commit 18cc44d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"net"
"net/netip"
"reflect"
"strconv"
"sync"
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 18cc44d

Please sign in to comment.