unbreak and adopt to the changes to rdomains/rtables in -current.

feedback and ok sthen@
This commit is contained in:
fkr 2010-07-08 09:18:25 +00:00
parent 30c70a8a68
commit 712a318987
7 changed files with 36 additions and 35 deletions

View File

@ -1,9 +1,10 @@
# $OpenBSD: Makefile,v 1.28 2009/12/11 23:05:37 benoit Exp $
# $OpenBSD: Makefile,v 1.29 2010/07/08 09:18:25 fkr Exp $
COMMENT= easy-to-use, robust, and highly configurable VPN
VERSION= 2.1.0
DISTNAME= openvpn-${VERSION}
PKGNAME= ${DISTNAME}p0
CATEGORIES= net security
HOMEPAGE= http://openvpn.net/

View File

@ -1,11 +1,11 @@
$OpenBSD: patch-init_c,v 1.1 2009/11/26 22:55:27 fkr Exp $
--- init.c.orig Thu Oct 1 18:02:18 2009
+++ init.c Thu Oct 29 18:44:33 2009
$OpenBSD: patch-init_c,v 1.2 2010/07/08 09:18:25 fkr Exp $
--- init.c.orig Thu Oct 1 20:02:18 2009
+++ init.c Thu Jul 8 07:15:30 2010
@@ -2216,6 +2216,7 @@ do_init_socket_1 (struct context *c, const int mode)
c->options.mtu_discover_type,
c->options.rcvbuf,
c->options.sndbuf,
+ c->options.rdomain,
+ c->options.rtable,
sockflags);
}

View File

@ -1,12 +1,12 @@
$OpenBSD: patch-openvpn_8,v 1.1 2009/11/26 22:55:27 fkr Exp $
--- openvpn.8.orig Sat Nov 21 00:02:43 2009
+++ openvpn.8 Fri Nov 20 23:45:31 2009
$OpenBSD: patch-openvpn_8,v 1.2 2010/07/08 09:18:25 fkr Exp $
--- openvpn.8.orig Fri Dec 11 09:04:24 2009
+++ openvpn.8 Thu Jul 8 07:32:55 2010
@@ -1313,6 +1313,11 @@ on both client and server for maximum effect.
Currently defaults to 100.
.\"*********************************************************
.TP
+.B --rdomain n
+(OpenBSD only) Set the routing domain.
+.B --rtable n
+(OpenBSD only) Set the routing table.
+Defaults to 0.
+.\"*********************************************************
+.TP

View File

