summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--packet/bgp.go4
-rw-r--r--packet/validate.go6
-rw-r--r--table/path.go21
3 files changed, 6 insertions, 25 deletions
diff --git a/packet/bgp.go b/packet/bgp.go
index e12d7cda..f5afc948 100644
--- a/packet/bgp.go
+++ b/packet/bgp.go
@@ -1864,7 +1864,7 @@ type PathAttributeInterface interface {
Serialize() ([]byte, error)
Len() int
getFlags() BGPAttrFlag
- getType() BGPAttrType
+ GetType() BGPAttrType
ToApiStruct() *api.PathAttr
}
@@ -1889,7 +1889,7 @@ func (p *PathAttribute) getFlags() BGPAttrFlag {
return p.Flags
}
-func (p *PathAttribute) getType() BGPAttrType {
+func (p *PathAttribute) GetType() BGPAttrType {
return p.Type
}
diff --git a/packet/validate.go b/packet/validate.go
index 3da96387..2afd53c4 100644
--- a/packet/validate.go
+++ b/packet/validate.go
@@ -23,10 +23,10 @@ func ValidateUpdateMsg(m *BGPUpdate, rfs map[RouteFamily]bool) (bool, error) {
// check path attribute
for _, a := range m.PathAttributes {
// check duplication
- if _, ok := seen[a.getType()]; !ok {
- seen[a.getType()] = a
+ if _, ok := seen[a.GetType()]; !ok {
+ seen[a.GetType()] = a
} else {
- eMsg := "the path attribute apears twice. Type : " + strconv.Itoa(int(a.getType()))
+ eMsg := "the path attribute apears twice. Type : " + strconv.Itoa(int(a.GetType()))
return false, NewMessageError(eCode, eSubCodeAttrList, nil, eMsg)
}
diff --git a/table/path.go b/table/path.go
index 7ede28b8..0b8f732a 100644
--- a/table/path.go
+++ b/table/path.go
@@ -23,7 +23,6 @@ import (
"github.com/osrg/gobgp/packet"
"math"
"net"
- "reflect"
"time"
)
@@ -261,26 +260,8 @@ func (path *Path) getPathAttrs() []bgp.PathAttributeInterface {
}
func (path *Path) getPathAttr(pattrType bgp.BGPAttrType) (int, bgp.PathAttributeInterface) {
- attrMap := [bgp.BGP_ATTR_TYPE_AS4_AGGREGATOR + 1]reflect.Type{}
- attrMap[bgp.BGP_ATTR_TYPE_ORIGIN] = reflect.TypeOf(&bgp.PathAttributeOrigin{})
- attrMap[bgp.BGP_ATTR_TYPE_AS_PATH] = reflect.TypeOf(&bgp.PathAttributeAsPath{})
- attrMap[bgp.BGP_ATTR_TYPE_NEXT_HOP] = reflect.TypeOf(&bgp.PathAttributeNextHop{})
- attrMap[bgp.BGP_ATTR_TYPE_MULTI_EXIT_DISC] = reflect.TypeOf(&bgp.PathAttributeMultiExitDisc{})
- attrMap[bgp.BGP_ATTR_TYPE_LOCAL_PREF] = reflect.TypeOf(&bgp.PathAttributeLocalPref{})
- attrMap[bgp.BGP_ATTR_TYPE_ATOMIC_AGGREGATE] = reflect.TypeOf(&bgp.PathAttributeAtomicAggregate{})
- attrMap[bgp.BGP_ATTR_TYPE_AGGREGATOR] = reflect.TypeOf(&bgp.PathAttributeAggregator{})
- attrMap[bgp.BGP_ATTR_TYPE_COMMUNITIES] = reflect.TypeOf(&bgp.PathAttributeCommunities{})
- attrMap[bgp.BGP_ATTR_TYPE_ORIGINATOR_ID] = reflect.TypeOf(&bgp.PathAttributeOriginatorId{})
- attrMap[bgp.BGP_ATTR_TYPE_CLUSTER_LIST] = reflect.TypeOf(&bgp.PathAttributeClusterList{})
- attrMap[bgp.BGP_ATTR_TYPE_MP_REACH_NLRI] = reflect.TypeOf(&bgp.PathAttributeMpReachNLRI{})
- attrMap[bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI] = reflect.TypeOf(&bgp.PathAttributeMpUnreachNLRI{})
- attrMap[bgp.BGP_ATTR_TYPE_EXTENDED_COMMUNITIES] = reflect.TypeOf(&bgp.PathAttributeExtendedCommunities{})
- attrMap[bgp.BGP_ATTR_TYPE_AS4_PATH] = reflect.TypeOf(&bgp.PathAttributeAs4Path{})
- attrMap[bgp.BGP_ATTR_TYPE_AS4_AGGREGATOR] = reflect.TypeOf(&bgp.PathAttributeAs4Aggregator{})
-
- t := attrMap[pattrType]
for i, p := range path.pathAttrs {
- if t == reflect.TypeOf(p) {
+ if p.GetType() == pattrType {
return i, p
}
}