From: "plaisthos (Code Review)" Date: Wed, 25 Sep 2024 14:06:57 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="iFQcJJhOOR4="; charset=UTF-8 Subject: [Openvpn-devel] [XS] Change in openvpn[master]: Fix check for struct cmsg not detecting the struct List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --iFQcJJhOOR4= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/771?usp=3Demail to review the following change. Change subject: Fix check for struct cmsg not detecting the struct ...................................................................... Fix check for struct cmsg not detecting the struct This check seems to have never worked and on Linux we hard coded the check instead. Remove this hard coded assumption and use a working check based on check_struct_has_member instead. This is has the side-effect of port-sharing being enabled on macOS when compiled with cmake. Change-Id: Ia020c696f63a2a317f001c061b2ab4da69977750 --- M CMakeLists.txt 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/71/771/1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6271574..5db207d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,6 @@ set(ENABLE_FEATURE_TUN_PERSIST 1) set(HAVE_LINUX_TYPES_H 1) set(ENABLE_DCO YES) - set(HAVE_CMSGHDR YES) elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") set(TARGET_FREEBSD YES) set(ENABLE_DCO YES) @@ -185,7 +184,6 @@ check_symbol_exists(sendmsg sys/socket.h HAVE_SENDMSG) check_symbol_exists(recvmsg sys/socket.h HAVE_RECVMSG) -check_symbol_exists(cmsghdr sys/socket.h HAVE_CMSGHDR) check_symbol_exists(openlog syslog.h HAVE_OPENLOG) check_symbol_exists(syslog syslog.h HAVE_SYSLOG) check_symbol_exists(getgrnam grp.h HAVE_GETGRNAM) @@ -193,6 +191,11 @@ check_symbol_exists(getsockname sys/socket.h HAVE_GETSOCKNAME) check_symbol_exists(getrlimit "sys/time.h;sys/resource.h" HAVE_GETRLIMIT) +# Checking for existence of structs with check_symbol_exists does not work, +# so we use check_struct_hash_member with a member instead +check_struct_has_member("struct cmsghdr" cmsg_len sys/socket.h HAVE_CMSGHD= R) + + # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers set(NETEXTRA sys/types.h) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/771?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ia020c696f63a2a317f001c061b2ab4da69977750 Gerrit-Change-Number: 771 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --iFQcJJhOOR4= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

Fix check for struct cmsg not detecting the struct

Thi= s check seems to have never worked and on Linux we hard coded
the check = instead. Remove this hard coded assumption and use a
working check based= on check_struct_has_member instead.

This is has the side-effect of = port-sharing being enabled on macOS
when compiled with cmake.

Cha= nge-Id: Ia020c696f63a2a317f001c061b2ab4da69977750
---
M CMakeLists.tx= t
1 file changed, 5 insertions(+), 2 deletions(-)

git pull ssh=
://gerrit.openvpn.net:29418/openvpn refs/changes/71/771/1
diff --=
git a/CMakeLists.txt b/CMakeLists.txt
index 6271574..5db207= d 100644
--- a/CMakeLists.txt
+++ b/CMakeLi= sts.txt
@@ -131,7 +131,6 @@
set(ENABLE= _FEATURE_TUN_PERSIST 1)
set(HAVE_LINUX_TYPES_H 1)
set(ENABLE_DCO YES)
- set(HAVE_CMSGHDR YES)
elseif (${CMAKE_S= YSTEM_NAME} STREQUAL "FreeBSD")
set(TARGET_F= REEBSD YES)
set(ENABLE_DCO YES)
@@ -18= 5,7 +184,6 @@

check_symbol_exists(sendms= g sys/socket.h HAVE_SENDMSG)
check_symbol_exists(recvmsg s= ys/socket.h HAVE_RECVMSG)
-check_symbol_exists(cmsghdr sys/socket.h HAVE_CMSGHDR)
= check_symbol_exists(openlog syslog.h HAVE_OPENLOG)
check_= symbol_exists(syslog syslog.h HAVE_SYSLOG)
check_symbol_ex= ists(getgrnam grp.h HAVE_GETGRNAM)
@@ -193,6 +191,11 @@
check_symbol_exists(getsockname sys/socket.h HAVE_GETSOCKNAME= )
check_symbol_exists(getrlimit "sys/time.h;sys/resou= rce.h" HAVE_GETRLIMIT)

+# Checking for existence of structs with check_sy= mbol_exists does not work,
+# so we use check_struct_hash_member with a member instead+check_struct_has_member("= ;struct cmsghdr" cmsg_len sys/socket.h HAVE_CMSGHDR)
+
+
# Some OS (e.g. FreeBSD) need some bas= ic headers to allow
# including network headers
= set(NETEXTRA sys/types.h)

To vie= w, visit = change 771. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia020c696f63a2a317f001c061b2= ab4da69977750
Gerrit-Change-Number: 771
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--iFQcJJhOOR4=--