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) {
}
func (s *establishedState) processAttributes(attrs *packet.PathAttribute, path *route.Path) {
var unknownAttributes *packet.PathAttribute
var currentUnknown *packet.PathAttribute
for pa := attrs; pa != nil; pa = pa.Next {
......@@ -248,23 +247,26 @@ func (s *establishedState) processAttributes(attrs *packet.PathAttribute, path *
case packet.LargeCommunitiesAttr:
path.BGPPath.LargeCommunities = pa.Value.([]packet.LargeCommunity)
default:
if !pa.Transitive {
continue
currentUnknown = s.processUnknownAttribute(pa, currentUnknown)
if path.BGPPath.UnknownAttributes == nil {
path.BGPPath.UnknownAttributes = currentUnknown
}
}
}
}
p := pa.Copy()
if unknownAttributes == nil {
unknownAttributes = p
currentUnknown = unknownAttributes
continue
}
func (s *establishedState) processUnknownAttribute(attr, current *packet.PathAttribute) *packet.PathAttribute {
if !attr.Transitive {
return current
}
currentUnknown.Next = p
currentUnknown = p
}
p := attr.Copy()
if current == nil {
return p
}
path.BGPPath.UnknownAttributes = unknownAttributes
current.Next = p
return p
}
func (s *establishedState) keepaliveReceived() (state, string) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment