43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
$OpenBSD: patch-socket_c,v 1.4 2012/01/12 08:15:30 sthen Exp $
|
|
--- socket.c.orig Mon Feb 21 16:38:10 2011
|
|
+++ socket.c Tue Mar 22 23:00:56 2011
|
|
@@ -532,6 +532,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)
|
|
{
|
|
@@ -1210,6 +1224,7 @@ link_socket_init_phase1 (struct link_socket *sock,
|
|
int mtu_discover_type,
|
|
int rcvbuf,
|
|
int sndbuf,
|
|
+ int rtable,
|
|
unsigned int sockflags)
|
|
{
|
|
ASSERT (sock);
|
|
@@ -1320,6 +1335,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);
|