aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/net/rtsock.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 3c1fea497af6..221661585bbf 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1376,6 +1376,14 @@ cleanup_xaddrs_gateway(struct rt_addrinfo *info)
return (0);
}
+static void
+remove_netmask(struct rt_addrinfo *info)
+{
+ info->rti_info[RTAX_NETMASK] = NULL;
+ info->rti_flags |= RTF_HOST;
+ info->rti_addrs &= ~RTA_NETMASK;
+}
+
#ifdef INET
static int
cleanup_xaddrs_inet(struct rt_addrinfo *info)
@@ -1405,11 +1413,8 @@ cleanup_xaddrs_inet(struct rt_addrinfo *info)
if (mask.s_addr != INADDR_BROADCAST)
fill_sockaddr_inet(mask_sa, mask);
- else {
- info->rti_info[RTAX_NETMASK] = NULL;
- info->rti_flags |= RTF_HOST;
- info->rti_addrs &= ~RTA_NETMASK;
- }
+ else
+ remove_netmask(info);
/* Check gateway */
if (info->rti_info[RTAX_GATEWAY] != NULL)
@@ -1445,11 +1450,8 @@ cleanup_xaddrs_inet6(struct rt_addrinfo *info)
if (!IN6_ARE_ADDR_EQUAL(&mask, &in6mask128))
fill_sockaddr_inet6(mask_sa, &mask, 0);
- else {
- info->rti_info[RTAX_NETMASK] = NULL;
- info->rti_flags |= RTF_HOST;
- info->rti_addrs &= ~RTA_NETMASK;
- }
+ else
+ remove_netmask(info);
/* Check gateway */
if (info->rti_info[RTAX_GATEWAY] != NULL)
@@ -1467,6 +1469,15 @@ cleanup_xaddrs(struct rt_addrinfo *info)
if (info->rti_info[RTAX_DST] == NULL)
return (EINVAL);
+ if (info->rti_flags & RTF_LLDATA) {
+ /*
+ * arp(8)/ndp(8) sends RTA_NETMASK for the associated
+ * prefix along with the actual address in RTA_DST.
+ * Remove netmask to avoid unnecessary address masking.
+ */
+ remove_netmask(info);
+ }
+
switch (info->rti_info[RTAX_DST]->sa_family) {
#ifdef INET
case AF_INET: