While looking at #152, I noticed that the fib handling on FreeBSD looks odd. It assigns to t->fd only if the setsockopt call fails.
|
/* Setting fib/routing-table is supported on FreeBSD and OpenBSD only */ |
|
#if defined(HAVE_FREEBSD) |
|
if (fib > 0 && setsockopt(fd, SOL_SOCKET, SO_SETFIB, &fib, sizeof(fib)) < 0) |
|
#elif defined(HAVE_OPENBSD) |
|
if (fib > 0 && setsockopt(fd, SOL_SOCKET, SO_RTABLE, &fib, sizeof(fib)) < 0) |
|
{ |
|
log_warn(NULL, "Cannot set FIB %d for kernel socket", fib); |
|
goto error; |
|
} |
|
#endif |
|
t->fd = fd; |
This will likely need a further #if to work as intended, something like
#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD)
#if defined(HAVE_FREEBSD)
if (fib > 0 && setsockopt(fd, SOL_SOCKET, SO_SETFIB, &fib, sizeof(fib)) < 0)
#elif defined(HAVE_OPEBSD)
if (fib > 0 && setsockopt(fd, SOL_SOCKET, SO_RTABLE, &fib, sizeof(fib)) < 0)
#endif
{
log_warn(NULL, "Cannot set FIB %d for kernel socket", fib);
goto error;
}
#endif
Or assign SO_SETFIB or SO_RTABLE to a variable and avoid the duplicated conditional.
While looking at #152, I noticed that the
fibhandling on FreeBSD looks odd. It assigns tot->fdonly if thesetsockoptcall fails.MLVPN/src/mlvpn.c
Lines 850 to 860 in 2263bab
This will likely need a further
#ifto work as intended, something likeOr assign
SO_SETFIBorSO_RTABLEto a variable and avoid the duplicated conditional.