4 ms·
It's mentioned in the prose. After bind() before connect() there is a race condition, you can receive packets going to unconnected bind() socket, right? bin
by majke 5y ago
It's mentioned in the prose.
After bind() before connect() there is a race condition, you can receive packets going to unconnected bind() socket, right?
bind(0.0.0.0, 1234)
## packet to port 1234 arrives NOW
connect(1.1.1.1, 53)
If you recv() you will not be able to figure out if the received packet came from 1.1.1.1 or someone else. Therefore in case of bind+connect you must use recvfrom and validate source of the packet, at least for early packets on the socket.
- khamphatg 5y agoAh so it means "filter the source IP/port when receiving early packets on the connected socket" is done by recvfrom()? I was misunderstood that it is done by some fancy iptable/epbf rule :) Thanks for clarification.