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.
This commit is contained in:
Ondrej Zajicek 2022-12-11 16:28:28 +01:00
parent 937ebf2536
commit 34ebc4e1ba

View file

@ -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;