aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven McDonald2017-04-14 03:31:29 +1000
committerGert Doering2017-05-18 20:29:58 +0200
commit50ba481c21a0e868491b02efe7a1d9c5664d8f58 (patch)
tree34e8deda5aaefac9506ca7601db82a8991bb3b70
parent0b339bf9588a8bca70b74926f03f8be05f06faa6 (diff)
downloadopenvpn-50ba481c21a0e868491b02efe7a1d9c5664d8f58.zip
openvpn-50ba481c21a0e868491b02efe7a1d9c5664d8f58.tar.gz
Fix gateway detection with OpenBSD routing domains
When OpenVPN is started using a non-default routing table on OpenBSD (e.g., with 'route -T10 exec openvpn ...'), it hangs forever trying to read its default gateway from a PF_ROUTE socket. This is because rtm_tableid is not being initialised after bzeroing the rt_msghdr we write to the socket, so we end up asking the kernel for the default route in routing table 0. By default, the OpenBSD kernel will not respond to requests for routing table 0 from a process running in a different routing table, and even if it did, it would give us the wrong default gateway. The solution here is to set rtm_tableid to the value returned by getrtable(2), which always succeeds and returns the calling process's current routing table. This patch makes the test suite (without a t_client.rc) pass when run in a non-default routing table, where it would fail previously. It has also been successfully tested in client mode against both git master and OpenVPN 2.4.1 from ports on an OpenBSD -current system. Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <20170413173129.87367-1-steven@steven-mcdonald.id.au> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14461.html Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit 3dd30bfe5fdf9f34afe7f847b4e30156982d9ff0)
-rw-r--r--src/openvpn/route.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 4ae0d6a..3e5436d 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -3023,6 +3023,9 @@ get_default_gateway (struct route_gateway_info *rgi)
rtm.rtm_flags = RTF_UP | RTF_GATEWAY;
rtm.rtm_version = RTM_VERSION;
rtm.rtm_seq = ++seq;
+#ifdef TARGET_OPENBSD
+ rtm.rtm_tableid = getrtable();
+#endif
rtm.rtm_addrs = rtm_addrs;
so_dst.sa_family = AF_INET;