All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] neighbour: confirm neigh entries when ARP packet is received
@ 2018-08-29  2:48 Vasily Khoruzhick
  2018-09-01 23:51 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Vasily Khoruzhick @ 2018-08-29  2:48 UTC (permalink / raw)
  To: Ihar Hrachyshka, David S. Miller, Roopa Prabhu, Alexey Dobriyan,
	Jim Westfall, Stephen Hemminger, Vasily Khoruzhick, Kees Cook,
	Wolfgang Bumiller, Eric Dumazet, netdev
  Cc: 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 no sense not to confirm it when ARP packet is
received.

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

Signed-off-by: Vasily Khoruzhick <vasilykh@arista.com>
---
 net/core/neighbour.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index aa19d86937af..901418ef70ea 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -1180,6 +1180,9 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
 		lladdr = neigh->ha;
 	}
 
+	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.
 	 */
@@ -1205,11 +1208,8 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
 	 * 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);
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] neighbour: confirm neigh entries when ARP packet is received
  2018-08-29  2:48 [PATCH] neighbour: confirm neigh entries when ARP packet is received Vasily Khoruzhick
@ 2018-09-01 23:51 ` David Miller
  2018-09-04 18:31   ` Ihar Hrachyshka
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2018-09-01 23:51 UTC (permalink / raw)
  To: vasilykh
  Cc: ihrachys, roopa, adobriyan, jwestfall, stephen, anarsoul,
	keescook, w.bumiller, edumazet, netdev

From: Vasily Khoruzhick <vasilykh@arista.com>
Date: Tue, 28 Aug 2018 19:48:25 -0700

> 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 no sense not to confirm it when ARP packet is
> received.
> 
> Fixes: 77d7123342 ("neighbour: update neigh timestamps iff update is
> effective")
> 
> Signed-off-by: Vasily Khoruzhick <vasilykh@arista.com>

I'm not so sure.

The comment above the code you are moving explains that the current
behavior is intention, and it explains why too.

Even if your change is correct, you're now making that comment
inaccuratte, so you'd have to update it to match the new code.

But I still think the current code is intentionally behaving that
way, and for good reason.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] neighbour: confirm neigh entries when ARP packet is received
  2018-09-01 23:51 ` David Miller
@ 2018-09-04 18:31   ` Ihar Hrachyshka
  2018-09-04 18:57     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Ihar Hrachyshka @ 2018-09-04 18:31 UTC (permalink / raw)
  To: David Miller
  Cc: Vasiliy Khoruzhick, roopa, adobriyan, jwestfall, stephen,
	anarsoul, keescook, w.bumiller, edumazet, Networking

On Sat, Sep 1, 2018 at 4:51 PM, David Miller <davem@davemloft.net> wrote:
> From: Vasily Khoruzhick <vasilykh@arista.com>
> Date: Tue, 28 Aug 2018 19:48:25 -0700
>
>> 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 no sense not to confirm it when ARP packet is
>> received.
>>
>> Fixes: 77d7123342 ("neighbour: update neigh timestamps iff update is
>> effective")
>>
>> Signed-off-by: Vasily Khoruzhick <vasilykh@arista.com>
>
> I'm not so sure.
>
> The comment above the code you are moving explains that the current
> behavior is intention, and it explains why too.
>
> Even if your change is correct, you're now making that comment
> inaccuratte, so you'd have to update it to match the new code.
>
> But I still think the current code is intentionally behaving that
> way, and for good reason.

Hi David,

(I am the one who put this comment there.)

I agree with the reasoning that Vasily provided for the change (we
should confirm the entry if e.g. ARP packet with identical
hwaddr/ipaddr pair arrives; just not mark it as updated). It was a
mistake of mine to put access to both updated and confirmed fields
under the "if" branch. Just leaving 'updated' there and moving
'confirmed' outside seems like the right thing to do.

The original intent was to not update 'updated' field when no update
happens (because of consequent ARP packets sent in short span of
time). The fix by Vasily should not negatively affect this scenario.

Of course, I also agree that the comment will need some adjustment to
reflect the fact that now a single timestamp is being updated. Perhaps
while at it, Vasily could also explicitly describe in a comment which
scenario the "if" branch check is supposed to cover. (I should have
done it myself, mea culpa.)

I hope it helps,
Ihar

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] neighbour: confirm neigh entries when ARP packet is received
  2018-09-04 18:31   ` Ihar Hrachyshka
@ 2018-09-04 18:57     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-09-04 18:57 UTC (permalink / raw)
  To: ihrachys
  Cc: vasilykh, roopa, adobriyan, jwestfall, stephen, anarsoul,
	keescook, w.bumiller, edumazet, netdev

From: Ihar Hrachyshka <ihrachys@redhat.com>
Date: Tue, 4 Sep 2018 11:31:23 -0700

> Of course, I also agree that the comment will need some adjustment to
> reflect the fact that now a single timestamp is being updated. Perhaps
> while at it, Vasily could also explicitly describe in a comment which
> scenario the "if" branch check is supposed to cover. (I should have
> done it myself, mea culpa.)

Yes, that would help a lot.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-09-04 23:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29  2:48 [PATCH] neighbour: confirm neigh entries when ARP packet is received Vasily Khoruzhick
2018-09-01 23:51 ` David Miller
2018-09-04 18:31   ` Ihar Hrachyshka
2018-09-04 18:57     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.