Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

socketmodule: support FreeBSD divert(4) socket #96534

Copy link
Copy link
Closed
@glebius

Description

@glebius
Issue body actions

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.