summaryrefslogtreecommitdiff
path: root/openbsd-compat/port-net.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2017-10-25 13:47:59 +1100
committerDamien Miller <djm@mindrot.org>2017-10-25 13:47:59 +1100
commitce1cca39d7935dd394080ce2df62f5ce5b51f485 (patch)
treed65924d9c163b317d725950bd054edd4bd085ca8 /openbsd-compat/port-net.c
parent6eee79f9b8d4a3b113b698383948a119acb82415 (diff)
implement get/set_rdomain() for Linux
Not enabled, pending implementation of valid_rdomain() and autoconf glue
Diffstat (limited to 'openbsd-compat/port-net.c')
-rw-r--r--openbsd-compat/port-net.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/openbsd-compat/port-net.c b/openbsd-compat/port-net.c
index d384b1454..f6e32ad49 100644
--- a/openbsd-compat/port-net.c
+++ b/openbsd-compat/port-net.c
@@ -41,7 +41,44 @@
41 * including tun/tap forwarding and routing domains. 41 * including tun/tap forwarding and routing domains.
42 */ 42 */
43 43
44#if defined(SYS_RDOMAIN_XXX) 44#if defined(SYS_RDOMAIN_LINUX) || defined(SSH_TUN_LINUX)
45#include <linux/if.h>
46#endif
47
48#if defined(SYS_RDOMAIN_LINUX)
49char *
50sys_get_rdomain(int fd)
51{
52 char dev[IFNAMSIZ + 1];
53 socklen_t len = sizeof(dev) - 1;
54
55 if (getsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, dev, &len) == -1) {
56 error("%s: cannot determine VRF for fd=%d : %s",
57 __func__, fd, strerror(errno));
58 return NULL;
59 }
60 dev[len] = '\0';
61 return strdup(dev);
62}
63
64int
65sys_set_rdomain(int fd, const char *name)
66{
67 if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE,
68 name, strlen(name)) == -1) {
69 error("%s: setsockopt(%d, SO_BINDTODEVICE, %s): %s",
70 __func__, fd, name, strerror(errno));
71 return -1;
72 }
73 return 0;
74}
75
76int
77valid_rdomain(const char *name)
78{
79 return 0;
80}
81#elif defined(SYS_RDOMAIN_XXX)
45/* XXX examples */ 82/* XXX examples */
46char * 83char *
47sys_get_rdomain(int fd) 84sys_get_rdomain(int fd)
@@ -84,7 +121,6 @@ sys_set_process_rdomain(const char *name)
84 */ 121 */
85 122
86#if defined(SSH_TUN_LINUX) 123#if defined(SSH_TUN_LINUX)
87#include <linux/if.h>
88#include <linux/if_tun.h> 124#include <linux/if_tun.h>
89 125
90int 126int