You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
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:
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.
The text was updated successfully, but these errors were encountered: