aboutsummaryrefslogtreecommitdiff
path: root/src/openvpn
diff options
context:
space:
mode:
authorGert Doering2024-01-01 10:40:54 +0100
committerGert Doering2024-01-01 15:42:05 +0100
commit77376fc5cf6235493bff78794c9c6589e3f710ad (patch)
tree03c0c294b185cf7cbc3ebe4494ffa83f1f220f5c /src/openvpn
parent5380fe02b9ef4f0f2b1f0eb52100b7922965dfdb (diff)
downloadopenvpn-77376fc5cf6235493bff78794c9c6589e3f710ad.zip
openvpn-77376fc5cf6235493bff78794c9c6589e3f710ad.tar.gz
OpenBSD: repair --show-gateway
OpenBSD route sockets do not want to be passed RTA_IFP on RTM_GET - if we do this, we get back EINVAL. On other platforms, if we do not request RTA_IFP, we will not get back interface information for queried routes - on OpenBSD, RTA_IFP comes back always... So we need to #ifdef this, RTA_IFP on all platforms except OpenBSD. (Found this fix in OpenBSD's ports tree, in their patches for OpenVPN 2.6.8 - but they just remove RTA_IFP, no #ifdef, so we can't just apply their patch) While at it, add M_ERRNO to the "write to routing socket" error message. Signed-off-by: Gert Doering <gert@greenie.muc.de> Acked-by: Arne Schwabe <arne@rfc2549.org> Message-Id: <20240101094054.38869-1-gert@greenie.muc.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27892.html Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit acf6f33987c72d9151f68eb618bbaf2d10e61877)
Diffstat (limited to 'src/openvpn')
-rw-r--r--src/openvpn/route.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index f23c3ff..106cc70 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -3513,7 +3513,11 @@ get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
/* setup data to send to routing socket */
pid = getpid();
seq = 0;
+#ifdef TARGET_OPENBSD
+ rtm_addrs = RTA_DST | RTA_NETMASK; /* Kernel refuses RTA_IFP */
+#else
rtm_addrs = RTA_DST | RTA_NETMASK | RTA_IFP;
+#endif
bzero(&m_rtmsg, sizeof(m_rtmsg));
bzero(&so_dst, sizeof(so_dst));
@@ -3551,7 +3555,7 @@ get_default_gateway(struct route_gateway_info *rgi, openvpn_net_ctx_t *ctx)
}
if (write(sockfd, (char *)&m_rtmsg, l) < 0)
{
- msg(M_WARN, "GDG: problem writing to routing socket");
+ msg(M_WARN|M_ERRNO, "GDG: problem writing to routing socket");
goto done;
}
do
@@ -3764,7 +3768,11 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
/* setup data to send to routing socket */
pid = getpid();
seq = 0;
+#ifdef TARGET_OPENBSD
+ rtm_addrs = RTA_DST | RTA_NETMASK; /* Kernel refuses RTA_IFP */
+#else
rtm_addrs = RTA_DST | RTA_NETMASK | RTA_IFP;
+#endif
bzero(&m_rtmsg, sizeof(m_rtmsg));
bzero(&so_dst, sizeof(so_dst));