8000 gh-104061: Add socket.SO_BINDTOIFINDEX constant (GH-104062) · python/cpython@e1fdc3c · GitHub
[go: up one dir, main page]

Skip to content

Commit e1fdc3c

Browse files
authored
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.
1 parent 142502e commit e1fdc3c

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Doc/library/socket.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,11 @@ Constants
445445
Added ``IP_PKTINFO``, ``IP_UNBLOCK_SOURCE``, ``IP_BLOCK_SOURCE``,
446446
``IP_ADD_SOURCE_MEMBERSHIP``, ``IP_DROP_SOURCE_MEMBERSHIP``.
447447

448+
.. versionchanged:: 3.13
449+
Added ``SO_BINDTOIFINDEX``. On Linux this constant can be used in the
450+
same way that ``SO_BINDTODEVICE`` is used, but with the index of a
451+
network interface instead of its name.
452+
448453
.. data:: AF_CAN
449454
PF_CAN
450455
SOL_CAN_*
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add :data:`socket.SO_BINDTOIFINDEX` constant.

Modules/socketmodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7927,6 +7927,9 @@ socket_exec(PyObject *m)
79277927
#ifdef SO_BINDTODEVICE
79287928
ADD_INT_MACRO(m, SO_BINDTODEVICE);
79297929
#endif
7930+
#ifdef SO_BINDTOIFINDEX
7931+
ADD_INT_MACRO(m, SO_BINDTOIFINDEX);
7932+
#endif
79307933
#ifdef SO_PRIORITY
79317934
ADD_INT_MACRO(m, SO_PRIORITY);
79327935
#endif

0 commit comments

Comments
 (0)
0