From a1971a1243d530b0b5fcd8cb48586dae7d66eacc Mon Sep 17 00:00:00 2001 From: Steven Jin Xuan Date: Thu, 3 Oct 2024 13:06:19 -0400 Subject: [PATCH 1/6] Add socket.SO_ORIGINAL_DST --- Modules/socketmodule.c | 3 +++ Modules/socketmodule.h | 4 ++++ configure | 6 ++++++ configure.ac | 2 +- pyconfig.h.in | 3 +++ 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index ded6f255aaddea..66ab8a12573655 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7922,6 +7922,9 @@ socket_exec(PyObject *m) ADD_INT_MACRO(m, SO_OOBINLINE); #endif #ifndef __GNU__ +#ifdef SO_ORIGINAL_DST + ADD_INT_MACRO(m, SO_ORIGINAL_DST); +#endif #ifdef SO_REUSEPORT ADD_INT_MACRO(m, SO_REUSEPORT); #endif diff --git a/Modules/socketmodule.h b/Modules/socketmodule.h index a77c620c2ef630..e1d96377728eb9 100644 --- a/Modules/socketmodule.h +++ b/Modules/socketmodule.h @@ -172,6 +172,10 @@ typedef int socklen_t; # undef AF_VSOCK #endif +#ifdef HAVE_LINUX_NETFILTER_IPV4_H +# include +#endif + #ifdef HAVE_SOCKADDR_ALG # include diff --git a/configure b/configure index 0cc73e4e66552d..a8e1282fc4d3bc 100755 --- a/configure +++ b/configure @@ -11104,6 +11104,12 @@ if test "x$ac_cv_header_linux_soundcard_h" = xyes then : printf "%s\n" "#define HAVE_LINUX_SOUNDCARD_H 1" >>confdefs.h +fi +ac_fn_c_check_header_compile "$LINENO" "linux/netfilter_ipv4.h" "ac_cv_header_linux_netfilter_ipv4_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_netfilter_ipv4_h" = xyes +then : + printf "%s\n" "#define HAVE_LINUX_NETFILTER_IPV4_H 1" >>confdefs.h + fi ac_fn_c_check_header_compile "$LINENO" "linux/tipc.h" "ac_cv_header_linux_tipc_h" "$ac_includes_default" if test "x$ac_cv_header_linux_tipc_h" = xyes diff --git a/configure.ac b/configure.ac index 1864e94ace9243..1e09fa6f1102b3 100644 --- a/configure.ac +++ b/configure.ac @@ -3013,7 +3013,7 @@ AC_DEFINE([STDC_HEADERS], [1], AC_CHECK_HEADERS([ \ alloca.h asm/types.h bluetooth.h conio.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/limits.h linux/memfd.h \ - linux/random.h linux/soundcard.h \ + linux/random.h linux/soundcard.h linux/netfilter_ipv4.h \ linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \ diff --git a/pyconfig.h.in b/pyconfig.h.in index 7f02603e26f5d0..1947d8ee14f83e 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -739,6 +739,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_MEMFD_H +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_NETFILTER_IPV4_H + /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_NETLINK_H From 5273778a2bf884067bf9407fed4f2244ca7eb137 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 17:13:23 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst diff --git a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst new file mode 100644 index 00000000000000..3c79a785ffd4da --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst @@ -0,0 +1 @@ +Add `SO_ORIGINAL_DST` to the `sockets` module. From b5a9708e131ed12f2324a57c1fe28ff1fc2af963 Mon Sep 17 00:00:00 2001 From: Steven Jin Xuan Date: Thu, 3 Oct 2024 13:16:40 -0400 Subject: [PATCH 3/6] Lint --- .../next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst index 3c79a785ffd4da..13b4b11b1dbf70 100644 --- a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst +++ b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst @@ -1 +1 @@ -Add `SO_ORIGINAL_DST` to the `sockets` module. +Add ``SO_ORIGINAL_DST`` to the ``sockets`` module. From 928a4f00575b8e23af78977da3bc1a430ecc5d3c Mon Sep 17 00:00:00 2001 From: Steven Jin Xuan Date: Fri, 4 Oct 2024 10:41:38 -0400 Subject: [PATCH 4/6] News message formatting --- .../next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst index 13b4b11b1dbf70..f12cece040aaec 100644 --- a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst +++ b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst @@ -1 +1 @@ -Add ``SO_ORIGINAL_DST`` to the ``sockets`` module. +Add :attr:`SO_ORIGINAL_DST` to the :mod:`sockets`. From ed669e0a228d34a231b1174ee5e119b910526820 Mon Sep 17 00:00:00 2001 From: Steven Jin Xuan Date: Mon, 7 Oct 2024 10:42:47 -0400 Subject: [PATCH 5/6] Review * Move include out of __GNU__ guard * Docs and lint --- .../2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst | 2 +- Modules/socketmodule.c | 2 +- configure | 12 ++++++------ configure.ac | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst index f12cece040aaec..0e238b0d9536cf 100644 --- a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst +++ b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst @@ -1 +1 @@ -Add :attr:`SO_ORIGINAL_DST` to the :mod:`sockets`. +Add :attr:`SO_ORIGINAL_DST` to the :mod:`socket` module. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 66ab8a12573655..153382d928d016 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7921,10 +7921,10 @@ socket_exec(PyObject *m) #ifdef SO_OOBINLINE ADD_INT_MACRO(m, SO_OOBINLINE); #endif -#ifndef __GNU__ #ifdef SO_ORIGINAL_DST ADD_INT_MACRO(m, SO_ORIGINAL_DST); #endif +#ifndef __GNU__ #ifdef SO_REUSEPORT ADD_INT_MACRO(m, SO_REUSEPORT); #endif diff --git a/configure b/configure index a8e1282fc4d3bc..c5bec6a1b0d7c2 100755 --- a/configure +++ b/configure @@ -11092,6 +11092,12 @@ if test "x$ac_cv_header_linux_memfd_h" = xyes then : printf "%s\n" "#define HAVE_LINUX_MEMFD_H 1" >>confdefs.h +fi +ac_fn_c_check_header_compile "$LINENO" "linux/netfilter_ipv4.h" "ac_cv_header_linux_netfilter_ipv4_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_netfilter_ipv4_h" = xyes +then : + printf "%s\n" "#define HAVE_LINUX_NETFILTER_IPV4_H 1" >>confdefs.h + fi ac_fn_c_check_header_compile "$LINENO" "linux/random.h" "ac_cv_header_linux_random_h" "$ac_includes_default" if test "x$ac_cv_header_linux_random_h" = xyes @@ -11104,12 +11110,6 @@ if test "x$ac_cv_header_linux_soundcard_h" = xyes then : printf "%s\n" "#define HAVE_LINUX_SOUNDCARD_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "linux/netfilter_ipv4.h" "ac_cv_header_linux_netfilter_ipv4_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_netfilter_ipv4_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_NETFILTER_IPV4_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "linux/tipc.h" "ac_cv_header_linux_tipc_h" "$ac_includes_default" if test "x$ac_cv_header_linux_tipc_h" = xyes diff --git a/configure.ac b/configure.ac index 1e09fa6f1102b3..d4b7942190207a 100644 --- a/configure.ac +++ b/configure.ac @@ -3013,7 +3013,7 @@ AC_DEFINE([STDC_HEADERS], [1], AC_CHECK_HEADERS([ \ alloca.h asm/types.h bluetooth.h conio.h direct.h dlfcn.h endian.h errno.h fcntl.h grp.h \ io.h langinfo.h libintl.h libutil.h linux/auxvec.h sys/auxv.h linux/fs.h linux/limits.h linux/memfd.h \ - linux/random.h linux/soundcard.h linux/netfilter_ipv4.h \ + linux/netfilter_ipv4.h linux/random.h linux/soundcard.h \ linux/tipc.h linux/wait.h netdb.h net/ethernet.h netinet/in.h netpacket/packet.h poll.h process.h pthread.h pty.h \ sched.h setjmp.h shadow.h signal.h spawn.h stropts.h sys/audioio.h sys/bsdtty.h sys/devpoll.h \ sys/endian.h sys/epoll.h sys/event.h sys/eventfd.h sys/file.h sys/ioctl.h sys/kern_control.h \ From d18bb4d2161f9ae8df64572a6b9fa8fe789cc036 Mon Sep 17 00:00:00 2001 From: Steven Jin Date: Mon, 7 Oct 2024 21:44:46 -0400 Subject: [PATCH 6/6] Update 2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- .../next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst index 0e238b0d9536cf..66af712c5ae5a8 100644 --- a/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst +++ b/Misc/NEWS.d/next/Library/2024-10-03-17-13-22.gh-issue-124944.YyLAzf.rst @@ -1 +1 @@ -Add :attr:`SO_ORIGINAL_DST` to the :mod:`socket` module. +Add ``SO_ORIGINAL_DST`` to the :mod:`socket` module.