path: root/sbin/route
diff options
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2014-05-08 11:56:06 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2014-05-08 11:56:06 +0000
commit3deb3649d5214fd68d9441b84f7c31724de5307c (patch)
tree21c270f49448afc585cf16bd6f30f2249df5152e /sbin/route
parentf0736f4cec5bd07539272021d9482ea079bbe7ad (diff)
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> link#1 (255) ffff ffff ff em0:8.0.27.c5.29.d4 _________________^^^^^^^^^^^^^^^^^^ 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> link#1 em0:8.0.27.c5.29.d4 _________________^^^^^^^^^^^^^^^^^^ Sponsored by: Yandex LLC MFC after: 1 month
Notes: svn path=/head/; revision=265666
Diffstat (limited to 'sbin/route')
1 files changed, 0 insertions, 2 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c
index 794f1430397b..9b3bb9533f61 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))
- 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]));