My two hosts reside on the same Ethernet segment. Host A is
10.1.0.1/16, host B is
10.1.0.2/16. A sends directed UDP broadcasts to
10.1.255.255 and a UDP listening socket bound to
INADDR_ANY on B receives them.
After I'm changing IP configuration on A to
10.0.0.1/16 so that it belongs to a different IP subnet and starts broadcasting to
10.0.255.255, that same socket on B still receives this broadcast.
If I restart the listening application on B, these broadcasts to a "wrong" subnet are not received by the socket any more.
Question: why the networking stack of B does not drop the packet, which is neither a unicast to B nor a broadcast to subnet of B, until socket shutdown?
I know that RFC1122 says:
Hosts SHOULD use the Limited Broadcast address to broadcast to a connected network.
I understand that the application on A sending directed broadcasts with the intention to broadcast to own subnet does not follow the "should" clause. But my question is why B does not drop them as long as UDP socket is alive.
I observed this behavior on Linux kernels 4.4 and 3.13.