ndp: correctness fix for BPF filter
authorDavid Härdeman <[email protected]>
Fri, 17 Oct 2025 13:32:08 +0000 (15:32 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Sun, 23 Nov 2025 19:05:35 +0000 (20:05 +0100)
commit650a5df88ebae82d956831c2f87c7c6eedd8c283
treed43bb3cc7785f66f39d89aac1525356e516ac1f6
parentb0739f23c310df06d227e5affeb49d85fbfe8161
ndp: correctness fix for BPF filter

Note that AF_PACKET sockets start receiving packets as soon as they are
created.  Thus, a packet can arrive between the creation of the socket
and the time the real filter is installed. Fix this using the same
technique as used in libpcap, i.e. by installing a drop-all filter,
removing any packets from the socket, then installing the real filter
later (an atomic operation which replaces the drop filter).

Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcpd/pull/319
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/ndp.c