Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socketmodule: support FreeBSD divert(4) socket #96534

Open
glebius opened this issue Sep 3, 2022 · 0 comments
Open

socketmodule: support FreeBSD divert(4) socket #96534

glebius opened this issue Sep 3, 2022 · 0 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@glebius
Copy link

glebius commented Sep 3, 2022

FreeBSD has divert(4) socket since previous century. Until recently it was in the namespace of PF_INET:

s = socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT)

This had no problems with Python's socketmodule, we just put a numeric constant in place of IPPROTO_DIVERT. And since bind(2) argument for divert(4) socket is struct sockaddr_in, luckily everything just worked.

Recently I moved the divert(4) out of PF_INET namespace, and now it should be created as:

s = socket(PF_DIVERT, SOCK_RAW, 0)

Unfortunately Python's socketmodule can't support this, cause to perform socket.bind() it doesn't know how to construct sockaddr. Attempt to socket.bind() just bails out due to internal socket module error, not even coming to syscall:

    s.bind(('0.0.0.0', port))
OSError: bind(): bad family

This functionality is important for FreeBSD, cause we use python in our internal regression testing suite.

So, better late than never, let socketmodule recognize and support FreeBSD divert(4) socket. Making pull request in a few minutes.

@glebius glebius added the type-bug An unexpected behavior, bug, or error label Sep 3, 2022
glebius added a commit to glebius/cpython that referenced this issue Sep 3, 2022
glebius added a commit to glebius/cpython that referenced this issue Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant