git: 945a7f0d21a0 - main - linux(4): Assert that the FreeBSD size of struct sockaddr is equal to Linux
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 04 Mar 2023 09:12:54 UTC
The branch main has been updated by dchagin:
URL: https://cgit.FreeBSD.org/src/commit/?id=945a7f0d21a0bcbcce3f308e080f54dfb7da54b1
commit 945a7f0d21a0bcbcce3f308e080f54dfb7da54b1
Author: Dmitry Chagin <dchagin@FreeBSD.org>
AuthorDate: 2023-03-04 09:11:39 +0000
Commit: Dmitry Chagin <dchagin@FreeBSD.org>
CommitDate: 2023-03-04 09:11:39 +0000
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.
---
sys/compat/linux/linux.c | 4 ++++
1 file changed, 4 insertions(+)
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,