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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some network TLC, including discarding multicast discovery on the "wrong" interface #1943

Merged
merged 7 commits into from Mar 20, 2024

Commits on Mar 20, 2024

  1. Recvmsg: return packet info (dst addr and nw i/f)

    This extends `ddsrt_recvmsg` to not only return the packet's source
    address, but also its destination address and the interface on which it
    was received.  If the operating system does not provide this
    information, they can be set to "unknown".
    
    The additional information is valuable because, at least on Linux, one
    sometimes receives multicast packets from an interface on which one did
    not join the multicast group for reasons I am yet to discover.  This
    allows detecting such cases.  It also makes it possible to make a more
    informed guess about which interface is the most suitable choice for
    communicating with a node X, and it also seems likely that receiving a
    multicast from X is a good indicator that sending a multicast to node X
    will work.
    
    This commit does not use the information other than for writing it in
    the trace.  Current implementation is verified to work on macOS, Linux
    and Windows for IPv4 and IPv6.
    
    Signed-off-by: Erik Boasson <eb@ilities.com>
    eboasson committed Mar 20, 2024
    Copy the full SHA
    31febb7 View commit details
    Browse the repository at this point in the history
  2. Split up ddsi_addrset_from_locatorlists

    Signed-off-by: Erik Boasson <eb@ilities.com>
    eboasson committed Mar 20, 2024
    Copy the full SHA
    3855d25 View commit details
    Browse the repository at this point in the history
  3. Ignore distant addresses if nearby ones exist

    Before this commit, the decision which unicast locators to include was
    to accept all distant locators if they were routable addresses and we
    had a network interface that looked like it could handle them.  The
    "DontRoute" configuration option would change this and made it ignore
    all distant locators.
    
    The first turns out to be problematic in practice because quite often
    there are no suitable routes defined in the networking stack, but
    defaulting to not allowing any routing is also problematic.
    
    What this commit does is twofold:
    
    * Firstly, it uses the new received packet information to associate the
      address with the network interface over which it was received (if
      possible) instead of the first seemingly suitable one;
    
    * Secondly, it only uses distant addresses when it has been established
      that no nearby addresses are in the advertised set.  This heuristic
      probably better fits the use cases.
    
    What it perhaps should also do is reject the address if we know what
    interface it arrived on and that interface is not enabled in the
    configuration.
    
    Signed-off-by: Erik Boasson <eb@ilities.com>
    eboasson committed Mar 20, 2024
    Copy the full SHA
    8758602 View commit details
    Browse the repository at this point in the history
  4. Try multicast on loopback when flag not set

    For IPv4 on Linux, the common case seems to be that the loopback
    interface is perfectly capable of handling multicast but the interface
    usually don't indicate this.  This commit adds a run-time test by
    sending a small multicast packet to itself in this specific case.
    
    For IPv6 there is some other complication, the test says the network is
    unreachable.  Perhaps correctly, perhaps there's a trick I haven't found
    yet.  Either way, if errs on the safe side, so that's fine.
    
    Signed-off-by: Erik Boasson <eb@ilities.com>
    eboasson committed Mar 20, 2024
    Copy the full SHA
    9b6357d View commit details
    Browse the repository at this point in the history
  5. Remove participant index limit in documentation

    There is no simple hard limit (other than 2^32-2).
    
    Signed-off-by: Erik Boasson <eb@ilities.com>
    eboasson committed Mar 20, 2024
    Copy the full SHA
    f5ae48d View commit details
    Browse the repository at this point in the history
  6. Make "allow multicast" per-interface

    This adds an "allow_multicast" attribute to the network interface
    configuration and uses the old General/AllowMulticast as the default
    value.  This way, both backwards compatibility and easy global
    configuration are supported.
    
    This incidentally addresses a slew of bugs in multi-network
    configurations, but it does make things rather more complicated.
    
    Signed-off-by: Erik Boasson <eb@ilities.com>
    eboasson committed Mar 20, 2024
    Copy the full SHA
    57cf02f View commit details
    Browse the repository at this point in the history
  7. Ignore SPDP from non-selected interfaces

    Ignore SPDP messages that:
    
    * Provably arrived over a network interface we didn't enable
    
    * Were multicast over a network interface on which did not allow
      multicast discovery.
    
    For an example why this is useful: on Linux, running two proceses one allowing multicast
    over loopback but not Ethernet, and one allowing it over Ethernet but not over loopback,
    both processes do receive the multicast message despite not having joined the multicast
    group on the interface it is sent on.  With this commit, those SPDP messages are ignored
    and the two processes do not discover each other.
    
    The direct reason for this change is to make it possible to have discovery over Ethernet
    only with unicast messages, while using relying on multicast over loopback.  This turns
    out to be a rather important set-up, and is even the new default in ROS 2.
    
    Signed-off-by: Erik Boasson <eb@ilities.com>
    eboasson committed Mar 20, 2024
    Copy the full SHA
    3e6d1c4 View commit details
    Browse the repository at this point in the history