udp: fix again pbuf management by d-a-v · Pull Request #7132 · esp8266/Arduino (original) (raw)

This PR: three packets are delivered, the first one contains all three of them interleaved with some garbage data, the second one contains the last two, again interleaved with some garbage, and the last one contains the last packet. I'm suspecting the garbage is the address info pbuf.

I think (and while I'm writing it becomes clear) it is because of

    size_t getSize() const
    {
        if (!_rx_buf)
            return 0;

        return _rx_buf->tot_len - _rx_buf_offset;
    }

The info pbuf (the garbage) should not be accessible but it is because of getSize() (which should only report size before next info pbuf) and your fix (use of pbuf_contiguous()).
So an update of this PR is needed in order to cache this value for the current packet.

I can take a look tomorrow. Not tested IPv6 yet.

This is not needed. The code needed for IPv6 is also used for IPv4 and is the info pbuf management.