diff --git a/protocols/bgp/server/update_sender.go b/protocols/bgp/server/update_sender.go index bc0f204ae378fb1370c5c683418afa04593f4aba..dd1c799985a6b6fb66b26381f26ebbfd4ab1c920 100644 --- a/protocols/bgp/server/update_sender.go +++ b/protocols/bgp/server/update_sender.go @@ -209,10 +209,8 @@ func (u *UpdateSender) bgpUpdateMultiProtocol(pfxs []bnet.Prefix, pa *packet.Pat } func (u *UpdateSender) copyAttributesWithoutNextHop(pa *packet.PathAttribute) (attrs *packet.PathAttribute, nextHop bnet.IP) { - cur := pa - var curCopy, lastCopy *packet.PathAttribute - for cur != nil { + for cur := pa; cur != nil; cur = cur.Next { if cur.TypeCode == packet.NextHopAttr { nextHop = cur.Value.(bnet.IP) } else { @@ -225,8 +223,6 @@ func (u *UpdateSender) copyAttributesWithoutNextHop(pa *packet.PathAttribute) (a } lastCopy = curCopy } - - cur = cur.Next } return attrs, nextHop