Date: Tue, 13 Aug 2002 03:40:03 -0700 (PDT) From: Ruslan Ermilov <ru@FreeBSD.org> To: freebsd-bugs@FreeBSD.org Subject: Re: kern/41494: static routes set with interface address as gateway are non-functional Message-ID: <200208131040.g7DAe3vl054414@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/41494; it has been noted by GNATS.
From: Ruslan Ermilov <ru@FreeBSD.org>
To: Qing Li <Qing.Li@windriver.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/41494: static routes set with interface address as gateway are non-functional
Date: Tue, 13 Aug 2002 13:27:58 +0300
--xJK8B5Wah2CMJs8h
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Fri, Aug 09, 2002 at 04:47:52PM -0700, Qing Li wrote:
>=20
> My interface xl0 is assigned 147.11.38.218.
>=20
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Routing tables
>=20
> Internet:
> Destination Gateway Flags Refs Use Netif Expi=
re
> 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 7=
83
> 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
>=20
> Internet6:
> Destination Gateway Flags Ne=
tif 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
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Now I add a host route:
> "route add -host 147.11.38.15 147.11.38.218"
>=20
> Then "ping 147.11.38.15" fails.
>=20
> This is due to the "G" flag in that static route entry with the gateway
> address being one of the interface addresses.
>=20
Yep, this corresponds to what you typed: gateway 147.11.38.218.
> During transmission the
> route lookup on the gateway address will point the output interface
> to the loopback interface.
>=20
Yes, gwroute will point to the 147.11.38.218 route which is thru lo0.
> This route addition should be allowed as a place holder
> to be filled in later, similar to of an entry with RTF_LLINFO flag.
>=20
I disagree. In your ``route add'', you specified a gateway and you
get what you requested. What would be a purpose of adding such a
route? ARP can already do this for you by cloning from the network
route, adding route with the gateway of some of the local addresses
has its own purpose; e.g. one can put a divert(4) daemon listetning
on lo0 that would get these packets. Or:
# ifconfig rl0 inet
rl0: flags=3D8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet 192.168.4.115 netmask 0xffffff00 broadcast 192.168.4.255
# ifconfig rl0 192.168.4.201/32 alias
# route delete 192.168.4.201/32
delete net 192.168.4.201
# route add 192.168.4.201 192.168.4.115
add host 192.168.4.201: gateway 192.168.4.115
# ping -c1 192.168.4.201
PING 192.168.4.201 (192.168.4.201): 56 data bytes
64 bytes from 192.168.4.201: icmp_seq=3D0 ttl=3D64 time=3D0.088 ms
--- 192.168.4.201 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev =3D 0.088/0.088/0.088/0.000 ms
#
> I put in the fixes, here is what the routing table shows after the fix
> using the same route command,
>=20
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> 147.11.38.15 link#5 UHLS 0 3 xl0
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
It's possible to create such an entry (though a bit tricky) even without
patching sys/net/route.c:
route -vn add -host 147.11.38.15 -link : -ifp rl0 -iface
> "ping 147.11.38.15" now succeeds, that route entry is modified to be
>=20
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> 147.11.38.15 8:0:20:d1:64:c6 UHLS 0 3 xl0
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>=20
> Similar problem exists in IPv6.
> Unlike "ping", "ping6" returns -1 with an error message
> of "No route to host".
>=20
>=20
> >How-To-Repeat:
>=20
> Add a static route entry to a host that is directely reachable, set
> the gateway value using the interface address.
>=20
> For IPv4
> --------
> Step 1: route add -host 147.11.38.15 147.11.38.218
> Step 2: ping 147.11.38.15
>=20
> 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
>=20
> >Fix:
>=20
> /usr/src/net/route.c
>=20
> *** 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 =3D 0;
> return EDQUOT; /* failure */
> }
> + if (rt->rt_gwroute->rt_ifp &&
> + (rt->rt_gwroute->rt_ifp->if_flags & IFF_LOOPBACK))
> + {
> + rt->rt_gwroute =3D 0;
This leaks. You need to RTFREE() it first.
> + rt->rt_flags &=3D ~RTF_GATEWAY;
> + rt->rt_flags |=3D RTF_LLINFO;
> + }
> }
>=20
> /*
>=20
>=20
> /usr/src/netinet/if_ether.c
>=20
> *** 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) =3D=3D 0 &&
> SIN(rt_mask(rt))->sin_addr.s_addr !=3D 0xffffffff)
> rt->rt_flags |=3D 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) =3D=3D 0 &&
> SIN(rt_mask(rt))->sin_addr.s_addr !=3D 0xffffffff)
> rt->rt_flags |=3D RTF_CLONING;
> ! if (rt->rt_flags & (RTF_CLONING | RTF_LLINFO)) {
> /*
> * Case 1: This route should come from a route to
> iface.
> */
I think this might make the ``route add'' I quoted above to do
what you want, though I disagree with the change in principle.
> ***************
> *** 198,204 ****
> SDL(gate)->sdl_type =3D rt->rt_ifp->if_type;
> SDL(gate)->sdl_index =3D rt->rt_ifp->if_index;
> rt->rt_expire =3D time_second;
> ! break;
> }
> /* Announce a new entry if requested. */
> if (rt->rt_flags & RTF_ANNOUNCE)
> --- 198,205 ----
> SDL(gate)->sdl_type =3D rt->rt_ifp->if_type;
> SDL(gate)->sdl_index =3D rt->rt_ifp->if_index;
> rt->rt_expire =3D time_second;
> ! if (rt->rt_flags & RTF_CLONING)
> ! break;
> }
> /* Announce a new entry if requested. */
> if (rt->rt_flags & RTF_ANNOUNCE)
>=20
>=20
> /usr/src/netinet6/nd6.c
>=20
> *** 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 =3D rt;
> /* this is required for "ndp" command. - shin */
> ! if (req =3D=3D 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 =3D rt;
> /* this is required for "ndp" command. - shin */
> ! if ((req =3D=3D RTM_ADD) && !(rt->rt_flags & RTF_LLINFO=
)) {
> /*
> * gate should have some valid AF_LINK entry,
> * and ln->ln_expire should have some lifetime
--=20
Ruslan Ermilov Sysadmin and DBA,
ru@sunbay.com Sunbay Software AG,
ru@FreeBSD.org FreeBSD committer,
+380.652.512.251 Simferopol, Ukraine
http://www.FreeBSD.org The Power To Serve
http://www.oracle.com Enabling The Information Age
--xJK8B5Wah2CMJs8h
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE9WN8uUkv4P6juNwoRAl5UAJ0bYxz0Qi+yTebpgcJmBGE6lqsujgCaAtbr
m2LslPsR/llwJkTFs0RwCgg=
=WApY
-----END PGP SIGNATURE-----
--xJK8B5Wah2CMJs8h--
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?200208131040.g7DAe3vl054414>
