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

Ignore unrecognised socket families in from_host #4

Conversation

andy-mortimer
Copy link

This change fixes the 'unknown sockaddr family' error on MacOS Catalina, #3 .

I don't know why this works. It seems like it's still masking another problem somewhere. But by triaging the changes in 01d8ebb, this is the difference which appears to have been causing the crash.

@andy-mortimer
Copy link
Author

I dug a little more. The reason casting to (int) worked, and the reason this was working before 01d8ebb, is that the ioctl was failing since that argument should be an unsigned long. When it succeeds, we get the unknown sockaddr family error soon after.

I've converted the PR to draft, as I don't really think this is a good fix (although if it works for you, let me know and I can mark it ready for review again!). I will dig further as I have the time. Any suggestions or pointers welcome.

On MacOS, SIOCGIFCONF returns sockets with a number of different families, including AF_LINK, AF_PUP, AF_LAT, and a few others with codes greater than the highest entry on the list. Rather than adding specific handling for each of these, we assume they are not of interest for this use case and ignore/log them.
@andy-mortimer andy-mortimer force-pushed the macos_siocgifnetmask_fix branch from ff3f171 to 93d848e Compare August 17, 2020 20:15
@andy-mortimer andy-mortimer changed the title mystery fix (cast to int) for Catalina sockaddr family error Ignore unrecognised socket families in from_host Aug 17, 2020
@andy-mortimer
Copy link
Author

I did try implementing AF_LINK in from_host, but after that it gave me AF_PUP, AF_LAT, and some others with numbers that aren't even defined in sys/socket.h. So I think @ChristopherHX is right: best just to log and ignore these oddities, assuming that any unusual socket families are not relevant here.

I wasn't sure what log level to use, is there a standard / would you rather a different?

I've updated the PR, let me know of any other comments.

@andy-mortimer andy-mortimer marked this pull request as ready for review August 17, 2020 20:21
@ChristopherHX
Copy link
Member

I mean skipping them and shrink the result set to only contain known values, setting them just to AF_UNSPEC wasn't my idea.
Still I cannot reproduce any errors with master on macOS 10.14, so idk what happen doing it with AF_UNSPEC

@ChristopherHX
Copy link
Member

I think we don't need this anymore as the original issue is fixed.

@andy-mortimer
Copy link
Author

I think we don't need this anymore as the original issue is fixed.

Agreed, thanks for the proper fix @ChristopherHX !

@andy-mortimer andy-mortimer deleted the macos_siocgifnetmask_fix branch September 6, 2020 21:00
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.

2 participants