UDP socket state list?

ip, linux, linux-kernel, sockets, udp

Solution

UDP 'connections' are stateless. From the iptables manual:

UDP connections are in themselves not stateful connections, but rather stateless. There are several reasons why, mainly because they don't contain any connection establishment or connection closing; most of all they lack sequencing. Receiving two UDP datagrams in a specific order does not say anything about the order in which they were sent. It is, however, still possible to set states on the connections within the kernel.

See this udp programming tutorial which also helps explain why a command like `ss -ua` shows an udp server socket as UNCONN (aka CLOSE for tcp connections).

To sum up, I do believe the udp 'states' shown in /proc/net are recycled from tcp connection states, but they have a slightly different meaning.

Problem

I'm currently writing a script pulling data from `/proc/net/tcp` and `/proc/net/udp` and I need to translate the connection states from their hex code into something meaningful. Example content: ``` sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode ref pointer drops 37: 00000000:2710 00000000:0000 07 00000000:00000000 00:00000000 00000000 0 0 862948 2 ffff8800109dbac0 0 54: 00000000:00A1 00000000:0000 07 00000000:00000000 00:00000000 00000000 0 0 2055110 2 ffff8800109db780 0 ``` So far I've turned up this answer which pointed me to the relevant kernel header file, but there is not a matching `udp_states.h` or anything in `udp.h` or `ip.h`. Where can I find a list of connection states for UDP sockets?

Original source

Related problems