Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose RFC 3542 IPv6 socket options on macOS #79750

Closed
chrysn mannequin opened this issue Dec 23, 2018 · 9 comments
Closed

Expose RFC 3542 IPv6 socket options on macOS #79750

chrysn mannequin opened this issue Dec 23, 2018 · 9 comments
Labels
3.9 only security fixes OS-mac topic-IO type-feature A feature request or enhancement

Comments

@chrysn
Copy link
Mannequin

chrysn mannequin commented Dec 23, 2018

BPO 35569
Nosy @ronaldoussoren, @ned-deily, @chrysn, @erlend-aasland
PRs
  • bpo-35569: Expose RFC 3542 IPv6 socket options on macOS #19526
  • bpo-35569: add Erlend to Misc/ACKS #20146
  • Files
  • 0001-bpo-35569-Expose-RFC-3542-socket-options-on-macOS.patch
  • 0002-bpo-35569-Add-unit-tests.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-05-17.06:37:41.536>
    created_at = <Date 2018-12-23.12:00:47.132>
    labels = ['OS-mac', 'type-feature', '3.9', 'expert-IO']
    title = 'Expose RFC 3542 IPv6 socket options on macOS'
    updated_at = <Date 2020-05-17.06:57:31.851>
    user = 'https://github.com/chrysn'

    bugs.python.org fields:

    activity = <Date 2020-05-17.06:57:31.851>
    actor = 'ned.deily'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-05-17.06:37:41.536>
    closer = 'ned.deily'
    components = ['macOS', 'IO']
    creation = <Date 2018-12-23.12:00:47.132>
    creator = 'chrysn'
    dependencies = []
    files = ['48937', '49059']
    hgrepos = []
    issue_num = 35569
    keywords = ['patch']
    message_count = 9.0
    messages = ['332389', '332391', '363032', '363830', '363831', '366323', '369095', '369096', '369098']
    nosy_count = 4.0
    nosy_names = ['ronaldoussoren', 'ned.deily', 'chrysn', 'erlendaasland']
    pr_nums = ['19526', '20146']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue35569'
    versions = ['Python 3.9']

    @chrysn
    Copy link
    Mannequin Author

    chrysn mannequin commented Dec 23, 2018

    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.

    @chrysn chrysn mannequin added topic-IO type-feature A feature request or enhancement labels Dec 23, 2018
    @ronaldoussoren
    Copy link
    Contributor

    #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.

    @ronaldoussoren ronaldoussoren added OS-mac 3.8 only security fixes labels Dec 23, 2018
    @erlend-aasland
    Copy link
    Contributor

    Proposed patch attached.

    @chrysn
    Copy link
    Mannequin Author

    chrysn mannequin commented Mar 10, 2020

    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.

    @erlend-aasland
    Copy link
    Contributor

    Thanks for testing @chrysn. I guess I should add unit tests if this is to be applied to master.

    @erlend-aasland
    Copy link
    Contributor

    Added (Mac OS specific) unit tests.

    @erlend-aasland erlend-aasland added the 3.9 only security fixes label Apr 13, 2020
    @ned-deily
    Copy link
    Member

    New changeset 9a45bfe by Erlend Egeberg Aasland in branch 'master':
    bpo-35569: Expose RFC 3542 IPv6 socket options on macOS (GH-19526)
    9a45bfe

    @ned-deily
    Copy link
    Member

    Thanks for the PR! Merged for 3.9.0b1

    @ned-deily ned-deily removed the 3.8 only security fixes label May 17, 2020
    @ned-deily ned-deily changed the title OSX: Enable IPV6_RECVPKTINFO Expose RFC 3542 IPv6 socket options on macOS May 17, 2020
    @ned-deily
    Copy link
    Member

    New changeset fa098b6 by Ned Deily in branch 'master':
    bpo-35569: add Erlend to Misc/ACKS (GH-20146)
    fa098b6

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes OS-mac topic-IO type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants