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

fix bind_addr assignment for IPv6 #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

timbz
Copy link

@timbz timbz commented Jun 4, 2024

As far as I can tell the if statement is not needed with IPv6. It actually fails on my machine with:

Traceback (most recent call last):
  File "monitor-sd.py", line 87, in <module>
    main()
  File "monitor-sd.py", line 79, in main
    asyncio.get_event_loop().run_until_complete(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "monitor-sd.py", line 22, in run
    trsp_u, trsp_m, protocol = await SDProto.create_endpoints(
  File "/usr/local/lib/python3.8/dist-packages/someip/sd.py", line 380, in create_endpoints
    trsp_m = await cls._create_endpoint(
  File "/usr/local/lib/python3.8/dist-packages/someip/sd.py", line 254, in _create_endpoint
    trsp, _ = await loop.create_datagram_endpoint(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1265, in create_datagram_endpoint
    infos = await self._ensure_resolved(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1365, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "/usr/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

Some testing:

>socket.getaddrinfo("ff14::4:0%eth0.4", 30490)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

>socket.getaddrinfo("ff14::4:0", 30490)
[(<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('ff14::4:0', 30490, 0, 0)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_DGRAM: 2>, 17, '', ('ff14::4:0', 30490, 0, 0)), (<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_RAW: 3>, 0, '', ('ff14::4:0', 30490, 0, 0))]

@afflux
Copy link
Owner

afflux commented Jun 9, 2024

Hi! Thanks for your PR. Please ignore the CI errors for now, they are unrelated.

I have to admit I'm no expert on IPv6 multicast addressing schemes, but I see that addresses in ff02::/16 really do require the scope suffix (which makes sense, as they are link-local). If other prefixes don't need it, I guess it could make sense to remove that logic and instead instruct the library user to provide it if necessary.

Just out of curiosity, what's your reasoning to use ff14::/16?

@timbz
Copy link
Author

timbz commented Jun 11, 2024

remove that logic and instead instruct the library user to provide it if necessary

Sounds like a good solution.

Just out of curiosity, what's your reasoning to use ff14::/16?

To be honest I never thought about it too much. The address comes from a requirement and I never challenged it (I'm not expert on IPv6 multicast addressing schemes too)

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