summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorHiroshi Yokoi <yokoi.hiroshi@po.ntts.co.jp>2015-07-15 19:53:53 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-07-31 16:26:17 +0900
commit0b4b806c06f0ee50bb1bc1b30c38399553687abd (patch)
tree6898ec9eeb21a26668012c1c7743772da7b72214 /table
parent2ad42ead02cce21cf71b3dde0731e8f5c6d4ac6a (diff)
config: use the latest openconfig yang
Diffstat (limited to 'table')
-rw-r--r--table/path.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/table/path.go b/table/path.go
index 12f7d498..251eefbc 100644
--- a/table/path.go
+++ b/table/path.go
@@ -74,26 +74,27 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
return
}
- if peer.PeerType == config.PEER_TYPE_EXTERNAL {
+ localAddress := peer.Transport.TransportConfig.LocalAddress
+ if peer.NeighborConfig.PeerType == config.PEER_TYPE_EXTERNAL {
// NEXTHOP handling
- path.SetNexthop(peer.LocalAddress)
+ path.SetNexthop(localAddress)
// AS_PATH handling
- path.PrependAsn(global.As, 1)
+ path.PrependAsn(global.GlobalConfig.As, 1)
// MED Handling
idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC)
if idx >= 0 {
path.pathAttrs = append(path.pathAttrs[:idx], path.pathAttrs[idx+1:]...)
}
- } else if peer.PeerType == config.PEER_TYPE_INTERNAL {
+ } else if peer.NeighborConfig.PeerType == config.PEER_TYPE_INTERNAL {
// NEXTHOP handling for iBGP
// if the path generated locally set local address as nexthop.
// if not, don't modify it.
// TODO: NEXT-HOP-SELF support
selfGenerated := path.GetSource().ID == nil
if selfGenerated {
- path.SetNexthop(peer.LocalAddress)
+ path.SetNexthop(localAddress)
}
// AS_PATH handling for iBGP
@@ -117,8 +118,8 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
} else {
log.WithFields(log.Fields{
"Topic": "Peer",
- "Key": peer.NeighborAddress,
- }).Warnf("invalid peer type: %d", peer.PeerType)
+ "Key": peer.NeighborConfig.NeighborAddress,
+ }).Warnf("invalid peer type: %d", peer.NeighborConfig.PeerType)
}
}
@@ -373,11 +374,12 @@ func (path *Path) GetCommunities() []uint32 {
}
// SetCommunities adds or replaces communities with new ones.
-// If the length of communites is 0, it does nothing.
+// If the length of communities is 0 and doReplace is true, it clears communities.
func (path *Path) SetCommunities(communities []uint32, doReplace bool) {
- if len(communities) == 0 {
- // do nothing
+ if len(communities) == 0 && doReplace {
+ // clear communities
+ path.ClearCommunities()
return
}