diff options
author | melifaro <melifaro@FreeBSD.org> | 2014-05-08 11:56:06 +0000 |
---|---|---|
committer | melifaro <melifaro@FreeBSD.org> | 2014-05-08 11:56:06 +0000 |
commit | 4a170f05aac2077fa2f5ffeac81602b94665b996 (patch) | |
tree | 21c270f49448afc585cf16bd6f30f2249df5152e /sbin/route | |
parent | b2936ab3df6fac9d0c863866eb4ec0dc54f95f19 (diff) | |
download | FreeBSD-src-4a170f05aac2077fa2f5ffeac81602b94665b996.zip FreeBSD-src-4a170f05aac2077fa2f5ffeac81602b94665b996.tar.gz |
Fix incorrect netmasks being passed via rtsock.
Since radix has been ignoring sa_family in passed sockaddrs,
no one ever has bothered filling valid sa_family in netmasks.
Additionally, radix adjusts sa_len field in every netmask not to
compare zero bytes at all.
This leads us to rt_mask with sa_family of AF_UNSPEC (-1) and
arbitrary sa_len field (0 for default route, for example).
However, rtsock have been passing that rt_mask intact for ages,
requiring all rtsock consumers to make ther own local hacks.
We even have unfixed on in base:
do `route -n monitor` in one window and issue `route -n get addr`
for some directly-connected address. You will probably see the following:
got message of size 304 on Thu May 8 15:06:06 2014
RTM_GET: Report Metrics: len 304, pid: 30493, seq 1, errno 0, flags:<UP,DONE,PINNED>
locks: inits:
sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA>
10.0.0.0 link#1 (255) ffff ffff ff em0:8.0.27.c5.29.d4 10.0.0.92
_________________^^^^^^^^^^^^^^^^^^
after the change:
got message of size 312 on Thu May 8 15:44:07 2014
RTM_GET: Report Metrics: len 312, pid: 2895, seq 1, errno 0, flags:<UP,DONE,PINNED>
locks: inits:
sockaddrs: <DST,GATEWAY,NETMASK,IFP,IFA>
10.0.0.0 link#1 255.255.255.0 em0:8.0.27.c5.29.d4 10.0.0.92
_________________^^^^^^^^^^^^^^^^^^
Sponsored by: Yandex LLC
MFC after: 1 month
Diffstat (limited to 'sbin/route')
-rw-r--r-- | sbin/route/route.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index 794f143..9b3bb95 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1727,8 +1727,6 @@ print_getmsg(struct rt_msghdr *rtm, int msglen, int fib) (sp[RTAX_IFP]->sa_family != AF_LINK || ((struct sockaddr_dl *)(void *)sp[RTAX_IFP])->sdl_nlen == 0)) sp[RTAX_IFP] = NULL; - if (sp[RTAX_DST] && sp[RTAX_NETMASK]) - sp[RTAX_NETMASK]->sa_family = sp[RTAX_DST]->sa_family; /* XXX */ if (sp[RTAX_DST]) (void)printf("destination: %s\n", routename(sp[RTAX_DST])); if (sp[RTAX_NETMASK]) |