[Python-checkins] GH-107812: extend `socket`'s netlink support to FreeBSD (gh-107813)

corona10 webhook-mailer at python.org
Wed Aug 9 20:47:50 EDT 2023


https://github.com/python/cpython/commit/f50c17243a87b02086000185f6ed1cad4b8c2376
commit: f50c17243a87b02086000185f6ed1cad4b8c2376
branch: main
author: Mina Galić <me+github at igalic.co>
committer: corona10 <donghee.na92 at gmail.com>
date: 2023-08-10T00:47:46Z
summary:

GH-107812: extend `socket`'s netlink support to FreeBSD (gh-107813)

files:
A Misc/NEWS.d/next/Library/2023-08-09-15-37-20.gh-issue-107812.CflAXa.rst
M Modules/socketmodule.h
M configure
M configure.ac
M pyconfig.h.in

diff --git a/Misc/NEWS.d/next/Library/2023-08-09-15-37-20.gh-issue-107812.CflAXa.rst b/Misc/NEWS.d/next/Library/2023-08-09-15-37-20.gh-issue-107812.CflAXa.rst
new file mode 100644
index 0000000000000..0aac44fb41883
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-08-09-15-37-20.gh-issue-107812.CflAXa.rst
@@ -0,0 +1 @@
+Extend socket's netlink support to the FreeBSD platform.
diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h
index 663ae3d6e0dd6..47146a28e02c8 100644
--- a/Modules/socketmodule.h
+++ b/Modules/socketmodule.h
@@ -100,6 +100,8 @@ typedef int socklen_t;
 #  include <asm/types.h>
 # endif
 # include <linux/netlink.h>
+#elif defined(HAVE_NETLINK_NETLINK_H)
+# include <netlink/netlink.h>
 #else
 #  undef AF_NETLINK
 #endif
diff --git a/configure b/configure
index 80b4a001c6d6d..aaacf8d2669c1 100755
--- a/configure
+++ b/configure
@@ -11153,6 +11153,7 @@ fi
 
 
 # On Linux, netlink.h requires asm/types.h
+# On FreeBSD, netlink.h is located in netlink/netlink.h
 ac_fn_c_check_header_compile "$LINENO" "linux/netlink.h" "ac_cv_header_linux_netlink_h" "
 #ifdef HAVE_ASM_TYPES_H
 #include <asm/types.h>
@@ -11167,6 +11168,20 @@ then :
   printf "%s\n" "#define HAVE_LINUX_NETLINK_H 1" >>confdefs.h
 
 fi
+ac_fn_c_check_header_compile "$LINENO" "netlink/netlink.h" "ac_cv_header_netlink_netlink_h" "
+#ifdef HAVE_ASM_TYPES_H
+#include <asm/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+"
+if test "x$ac_cv_header_netlink_netlink_h" = xyes
+then :
+  printf "%s\n" "#define HAVE_NETLINK_NETLINK_H 1" >>confdefs.h
+
+fi
 
 
 # On Linux, qrtr.h requires asm/types.h
diff --git a/configure.ac b/configure.ac
index 8a84eaf6b370a..ddf6da0b9da12 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2880,7 +2880,8 @@ AC_CHECK_HEADERS([net/if.h], [], [],
 ])
 
 # On Linux, netlink.h requires asm/types.h
-AC_CHECK_HEADERS([linux/netlink.h], [], [], [
+# On FreeBSD, netlink.h is located in netlink/netlink.h
+AC_CHECK_HEADERS([linux/netlink.h netlink/netlink.h], [], [], [
 #ifdef HAVE_ASM_TYPES_H
 #include <asm/types.h>
 #endif
diff --git a/pyconfig.h.in b/pyconfig.h.in
index dab8ebf64371f..181dc3d7d1137 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -841,6 +841,9 @@
 /* Define to 1 if you have the <netinet/in.h> header file. */
 #undef HAVE_NETINET_IN_H
 
+/* Define to 1 if you have the <netlink/netlink.h> header file. */
+#undef HAVE_NETLINK_NETLINK_H
+
 /* Define to 1 if you have the <netpacket/packet.h> header file. */
 #undef HAVE_NETPACKET_PACKET_H
 



More information about the Python-checkins mailing list