From 8fd86716d0a53c3cc5e1b5b4367e908061aacabc Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Wed, 31 Dec 2014 00:01:50 +0900 Subject: table: use 4byte AS as internal data structure Always use 4byte for AS internally. Convert AS for 2byte AS peer when necessary. Signed-off-by: FUJITA Tomonori --- table/table.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'table/table.go') diff --git a/table/table.go b/table/table.go index 1f4058f0..0be4c75f 100644 --- a/table/table.go +++ b/table/table.go @@ -145,7 +145,23 @@ func (td *TableDefault) validatePath(path Path) { if path == nil || path.GetRouteFamily() != td.ROUTE_FAMILY { log.Errorf("Invalid path. Expected instance of %s route family path, got %s.", td.ROUTE_FAMILY, path) } + _, attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_AS_PATH) + if attr != nil { + pathParam := attr.(*bgp.PathAttributeAsPath).Value + for _, as := range pathParam { + _, y := as.(*bgp.As4PathParam) + if !y { + log.Fatal("AsPathParam must be converted to As4PathParam, ", as) + } + } + } + + _, attr = path.getPathAttr(bgp.BGP_ATTR_TYPE_AS4_PATH) + if attr != nil { + log.Fatal("AS4_PATH must be converted to AS_PATH") + } } + func (td *TableDefault) validateNlri(nlri bgp.AddrPrefixInterface) { if nlri == nil { log.Error("Invalid Vpnv4 prefix given.") -- cgit v1.2.3