From nobody@FreeBSD.org  Thu Oct 17 17:29:31 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 04D3F37B404
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 17 Oct 2002 17:29:31 -0700 (PDT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7D57743E4A
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 17 Oct 2002 17:29:30 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.6/8.12.6) with ESMTP id g9I0TP7R052507
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 17 Oct 2002 17:29:25 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.6/8.12.6/Submit) id g9I0TP8b052496;
	Thu, 17 Oct 2002 17:29:25 -0700 (PDT)
Message-Id: <200210180029.g9I0TP8b052496@www.freebsd.org>
Date: Thu, 17 Oct 2002 17:29:25 -0700 (PDT)
From: Reza Sabdar <sabdar@procom.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Problem adding route with -interface option "can't allocate llinfo"
X-Send-Pr-Version: www-1.0
X-GNATS-Notify: ru

>Number:         44185
>Category:       kern
>Synopsis:       Problem adding route with -interface option "can't allocate llinfo"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bms
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 17 17:30:00 PDT 2002
>Closed-Date:    Tue Nov 25 06:39:00 PST 2003
>Last-Modified:  Tue Nov 25 06:39:00 PST 2003
>Originator:     Reza Sabdar
>Release:        4.3
>Organization:
Procom Technology
>Environment:
FreeBSD fbsd5.procom.com 4.3-RELEASE FreeBSD 4.3-RELEASE #0: Tue Jul 31 17:19:10 GMT 2001 i386
>Description:
While trying to add a direct static route with -interface option with:
#route add -interface <desination IP> <Interface IP>
the kernel logs : arp_rtrequest: bad gateway value
and any subsequent activity, e.g. ping result in the following log over
and over in the system:
arplookup 142.128.91.22 failed: could not allocate llinfo
arpresolve: can't allocate llinfo for 142.128.91.22rt


>How-To-Repeat:
Suppose that your FreeBSD IP is 142.128.91.21 and you have another system on the same network with IP 142.128.91.22, I want to define a direct static route to that system:
#route add -interface 142.128.91.22 142.128.91.21
add host 142.128.91.22: gateway 142.128.91.21
then
#ping 142.128.91.21 -> fails
#dmesg
arpresolve: can't allocate llinfo for ...



>Fix:
The problem seems to be related to arp_rtrequest() being called with the new interface route entry and with the NIC address as gateway which apparently isn't a AF_LINK type so arp_rtrequest() exits with "bad gateway" error not allocating the llinfo so the rt->rt_llinfo remains null. On any subsequent arpresolve() call, it gets the route entry as an arp and expects to find the llinfo but it is null so it presumes that the allocation has been failed reporting "can't allocate llinfo". Note that even trying to add the ARP entry for the given destination is useless because it returns with EEXISTS error. By taking advantage of RTF_STATIC flag I changed the Net/3 code so that this new entry can play both roles of an ARP and route entry at the same time. Please let me know if you verify the problem and how can I submit my changes to freebsd.org
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bms 
Responsible-Changed-By: bms 
Responsible-Changed-When: Tue 30 Sep 2003 23:52:52 PDT 
Responsible-Changed-Why:  
I'll look into this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=44185 
State-Changed-From-To: open->closed 
State-Changed-By: bms 
State-Changed-When: Tue 25 Nov 2003 06:36:23 PST 
State-Changed-Why:  
I feel this is a feature, not a bug:- 

FreeBSD 5.2-BETA (KIMCHI) #4: Sun Nov 23 01:52:10 GMT 2003 
kimchi# route -n add 81.3.72.68 -interface 81.3.72.77 
add host 81.3.72.68: gateway 81.3.72.77 
Nov 25 07:37:56 kimchi kernel: arp_rtrequest: bad gateway 81.3.72.68 (!AF_LINK) 
kimchi# ping 81.3.72.68 
PING 81.3.72.68 (81.3.72.68): 56 data bytes 
Nov 25 07:38:12 kimchi kernel: arplookup 81.3.72.68 failed: could not allocate llinfo 
Nov 25 07:38:12 kimchi kernel: arpresolve: can't allocate llinfo for 81.3.72.68rt 
Nov 25 07:38:13 kimchi kernel: arplookup 81.3.72.68 failed: could not allocate llinfo 
Nov 25 07:38:13 kimchi kernel: arpresolve: can't allocate llinfo for 81.3.72.68rt 

We will revisit this after 5.2-RELEASE when we're in a position to look at 
the ARP code in more detail. But it seems to me that after adding a static 
host route with something route(8) parsed as an AF_INET address (when an 
AF_LINK address is required to bind as an interface route) that this is in 
fact the correct behaviour. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=44185 
>Unformatted:
