From 308841d8c99907a364d6876ed9375507153729eb Mon Sep 17 00:00:00 2001
From: Andreas Schultz
Date: Thu, 2 Feb 2017 11:17:17 +0100
Subject: implement SO_BINDTODEVICE for inet protocols
bind to device is needed to properly support VRF-Lite under
Linux (see [1] for details).
[1]: https://www.kernel.org/doc/Documentation/networking/vrf.txt
---
lib/kernel/doc/src/inet.xml | 26 ++++++++++++++++
lib/kernel/src/inet.erl | 8 ++---
lib/kernel/src/inet_int.hrl | 1 +
lib/kernel/test/inet_SUITE.erl | 70 ++++++++++++++++++++++++++++++++++++++++--
4 files changed, 99 insertions(+), 6 deletions(-)
(limited to 'lib')
diff --git a/lib/kernel/doc/src/inet.xml b/lib/kernel/doc/src/inet.xml
index 076e50cd10..947e4d4560 100644
--- a/lib/kernel/doc/src/inet.xml
+++ b/lib/kernel/doc/src/inet.xml
@@ -897,6 +897,32 @@ setcap cap_sys_admin,cap_sys_ptrace,cap_dac_read_search+epi beam.smp
file:native_name_encoding/0.
+ -
+
Binds a socket to a specific network interface. This option
+ must be used in a function call that creates a socket, that is,
+ gen_tcp:connect/3,4,
+ gen_tcp:listen/2,
+ gen_udp:open/1,2, or
+ gen_sctp:open/0,1,2.
+ Unlike getifaddrs/0, Ifname
+ is encoded a binary. In the unlikely case that a system is using
+ non-7-bit-ASCII characters in network device names, special care
+ has to be taken when encoding this argument.
+ This option uses the Linux-specific socket option
+ SO_BINDTODEVICE, such as in Linux kernel 2.0.30 or later,
+ and therefore only exists when the runtime system
+ is compiled for such an operating system.
+ Before Linux 3.8, this socket option could be set, but could not retrieved
+ with getopts/2. Since Linux 3.8,
+ it is readable.
+ The virtual machine also needs elevated privileges, either
+ running as superuser or (for Linux) having capability
+ CAP_NET_RAW.
+ The primary use case for this option is to bind sockets into
+ Linux VRF instances.
+
+