Summary: Multicast socket blocks other UDP sockets
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: dapaulid
Submitted on: Tue 27 Aug 2019 10:43:16 AM CEST
Severity: 3 - Normal
Item Group: Faulty Behaviour
Assigned to: None
Discussion Lock: Any
Planned Release: None
lwIP version: git head
We came across an issue where an UDP socket that joined a multicast group led
to blocking recv() calls on other sockets, given that some datagrams were sent
to the multicast socket but not yet received by the application.
In our case, the effect was that the whole UDP communication to our embedded
device was down, because a single thread was blocked so that it could not
consume the multicast datagrams.
The setup is as follows:
LWIP application (server):
- socket1 bound to 5000
- socket2 bound to 5001 and joined multicast group 22.214.171.124
- while (1):
- receive datagram on socket1 and send it back (echo)
- do nothing with socket2 (do not receive multicast data)
PC application (client):
- while (1):
- send multicast to 5001
- send and receive datagram from 5000 (echo)
=> will timeout in the second iteration because no echo received.
See attached code to reproduce the issue.
- It seems that all UDP sockets are affected, but not TCP sockets.
- When the client uses the unicast IP instead of 126.96.36.199 to send data to
5001, the problem does not occur.
This is most probably a configuration issue:
- either SO_REUSE_RXTOALL is not set
- or you run out of pbuf memory (for SO_REUSE_RXTOALL, incoming pbus are
cloned before being passed to the recv function that buffers the pbuf per