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

bpo-35569: Expose RFC 3542 IPv6 socket options on macOS #19526

Merged
merged 4 commits into from
May 17, 2020

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Apr 14, 2020

From macOS SDK netinet6/in6.h:

    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>
    
    [...]
    
    Note that eventually RFC 3542 is going to be the
    default and RFC 2292 will be obsolete.

https://bugs.python.org/issue35569

@erlend-aasland
Copy link
Contributor Author

FYI, force pushed to kick off stalled checks.

@remilapeyre
Copy link
Contributor

FYI, force pushed to kick off stalled checks.

I tested the path on Catalina and its works well. Thanks!

@erlend-aasland
Copy link
Contributor Author

Thank you, @remilapeyre !

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Erlend E. Aasland added 4 commits April 27, 2020 12:27
From macOS SDK netinet6/in6.h:
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>

[...]

Note that eventually RFC 3542 is going to be the
default and RFC 2292 will be obsolete.
@erlend-aasland
Copy link
Contributor Author

I have made the requested changes; please review again.

FYI: test_peg_generator fails on my machine (master HEAD => 4044c84). I pushed this to GitHub to see if the CI also fails.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@ned-deily: please review the changes made to this pull request.

@bedevere-bot bedevere-bot requested a review from ned-deily April 27, 2020 10:43
@erlend-aasland
Copy link
Contributor Author

Ref. my previous comment (and completely irrelevant to this PR): I see that the CI has no problems with test_peg_generator, so that problem is on my side.

@erlend-aasland
Copy link
Contributor Author

BTW, detect_socket() in setup.py could be restructured a little bit. Something like this would be cleaner:

    def detect_socket(self):
        # socket(2)
        kwargs = {'depends': ['socketmodule.h']}
        if VXWORKS:
            kwargs['libraries'] = ['net']
        elif MACOS:
            # Issue #35569: Expose RFC 3542 socket options.
            kwargs['extra_compile_args'] = ['-D__APPLE_USE_RFC_3542']

        self.add(Extension('_socket', ['socketmodule.c'], **kwargs))

I guess that would need to go in a separate issue?

@ned-deily
Copy link
Member

Your restructered detect_socket() looks nicer but, unless I'm missing something, it doesn't seem to behave the same as the original code. The current code doesn't attempt to build _socket on VxWorks if it can't find the net lib directory, no? Let's go with how the PR stands currently.

Copy link
Member

@ned-deily ned-deily left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! That's a lot cleaner.

@ned-deily ned-deily merged commit 9a45bfe into python:master May 17, 2020
@erlend-aasland
Copy link
Contributor Author

erlend-aasland commented May 17, 2020

Thanks, @ned-deily !

Your restructered detect_socket() looks nicer but, unless I'm missing something, it doesn't seem to behave the same as the original code. The current code doesn't attempt to build _socket on VxWorks if it can't find the net lib directory, no?

You're right, I mistook the elif for an else!

This should do the trick:

    def detect_socket(self):
        # socket(2)
        if VXWORKS:
            if not self.compiler.find_library_file(self.lib_dirs, 'net'):
                return
            kwargs = {'libraries': ['net']}
        elif MACOS:
            # Issue #35569: Expose RFC 3542 socket options.
            kwargs = {'extra_compile_args': ['-D__APPLE_USE_RFC_3542']}
        else:
            kwargs = {}

        kwargs['depends'] = ['socketmodule.h']
        self.add(Extension('_socket', ['socketmodule.c'], **kwargs))

Or we could just initialize kwargs first, and drop the last else

@erlend-aasland erlend-aasland deleted the fix-issue-35569 branch May 17, 2020 07:56
arturoescaip pushed a commit to arturoescaip/cpython that referenced this pull request May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants