Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Aug 2002 16:47:52 -0700
From:      "Qing Li" <Qing.Li@windriver.com>
To:        "FreeBSD gnats submit" <freebsd-gnats-submit@FreeBSD.org>
Subject:   kern/41494: static routes set with interface address as gateway are non-functional
Message-ID:  <DMEGKJAJNLKBGDDBEAIPAECMFPAA.Qing.Li@windriver.com>

next in thread | raw e-mail | index | archive | help

>Number:         41494
>Category:       kern
>Synopsis:       static routes set with interface address as gateway are
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Aug 09 16:51:24 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Qing Li
>Release:        FreeBSD 4.6-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD t38-108.wrs.com 4.6-PRERELEASE FreeBSD 4.6-PRERELEASE #2:
Mon Jun 17 11:10:00 GMT 2002
root@t38-108.wrs.com:/usr/obj/usr/src/sys/GENERIC i386

Timecounter "i8254"  frequency 1193182 Hz
CPU: Pentium II/Pentium II Xeon/Celeron (265.37-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x634  Stepping = 4

Features=0x80f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,M
MX>
real memory  = 167772160 (163840K bytes)
avail memory = 158187520 (154480K bytes)
pnpbios: Bad PnP BIOS data checksum
Preloaded elf kernel "kernel" at 0xc04c8000.
Pentium Pro MTRR support enabled

>Description:

	My interface xl0 is assigned 147.11.38.218.

	==========
	Routing tables

	Internet:
	Destination        Gateway            Flags    Refs      Use  Netif Expire
	default            147.11.38.1        UGSc        4        0    xl0
	127.0.0.1          127.0.0.1          UH          1       22    lo0
	147.11.38/24       link#5             UC          2        0    xl0
	147.11.38.1        00:00:0c:07:ac:26  UHLW        5        0    xl0    783
	147.11.38.15       147.11.38.218      UGHS        0        3    xl0
	147.11.38.218      127.0.0.1          UGHS        1        0    lo0
	147.11.38.254      00:02:7e:23:fa:80  UHLW        0        0    xl0     49

	Internet6:
	Destination                       Gateway                       Flags
Netif Expire
	::1                               ::1                           UH
lo0
	fe80::%xl0/64                     link#5                        UC
xl0
	fe80::2b0:d0ff:fe84:c8bc%xl0      fe80::2c0:4fff:fe8d:63b9%xl0  UGHS
xl0
	fe80::2c0:4fff:fe8d:63b9%xl0      00:c0:4f:8d:63:b9             UHL
lo0
	fe80::2e0:ff:fe84:4237%xl0        00:e0:00:84:42:37             UHLW
xl0
	fe80::%lo0/64                     fe80::1%lo0                   Uc
lo0
	fe80::1%lo0                       link#8                        UHL
lo0
	ff01::/32                         ::1                           U
lo0
	ff02::%xl0/32                     link#5                        UC
xl0
	ff02::%lo0/32                     ::1                           UC
lo0
	==========

	Now I add a host route:
	"route add -host 147.11.38.15 147.11.38.218"

	Then "ping 147.11.38.15"  fails.

	This is due to the "G" flag in that static route entry with the gateway
	address being one of the interface addresses. During transmission the
	route lookup on the gateway address will point the output interface
	to the loopback interface.

	This route addition should be allowed as a place holder
	to be filled in later, similar to of an entry with RTF_LLINFO flag.

	I put in the fixes, here is what the routing table shows after the fix
	using the same route command,

	===========
	147.11.38.15       link#5      UHLS        0        3    xl0
	===========

	"ping 147.11.38.15" now succeeds, that route entry is modified to be

	===========
	147.11.38.15       8:0:20:d1:64:c6    UHLS        0        3    xl0
	===========

	Similar problem exists in IPv6.
	Unlike "ping", "ping6" returns -1 with an error message
	of "No route to host".


>How-To-Repeat:

	Add a static route entry to a host that is directely reachable, set
	the gateway value using the interface address.

	For IPv4
	--------
	Step 1: route add -host 147.11.38.15 147.11.38.218
	Step 2: ping 147.11.38.15

	For IPv6
	--------
	Step 1: route add -host -inet6 fe80::2b0:d0ff:fe84:c8bc%xl0 -inet6 \
					      fe80::2c0:4fff:fe8d:63b9%xl0
	Step 2: ping6 fe80::2b0:d0ff:fe84:c8bc%xl0

>Fix:

	/usr/src/net/route.c

*** route.c     Mon Aug  5 17:33:39 2002
--- route.c.new Fri Aug  9 15:18:04 2002
***************
*** 1006,1011 ****
--- 1006,1018 ----
                        rt->rt_gwroute = 0;
                        return EDQUOT; /* failure */
                }
