summaryrefslogtreecommitdiffhomepage
path: root/table
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-07-03 11:40:02 +0900
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-07-03 11:40:02 +0900
commitb02f24e01213a19b92ebd96b703e0240fdf8d3ff (patch)
treea591d3d8eaa1fc437f4a0b11f5705c9e8eeb589b /table
parentc922dd575ac2c35afe3c6fb3ffea66e9b621c23e (diff)
server: bug fix of extra as-path prepending
When gobgp originates a route, the generated route had incorrect as-path. this patch fix this bug. Scenario test is also added to check this. [before] $ gobgp neighbor global rib Network Next Hop AS_PATH Age Attrs *> 10.0.1.0/24 192.168.10.3 65001 00:03:20 [{Origin: IGP} {Med: 0}] *> 10.0.2.0/24 192.168.10.4 65002 00:03:36 [{Origin: IGP} {Med: 200}] *> 10.10.0.0/24 0.0.0.0 65000 00:03:37 [{Origin: IGP}] $ gobgp neighbor 192.168.10.5 adj-out Network Next Hop AS_PATH Attrs 10.0.1.0/24 192.168.10.2 65000 65001 [{Origin: IGP}] 10.0.2.0/24 192.168.10.2 65000 65002 [{Origin: IGP}] 10.10.0.0/24 192.168.10.2 65000 65000 [{Origin: IGP}] [after] $ gobgp neighbor global rib Network Next Hop AS_PATH Age Attrs *> 10.0.1.0/24 192.168.10.3 65001 00:03:20 [{Origin: IGP} {Med: 0}] *> 10.0.2.0/24 192.168.10.4 65002 00:03:36 [{Origin: IGP} {Med: 200}] *> 10.10.0.0/24 0.0.0.0 00:03:37 [{Origin: IGP}] $ gobgp neighbor 192.168.10.5 adj-out Network Next Hop AS_PATH Attrs 10.0.1.0/24 192.168.10.2 65000 65001 [{Origin: IGP}] 10.0.2.0/24 192.168.10.2 65000 65002 [{Origin: IGP}] 10.10.0.0/24 192.168.10.2 65000 [{Origin: IGP}] Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table')
-rw-r--r--table/path.go25
1 files changed, 14 insertions, 11 deletions
diff --git a/table/path.go b/table/path.go
index 51be91af..bd368ec6 100644
--- a/table/path.go
+++ b/table/path.go
@@ -102,18 +102,21 @@ func (path *Path) UpdatePathAttrs(global *config.Global, peer *config.Neighbor)
// segment, and places that segment into the AS_PATH.
idx, originalAsPath := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH)
if idx < 0 {
- log.Fatal("missing AS_PATH mandatory attribute")
- }
- asPath := cloneAsPath(originalAsPath.(*bgp.PathAttributeAsPath))
- path.pathAttrs[idx] = asPath
- fst := asPath.Value[0].(*bgp.As4PathParam)
- if len(asPath.Value) > 0 && fst.Type == bgp.BGP_ASPATH_ATTR_TYPE_SEQ &&
- fst.ASLen() < 255 {
- fst.AS = append([]uint32{global.As}, fst.AS...)
- fst.Num += 1
- } else {
p := bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, []uint32{global.As})
- asPath.Value = append([]bgp.AsPathParamInterface{p}, asPath.Value...)
+ asPath := bgp.NewPathAttributeAsPath([]bgp.AsPathParamInterface{p})
+ path.pathAttrs = append(path.pathAttrs, asPath)
+ } else {
+ asPath := cloneAsPath(originalAsPath.(*bgp.PathAttributeAsPath))
+ path.pathAttrs[idx] = asPath
+ fst := asPath.Value[0].(*bgp.As4PathParam)
+ if len(asPath.Value) > 0 && fst.Type == bgp.BGP_ASPATH_ATTR_TYPE_SEQ &&
+ fst.ASLen() < 255 {
+ fst.AS = append([]uint32{global.As}, fst.AS...)
+ fst.Num += 1
+ } else {
+ p := bgp.NewAs4PathParam(bgp.BGP_ASPATH_ATTR_TYPE_SEQ, []uint32{global.As})
+ asPath.Value = append([]bgp.AsPathParamInterface{p}, asPath.Value...)
+ }
}
// MED Handling