summaryrefslogtreecommitdiffhomepage
path: root/server/server.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-29 12:27:55 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-08-29 12:27:55 +0900
commit46a99f289acd19dda0bced25634ab049f43d7090 (patch)
tree1f18f7c932d6a6f7b2db1a9c316f7bad0777298e /server/server.go
parentec7b27eb3da385d68ddf2f8ed735d43afe2cb7fd (diff)
server: check duplicate path attributes for ModPath request
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/server.go')
-rw-r--r--server/server.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/server/server.go b/server/server.go
index ed09f528..64db3420 100644
--- a/server/server.go
+++ b/server/server.go
@@ -867,6 +867,7 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest, peerInfo *ta
var nexthop string
var rf bgp.RouteFamily
var path *api.Path
+ seen := make(map[bgp.BGPAttrType]bool)
arg, ok := grpcReq.Data.(*api.ModPathArguments)
if !ok {
@@ -897,6 +898,12 @@ func (server *BgpServer) handleModPathRequest(grpcReq *GrpcRequest, peerInfo *ta
goto ERR
}
+ if _, ok := seen[p.GetType()]; !ok {
+ seen[p.GetType()] = true
+ } else {
+ result.ResponseErr = fmt.Errorf("the path attribute apears twice. Type : " + strconv.Itoa(int(p.GetType())))
+ goto ERR
+ }
switch p.GetType() {
case bgp.BGP_ATTR_TYPE_NEXT_HOP:
nexthop = p.(*bgp.PathAttributeNextHop).Value.String()