]> git.ipfire.org Git - thirdparty/openvpn.git/commit
Fix gateway detection with OpenBSD routing domains
authorSteven McDonald <steven@steven-mcdonald.id.au>
Thu, 13 Apr 2017 17:31:29 +0000 (03:31 +1000)
committerGert Doering <gert@greenie.muc.de>
Thu, 18 May 2017 18:24:21 +0000 (20:24 +0200)
commit212e24ddc7b60fc2d2303ccf5893054e952232bb
tree2d0c8af2d3275277829b7befc07d913d822fa6f0
parenta91c54de67312f4026db61fd2b0e98cbd11e5323
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)
src/openvpn/route.c