For my UDP application I want to spread the handling per session (4 tuple) over to different threads. But looks like if there are multiple server sockets (bind calls) for unicast packets kernel will deliver the packet only to one of the threads.
Is this the behavior always or are there any config knobs to enable per session routing of the incoming packets to different sockets ?
Pointer to the relevant functions in the kernel code that delivers the incoming packet to the socket will also be helpful.
Thanks.
CodePudding user response:
But looks like if there are multiple server sockets (bind calls) for unicast packets kernel will deliver the packet only to one of the threads.
This is correct, the packet will only be delivered to one socket.
... enable per session routing of the incoming packets to different sockets ?
There are no sessions in UDP and thus no per sessions routing.
It is possible though to connect UDP sockets, i.e. call both bind and connect. In this case the packet will be delivered to the connected socket. If there are multiple connected sockets for the same source it will again be delivered to only one. And note that a connected socket will only receive packets for this connection, i.e. not from arbitrary sources like an unconnected socket.
Pointer to the relevant functions in the kernel code that delivers the incoming packet to the socket will also be helpful.
This behavior is not specific to Linux.