diff options
author | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2021-04-23 21:53:47 +0000 |
---|---|---|
committer | Alexander V. Chernikov <melifaro@FreeBSD.org> | 2021-04-24 22:41:27 +0000 |
commit | 5d1403a79a3e56403fb63c062252a23fce81e5f1 (patch) | |
tree | 62878d7aaffa25764cfdf335577b7db3649aa011 | |
parent | bddae5c8a64dc6b292198945cbe676bb2158d438 (diff) | |
download | src-5d1403a79a3e56403fb63c062252a23fce81e5f1.tar.gz src-5d1403a79a3e56403fb63c062252a23fce81e5f1.zip |
[rtsock] Enforce netmask/RTF_HOST consistency.
Traditionally we had 2 sources of information whether the
added/delete route request targets network or a host route:
netmask (RTA_NETMASK) and RTF_HOST flag.
The former one is tricky: netmask can be empty or can explicitly
specify the host netmask. Parsing netmask sockaddr requires per-family
parsing and that's what rtsock code traditionally avoided. As a result,
consistency was not enforced and it was possible to specify network with
the RTF_HOST flag and vice versa.
Continue normalization efforts from D29826 and D29826 and ensure that
RTF_HOST flag always reflects host/network data from netmask field.
Differential Revision: https://reviews.freebsd.org/D29958
MFC after: 2 days
-rw-r--r-- | sys/net/rtsock.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index b7a7e5170c74..fae15fdf4be6 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1503,6 +1503,7 @@ cleanup_xaddrs_inet(struct rt_addrinfo *info, struct linear_buffer *lb) return (ENOBUFS); fill_sockaddr_inet(mask_sa, mask); info->rti_info[RTAX_NETMASK] = (struct sockaddr *)mask_sa; + info->rti_flags &= ~RTF_HOST; } else remove_netmask(info); @@ -1563,6 +1564,7 @@ cleanup_xaddrs_inet6(struct rt_addrinfo *info, struct linear_buffer *lb) return (ENOBUFS); fill_sockaddr_inet6((struct sockaddr_in6 *)sa, &mask, 0); info->rti_info[RTAX_NETMASK] = sa; + info->rti_flags &= ~RTF_HOST; } else remove_netmask(info); |