Subject: arplookup() incrementing arpstat.as_allocfail erroneously.
To: None <tech-net@netbsd.org>
From: Sean Boudreau <seanb@qnx.com>
List: tech-net
Date: 06/09/2003 13:22:00
Do a 'netstat -sfarp' on a network with a lot
of arp traffic and notice the large count of
'failures to allocate llinfo'.  arplookup()
shouldn't be incrementing arpstat.as_allocfail++
if creation wasn't specified.  Here's a suggested
diff:

-seanb


Index: netinet/if_arp.c
===================================================================
RCS file: /cvsroot/src/sys/netinet/if_arp.c,v
retrieving revision 1.79
diff -c -r1.79 if_arp.c
*** netinet/if_arp.c	2001/11/13 00:32:35	1.79
--- netinet/if_arp.c	2003/06/09 17:10:38
***************
*** 1054,1074 ****
  		return (0);
  	rt->rt_refcnt--;
  
! 	if (rt->rt_flags & RTF_GATEWAY)
! 		why = "host is not on local network";
! 	else if ((rt->rt_flags & RTF_LLINFO) == 0) {
! 		arpstat.as_allocfail++;
! 		why = "could not allocate llinfo";
! 	} else if (rt->rt_gateway->sa_family != AF_LINK)
! 		why = "gateway route is not ours";
! 	else
  		return ((struct llinfo_arp *)rt->rt_llinfo);
  
! 	if (create)
  		log(LOG_DEBUG, "arplookup: unable to enter address"
  		    " for %s@%s on %s (%s)\n",
  		    in_fmtaddr(*addr), lla_snprintf(ar_sha(ah), ah->ar_hln),
  		    ifp->if_xname, why);
  	return (0);
  }
  
--- 1054,1082 ----
  		return (0);
  	rt->rt_refcnt--;
  
! 	if ((rt->rt_flags & (RTF_GATEWAY | RTF_LLINFO)) == RTF_LLINFO &&
! 	    rt->rt_gateway->sa_family == AF_LINK) {
  		return ((struct llinfo_arp *)rt->rt_llinfo);
+ 	}
  
! 	if (create) {
! 		if (rt->rt_flags & RTF_GATEWAY) {
! 			why = "host is not on local network";
! 		}
! 		else if ((rt->rt_flags & RTF_LLINFO) == 0) {
! 			arpstat.as_allocfail++;
! 			why = "could not allocate llinfo";
! 		}
! 		else {
! 			why = "gateway route is not ours";
! 		}
! 
  		log(LOG_DEBUG, "arplookup: unable to enter address"
  		    " for %s@%s on %s (%s)\n",
  		    in_fmtaddr(*addr), lla_snprintf(ar_sha(ah), ah->ar_hln),
  		    ifp->if_xname, why);
+ 	}
+ 
  	return (0);
  }