1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
--- src/mlvpn.c.orig 2015-12-28 11:20:16 UTC
+++ src/mlvpn.c
@@ -597,7 +597,7 @@ mlvpn_rtun_write(EV_P_ ev_io *w, int rev
mlvpn_tunnel_t *
mlvpn_rtun_new(const char *name,
- const char *bindaddr, const char *bindport,
+ const char *bindaddr, const char *bindport, uint32_t bindfib,
const char *destaddr, const char *destport,
int server_mode, uint32_t timeout,
int fallback_only, uint32_t bandwidth,
@@ -653,6 +653,7 @@ mlvpn_rtun_new(const char *name,
strlcpy(new->bindaddr, bindaddr, sizeof(new->bindaddr));
if (bindport)
strlcpy(new->bindport, bindport, sizeof(new->bindport));
+ new->bindfib = bindfib;
if (destaddr)
strlcpy(new->destaddr, destaddr, sizeof(new->destaddr));
if (destport)
@@ -780,6 +781,7 @@ static int
mlvpn_rtun_start(mlvpn_tunnel_t *t)
{
int ret, fd = -1;
+ int fib = 0;
char *addr, *port;
struct addrinfo hints, *res;
@@ -788,9 +790,11 @@ mlvpn_rtun_start(mlvpn_tunnel_t *t)
{
addr = t->bindaddr;
port = t->bindport;
+ fib = t->bindfib;
} else {
addr = t->destaddr;
port = t->destport;
+ fib = t->bindfib;
}
/* Initialize hints */
@@ -817,6 +821,14 @@ mlvpn_rtun_start(mlvpn_tunnel_t *t)
log_warn(NULL, "%s socket creation error",
t->name);
} else {
+#if defined(HAVE_FREEBSD) || defined(HAVE_OPENBSD)
+ /* Setting SO_SETFIB (fib) supported on FreeBSD and OpenBSD only */
+ if (setsockopt(fd, SOL_SOCKET, SO_SETFIB, &fib, sizeof(fib)) < 0)
+ {
+ log_warnx(NULL, "Cannot set FIB %d for kernel socket", fib);
+ goto error;
+ }
+#endif
t->fd = fd;
break;
}
|