Skip to content

Conversation

@NoAnyLove
Copy link

See #4582 for more details

@NoAnyLove
Copy link
Author

IPv6 multicast more tricky than IPv4. To bind on multicast group in IPv6, it requires to set the sin6_scope_id to the network interface index, i.e., user must specify the network interface for DISH socket (but not RADIO). This requires to change the resolve logic to set the sin6_scope_id for target address if it's IPv6 multicast, and the change also breaks some test cases.

if (ipv6_ && _is_multicast && _bind_interface < 0) {
errno = ENODEV;
return -1;
if (ipv6_ && _is_multicast && bind_) {
Copy link
Author

Choose a reason for hiding this comment

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

interface index is only needed if it's IPv6 multicast and the socket needs to perform bind(), i.e., the DISH socket.

errno = ENODEV;
return -1;
}
_target_address.ipv6.sin6_scope_id = _bind_interface;
Copy link
Author

Choose a reason for hiding this comment

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

To bind on multicast group in IPv6, it requires to set the scope id to the network interface index, otherwise it will fail.

{
if (ipv6_) {
return "udp://[" MCAST_IPV6 "]:5555";
return "udp://eth0;[" MCAST_IPV6 "]:5555";
Copy link
Author

Choose a reason for hiding this comment

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

the DISH socket now must specify the network interface for bind with this change.

I'm concerned about hard-coding the network interface name here, as it might break on other OS or if the host use different names. Not sure if there is any better choice.

Besides, it seems we cannot bind on lo, as it will result Network is unreachable on my box (not sue if it's a common case or just on my box).


zmq::udp_address_t addr;
int rc = addr.resolve ("[1:2:3::4];[ff01::1]:5555", false, true);
int rc = addr.resolve ("[1:2:3::4];[ff01::1]:5555", true, true);
Copy link
Author

Choose a reason for hiding this comment

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

change bind from false to true. It won't trigger the ENODEV error when bind is false, as RADIO socket does not require the interface for bind.

@NoAnyLove
Copy link
Author

This is more tricky than I thought, adding network interface makes the test cases dependent on OS and actual host configs, I don't have a good idea how to fix it.

Possible options,

  • only bind multicast group for IPv4 and leave IPv6 as is
  • add a socket option like ZMQ_IPV6, e.g., ZMQ_MULTICAST_BIND_GROUP or ZMQ_MULTICAST_BIND_ANY to control whether it should bind on multicast group or INADDR_ANY
  • add mechanism to detect the host network interface configs and use that for tests

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