Skip to content

Commit acf7134

Browse files
committed
Add socket.SO_BINDTOIFINDEX constant
This socket option avoids a race condition between SO_BINDTODEVICE and network interface renaming.
1 parent 39ec7fb commit acf7134

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

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
@@ -7926,6 +7926,9 @@ socket_exec(PyObject *m)
79267926
#ifdef SO_BINDTODEVICE
79277927
ADD_INT_MACRO(m, SO_BINDTODEVICE);
79287928
#endif
7929+
#ifdef SO_BINDTOIFINDEX
7930+
ADD_INT_MACRO(m, SO_BINDTOIFINDEX);
7931+
#endif
79297932
#ifdef SO_PRIORITY
79307933
ADD_INT_MACRO(m, SO_PRIORITY);
79317934
#endif

0 commit comments

Comments
 (0)