[Python-checkins] gh-91968: Add socket constants SO_USER_COOKIE/SO_RTABLE from BSD (#91967)

JelleZijlstra webhook-mailer at python.org
Sun May 8 19:19:50 EDT 2022


https://github.com/python/cpython/commit/9d85aba9e245c1a0f6d1879f8bc6c260cb4eb721
commit: 9d85aba9e245c1a0f6d1879f8bc6c260cb4eb721
branch: main
author: David CARLIER <devnexen at gmail.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-05-08T16:19:41-07:00
summary:

gh-91968: Add socket constants SO_USER_COOKIE/SO_RTABLE from BSD (#91967)

Those are somewhat equivalent to Linux' SO_MARK.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra at gmail.com>

files:
A Misc/NEWS.d/next/Library/2022-04-26-18-37-24.gh-issue-91968.fuuH1_.rst
M Doc/library/socket.rst
M Modules/socketmodule.c

diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index ee1aee5278b3b..4c193b892bda8 100755
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -392,6 +392,11 @@ Constants
       Added ``TCP_CONNECTION_INFO``. On MacOS this constant can be used in the
       same way that ``TCP_INFO`` is used on Linux and BSD.
 
+   .. versionchanged:: 3.12
+      Added ``SO_RTABLE`` and ``SO_USER_COOKIE``. On OpenBSD
+      and FreeBSD respectively those constants can be used in the same way that
+      ``SO_MARK`` is used on Linux.
+
 .. data:: AF_CAN
           PF_CAN
           SOL_CAN_*
diff --git a/Misc/NEWS.d/next/Library/2022-04-26-18-37-24.gh-issue-91968.fuuH1_.rst b/Misc/NEWS.d/next/Library/2022-04-26-18-37-24.gh-issue-91968.fuuH1_.rst
new file mode 100644
index 0000000000000..f16f5d3a668bd
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-04-26-18-37-24.gh-issue-91968.fuuH1_.rst
@@ -0,0 +1 @@
+Add ``SO_RTABLE`` and ``SO_USER_COOKIE`` constants to :mod:`socket`.
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 9aefa443c7c69..f376513fead1b 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -7595,6 +7595,12 @@ PyInit__socket(void)
 #ifdef  SO_MARK
     PyModule_AddIntMacro(m, SO_MARK);
 #endif
+#ifdef  SO_USER_COOKIE
+    PyModule_AddIntMacro(m, SO_USER_COOKIE);
+#endif
+#ifdef  SO_RTABLE
+    PyModule_AddIntMacro(m, SO_RTABLE);
+#endif
 #ifdef SO_DOMAIN
     PyModule_AddIntMacro(m, SO_DOMAIN);
 #endif



More information about the Python-checkins mailing list