Search code examples
cudpso-reuseport

Get UDP packets from the same client delivered to the same server process, when using SO_REUSEPORT?


I'm writing a multi-process UDP server, which uses SO_REUSEPORT to let multiple worker processes listen on the same port.

Is there a way of telling the kernel that I would like consistent delivery of packets to processes, based on the packets' source address?

(The server needs to hold a little state, per source address. It would be easier to have state local to the processes, rather than for state to have to be shared between processes.)


Solution

  • You might be able to achieve a similar result using a BPF with the SO_ATTACH_REUSEPORT_CBPF or SO_ATTACH_REUSEPORT_EBPF socket options to assign each client to a specific socket index.