Skip to contentSkip to conversation

neighbour: confirm neigh entries when ARP packet is received

PATCH Superseded Vasily Khoruzhick 4 participants 5 messages Sep 11, 2018 – Sep 13, 2018

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 neighbour: confirm neigh entries when ARP packet is received

Update 'confirmed' timestamp when ARP packet is received. It shouldn't affect locktime logic and anyway entry can be confirmed by any higher-layer protocol. Thus it makes to sense not to confirm it when ARP packet is received.

Fixes 77d7123342 ("neighbour: update neigh timestamps iff update is

effective")

---
v2: - update comment to match new code.

 net/core/neighbour.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
net/core/neighbour.c +8 -5
index aa19d86937af..56a554597db5 100644
@@ -1180,6 +1180,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
 		lladdr = neigh->ha;
 	}
 
+	/* Update confirmed timestamp for neighbour entry after we
+	 * received ARP packet even if it doesn't change IP to MAC binding.
+	 */
+	if (new & NUD_CONNECTED)
+		neigh->confirmed = jiffies;
+
 	/* If entry was valid and address is not changed,
 	   do not change entry state, if new one is STALE.
 	 */
@@ -1201,15 +1207,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
 		}
 	}
 
-	/* Update timestamps only once we know we will make a change to the
+	/* Update timestamp only once we know we will make a change to the
 	 * neighbour entry. Otherwise we risk to move the locktime window with
 	 * noop updates and ignore relevant ARP updates.
 	 */
-	if (new != old || lladdr != neigh->ha) {
-		if (new & NUD_CONNECTED)
-			neigh->confirmed = jiffies;
+	if (new != old || lladdr != neigh->ha)
 		neigh->updated = jiffies;
-	}
 
 	if (new != old) {
 		neigh_del_timer(neigh);
Signature · 1 line
2.18.0
#1 lore raw

net/core/neighbour.c int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, · line 1187

Quoted 13 lines · On Tue, 11 Sep 2018 11:04:06 -0700 Vasily Khoruzhick <[email protected]>…
net/core/neighbour.c +5 -0
index aa19d86937af..56a554597db5 100644
@@ -1180,6 +1180,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
 		lladdr = neigh->ha;
 	}
 
+	/* Update confirmed timestamp for neighbour entry after we
+	 * received ARP packet even if it doesn't change IP to MAC binding.
+	 */
+	if (new & NUD_CONNECTED)
+		neigh->confirmed = jiffies;

You might want to do:

	if ((new & NUD_CONNECTED) && neigh->confirmed != jiffies)
		neigh->confirmed = jiffies;

This avoid poisoning the cacheline with unnecessary write.

#2 lore raw
Quoted 18 lines · Stephen Hemminger

net/core/neighbour.c int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, · line 1187

Quoted 13 lines · On Tue, 11 Sep 2018 11:04:06 -0700 Vasily Khoruzhick <[email protected]>…
net/core/neighbour.c +5 -0
index aa19d86937af..56a554597db5 100644
@@ -1180,6 +1180,12 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
              lladdr = neigh->ha;
      }
 
+     /* Update confirmed timestamp for neighbour entry after we
+      * received ARP packet even if it doesn't change IP to MAC binding.
+      */
+     if (new & NUD_CONNECTED)
+             neigh->confirmed = jiffies;

You might want to do:

Quoted 4 lines
        if ((new & NUD_CONNECTED) && neigh->confirmed != jiffies)
                neigh->confirmed = jiffies;

This avoid poisoning the cacheline with unnecessary write.

Sorry for duplicate - this time in plain text, so it should get through lkml filter:

I don't think that it's performance-critical path, so this optimization is unnecessary
and it doesn't improve code readability.

#3 lore raw
In reply to Vasily Khoruzhick

Hello!

Quoted 3 lines · Vasily Khoruzhick

Update 'confirmed' timestamp when ARP packet is received. It shouldn't affect locktime logic and anyway entry can be confirmed by any higher-layer protocol. Thus it makes to sense not to confirm it when ARP packet is

"Makes sense" or "makes no sense"?

Quoted 6 lines

received.

Fixes 77d7123342 ("neighbour: update neigh timestamps iff update is

effective")

[...]

MBR, Sergei

maintainer
#4 lore raw
In reply to Vasily Khoruzhick

From: Vasily Khoruzhick <[email protected]>
Date: Tue, 11 Sep 2018 11:04:06 -0700

Quoted 11 lines

Update 'confirmed' timestamp when ARP packet is received. It shouldn't affect locktime logic and anyway entry can be confirmed by any higher-layer protocol. Thus it makes to sense not to confirm it when ARP packet is received.

Fixes 77d7123342 ("neighbour: update neigh timestamps iff update is

effective")

---
v2: - update comment to match new code.

Please fix the wording in this commit message, as per Sergei's feedback.

Also, the Fixes: tag should be all one line (people grep for these strings in the repository) and with no empty lines between it and the rest of the tags such as Signed-off-by:

Thanks.