Skip to contentSkip to conversation

bonding: verify if bond has ip only once on arp validate

PATCH Superseded Veaceslav Falico 2 participants 3 messages Jun 19, 2013

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/6 bonding: verify if bond has ip only once on arp validate

It's extra work to verify bond's ip presence for every slave, so take it out of the loop.

---
 drivers/net/bonding/bond_main.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/bonding/bond_main.c +8 -5
index bc1246f..3d8b5ba 100644
@@ -2602,13 +2602,16 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32
 	int i;
 	__be32 *targets = bond->params.arp_targets;
 
+	if (!bond_has_this_ip(bond, tip)) {
+		pr_debug("bva: tip %pI4 not found\n", &tip);
+		return;
+	}
+
 	for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
-		pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip) %d\n",
-			 &sip, &tip, i, &targets[i],
-			 bond_has_this_ip(bond, tip));
+		pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip)\n",
+			 &sip, &tip, i, &targets[i]);
 		if (sip == targets[i]) {
-			if (bond_has_this_ip(bond, tip))
-				slave->last_arp_rx = jiffies;
+			slave->last_arp_rx = jiffies;
 			return;
 		}
 	}
Signature · 1 line
1.7.1
#1 lore raw
Quoted 2 lines · Veaceslav Falico

It's extra work to verify bond's ip presence for every slave, so take it out of the loop.

The current code doesn't verify for every slave (target address,
actually). The call to bond_has_this_ip() happens at most once, if the sip (source IP) matches the arp_ip_target being inspected, after which the function returns.

I can see that the patch will bypass the loop entirely if the
bond lacks the IP, but I'm not sure that's a meaningful improvement, since it changes from calling bond_has_this_ip 0 or 1 times to always 1 time.

	-J
Quoted 34 lines

---
drivers/net/bonding/bond_main.c | 13 ++++++++-----

1 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/bonding/bond_main.c +8 -5
index bc1246f..3d8b5ba 100644
@@ -2602,13 +2602,16 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32
 	int i;
 	__be32 *targets = bond->params.arp_targets;
 
+	if (!bond_has_this_ip(bond, tip)) {
+		pr_debug("bva: tip %pI4 not found\n", &tip);
+		return;
+	}
+
 	for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
-		pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip) %d\n",
-			 &sip, &tip, i, &targets[i],
-			 bond_has_this_ip(bond, tip));
+		pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip)\n",
+			 &sip, &tip, i, &targets[i]);
 		if (sip == targets[i]) {
-			if (bond_has_this_ip(bond, tip))
-				slave->last_arp_rx = jiffies;
+			slave->last_arp_rx = jiffies;
 			return;
 		}
 	}
Signature · 1 line
1.7.1

---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]

#2 lore raw
Quoted 10 lines · Jay Vosburgh
Quoted 2 lines · Veaceslav Falico

It's extra work to verify bond's ip presence for every slave, so take it out of the loop.

The current code doesn't verify for every slave (target address,
actually). The call to bond_has_this_ip() happens at most once, if the sip (source IP) matches the arp_ip_target being inspected, after which the function returns.

Quoted 4 lines

I can see that the patch will bypass the loop entirely if the
bond lacks the IP, but I'm not sure that's a meaningful improvement, since it changes from calling bond_has_this_ip 0 or 1 times to always 1 time.

Yep, you're right, I've misread the code.

It's just not worth it, will drop this patch in v2.

Quoted 42 lines
	-J
Quoted 32 lines

---
drivers/net/bonding/bond_main.c | 13 ++++++++-----

1 files changed, 8 insertions(+), 5 deletions(-)
drivers/net/bonding/bond_main.c +8 -6
index bc1246f..3d8b5ba 100644
@@ -2602,13 +2602,16 @@ static void bond_validate_arp(struct bonding *bond, struct slave *slave, __be32
 	int i;
 	__be32 *targets = bond->params.arp_targets;
 
+	if (!bond_has_this_ip(bond, tip)) {
+		pr_debug("bva: tip %pI4 not found\n", &tip);
+		return;
+	}
+
 	for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
-		pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip) %d\n",
-			 &sip, &tip, i, &targets[i],
-			 bond_has_this_ip(bond, tip));
+		pr_debug("bva: sip %pI4 tip %pI4 t[%d] %pI4 bhti(tip)\n",
+			 &sip, &tip, i, &targets[i]);
 		if (sip == targets[i]) {
-			if (bond_has_this_ip(bond, tip))
-				slave->last_arp_rx = jiffies;
+			slave->last_arp_rx = jiffies;
 			return;
 		}
 	}
--
Quoted 2 lines

1.7.1

---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]