summaryrefslogtreecommitdiff
path: root/sysdep/bsd/krt-sock.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2022-12-11 16:28:28 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2022-12-11 16:28:28 +0100
commit34ebc4e1ba41c618e5d46112696011ed596c5ebc (patch)
treee792939a6b8fd2796e94a90e986b87eef3bb3731 /sysdep/bsd/krt-sock.c
parent937ebf2536e6b4d65f996af53a29ac550ac0cc2a (diff)
BSD: Workaround for direct routes on FreeBSD 13.0
FreeBSD 13.0 added some safechecks for syscalls, rejecting sockaddrs that are too small, later versions loosen up the check.
Diffstat (limited to 'sysdep/bsd/krt-sock.c')
-rw-r--r--sysdep/bsd/krt-sock.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c
index 256c4ed0..47f5cf59 100644
--- a/sysdep/bsd/krt-sock.c
+++ b/sysdep/bsd/krt-sock.c
@@ -190,6 +190,10 @@ static inline void
sockaddr_fill_dl(struct sockaddr_dl *sa, struct iface *ifa)
{
uint len = OFFSETOF(struct sockaddr_dl, sdl_data);
+
+ /* Workaround for FreeBSD 13.0 */
+ len = MAX(len, sizeof(struct sockaddr));
+
memset(sa, 0, len);
sa->sdl_len = len;
sa->sdl_family = AF_LINK;