Skip to content

socketmodule: support FreeBSD divert(4) socket #96534

@glebius

Description

@glebius

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 dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy