From 46a99f289acd19dda0bced25634ab049f43d7090 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sat, 29 Aug 2015 12:27:55 +0900 Subject: server: check duplicate path attributes for ModPath request Signed-off-by: FUJITA Tomonori --- server/server.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'server/server.go') 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() -- cgit v1.2.3