diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-03-15 22:44:14 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-03-15 22:44:14 +0900 |
commit | 77f0e6acf15716776eaf11d81a7b730cac73352a (patch) | |
tree | ea752c1a058aac65c48e413f7ee1459c994a022c | |
parent | c3ed01999f8cb33fc1dd7f49ef283719b5f829fc (diff) |
table: support advertising local route with specified nexthop via eBGP
we support this for iBGP. why not for eBGP.
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | table/path.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/table/path.go b/table/path.go index 1a10b965..9469fe1d 100644 --- a/table/path.go +++ b/table/path.go @@ -162,9 +162,15 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor) } localAddress := net.ParseIP(peer.Transport.Config.LocalAddress) + isZero := func(ip net.IP) bool { + return ip.Equal(net.ParseIP("0.0.0.0")) || ip.Equal(net.ParseIP("::")) + } + nexthop := path.GetNexthop() if peer.Config.PeerType == config.PEER_TYPE_EXTERNAL { // NEXTHOP handling - path.SetNexthop(localAddress) + if !path.IsLocal() || isZero(nexthop) { + path.SetNexthop(localAddress) + } // AS_PATH handling path.PrependAsn(peer.Config.LocalAs, 1) @@ -184,8 +190,7 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor) // if the path generated locally set local address as nexthop. // if not, don't modify it. // TODO: NEXT-HOP-SELF support - nexthop := path.GetNexthop() - if path.IsLocal() && (nexthop.Equal(net.ParseIP("0.0.0.0")) || nexthop.Equal(net.ParseIP("::"))) { + if path.IsLocal() && isZero(nexthop) { path.SetNexthop(localAddress) } |