[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [patch #9257] core support for udp IPv6 and raw multicast

From: David van Moolenbroek
Subject: [lwip-devel] [patch #9257] core support for udp IPv6 and raw multicast
Date: Fri, 10 Feb 2017 07:37:27 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0


                 Summary: core support for udp IPv6 and raw multicast
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: dcvmoole
            Submitted on: Fri 10 Feb 2017 12:37:26 PM UTC
                Category: UDP
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None



I was hoping I could leave socket-level multicast support on my own wishlist,
but the last utility I needed to get to work turned out to require IPv6
multicast on raw sockets. Sigh, alright. While trying to implement my own
multicast support I quickly realized that the lwIP core layer doesn't quite
offer what I need just yet. In fact the following table shows the current
status of core support for multicast source addresses bound to sockets
("mc-src"), and for the mechanisms needed to implement the socket options

       |      UDP      |      RAW      |
       | IPv4  | IPv6  | IPv4  | IPv6  |
mc-src | yes   | no    | no    | no    |
_IF    | yes   | no    | no    | no    |
_TTL   | yes   | yes   | no    | no    |
_LOOP  | yes   | no[1] | no    | no    |

[1] the MCASTLOOP flag is set on pbufs here, but never checked.

(I hope some of the formatting remains at least by email..)

The attached two patches aim to improve this situation with a few small
additions of code, while retaining backward compatibility and (in the common
case) in fact saving a bit of PCB memory.

0001-udp-add-core-level-multicast-support-for-IPv6: this patch adds IPv6
multicast support to the UDP core module. It is especially worth noting here
that the IPV6_MULTICAST_IF socket option (from RFC 3493) takes not an IP
address but an interface index. This is therefore the part that diverges most
from the IPv4 equivalent. The new code can nicely use the just-added netif
index though!

0002-raw-add-core-support-for-multicast-TX-options: as practice shows, use of
multicast with raw sockets does actually occur, and will probably become even
more used as IPv6 generally takes off. This patch therefore adds (IPv4 and
IPv6) multicast support to raw sockets. The result, if nothing else, is that
the raw code is once more a bit better synchronized with the udp code.

The two patches have been tested against a basic multicast functionality test
that I've written for the occasion, which triggers all the code in these
patches except for the new IPv6 check on PBUF_FLAG_MCASTLOOP (because I do not
have ENABLE_LOOPBACK set here) but that bit is copied directly from the IPv4
code anyway. In particular, the tests show that the packet receipt sides of
both core modules already function entirely as needed and expected.

In any case, after these patches, the table now looks like this :)

       |      UDP      |      RAW      |
       | IPv4  | IPv6  | IPv4  | IPv6  |
mc-src | yes   | yes   | yes   | yes   |
_IF    | yes   | yes   | yes   | yes   |
_TTL   | yes   | yes   | yes   | yes   |
_LOOP  | yes   | yes   | yes   | yes   |

As always, implementation of the IPv6 (and perhaps also raw) multicast support
in lwIP's own socket API is left to others, but it should be trivial to do
that now.

Commit message of the 0001 patch reproduced below; the one for the 0002 is a
bit less interesting.


So far, the UDP core module implemented only IPv4 multicast support. This
patch extends the module with the features necessary for socket layers on top
to implement IPv6 multicast support as well:

o If a UDP PCB is bound to an IPv6 multicast address, a unicast source address
is selected and used to send the packet instead, as is required (and was the
case for IPv4 multicast already).

o Unlike IPv4's IP_MULTICAST_IF socket option, which takes a source IPv4
address, the IPV6_MULTICAST_IF socket option (from RFC 3493) takes an
interface identifier to denote the interface to use for outgoing
multicast-destined packets. A new pair of UDP PCB API calls,
udp_[gs]et_multicast_netif_index(), are added to support this. The new
definition "NETIF_NO_INDEX" may be used to indicate that lwIP should pick an
interface instead.

  IPv4 socket implementations may now also choose to map the given source
address to an interface index immediately and use the new facility instead of
the old udp_[gs]et_multicast_netif_addr() one. A side effect of limiting the
old facility to IPv4 is that for dual-stack configurations with multicast
support, the UDP PCB size is reduced by (up to) 16 bytes.

o For configurations that enable loopback interface support, the IPv6 code now
also supports multicast loopback (IPV6_MULTICAST_LOOP).

o The LWIP_MULTICAST_TX_OPTIONS opt.h setting now covers both IPv4 and IPv6,
and as such is no longer strictly linked to IGMP. It is therefore placed in
its own lwIP options subgroup in opt.h.

The IPV6_MULTICAST_HOPS socket option can already be implemented using the
existing IP_MULTICAST_TTL support, and thus requires no additional changes.
Overall, this patch should not break any existing code.


File Attachments:

Date: Fri 10 Feb 2017 12:37:26 PM UTC  Name:
0001-udp-add-core-level-multicast-support-for-IPv6.patch  Size: 14kB   By:

Date: Fri 10 Feb 2017 12:37:26 PM UTC  Name:
0002-raw-add-core-support-for-multicast-TX-options.patch  Size: 8kB   By:



Reply to this item at:


  Message sent via/by Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]