aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2023-03-04 09:11:39 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2023-03-04 09:11:39 +0000
commit945a7f0d21a0bcbcce3f308e080f54dfb7da54b1 (patch)
treef21e6e5f47f598a8698a993e9be2a68a6297a289
parent9883961ed5af5f0ade31579e95ac53e8c514faed (diff)
downloadsrc-945a7f0d21a0bcbcce3f308e080f54dfb7da54b1.tar.gz
src-945a7f0d21a0bcbcce3f308e080f54dfb7da54b1.zip
linux(4): Assert that the FreeBSD size of struct sockaddr is equal to Linux
Our code depends on the fact that the size of struct sockaddr and the size of sa_data is equal between FreeBSD and Linux.
-rw-r--r--sys/compat/linux/linux.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/compat/linux/linux.c b/sys/compat/linux/linux.c
index a4df46d7f9a7..53a874ebfab7 100644
--- a/sys/compat/linux/linux.c
+++ b/sys/compat/linux/linux.c
@@ -57,6 +57,10 @@ __FBSDID("$FreeBSD$");
#include <compat/linux/linux_util.h>
_Static_assert(LINUX_IFNAMSIZ == IFNAMSIZ, "Linux IFNAMSIZ");
+_Static_assert(sizeof(struct sockaddr) == sizeof(struct l_sockaddr),
+ "Linux struct sockaddr size");
+_Static_assert(offsetof(struct sockaddr, sa_data) ==
+ offsetof(struct l_sockaddr, sa_data), "Linux struct sockaddr layout");
static bool use_real_ifnames = false;
SYSCTL_BOOL(_compat_linux, OID_AUTO, use_real_ifnames, CTLFLAG_RWTUN,