netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] ipv4: arp: Always update neighbour address when a gratuitous arp is received
@ 2013-12-20  5:41 Salam Noureddine
  2013-12-20 14:00 ` Hannes Frederic Sowa
  0 siblings, 1 reply; 7+ messages in thread
From: Salam Noureddine @ 2013-12-20  5:41 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Hannes Frederic Sowa, netdev
  Cc: Salam Noureddine

Gratuitous arp packets are useful in switchover scenarios to update
client arp tables as quickly as possible. Currently, the mac address
of a neighbour is only updated after a locktime period has elapsed
since the last update. In most use cases such delays are unacceptable
for network admins. Moreover, the "updated" field of the neighbour
stucture doesn't record the last time the address of a neighbour
changed but records any change that happens to theneighbour. This is
clearly a bug since locktime uses that field as meaning "addr_updated".
With this observation, I was able to perpetuate a stale address by
sending a stream of gratuitous arp packets spaced less than locktime
apart.

Signed-off-by: Salam Noureddine <noureddine@aristanetworks.com>
---
 net/ipv4/arp.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 7808093..ab13347 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -910,7 +910,10 @@ static int arp_process(struct sk_buff *skb)
 		   agents are active. Taking the first reply prevents
 		   arp trashing and chooses the fastest router.
 		 */
-		override = time_after(jiffies, n->updated + n->parms->locktime);
+		override = time_after(jiffies,
+				      n->updated + n->parms->locktime) ||
+			   (tip == sip &&
+			    inet_addr_type(net, sip) == RTN_UNICAST);
 
 		/* Broadcast replies and request packets
 		   do not assert neighbour reachability.
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH 1/1] ipv4: arp: Always update neighbour address when a gratuitous arp is received
@ 2013-12-20 18:59 Salam Noureddine
  2013-12-20 22:06 ` Stephen Hemminger
  2013-12-21  0:36 ` Hannes Frederic Sowa
  0 siblings, 2 replies; 7+ messages in thread
From: Salam Noureddine @ 2013-12-20 18:59 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Hannes Frederic Sowa, netdev
  Cc: Salam Noureddine

Gratuitous arp packets are useful in switchover scenarios to update
client arp tables as quickly as possible. Currently, the mac address
of a neighbour is only updated after a locktime period has elapsed
since the last update. In most use cases such delays are unacceptable
for network admins. Moreover, the "updated" field of the neighbour
stucture doesn't record the last time the address of a neighbour
changed but records any change that happens to the neighbour. This is
clearly a bug since locktime uses that field as meaning "addr_updated".
With this observation, I was able to perpetuate a stale address by
sending a stream of gratuitous arp packets spaced less than locktime
apart.

Signed-off-by: Salam Noureddine <noureddine@aristanetworks.com>
---
 net/ipv4/arp.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 7808093..6597708 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -904,13 +904,19 @@ static int arp_process(struct sk_buff *skb)
 	if (n) {
 		int state = NUD_REACHABLE;
 		int override;
+		bool is_garp = tip == sip &&
+			       inet_addr_type(net, sip) == RTN_UNICAST;
 
 		/* If several different ARP replies follows back-to-back,
 		   use the FIRST one. It is possible, if several proxy
 		   agents are active. Taking the first reply prevents
-		   arp trashing and chooses the fastest router.
+		   arp trashing and chooses the fastest router. In the
+		   case of gratuitous arp we always set override in order
+		   to update the address.
 		 */
-		override = time_after(jiffies, n->updated + n->parms->locktime);
+		override = time_after(jiffies,
+				      n->updated + n->parms->locktime) ||
+			   is_garp;
 
 		/* Broadcast replies and request packets
 		   do not assert neighbour reachability.
-- 
1.7.4.4

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

end of thread, other threads:[~2013-12-21  0:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-20  5:41 [PATCH 1/1] ipv4: arp: Always update neighbour address when a gratuitous arp is received Salam Noureddine
2013-12-20 14:00 ` Hannes Frederic Sowa
  -- strict thread matches above, loose matches on Subject: below --
2013-12-20 18:59 Salam Noureddine
2013-12-20 22:06 ` Stephen Hemminger
2013-12-20 22:25   ` Salam Noureddine
2013-12-20 22:30   ` Hannes Frederic Sowa
2013-12-21  0:36 ` Hannes Frederic Sowa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).