OpenBSD: repair --show-gateway
PATCH 1/1 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.
--- src/openvpn/route.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
src/openvpn/route.c +9 -1
@@ -3518,7 +3518,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));
@@ -3556,7 +3560,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
@@ -3733,7 +3737,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));
Signature · 1 line
2.28.0
Am 01.01.24 um 10:40 schrieb Gert Doering:
Quoted 7 lines
OpenBSD route sockets do not want to be passed
RTA_IFPonRTM_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_IFPcomes back always...
Quoted 7 lines
So we need to #ifdef this,
RTA_IFPon 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_ERRNOto the "write to routing socket" error message.
Patch has been applied to the master and release/2.6 branch (bugfix).
commit acf6f33987c72d9151f68eb618bbaf2d10e61877 (master) commit 77376fc5cf6235493bff78794c9c6589e3f710ad (release/2.6)
Author: Gert Doering Date: Mon Jan 1 10:40:54 2024 +0100
OpenBSD: repair --show-gateway
Signed-off-by: Gert Doering <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg27892.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering