Subject: [patch] aarp.c

From: Alistair Riddell <[email-masked]>
Date: Mon, 21 Aug 2000 00:13:53 +0100 (BST)

A few months ago I reported a problem whereby a Netatalk server would not
appear in the Chooser of certain machines on the network, seemingly at
random. 

Investigation showed that aarp cache entries on the Linux Netatalk server
would become corrupted. Lately I was bored so I thought I would sort it.
Attached is a patch against 2.2.16. Patch against 2.4test to follow
shortly.

For those that are interested, I finally managed to reproduce the problem 
as follows:

AppleMac A with appletalk address 123.123 has an entry in the AARP cache
on linux box.

AppleMac A is switched off; entry stays in AARP cache of linux machine
(AARP entries expire after 10*sysctl_aarp_expiry_time i.e. 50 minutes for
some reason)

AppleMac B is switched on and probes for appletalk address 123.123. Since
AppleMac A is off it (correctly) decides this address is free to use.
Linux machine sees the AARP probes and sets the AARP entry for 123.123 to
expire next time aarp_expire_timeout runs which can be up to five minutes
away. The AARP cache entry is still marked as resolved and still points to
the hardware address of AppleMac A.

AppleMac B finishes starting up and tries to connect to the Linux box.
Upon receiving packets from appletalk address 123.123 the Linux box resets
the expiry time on the AARP cache entry to jiffies +
10*sysctl_aarp_expiry_time i.e. 50 minutes in the future.

Since the aarp cache entry still points to the hardware address of
AppleMac A then no communcation can take place between the Linux server
and AppleMac B.

The attached patch fixes the problem by calling mod_timer to schedule the
expiry of the old AARP cache entry soon after seeing the probe packets
from AppleMac B. When AppleMac B tries to communicate with the Linux
machine it then has no corresponding AARP cache entry and so sends an AARP
request in the usual way, and everybody is happy.

-- 
Alistair Riddell - BOFH
IT Support Department, George Watson's College, Edinburgh
Tel: +44 131 447 7931 Ext 176       Fax: +44 131 452 8594
Microsoft - because god hates us

*** linux-2.2.16-vanilla/net/appletalk/aarp.c	Wed Jun  7 22:26:44 2000
--- linux/net/appletalk/aarp.c	Sun Aug 20 23:40:41 2000
***************
*** 25,30 ****
--- 25,32 ----
   *		Jaume Grau	-	flush caches on AARP_PROBE
   *		Rob Newberry	-	Added proxy AARP and AARP proc fs, 
   *					moved probing from DDP module.
+  *		Alistair Riddell-	on AARP_PROBE flush sooner - 
+  *					[email-masked] 000820
   *
   */
  
***************
*** 1008,1014 ****
--- 1010,1019 ----
  				   getting into a probe/flush/learn/probe/flush/learn
  				   cycle during probing of a slow to respond host addr */
  				if(a!=NULL)
+ 				{
  					a->expires_at=jiffies-1;
+ 					mod_timer(&aarp_timer, jiffies + sysctl_aarp_tick_time);
+ 				}
  			}
  			if(sa.s_node!=ma->s_node)
  				break;