[mod.protocols.appletalk] Fastpath and subnetting...

cck@CUCCA.COLUMBIA.EDU.UUCP (05/18/86)

Problem: We're running in a subnetted environment with two 4.2 (one is
actually ultrix 1.1) subnet gateways.  Since our code doesn't handle
subnets very nicely yet (e.g. subnetting really only possible on the
third byte of a class b network, or second of a class a network), we
have to install manual routes on these gateways.  I discovered, to my
dismay, that adding a route on the gatways to the appletalk box subnet
caused UDP broadcasts to be duplicated a number of times.
Specifically, rwho packets got duplicated about 15 times or so.
Performance for the appletalk box dies and the ethernet gets a little
hosed.  This problem holds for the original software from Kinetics and
the newest software distributed by the user group.

Diagnosis: Both the kinetics box and the gateways are dysfunctional.
The gateways are resending the IP broadcast (- ethernet broadcast -)
directly back, e.g. using it's ethernet address, to the appletalk box.
I assume the gateways were doing this because of the manual route.
This wouldn't be bad except the appletalk box was retransmitting this
packet back onto the ethernet!

This problem was diagnosed using the MIT PC/IP netwatch program.

Solution: Agreed our gateways have a problem, but the appletalk box
should never resend a packet on the same interface which this packet
was received on.  (At least I can't think of a case where this is
proper behavior).  Patching the software so this condition holds for
the ethernet interface fixes this problem.  As a side effect, it stops
our box from sending ARP packets out to 128.59.0.0; I'm not sure why
this was happening, but I'm happy it stopped.  (Actually, it was a
good way to see if the box was still alive :-).  Sometime I'll look at
the appletalk forwarding to see if it's a problem there to.

By the way, if IP broadcasts should be forwarded to other segments,
then this fix is only partial.  routeip doesn't forward ip broadcasts
to the appletalk network in a subnet environment as things stand now.

Following are the context diffs to gw.c which eliminates this problem.
I admit that it isn't the best way to do things, but given the current
structure, it is the easiest way.  (Maybe the interface the packet was
received on should be recorded in the packet buffer in some way?)

*** /tmp/,RCSt1000696	Sat May 17 17:13:43 1986
--- gw.c	Sat May 17 16:52:54 1986
***************
*** 584,589
   * If a routing table existed within the gateway, it would determine
   * which interface pointer (ifp) and destination address (dst below)
   * are passed to ifp->if_output.
   */
  routeip(p)
  	register struct pbuf *p;

--- 584,595 -----
   * If a routing table existed within the gateway, it would determine
   * which interface pointer (ifp) and destination address (dst below)
   * are passed to ifp->if_output.
+  *
+  * Don't send a packet back out on the same interface it came in on.  Here
+  * this means don't ever send an ethernet packet back out on the ethernet.
+  * Check this by looking at p->p_type.  This isn't a general solution - 
+  * multiple ethernet interfaces won't route correctly...  Charlie C. Kim
+  *
   */
  routeip(p)
  	register struct pbuf *p;
***************
*** 624,629
  			dst = iproutedef;
  	}
  out:
  	(*ifp->if_output)(ifp, p, AF_IP, &dst);
  	return;
  drop:

--- 630,637 -----
  			dst = iproutedef;
  	}
  out:
+ 	if (p->p_type == PT_ENET && ifp == &ifie) /* prevent dups */
+ 	  goto drop;
  	(*ifp->if_output)(ifp, p, AF_IP, &dst);
  	return;
  drop:
$END OF CONTEXT DIFF$

Charlie C. Kim
User Services
Columbia University
New York, NY