gh-96534: socketmodule: support FreeBSD divert(4) socket#96536
Conversation
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Most changes to Python require a NEWS entry. Please add it using the blurb_it web app or the blurb command-line tool. |
Sorry, something went wrong.
|
Since this trivial pull request is being ignored for 2 months, tagging people who were the most recent committers to this module. Please take a look! |
Sorry, something went wrong.
|
I see no problem with it, as it's just constants. But should we have a test? |
Sorry, something went wrong.
Do you have FreeBSD in your CI? Is it worth to have one just for this small case? I can ensure you that this code will be exercised in our FreeBSD CI, as we use python for regression test of the divert module :) |
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
I don't get the point of this PR. AF_DIVERT and PF_DIVERT don't exist my FreeBSD 13 VM (grep doesn't match any line):
vstinner@freebsd$ grep AF_DIVERT -R /usr/include/
vstinner@freebsd$ grep PF_DIVERT -R /usr/include/
But IPPROTO_DIVERT is defined:
vstinner@freebsd$ grep IPPROTO_DIVERT -R /usr/include/
/usr/include/netinet/in.h:#define IPPROTO_DIVERT 258 /* divert pseudo-protocol */
And the manual page mentioned in the Python issue contains:
int socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT);
For me, IPPROTO_DIVERT constant should be added, no?
Sorry, something went wrong.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Sorry, something went wrong.
|
FreeBSD divert manual page: https://www.freebsd.org/cgi/man.cgi?divert |
Sorry, something went wrong.
There are FreeBSD buildbot workers, but I don't think that it's worth it to add an unit test (I'm fine with merging the PR without a test). |
Sorry, something went wrong.
The new protocol family exists only in FreeBSD 14 and the old PF_INET/IPPROTO_DIVERT will go away in FreeBSD 14: All known open source software is already patched wrt this change. The way I patched the Python's socketmodule allows it to be compiled both on FreeBSD 14 and old versions correctly, so that new builds will support PF_DIVERT and old builds will allow to use PF_INET with protocol integer equal to IPPROTO_DIVERT, just as they did before. |
Sorry, something went wrong.
|
Sorry, something went wrong.
Ah, I tested your PR on a FreeBSD 13 VM. When is the FreeBSD 14 release planned? I understand that his PR is not usable on FreeBSD 13, right? Would it be useful to expose IPPROTO_DIVERT for FreeBSD 13? |
Sorry, something went wrong.
|
The current https://cgit.freebsd.org/src/plain/tests/sys/common/divert.py script mentioned in the issue uses IPPROTO_DIVERT (by defining it manually to 258). |
Sorry, something went wrong.
The 12.x buildbot worker will verify/confirm that |
Sorry, something went wrong.
Sorry, something went wrong.
It is planned for summer 2023.
Right, on FreeBSD 13 the new code won't be compiled in. I don't think there is any reason to add support for obsolete constant. To my knowledge our regression suite CI is the only Python code that uses it. |
Sorry, something went wrong.
nirs
left a comment
There was a problem hiding this comment.
Looks good to me.
It would be nice to have tests using the new constants when they are available.
Sorry, something went wrong.
Addressed in #96536 (comment), no longer awaiting changes |
Sorry, something went wrong.
They are users running FreeBSD older than FreeBSD 14. Without IPPROTO_DIVERT exposed in Python, this kind of socket cannot be used in Python. Well, if your plan is to only add support for divert sockets on FreeBSD 14, I will wait until FreeBSD 14 is released to manually test this PR. |
Sorry, something went wrong.
Nothing changes to users of older FreeBSD with my change. The constant wasn't defined before and it stays undefined. The old style socket could actually be used, just using 258 literal. However, the new can not be used with this hack, due to bind() failing due to socketmodule not recognizing the address family. See this change.
You can install this VM image from here https://download.freebsd.org/snapshots/VM-IMAGES/14.0-CURRENT/amd64/ Either date shall work, they all are new enough. I'd really appreciate if this happens soon rather than wait for 14.0-RELEASE. This will make our testing easier and will allow to faster obsolete the old socket. |
Sorry, something went wrong.
Sorry, something went wrong.
Can't you have a downstream patch in FreeBSD to test your change before FreeBSD 14 is released? That's what we do in Fedora to unblock issues before upstream accepts our patches (or when the change is merged but not released yet). I would prefer to wait until FreeBSD 14 is released, before making changes to support it. By the way, Python 3.12 is not going to be released before October 2023 (in one year). |
Sorry, something went wrong.
Can you please propose a PR just to add IPPROTO_DIVERT? I could test it immediately. |
Sorry, something went wrong.
Now all Python ports has been patched to support PF_DIVERT, and Python kinda promises to add support in 3.12 [1]. This reverts commit 322b5b7. [1] python/cpython#96536 (comment)
|
Status update: mmkay, I have added this patch to all python ports on FreeBSD. Victor, I hope you will merge it once FreeBSD 14.0-RELEASE is officially out. |
Sorry, something went wrong.
Now all Python ports has been patched to support PF_DIVERT, and Python kinda promises to add support in 3.12 [1]. This reverts commit 322b5b7. [1] python/cpython#96536 (comment)
vstinner
left a comment
There was a problem hiding this comment.
Would it be possible to somehow document these constants? See for example:
https://docs.python.org/dev/library/socket.html#socket.AF_RDS
Document that they are new in Python 3.12.
Sorry, something went wrong.
|
I understand that you have this downstream patch in FreeBSD CURRENT for a few weeks/months. I'm now fine with adding these FreeBSD 14 constants (once the review will be done). |
Sorry, something went wrong.
|
@vstinner updated socket module documentation as you suggested. Let me know if I need anything else to be done to get this in. |
Sorry, something went wrong.
|
@vstinner We are entering FreeBSD 14 release cycle. I'd like to get this in python before FreeBSD 14.0 is released. Let me know how I can help to achieve that. |
Sorry, something went wrong.
vstinner
left a comment
There was a problem hiding this comment.
LGTM. Thanks for adding the documentation.
Sorry, something went wrong.
|
Better late than never, I merged your PR. Thanks for your contribution. |
Sorry, something went wrong.
Thanks Victor! ❤️ |
Sorry, something went wrong.
* main: (61 commits) pythongh-64595: Argument Clinic: Touch source file if any output file changed (python#104152) pythongh-64631: Test exception messages in cloned Argument Clinic funcs (python#104167) pythongh-68395: Avoid naming conflicts by mangling variable names in Argument Clinic (python#104065) pythongh-64658: Expand Argument Clinic return converter docs (python#104175) pythonGH-103092: port `_asyncio` freelist to module state (python#104196) pythongh-104051: fix crash in test_xxtestfuzz with -We (python#104052) pythongh-104190: fix ubsan crash (python#104191) pythongh-104106: Add gcc fallback of mkfifoat/mknodat for macOS (pythongh-104129) pythonGH-104142: Fix _Py_RefcntAdd to respect immortality (pythonGH-104143) pythongh-104112: link from cached_property docs to method-caching FAQ (python#104113) pythongh-68968: Correcting message display issue with assertEqual (python#103937) pythonGH-103899: Provide a hint when accidentally calling a module (pythonGH-103900) pythongh-103963: fix 'make regen-opcode' in out-of-tree builds (python#104177) pythongh-102500: Add PEP 688 and 698 to the 3.12 release highlights (python#104174) pythonGH-81079: Add case_sensitive argument to `pathlib.Path.glob()` (pythonGH-102710) pythongh-91896: Deprecate collections.abc.ByteString (python#102096) pythongh-99593: Add tests for Unicode C API (part 2) (python#99868) pythongh-102500: Document PEP 688 (python#102571) pythongh-102500: Implement PEP 688 (python#102521) pythongh-96534: socketmodule: support FreeBSD divert(4) socket (python#96536) ...
All rationale in #96534