From 2677986f06b916c4bbcea10bccb25c46a14a9796 Mon Sep 17 00:00:00 2001
From: Daniel Czerwonk <daniel@dan-nrw.de>
Date: Fri, 6 Jul 2018 07:52:06 +0200
Subject: [PATCH] simplified loop

---
 protocols/bgp/server/update_sender.go | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/protocols/bgp/server/update_sender.go b/protocols/bgp/server/update_sender.go
index ff82ba88..478e9a08 100644
--- a/protocols/bgp/server/update_sender.go
+++ b/protocols/bgp/server/update_sender.go
@@ -90,7 +90,7 @@ func (u *UpdateSender) sender(aggrTime time.Duration) {
 
 		for key, pathNLRIs := range u.toSend {
 			budget = packet.MaxLen - packet.HeaderLen - packet.MinUpdateLen - int(pathNLRIs.path.BGPPath.Length()) - overhead
-      
+
 			pathAttrs, err = packet.PathAttributes(pathNLRIs.path, u.iBGP, u.rrClient)
 			if err != nil {
 				log.Errorf("Unable to get path attributes: %v", err)
@@ -193,10 +193,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 {
@@ -209,8 +207,6 @@ func (u *UpdateSender) copyAttributesWithoutNextHop(pa *packet.PathAttribute) (a
 			}
 			lastCopy = curCopy
 		}
-
-		cur = cur.Next
 	}
 
 	return attrs, nextHop
-- 
GitLab