Content-Length: 290982 | pFad | http://github.com/matttbe/cpython/commit/da8e557a48b0d85980a752f5dff1bda90fcc8591

39 gh-98030: socket: add missing TCP socket options · matttbe/cpython@da8e557 · GitHub
Skip to content

Commit

Permalink
pythongh-98030: socket: add missing TCP socket options
Browse files Browse the repository at this point in the history
A few TCP socket options have been added to the Linux kernel these last
few years.

This commit adds all the ones available in Linux 6.0:

  https://elixir.bootlin.com/linux/v6.0/source/include/uapi/linux/tcp.h#L91

While at it, the TCP_FASTOPEN option has been moved lower in the list
just to keep the same order as in tcp.h to ease future synchronisations.

Please note that I initially wanted to get socket.TCP_FASTOPEN_CONNECT.
I was going to add only this one but while at it, here are all the
missing ones.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
matttbe committed Oct 10, 2022
1 parent 571e23d commit da8e557
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ Constants
.. 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.
``SO_MARK`` is used on Linux. Also added missing ``TCP_*`` available in
Linux 6.0.

.. data:: AF_CAN
PF_CAN
Expand Down
66 changes: 63 additions & 3 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8471,18 +8471,78 @@ PyInit__socket(void)
#ifdef TCP_QUICKACK
PyModule_AddIntMacro(m, TCP_QUICKACK);
#endif
#ifdef TCP_FASTOPEN
PyModule_AddIntMacro(m, TCP_FASTOPEN);
#endif
#ifdef TCP_CONGESTION
PyModule_AddIntMacro(m, TCP_CONGESTION);
#endif
#ifdef TCP_MD5SIG
PyModule_AddIntMacro(m, TCP_MD5SIG);
#endif
#ifdef TCP_THIN_LINEAR_TIMEOUTS
PyModule_AddIntMacro(m, TCP_THIN_LINEAR_TIMEOUTS);
#endif
#ifdef TCP_THIN_DUPACK
PyModule_AddIntMacro(m, TCP_THIN_DUPACK);
#endif
#ifdef TCP_USER_TIMEOUT
PyModule_AddIntMacro(m, TCP_USER_TIMEOUT);
#endif
#ifdef TCP_REPAIR
PyModule_AddIntMacro(m, TCP_REPAIR);
#endif
#ifdef TCP_REPAIR_QUEUE
PyModule_AddIntMacro(m, TCP_REPAIR_QUEUE);
#endif
#ifdef TCP_QUEUE_SEQ
PyModule_AddIntMacro(m, TCP_QUEUE_SEQ);
#endif
#ifdef TCP_REPAIR_OPTIONS
PyModule_AddIntMacro(m, TCP_REPAIR_OPTIONS);
#endif
#ifdef TCP_FASTOPEN
PyModule_AddIntMacro(m, TCP_FASTOPEN);
#endif
#ifdef TCP_TIMESTAMP
PyModule_AddIntMacro(m, TCP_TIMESTAMP);
#endif
#ifdef TCP_NOTSENT_LOWAT
PyModule_AddIntMacro(m, TCP_NOTSENT_LOWAT);
#endif
#ifdef TCP_CC_INFO
PyModule_AddIntMacro(m, TCP_CC_INFO);
#endif
#ifdef TCP_SAVE_SYN
PyModule_AddIntMacro(m, TCP_SAVE_SYN);
#endif
#ifdef TCP_SAVED_SYN
PyModule_AddIntMacro(m, TCP_SAVED_SYN);
#endif
#ifdef TCP_REPAIR_WINDOW
PyModule_AddIntMacro(m, TCP_REPAIR_WINDOW);
#endif
#ifdef TCP_FASTOPEN_CONNECT
PyModule_AddIntMacro(m, TCP_FASTOPEN_CONNECT);
#endif
#ifdef TCP_ULP
PyModule_AddIntMacro(m, TCP_ULP);
#endif
#ifdef TCP_MD5SIG_EXT
PyModule_AddIntMacro(m, TCP_MD5SIG_EXT);
#endif
#ifdef TCP_FASTOPEN_KEY
PyModule_AddIntMacro(m, TCP_FASTOPEN_KEY);
#endif
#ifdef TCP_FASTOPEN_NO_COOKIE
PyModule_AddIntMacro(m, TCP_FASTOPEN_NO_COOKIE);
#endif
#ifdef TCP_ZEROCOPY_RECEIVE
PyModule_AddIntMacro(m, TCP_ZEROCOPY_RECEIVE);
#endif
#ifdef TCP_INQ
PyModule_AddIntMacro(m, TCP_INQ);
#endif
#ifdef TCP_TX_DELAY
PyModule_AddIntMacro(m, TCP_TX_DELAY);
#endif

/* IPX options */
#ifdef IPX_TYPE
Expand Down

0 comments on commit da8e557

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/matttbe/cpython/commit/da8e557a48b0d85980a752f5dff1bda90fcc8591

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy