]> git.ipfire.org Git - thirdparty/openvpn.git/commit
get_default_gateway() HWADDR overhaul
authorGert Doering <gert@greenie.muc.de>
Mon, 1 Jan 2024 09:27:14 +0000 (10:27 +0100)
committerGert Doering <gert@greenie.muc.de>
Mon, 1 Jan 2024 17:18:44 +0000 (18:18 +0100)
commitbfd5b12e49785cc658f6f2f86360797fd2201cdc
treef44bc41905cfb28bcf29b9ec845acc22446bbbef
parent77376fc5cf6235493bff78794c9c6589e3f710ad
get_default_gateway() HWADDR overhaul

commit f13331005d5a7 (gerrit/454) most painfully works around the limitations
of the SIOCGIFCONF API, with struct member access on an unaligned buffer,
possibly overrunning sockaddr structures, etc. - and the result still did
not work on OpenSolaris and OpenBSD (no AF_LINK in the returned elements).

Reading through OpenBSD "ifconfig" source, I found getifaddrs(3), which
is exactly what we want here - it works on FreeBSD, NetBSD, OpenBSD and
MacOS, and all returned pointers are properly aligned, so the code gets
shorter, easier to read, and UBSAN is still happy.

OpenSolaris does have getifaddrs(3), but (surprise) it does not work, as
in "it does not return AF_LINK addresses".  It does have SIOCGIFHWADDR,
instead, and "man if_tcp" claims "should behave in a manner compatible
with Linux" - so TARGET_SOLARIS gets a copy of the Linux code now (works).

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20240101092714.18992-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27891.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 76d11614797617708c31dc3db22e3568fee3de6d)
src/openvpn/route.c