Skip to content
Snippets Groups Projects
Commit cd68c8be authored by Daniel Czerwonk's avatar Daniel Czerwonk
Browse files

optimized complexity of method

parent c6587afa
No related branches found
No related tags found
No related merge requests found
...@@ -227,7 +227,6 @@ func (s *establishedState) updates(u *packet.BGPUpdate) { ...@@ -227,7 +227,6 @@ func (s *establishedState) updates(u *packet.BGPUpdate) {
} }
func (s *establishedState) processAttributes(attrs *packet.PathAttribute, path *route.Path) { func (s *establishedState) processAttributes(attrs *packet.PathAttribute, path *route.Path) {
var unknownAttributes *packet.PathAttribute
var currentUnknown *packet.PathAttribute var currentUnknown *packet.PathAttribute
for pa := attrs; pa != nil; pa = pa.Next { for pa := attrs; pa != nil; pa = pa.Next {
...@@ -248,23 +247,26 @@ func (s *establishedState) processAttributes(attrs *packet.PathAttribute, path * ...@@ -248,23 +247,26 @@ func (s *establishedState) processAttributes(attrs *packet.PathAttribute, path *
case packet.LargeCommunitiesAttr: case packet.LargeCommunitiesAttr:
path.BGPPath.LargeCommunities = pa.Value.([]packet.LargeCommunity) path.BGPPath.LargeCommunities = pa.Value.([]packet.LargeCommunity)
default: default:
if !pa.Transitive { currentUnknown = s.processUnknownAttribute(pa, currentUnknown)
continue if path.BGPPath.UnknownAttributes == nil {
path.BGPPath.UnknownAttributes = currentUnknown
} }
}
}
}
p := pa.Copy() func (s *establishedState) processUnknownAttribute(attr, current *packet.PathAttribute) *packet.PathAttribute {
if unknownAttributes == nil { if !attr.Transitive {
unknownAttributes = p return current
currentUnknown = unknownAttributes }
continue
}
currentUnknown.Next = p p := attr.Copy()
currentUnknown = p if current == nil {
} return p
} }
path.BGPPath.UnknownAttributes = unknownAttributes current.Next = p
return p
} }
func (s *establishedState) keepaliveReceived() (state, string) { func (s *establishedState) keepaliveReceived() (state, string) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment