3ebadeeb9d
while here, enable dropping to _openvpn user in the sample configs. ok and feedback ajacoutot@
43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
$OpenBSD: patch-socket_c,v 1.3 2010/08/30 18:32:20 fkr Exp $
|
|
--- socket.c.orig Mon Jul 26 08:15:03 2010
|
|
+++ socket.c Sun Aug 22 16:13:58 2010
|
|
@@ -533,6 +533,20 @@ socket_set_tcp_nodelay (int sd, int state)
|
|
#endif
|
|
}
|
|
|
|
+static void
|
|
+socket_set_rtable (int sd, int rtable)
|
|
+{
|
|
+#ifdef TARGET_OPENBSD
|
|
+ if (rtable > 0)
|
|
+ {
|
|
+ if (setsockopt (sd, IPPROTO_IP, SO_RTABLE, &rtable, sizeof(rtable)) == -1)
|
|
+ msg (M_SOCKERR, "Socket flags: SO_RTABLE=%d failed, cannot bind on specified routing domain", rtable);
|
|
+ else
|
|
+ dmsg (D_SOCKET_DEBUG, "Socket flags: SO_RTABLE=%d succeeded", rtable);
|
|
+ }
|
|
+#endif
|
|
+}
|
|
+
|
|
static bool
|
|
socket_set_flags (int sd, unsigned int sockflags)
|
|
{
|
|
@@ -1211,6 +1225,7 @@ link_socket_init_phase1 (struct link_socket *sock,
|
|
int mtu_discover_type,
|
|
int rcvbuf,
|
|
int sndbuf,
|
|
+ int rtable,
|
|
unsigned int sockflags)
|
|
{
|
|
ASSERT (sock);
|
|
@@ -1321,6 +1336,9 @@ link_socket_init_phase1 (struct link_socket *sock,
|
|
else if (mode != LS_MODE_TCP_ACCEPT_FROM)
|
|
{
|
|
create_socket (sock);
|
|
+
|
|
+ /* set the routing domain for the socket */
|
|
+ socket_set_rtable (sock->sd, rtable);
|
|
|
|
/* set socket buffers based on --sndbuf and --rcvbuf options */
|
|
socket_set_buffers (sock->sd, &sock->socket_buffer_sizes);
|