@ -1,11 +1,11 @@
$OpenBSD: patch-options_c,v 1.1 2009/11/26 22:55:27 fkr Exp $
--- options.c.orig Fri Nov 20 13:09:14 2009
+++ options.c Fri Nov 20 23:38:08 2009
$OpenBSD: patch-options_c,v 1.2 2010/07/08 09:18:25 fkr Exp $
--- options.c.orig Fri Dec 11 09:09:39 2009
+++ options.c Thu Jul 8 07:15:14 2010
@@ -250,6 +250,7 @@ static const char usage_message[] =
"--sndbuf size : Set the TCP/UDP send buffer size.\n"
"--rcvbuf size : Set the TCP/UDP receive buffer size.\n"
"--txqueuelen n : Set the tun/tap TX queue length to n (Linux only).\n"
+ "--rdomain n : Set the routing domain (default=0, OpenBSD only)\n"
+ "--rtable n : Set the routing table (default=0, OpenBSD only)\n"
"--mlock : Disable Paging -- ensures key material and tunnel\n"
" data will never be written to disk.\n"
"--up cmd : Shell cmd to execute after successful tun device open.\n"
@ -13,7 +13,7 @@ $OpenBSD: patch-options_c,v 1.1 2009/11/26 22:55:27 fkr Exp $
#endif
SHOW_INT (rcvbuf);
SHOW_INT (sndbuf);
+ SHOW_INT (rdomain);
+ SHOW_INT (rtable);
SHOW_INT (sockflags);
SHOW_BOOL (fast_io);
@ -22,10 +22,10 @@ $OpenBSD: patch-options_c,v 1.1 2009/11/26 22:55:27 fkr Exp $
VERIFY_PERMISSION (OPT_P_SOCKBUF);
options->sndbuf = positive_atoi (p[1]);
+ }
+ else if (streq (p[0], "rdomain") && p[1])
+ else if (streq (p[0], "rtable") && p[1])
+ {
+ VERIFY_PERMISSION (OPT_P_SOCKFLAGS);
+ options->rdomain = positive_atoi (p[1]);
+ options->rtable = positive_atoi (p[1]);
}
else if (streq (p[0], "socket-flags"))
{

View File

@ -1,12 +1,12 @@
$OpenBSD: patch-options_h,v 1.1 2009/11/26 22:55:27 fkr Exp $
--- options.h.orig Thu Oct 1 18:02:18 2009
+++ options.h Thu Oct 29 18:44:33 2009
$OpenBSD: patch-options_h,v 1.2 2010/07/08 09:18:25 fkr Exp $
--- options.h.orig Thu Oct 1 20:02:18 2009
+++ options.h Thu Jul 8 07:32:35 2010
@@ -285,6 +285,9 @@ struct options
int rcvbuf;
int sndbuf;
+ /* routing domain */
+ int rdomain;
+ int rtable;
+
/* socket flags */
unsigned int sockflags;

View File

@ -1,20 +1,20 @@
$OpenBSD: patch-socket_c,v 1.1 2009/11/26 22:55:27 fkr Exp $
--- socket.c.orig Thu Oct 1 18:02:18 2009
+++ socket.c Thu Oct 29 21:27:46 2009
$OpenBSD: patch-socket_c,v 1.2 2010/07/08 09:18:25 fkr Exp $
--- socket.c.orig Fri Dec 11 05:59:45 2009
+++ socket.c Tue Jul 6 23:49:11 2010
@@ -503,6 +503,20 @@ socket_set_tcp_nodelay (int sd, int state)
#endif
}
+static void
+socket_set_rdomain (int sd, int rdomain)
+socket_set_rtable (int sd, int rtable)
+{
+#ifdef TARGET_OPENBSD
+ if (rdomain > 0)
+ if (rtable > 0)
+ {
+ if (setsockopt (sd, IPPROTO_IP, SO_RDOMAIN, &rdomain, sizeof(rdomain)) == -1)
+ msg (M_SOCKERR, "Socket flags: SO_RDOMAIN=%d failed, cannot bind on specified routing domain", rdomain);
+ 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_RDOMAIN=%d succeeded", rdomain);
+ dmsg (D_SOCKET_DEBUG, "Socket flags: SO_RTABLE=%d succeeded", rtable);
+ }
+#endif
+}
@ -26,7 +26,7 @@ $OpenBSD: patch-socket_c,v 1.1 2009/11/26 22:55:27 fkr Exp $
int mtu_discover_type,
int rcvbuf,
int sndbuf,
+ int rdomain,
+ int rtable,
unsigned int sockflags)
{
ASSERT (sock);
@ -36,7 +36,7 @@ $OpenBSD: patch-socket_c,v 1.1 2009/11/26 22:55:27 fkr Exp $
create_socket (sock);
+
+ /* set the routing domain for the socket */
+ socket_set_rdomain (sock->sd, rdomain);
+ socket_set_rtable (sock->sd, rtable);
+
resolve_bind_local (sock);
resolve_remote (sock, 1, NULL, NULL);

View File

@ -1,11 +1,11 @@
$OpenBSD: patch-socket_h,v 1.1 2009/11/26 22:55:27 fkr Exp $
--- socket.h.orig Thu Oct 1 18:02:18 2009
+++ socket.h Thu Oct 29 18:44:33 2009
$OpenBSD: patch-socket_h,v 1.2 2010/07/08 09:18:25 fkr Exp $
--- socket.h.orig Thu Oct 1 20:02:18 2009
+++ socket.h Thu Jul 8 07:22:47 2010
@@ -311,6 +311,7 @@ link_socket_init_phase1 (struct link_socket *sock,
int mtu_discover_type,
int rcvbuf,
int sndbuf,
+ int rdomain,
+ int rtable,
unsigned int sockflags);
void link_socket_init_phase2 (struct link_socket *sock,