summaryrefslogtreecommitdiffhomepage
path: root/pkg/packet/bgp/validate.go
diff options
context:
space:
mode:
authorSergey Elantsev <elantsev.s@yandex.ru>2020-03-15 23:31:38 +0300
committerSergey Elantsev <elantsev.s@yandex.ru>2020-03-15 23:31:38 +0300
commitff36bb98781c92fd8ec20c9a89c0c5a4f63b05da (patch)
tree388aa42c02c74ffc400ddab967e2ebae2f58f996 /pkg/packet/bgp/validate.go
parent2ef8db0290bbc938b3f6a2404cdd927663da3a00 (diff)
optimized allocations in packet/bgp validations
Diffstat (limited to 'pkg/packet/bgp/validate.go')
-rw-r--r--pkg/packet/bgp/validate.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/pkg/packet/bgp/validate.go b/pkg/packet/bgp/validate.go
index a76c906a..f14458e7 100644
--- a/pkg/packet/bgp/validate.go
+++ b/pkg/packet/bgp/validate.go
@@ -33,17 +33,18 @@ func ValidateUpdateMsg(m *BGPUpdate, rfs map[RouteFamily]BGPAddPathMode, isEBGP
//check specific path attribute
ok, err := ValidateAttribute(a, rfs, isEBGP, isConfed)
if !ok {
- if err.(*MessageError).ErrorHandling == ERROR_HANDLING_SESSION_RESET {
+ msgErr := err.(*MessageError)
+ if msgErr.ErrorHandling == ERROR_HANDLING_SESSION_RESET {
return false, err
- } else if err.(*MessageError).Stronger(strongestError) {
+ } else if msgErr.Stronger(strongestError) {
strongestError = err
}
}
} else if a.GetType() == BGP_ATTR_TYPE_MP_REACH_NLRI || a.GetType() == BGP_ATTR_TYPE_MP_UNREACH_NLRI {
- eMsg := "the path attribute apears twice. Type : " + strconv.Itoa(int(a.GetType()))
+ eMsg := "the path attribute appears twice. Type : " + strconv.Itoa(int(a.GetType()))
return false, NewMessageError(eCode, eSubCodeAttrList, nil, eMsg)
} else {
- eMsg := "the path attribute apears twice. Type : " + strconv.Itoa(int(a.GetType()))
+ eMsg := "the path attribute appears twice. Type : " + strconv.Itoa(int(a.GetType()))
e := NewMessageErrorWithErrorHandling(eCode, eSubCodeAttrList, nil, ERROR_HANDLING_ATTRIBUTE_DISCARD, nil, eMsg)
if e.(*MessageError).Stronger(strongestError) {
strongestError = e
@@ -201,7 +202,7 @@ func ValidateAttribute(a PathAttributeInterface, rfs map[RouteFamily]BGPAddPathM
for _, x := range p.Values {
found := false
for _, y := range uniq {
- if x.String() == y.String() {
+ if x.Eq(y) {
found = true
break
}