Invalid 'route change' functioning
Ruslan Ermilov
ru at FreeBSD.org
Mon Jan 17 14:36:27 PST 2005
On Mon, Jan 17, 2005 at 07:20:53PM +0300, Vladimir Grebenschikov wrote:
> Ruslan Ermilov wrote:
>
> > > Any ideas what wrong with 'route change' ?
> > >
> > The route(8) manpage says:
> >
> > : In a change or add command where the destination and gateway are not suf-
> > : ficient to specify the route (as in the ISO case where several interfaces
> > : may have the same address), the -ifp or -ifa modifiers may be used to
> > : determine the interface or interface address.
> >
> > So try this instead:
> >
> > route change 192.168.0/23 -ifp fxp0
>
> Thank you, it works.
>
> So, as I understand, route add ... -iface fxp0 is invalid if I want
> specify gateway interface ?
>
No, it's valid.
> (how this works, '-iface' flag and 'fxp0' is what ? gateway ?)
>
When the -iface keyword is present, the route(8) utility treats
the "gateway" argument specially, allowing it to be an interface
name, in which case the gateway address is passed as "struct
sockaddr_dl" denoting this interface. See the output of the
"route -v add" command. Hence, there's no a reason (other than
a kernel code bug) to prevent a "route change ... -iface fxp0"
command from working. Here's a fix:
%%%
Index: rtsock.c
===================================================================
RCS file: /home/ncvs/src/sys/net/rtsock.c,v
retrieving revision 1.120
diff -u -p -r1.120 rtsock.c
--- rtsock.c 7 Jan 2005 01:45:35 -0000 1.120
+++ rtsock.c 17 Jan 2005 22:01:47 -0000
@@ -491,8 +491,7 @@ route_output(struct mbuf *m, struct sock
* flags may also be different; ifp may be specified
* by ll sockaddr when protocol address is ambiguous
*/
- if (((rt->rt_flags & RTF_GATEWAY) &&
- info.rti_info[RTAX_GATEWAY] != NULL) ||
+ if (info.rti_info[RTAX_GATEWAY] != NULL ||
info.rti_info[RTAX_IFP] != NULL ||
(info.rti_info[RTAX_IFA] != NULL &&
!sa_equal(info.rti_info[RTAX_IFA],
%%%
Cheers,
--
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20050118/aec55fdf/attachment.bin
More information about the freebsd-net
mailing list