+                 if (rt->rt_gwroute->rt_ifp &&
+                     (rt->rt_gwroute->rt_ifp->if_flags & IFF_LOOPBACK))
+                 {
+                     rt->rt_gwroute = 0;
+                     rt->rt_flags &= ~RTF_GATEWAY;
+                     rt->rt_flags |= RTF_LLINFO;
+                 }
        }

        /*


	/usr/src/netinet/if_ether.c

*** if_ether.c  Mon Aug  5 17:33:44 2002
--- if_ether.c.new      Fri Aug  9 15:15:50 2002
***************
*** 188,194 ****
                if ((rt->rt_flags & RTF_HOST) == 0 &&
                    SIN(rt_mask(rt))->sin_addr.s_addr != 0xffffffff)
                        rt->rt_flags |= RTF_CLONING;
!               if (rt->rt_flags & RTF_CLONING) {
                        /*
                         * Case 1: This route should come from a route to
iface.
                         */
--- 188,194 ----
                if ((rt->rt_flags & RTF_HOST) == 0 &&
                    SIN(rt_mask(rt))->sin_addr.s_addr != 0xffffffff)
                        rt->rt_flags |= RTF_CLONING;
!               if (rt->rt_flags & (RTF_CLONING | RTF_LLINFO)) {
                        /*
                         * Case 1: This route should come from a route to
iface.
                         */
***************
*** 198,204 ****
                        SDL(gate)->sdl_type = rt->rt_ifp->if_type;
                        SDL(gate)->sdl_index = rt->rt_ifp->if_index;
                        rt->rt_expire = time_second;
!                       break;
                }
                /* Announce a new entry if requested. */
                if (rt->rt_flags & RTF_ANNOUNCE)
--- 198,205 ----
                        SDL(gate)->sdl_type = rt->rt_ifp->if_type;
                        SDL(gate)->sdl_index = rt->rt_ifp->if_index;
                        rt->rt_expire = time_second;
!                         if (rt->rt_flags & RTF_CLONING)
!                           break;
                }
                /* Announce a new entry if requested. */
                if (rt->rt_flags & RTF_ANNOUNCE)


	/usr/src/netinet6/nd6.c

*** nd6.c       Tue Apr 30 14:09:54 2002
--- nd6.c.new   Fri Aug  9 15:20:11 2002
***************
*** 1227,1233 ****
                Bzero(ln, sizeof(*ln));
                ln->ln_rt = rt;
                /* this is required for "ndp" command. - shin */
!               if (req == RTM_ADD) {
                        /*
                         * gate should have some valid AF_LINK entry,
                         * and ln->ln_expire should have some lifetime
--- 1227,1233 ----
                Bzero(ln, sizeof(*ln));
                ln->ln_rt = rt;
                /* this is required for "ndp" command. - shin */
!                 if ((req == RTM_ADD) && !(rt->rt_flags & RTF_LLINFO)) {
                        /*
                         * gate should have some valid AF_LINK entry,
                         * and ln->ln_expire should have some lifetime




>Release-Note:
>Audit-Trail:
>Unformatted:
 non-functional

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DMEGKJAJNLKBGDDBEAIPAECMFPAA.Qing.Li>