From 1bf1652c08dde3368e098c2f28260cb24f4aa0f8 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Fri, 3 Jul 2015 15:16:11 +0900 Subject: server/table: support iBGP behavior also added scenario_test Signed-off-by: ISHIDA Wataru --- table/path.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'table/path.go') 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 { -- cgit v1.2.3