summaryrefslogtreecommitdiffhomepage
path: root/packet/validate.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-03-08 15:13:07 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-03-08 15:13:07 +0900
commit1c982d8336c9d89732e8a481a8c90b3e7e283f6f (patch)
tree60c48bd57d3fb771ddab46a9e9e2b76b7715069b /packet/validate.go
parent608d09c90e906ed43e9206e903443753f73d80b0 (diff)
server: support multiple route familes per peer
You can configure like the following: [Global] As = 65032 RouterId = "192.168.255.1" [[NeighborList]] NeighborAddress = "10.0.255.1" PeerAs = 65001 [NeighborList.RouteServer] RouteServerClient = true [[NeighborList.AfiSafiList]] AfiSafiName = "ipv4-unicast" [[NeighborList.AfiSafiList]] AfiSafiName = "ipv6-unicast" Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/validate.go')
-rw-r--r--packet/validate.go21
1 files changed, 6 insertions, 15 deletions
diff --git a/packet/validate.go b/packet/validate.go
index 80d51a9e..b05574b2 100644
--- a/packet/validate.go
+++ b/packet/validate.go
@@ -7,23 +7,14 @@ import (
"strconv"
)
-func isRfSupported(rf RouteFamily, rfs []RouteFamily) bool {
- for _, r := range rfs {
- if rf == r {
- return true
- }
- }
- return false
-}
-
// Validator for BGPUpdate
-func ValidateUpdateMsg(m *BGPUpdate, rfs []RouteFamily) (bool, error) {
+func ValidateUpdateMsg(m *BGPUpdate, rfs map[RouteFamily]bool) (bool, error) {
eCode := uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR)
eSubCodeAttrList := uint8(BGP_ERROR_SUB_MALFORMED_ATTRIBUTE_LIST)
eSubCodeMissing := uint8(BGP_ERROR_SUB_MISSING_WELL_KNOWN_ATTRIBUTE)
if len(m.NLRI) > 0 || len(m.WithdrawnRoutes) > 0 {
- if isRfSupported(RF_IPv4_UC, rfs) == false {
+ if _, ok := rfs[RF_IPv4_UC]; !ok {
return false, NewMessageError(0, 0, nil, fmt.Sprintf("Address-family rf %d not avalible for session", RF_IPv4_UC))
}
}
@@ -67,7 +58,7 @@ func ValidateUpdateMsg(m *BGPUpdate, rfs []RouteFamily) (bool, error) {
return true, nil
}
-func ValidateAttribute(a PathAttributeInterface, rfs []RouteFamily) (bool, error) {
+func ValidateAttribute(a PathAttributeInterface, rfs map[RouteFamily]bool) (bool, error) {
eCode := uint8(BGP_ERROR_UPDATE_MESSAGE_ERROR)
eSubCodeBadOrigin := uint8(BGP_ERROR_SUB_INVALID_ORIGIN_ATTRIBUTE)
@@ -77,7 +68,7 @@ func ValidateAttribute(a PathAttributeInterface, rfs []RouteFamily) (bool, error
checkPrefix := func(l []AddrPrefixInterface) bool {
for _, prefix := range l {
rf := AfiSafiToRouteFamily(prefix.AFI(), prefix.SAFI())
- if isRfSupported(rf, rfs) == false {
+ if _, ok := rfs[rf]; !ok {
return false
}
}
@@ -87,7 +78,7 @@ func ValidateAttribute(a PathAttributeInterface, rfs []RouteFamily) (bool, error
switch p := a.(type) {
case *PathAttributeMpUnreachNLRI:
rf := AfiSafiToRouteFamily(p.AFI, p.SAFI)
- if isRfSupported(rf, rfs) == false {
+ if _, ok := rfs[rf]; !ok {
return false, NewMessageError(0, 0, nil, fmt.Sprintf("Address-family rf %d not avalible for session", rf))
}
if checkPrefix(p.Value) == false {
@@ -95,7 +86,7 @@ func ValidateAttribute(a PathAttributeInterface, rfs []RouteFamily) (bool, error
}
case *PathAttributeMpReachNLRI:
rf := AfiSafiToRouteFamily(p.AFI, p.SAFI)
- if isRfSupported(rf, rfs) == false {
+ if _, ok := rfs[rf]; !ok {
return false, NewMessageError(0, 0, nil, fmt.Sprintf("Address-family rf %d not avalible for session", rf))
}
if checkPrefix(p.Value) == false {