summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-08-04 15:15:01 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-09-29 15:05:43 +0900
commitf662b657abc3341d32eeba302d776ecada28e852 (patch)
treebdcb9f74c47e7051201b00a62c765fd42ff311b1
parent9b278ba79ba2d12598405d1109b0b90b42e68357 (diff)
bgp/validate: Check Wellknown Attributes exist with MultiProtocol
RFC4760 says "An UPDATE message that carries the MP_REACH_NLRI MUST also carry the ORIGIN and the AS_PATH attributes". This patch adds a validation to comply with it. Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
-rw-r--r--packet/bgp/validate.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/packet/bgp/validate.go b/packet/bgp/validate.go
index 77a125b9..be44e605 100644
--- a/packet/bgp/validate.go
+++ b/packet/bgp/validate.go
@@ -37,7 +37,7 @@ func ValidateUpdateMsg(m *BGPUpdate, rfs map[RouteFamily]BGPAddPathMode, doConfe
}
}
- if len(m.NLRI) > 0 {
+ if _, ok := seen[BGP_ATTR_TYPE_MP_REACH_NLRI]; ok || len(m.NLRI) > 0 {
// check the existence of well-known mandatory attributes
exist := func(attrs []BGPAttrType) (bool, BGPAttrType) {
for _, attr := range attrs {
@@ -48,7 +48,10 @@ func ValidateUpdateMsg(m *BGPUpdate, rfs map[RouteFamily]BGPAddPathMode, doConfe
}
return true, 0
}
- mandatory := []BGPAttrType{BGP_ATTR_TYPE_ORIGIN, BGP_ATTR_TYPE_AS_PATH, BGP_ATTR_TYPE_NEXT_HOP}
+ mandatory := []BGPAttrType{BGP_ATTR_TYPE_ORIGIN, BGP_ATTR_TYPE_AS_PATH}
+ if len(m.NLRI) > 0 {
+ mandatory = append(mandatory, BGP_ATTR_TYPE_NEXT_HOP)
+ }
if ok, t := exist(mandatory); !ok {
eMsg := "well-known mandatory attributes are not present. type : " + strconv.Itoa(int(t))
data := []byte{byte(t)}