Search code examples
linuxsocketsnetwork-programmingudpiptables

UDP connect doesn't route traffic for particular interface


I have an odd issue where the behavior of connect on a UDP socket depends on interface from which traffic is received.

I generate a UDP socket that binds to a specific port on all interfaces and waits for incoming packets. If connect hasn't been called on the local socket, I (1) connect to the remote address (2) track the socket and (3) generate a new unconnected socket on the same local port. If connect has been called on the socket, I just call recv and handle the data.

When traffic comes over the ethernet interface, traffic routes correctly to the connected socket. However, on the wifi interface, traffic always routes to the newly created, unconnected socket.

I have verified that this works normally on my ubuntu machine, and it seems to be a quirk of another hardware platform I'm working on.

What can I do to debug the issue? The fact that connect system call never fails but has different behavior for the two interfaces, suggests that it's not a kernel problem. Is there something in the IP tables that could be affecting the traffic routing or in the wifi driver? Something else?


Solution

  • So in my case, the issue was asymmetry of ip rules between the ethernet and wifi interface that cause routing problems. If you run into a similar thing, you can see some rules that are set with:

    ip rule show
    

    and/or

    iptables --list