Title: socketmodule: support FreeBSD divert(4) socket · Issue #96534 · python/cpython · GitHub
Open Graph Title: socketmodule: support FreeBSD divert(4) socket · Issue #96534 · python/cpython
X Title: socketmodule: support FreeBSD divert(4) socket · Issue #96534 · python/cpython
Description: 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 plac...
Open Graph Description: 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...
X Description: 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 socketmo...
Opengraph URL: https://github.com/python/cpython/issues/96534
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"socketmodule: support FreeBSD divert(4) socket","articleBody":"FreeBSD has divert(4) socket since previous century. Until recently it was in the namespace of PF_INET:\r\n\r\n`s = socket(PF_INET, SOCK_RAW, IPPROTO_DIVERT)`\r\n\r\nThis 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.\r\n\r\nRecently I [moved the divert(4) out of PF_INET namespace](https://cgit.freebsd.org/src/commit/sys/netinet/ip_divert.c?id=8624f4347e8133911b0554e816f6bedb56dc5fb3), and now it should be created as:\r\n\r\n`s = socket(PF_DIVERT, SOCK_RAW, 0)`\r\n\r\nUnfortunately 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:\r\n```\r\n s.bind(('0.0.0.0', port))\r\nOSError: bind(): bad family\r\n```\r\nThis functionality is important for FreeBSD, cause [we use python in our internal regression testing suite](https://cgit.freebsd.org/src/plain/tests/sys/common/divert.py).\r\n\r\nSo, better late than never, let socketmodule recognize and support FreeBSD divert(4) socket. Making pull request in a few minutes.\n\n\u003c!-- gh-pr-number: gh-96536 --\u003e\n* PR: gh-96536\n\u003c!-- /gh-pr-number --\u003e\n","author":{"url":"https://github.com/glebius","@type":"Person","name":"glebius"},"datePublished":"2022-09-03T15:45:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/96534/cpython/issues/96534"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:35e45234-afdd-1c2a-a93b-fa83f1b284f5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B900:24B668:16D5B40:1E990E0:6969A9D4 |
| html-safe-nonce | 85b8eac3411ad72155eee1387c5631974e29590e8c90521fe4515f2f4ad123a5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTAwOjI0QjY2ODoxNkQ1QjQwOjFFOTkwRTA6Njk2OUE5RDQiLCJ2aXNpdG9yX2lkIjoiMzkwMDYwMjE2MzY5OTIzMTE4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 366fad8e258546797569b21b843581952da1b0a02a7b4c5097c9e2b28c781f9b |
| hovercard-subject-tag | issue:1360893005 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/96534/issue_layout |
| twitter:image | https://opengraph.githubassets.com/62bb97235e865ab0843809053553c6092e481f5d017fd62a728eeceea6dc3ebb/python/cpython/issues/96534 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/62bb97235e865ab0843809053553c6092e481f5d017fd62a728eeceea6dc3ebb/python/cpython/issues/96534 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | glebius |
| hostname | github.com |
| expected-hostname | github.com |
| None | 24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 124667f43168afb6c9c03b7c02eb5b1d2e1be3d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width