Subject: Re: IP4\6 multicast and interfaces?
To: None <tech-net@netbsd.org>
From: Andrew White <awhite@arc.corp.mot.com>
List: tech-net
Date: 10/09/2001 11:17:23
Another interesting data point in this discussion.
The difference seems to be between sendto and connect/send.
If the order of calls is:
socket
setopt interface
sendto link local mcast address
...
then it correctly chooses the source address based on the outgoing
interface.
If instead I go:
socket
connect link local mcast address
setopt interface
...
the source address is bound to the default interface at the time of the
connect and is not later changed by the setopt interface.
As a third data point,
socket
setopt interface
connect link local mcast address
correctly chooses the source address based on the chosen interface.
This seems to be playing on some subtleties of the semantics of 'connect' vs
'setopt mcast interface'. Are these semantics correct, or should I file a
bug report?
The symptoms above apply in either IPv4 or IPv6.
Related question (v4 and v6):
Two interfaces: en0, en1.
I create one socket and bind it to a multicast address and port, then join
the mcast group on en0, I receive packets from en0 only.
I create one socket and bind it to a multicast address and port, then join
the mcast group on en1, I receive packets from en1 only.
I create two sockets and bind them to the same address and port (socket
option SO_REUSEPORT set). Socket A joins en0, socket B joins en1. Packets
from en1 are delivered to BOTH A and B.
Is this the correct behaviour? Do I need a socket for each interface, or
can I simply create one socket and then do a multicast join on both
interfaces? In the latter case, can I determine which interface received
the packet other than by source address (which will probably be link local
and thus provide no useful information).
I must use the same mcast address and port number on each link, so changing
address or port is not a solution.
Thanks
--
Andrew White Andrew.E.White@motorola.com