[Python-checkins] gh-96534: socketmodule: support FreeBSD divert(4) socket (#96536)

vstinner webhook-mailer at python.org
Thu May 4 10:57:13 EDT 2023


https://github.com/python/cpython/commit/b17d32c1142d16a5fea0c95bce185bf9be696491
commit: b17d32c1142d16a5fea0c95bce185bf9be696491
branch: main
author: Gleb Smirnoff <glebius at FreeBSD.org>
committer: vstinner <vstinner at python.org>
date: 2023-05-04T14:57:05Z
summary:

gh-96534: socketmodule: support FreeBSD divert(4) socket (#96536)

files:
A Misc/NEWS.d/next/Library/2022-09-03-09-24-02.gh-issue-96534.EU4Oxv.rst
M Doc/library/socket.rst
M Modules/socketmodule.c

diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index 4ee0897db940..13a82cf82d59 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -509,6 +509,17 @@ Constants
    .. versionadded:: 3.9
 
 
+.. data:: AF_DIVERT
+          PF_DIVERT
+
+   These two constants, documented in the FreeBSD divert(4) manual page, are
+   also defined in the socket module.
+
+   .. availability:: FreeBSD >= 14.0.
+
+   .. versionadded:: 3.12
+
+
 .. data:: AF_PACKET
           PF_PACKET
           PACKET_*
diff --git a/Misc/NEWS.d/next/Library/2022-09-03-09-24-02.gh-issue-96534.EU4Oxv.rst b/Misc/NEWS.d/next/Library/2022-09-03-09-24-02.gh-issue-96534.EU4Oxv.rst
new file mode 100644
index 000000000000..0497d9eb6916
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2022-09-03-09-24-02.gh-issue-96534.EU4Oxv.rst
@@ -0,0 +1 @@
+Support divert(4) added in FreeBSD 14.
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index f11d4b1a6e05..e5478382e11f 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1903,6 +1903,11 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
         /* RDS sockets use sockaddr_in: fall-through */
 #endif /* AF_RDS */
 
+#ifdef AF_DIVERT
+    case AF_DIVERT:
+        /* FreeBSD divert(4) sockets use sockaddr_in: fall-through */
+#endif /* AF_DIVERT */
+
     case AF_INET:
     {
         struct maybe_idna host = {NULL, NULL};
@@ -7683,6 +7688,14 @@ socket_exec(PyObject *m)
     ADD_INT_MACRO(m, AF_SYSTEM);
 #endif
 
+/* FreeBSD divert(4) */
+#ifdef PF_DIVERT
+    PyModule_AddIntMacro(m, PF_DIVERT);
+#endif
+#ifdef AF_DIVERT
+    PyModule_AddIntMacro(m, AF_DIVERT);
+#endif
+
 #ifdef AF_PACKET
     ADD_INT_MACRO(m, AF_PACKET);
 #endif



More information about the Python-checkins mailing list