https://github.com/python/cpython/commit/e1fdc3c323bd605f92622b7ee18805885ff0bb4e
commit: e1fdc3c323bd605f92622b7ee18805885ff0bb4e
branch: main
author: Victor Westerhuis <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-02-20T23:08:15+02:00
summary:
gh-104061: Add socket.SO_BINDTOIFINDEX constant (GH-104062)
Add socket.SO_BINDTOIFINDEX constant
This socket option avoids a race condition between SO_BINDTODEVICE and network
interface renaming.
files:
A Misc/NEWS.d/next/Library/2023-05-01-22-28-57.gh-issue-104061.vxfBXf.rst
M Doc/library/socket.rst
M Modules/socketmodule.c
diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst
index dccf78ef8c0128..3a931e25de91e5 100644
--- a/Doc/library/socket.rst
+++ b/Doc/library/socket.rst
@@ -445,6 +445,11 @@ Constants
Added ``IP_PKTINFO``, ``IP_UNBLOCK_SOURCE``, ``IP_BLOCK_SOURCE``,
``IP_ADD_SOURCE_MEMBERSHIP``, ``IP_DROP_SOURCE_MEMBERSHIP``.
+ .. versionchanged:: 3.13
+ Added ``SO_BINDTOIFINDEX``. On Linux this constant can be used in the
+ same way that ``SO_BINDTODEVICE`` is used, but with the index of a
+ network interface instead of its name.
+
.. data:: AF_CAN
PF_CAN
SOL_CAN_*
diff --git
a/Misc/NEWS.d/next/Library/2023-05-01-22-28-57.gh-issue-104061.vxfBXf.rst
b/Misc/NEWS.d/next/Library/2023-05-01-22-28-57.gh-issue-104061.vxfBXf.rst
new file mode 100644
index 00000000000000..e15a811f904352
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-05-01-22-28-57.gh-issue-104061.vxfBXf.rst
@@ -0,0 +1 @@
+Add :data:`socket.SO_BINDTOIFINDEX` constant.
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 298c0e29d0d9b8..836cf6c05b3196 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -7927,6 +7927,9 @@ socket_exec(PyObject *m)
#ifdef SO_BINDTODEVICE
ADD_INT_MACRO(m, SO_BINDTODEVICE);
#endif
+#ifdef SO_BINDTOIFINDEX
+ ADD_INT_MACRO(m, SO_BINDTOIFINDEX);
+#endif
#ifdef SO_PRIORITY
ADD_INT_MACRO(m, SO_PRIORITY);
#endif
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]