patchlwIP - A Lightweight TCP/IP stack - Patches: patch #9257, core support for udp IPv6 and raw...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #9257: core support for udp IPv6 and raw multicast

Submitter:  David van Moolenbroek <dcvmoole>
Submitted:  Fri 10 Feb 2017 12:37:26 PM UTC
   
 
Category:  UDP Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Planned Release:  None

Fri 10 Feb 2017 09:43:07 PM UTC, comment #1: 

Cool! Thanks a lot once again for your work!

Dirk Ziegelmeier <dziegel>
Group administrator
Fri 10 Feb 2017 12:37:26 PM UTC, original submission:  

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 IP(V6)_MULTICAST_IF ("_IF"), IP_MULTICAST_TTL/IPV6_MULTICAST_HOPS ("_TTL"), and IP(V6)_MULTICAST_LOOP ("_LOOP"):

       |      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.

David van Moolenbroek <dcvmoole>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dziegel (Posted a comment)
  • -email is unavailable- added by dcvmoole (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-02-10 dziegel StatusNone Done
        Open/ClosedOpen Closed
    2017-02-10 dcvmoole Attached File- Added 0001-udp-add-core-level-multicast-support-for-IPv6.patch, #39717
        Attached File- Added 0002-raw-add-core-support-for-multicast-TX-options.patch, #39718

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code