[comp.bugs.4bsd.ucb-fixes] ARTICLE #11

bostic@OKEEFFE.BERKELEY.EDU (Keith Bostic) (03/23/87)

4.3BSD network bug (#7, arpresolve)
Index:	sys/netinet/if_ether.c 4.3BSD FIX

Description:
As several types of ethernet boards are unable to receive their own
transmissions, the loopback interface should be used for local packets
even before it is assigned an address.  This allows local traffic
to work normally while setting up interface addresses at boot time;
otherwise, ifconfig may hang when translating names to addresses.

The arpinput routine needs to protect itself from interruption
by ethernet interfaces that interrupt at higher priorities
than the one from which it received input.  This is rare,
but causes strange crashes in the ARP routines.

Fix:
*** if_ether.c.7.1	Wed Mar  4 23:42:36 1987
--- if_ether.c.7.1.1.1	Fri Feb 27 16:07:17 1987
***************
*** 5,7 ****
   *
!  *	@(#)if_ether.c	7.1 (Berkeley) 6/5/86
   */
--- 5,7 ----
   *
!  *	@(#)if_ether.c	7.1.1.1 (Berkeley) 2/27/87
   */
***************
*** 118,119 ****
--- 118,121 ----
  
+ int	useloopback = 1;	/* use loopback interface for local traffic */
+ 
  /*
***************
*** 154,156 ****
  	if (destip->s_addr == ac->ac_ipaddr.s_addr) {
! 		if (loif.if_flags & IFF_UP) {
  			sin.sin_family = AF_INET;
--- 156,158 ----
  	if (destip->s_addr == ac->ac_ipaddr.s_addr) {
! 		if (useloopback) {
  			sin.sin_family = AF_INET;
***************
*** 270,272 ****
  	struct in_addr isaddr, itaddr, myaddr;
! 	int proto, op;
  
--- 272,274 ----
  	struct in_addr isaddr, itaddr, myaddr;
! 	int proto, op, s;
  

***************
*** 297,298 ****
--- 299,301 ----
  	}
+ 	s = splimp();
  	ARPTAB_LOOK(at, isaddr.s_addr);
***************
*** 317,318 ****
--- 320,322 ----
  	}
+ 	splx(s);
  reply: