summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-07-03 15:16:11 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-07-13 08:56:08 +0900
commit1bf1652c08dde3368e098c2f28260cb24f4aa0f8 (patch)
treeae57764ac55db79bdd7cee417ae88ad156129eb9 /table
parentb759f2b1ca7176ea134b3a86d8bfea44509712dd (diff)
server/table: support iBGP behavior
also added scenario_test Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/path.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/table/path.go b/table/path.go
index f1f92573..8734c513 100644
--- a/table/path.go
+++ b/table/path.go
@@ -87,11 +87,28 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
path.pathAttrs = append(path.pathAttrs[:idx], path.pathAttrs[idx+1:]...)
}
} else if peer.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)
+ }
+
+ // AS_PATH handling for iBGP
+ // if the path has AS_PATH path attribute, don't modify it.
+ // if not, attach *empty* AS_PATH path attribute.
+ idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
+ if idx < 0 {
+ path.PrependAsn(0, 0)
+ }
+
// For iBGP peers we are required to send local-pref attribute
// for connected or local prefixes.
// We set default local-pref 100.
p := bgp.NewPathAttributeLocalPref(100)
- idx, _ := path.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
+ idx, _ = path.getPathAttr(bgp.BGP_ATTR_TYPE_LOCAL_PREF)
if idx < 0 {
path.pathAttrs = append(path.pathAttrs, p)
} else {