diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-08-02 10:19:26 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-04-04 22:07:46 +0900 |
commit | 029852207a0318056edd984ae876f85eefd1df1f (patch) | |
tree | ab597fadc5fb8ae40750b3573c90021aa6a92817 | |
parent | 94865943c66490dd8e3805e5826849c92ff6e36b (diff) |
server: fix bug of wrongly set <nil> to PeerInfo.LocalAddress
config.TransportState.LocalAddress may have zone info with ipv6 address
like "fe80::x%eth0".
In this case, net.ParseIP() returns <nil>, which leads to set <nil> to
PeerInfo.LocalAddress.
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | server/server.go | 5 | ||||
-rw-r--r-- | table/destination.go | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/server/server.go b/server/server.go index d0336de3..8260e566 100644 --- a/server/server.go +++ b/server/server.go @@ -759,8 +759,11 @@ func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg) { if nextState == bgp.BGP_FSM_ESTABLISHED { // update for export policy laddr, _ := peer.fsm.LocalHostPort() + // may include zone info peer.fsm.pConf.Transport.State.LocalAddress = laddr - peer.fsm.peerInfo.LocalAddress = net.ParseIP(laddr) + // exclude zone info + ipaddr, _ := net.ResolveIPAddr("ip", laddr) + peer.fsm.peerInfo.LocalAddress = ipaddr.IP deferralExpiredFunc := func(family bgp.RouteFamily) func() { return func() { server.mgmtOperation(func() error { diff --git a/table/destination.go b/table/destination.go index dbcbddb1..50d779df 100644 --- a/table/destination.go +++ b/table/destination.go @@ -108,12 +108,14 @@ func (i *PeerInfo) String() string { func NewPeerInfo(g *config.Global, p *config.Neighbor) *PeerInfo { id := net.ParseIP(string(p.RouteReflector.Config.RouteReflectorClusterId)).To4() + // exclude zone info + naddr, _ := net.ResolveIPAddr("ip", p.Config.NeighborAddress) return &PeerInfo{ AS: p.Config.PeerAs, LocalAS: g.Config.As, LocalID: net.ParseIP(g.Config.RouterId).To4(), - Address: net.ParseIP(p.Config.NeighborAddress), RouteReflectorClient: p.RouteReflector.Config.RouteReflectorClient, + Address: naddr.IP, RouteReflectorClusterID: id, MultihopTtl: p.EbgpMultihop.Config.MultihopTtl, } |