classification
Title: Expose RFC 3542 IPv6 socket options on macOS
Type: enhancement Stage: resolved
Components: IO, macOS Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: chrysn, erlendaasland, ned.deily, ronaldoussoren
Priority: normal Keywords: patch

Created on 2018-12-23 12:00 by chrysn, last changed 2020-05-17 06:57 by ned.deily. This issue is now closed.

Files
File name Uploaded Description Edit
0001-bpo-35569-Expose-RFC-3542-socket-options-on-macOS.patch erlendaasland, 2020-02-29 23:22
0002-bpo-35569-Add-unit-tests.patch erlendaasland, 2020-04-13 18:58
Pull Requests
URL Status Linked Edit
PR 19526 merged erlendaasland, 2020-04-14 22:16
PR 20146 merged ned.deily, 2020-05-17 06:50
Messages (9)
msg332389 - (view) Author: chrysn (chrysn) * Date: 2018-12-23 12:00
Python builds on MacOS do not expose the IPV6_RECVPKTINFO flag specified in [RFC3842], which is required for UDP protocols that need control over their servers' sending ports like [CoAP].

While I don't own Apple hardware and thus can't test it, the [nginx] code indicates that this API is available on OSX and is just gated behind `-D__APPLE_USE_RFC_3542`. Searching the web for that define indicates that other interpreted langues and applications use the flag as well (PHP, Ruby; PowerDNS, nmap, libcoap).

Please consider enabling this on future releases of Python on OSX.

[RFC3542]: https://tools.ietf.org/html/rfc3542
[CoAP]: https://github.com/chrysn/aiocoap/issues/69
[nginx]: http://hg.nginx.org/nginx/rev/9fb994513776
msg332391 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2018-12-23 15:15
#include <netinet6/in6.h> in the macOS 10.14 SDK says:

/*
 * RFC 3542 define the following socket options in a manner incompatible
 * with RFC 2292:
 *   IPV6_PKTINFO
 *   IPV6_HOPLIMIT
 *   IPV6_NEXTHOP
 *   IPV6_HOPOPTS
 *   IPV6_DSTOPTS
 *   IPV6_RTHDR
 *
 * To use the new IPv6 Sockets options introduced by RFC 3542
 * the constant __APPLE_USE_RFC_3542 must be defined before
 * including <netinet/in.h>
 *
 * To use the old IPv6 Sockets options from RFC 2292
 * the constant __APPLE_USE_RFC_2292 must be defined before
 * including <netinet/in.h>
 *
 * Note that eventually RFC 3542 is going to be the
 * default and RFC 2292 will be obsolete.
 */

My conclusion from reading this: the name might suggest that this is an internal macro, but should be safe to use.
msg363032 - (view) Author: Erlend Egeberg Aasland (erlendaasland) * Date: 2020-02-29 23:22
Proposed patch attached.
msg363830 - (view) Author: chrysn (chrysn) * Date: 2020-03-10 17:07
Testing the application to current git master (on a borrowed machine with Darwin Kernel Version 18.5.0), the provided patch does enable the desired IPV6_RECVPKTINFO flag, and the received pktinfo struct complies to the spec.
msg363831 - (view) Author: Erlend Egeberg Aasland (erlendaasland) * Date: 2020-03-10 17:14
Thanks for testing @chrysn. I guess I should add unit tests if this is to be applied to master.
msg366323 - (view) Author: Erlend Egeberg Aasland (erlendaasland) * Date: 2020-04-13 18:58
Added (Mac OS specific) unit tests.
msg369095 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-17 06:32
New changeset 9a45bfe6f4aedd2a9d94cb12aa276057b15d8b63 by Erlend Egeberg Aasland in branch 'master':
bpo-35569: Expose RFC 3542 IPv6 socket options on macOS (GH-19526)
https://github.com/python/cpython/commit/9a45bfe6f4aedd2a9d94cb12aa276057b15d8b63
msg369096 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-17 06:37
Thanks for the PR!  Merged for 3.9.0b1
msg369098 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2020-05-17 06:57
New changeset fa098b6bc8662cceb944ad5a4a3e5eb63d3cb517 by Ned Deily in branch 'master':
bpo-35569: add Erlend to Misc/ACKS (GH-20146)
https://github.com/python/cpython/commit/fa098b6bc8662cceb944ad5a4a3e5eb63d3cb517
History
Date User Action Args
2020-05-17 06:57:31ned.deilysetmessages: + msg369098
2020-05-17 06:50:01ned.deilysetpull_requests: + pull_request19451
2020-05-17 06:37:41ned.deilysetstatus: open -> closed
versions: - Python 3.8
title: OSX: Enable IPV6_RECVPKTINFO -> Expose RFC 3542 IPv6 socket options on macOS
messages: + msg369096

resolution: fixed
stage: patch review -> resolved
2020-05-17 06:32:53ned.deilysetmessages: + msg369095
2020-04-14 22:16:36erlendaaslandsetstage: needs patch -> patch review
pull_requests: + pull_request18876
2020-04-13 19:33:15erlendaaslandsetversions: + Python 3.9
2020-04-13 18:58:59erlendaaslandsetfiles: + 0002-bpo-35569-Add-unit-tests.patch

messages: + msg366323
2020-03-10 17:14:05erlendaaslandsetmessages: + msg363831
2020-03-10 17:07:32chrysnsetmessages: + msg363830
2020-02-29 23:22:45erlendaaslandsetfiles: + 0001-bpo-35569-Expose-RFC-3542-socket-options-on-macOS.patch
keywords: + patch
messages: + msg363032
2020-02-29 22:41:38erlendaaslandsetnosy: + erlendaasland
2018-12-23 15:15:46ronaldoussorensetversions: + Python 3.8
nosy: + ronaldoussoren, ned.deily

messages: + msg332391

components: + macOS
stage: needs patch
2018-12-23 12:00:47chrysncreate