summaryrefslogtreecommitdiffstats
path: root/sys/net/rtsock.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2018-01-29 10:19:15 +0000
committerkib <kib@FreeBSD.org>2018-01-29 10:19:15 +0000
commit11ecda44012566f756c09030aefd63e2c17c3fcd (patch)
treea232b16fbdec27068b3b47d0aeb824f5e4ae1e8e /sys/net/rtsock.c
parent01b293133ea434b55a946b442ddecec6624f7190 (diff)
downloadFreeBSD-src-11ecda44012566f756c09030aefd63e2c17c3fcd.zip
FreeBSD-src-11ecda44012566f756c09030aefd63e2c17c3fcd.tar.gz
MFC r328264:
Fix compat32 for sysctl net.PF_ROUTE...NET_RT_IFLISTL.
Diffstat (limited to 'sys/net/rtsock.c')
-rw-r--r--sys/net/rtsock.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 4388b67..88ad421 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -110,6 +110,12 @@ struct ifa_msghdrl32 {
int32_t ifam_metric;
struct if_data ifam_data;
};
+
+#define SA_SIZE32(sa) \
+ ( (((struct sockaddr *)(sa))->sa_len == 0) ? \
+ sizeof(int) : \
+ 1 + ( (((struct sockaddr *)(sa))->sa_len - 1) | (sizeof(int) - 1) ) )
+
#endif /* COMPAT_FREEBSD32 */
MALLOC_DEFINE(M_RTABLE, "routetbl", "routing tables");
@@ -1114,6 +1120,9 @@ rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, struct walkarg *w, int *
struct sockaddr_storage ss;
struct sockaddr_in6 *sin6;
#endif
+#ifdef COMPAT_FREEBSD32
+ bool compat32 = false;
+#endif
switch (type) {
@@ -1121,9 +1130,10 @@ rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, struct walkarg *w, int *
case RTM_NEWADDR:
if (w != NULL && w->w_op == NET_RT_IFLISTL) {
#ifdef COMPAT_FREEBSD32
- if (w->w_req->flags & SCTL_MASK32)
+ if (w->w_req->flags & SCTL_MASK32) {
len = sizeof(struct ifa_msghdrl32);
- else
+ compat32 = true;
+ } else
#endif
len = sizeof(struct ifa_msghdrl);
} else
@@ -1137,6 +1147,7 @@ rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, struct walkarg *w, int *
len = sizeof(struct if_msghdrl32);
else
len = sizeof(struct if_msghdr32);
+ compat32 = true;
break;
}
#endif
@@ -1167,7 +1178,12 @@ rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, struct walkarg *w, int *
if ((sa = rtinfo->rti_info[i]) == NULL)
continue;
rtinfo->rti_addrs |= (1 << i);
- dlen = SA_SIZE(sa);
+#ifdef COMPAT_FREEBSD32
+ if (compat32)
+ dlen = SA_SIZE32(sa);
+ else
+#endif
+ dlen = SA_SIZE(sa);
if (cp != NULL && buflen >= dlen) {
#ifdef INET6
if (V_deembed_scopeid && sa->sa_family == AF_INET6) {
OpenPOWER on IntegriCloud