[RFC BUG] Send queue accounting of AF_PACKET is always zero

Alexandre Ferrieux alexandre.ferrieux at gmail.com
Sun Mar 23 18:05:33 EDT 2025


Hi,

When sending raw ethernet frames over an AF_PACKET/SOCK_RAW socket, "ss" always
reports a empty send queue, even when it is obviously full of packets.

The root cause is that packet_snd() never updates sk->sk_wmem_alloc, which is
the counter used by "ss" for the send queue occupation. All other socket types
end up calling something like:

   refcount_add(SOME_SIZE, &sk->sk_wmem_alloc)

Unfortunately, the way it is done is extremely varied across socket families, so
it is not immediately obvious to a newbie where to add this increment, and
associated decrement on skb free.

I'd appreciate any insight on (1) perhaps why it is deemed unimportant to do
send queue accounting for AF_PACKET; and (2) if it is just a bug, where the
incr/decr should take place.

Additionally, an explanation of "tpacket_snd()" vs "packet_snd()" would be very
welcome, as the former does proper send queue accounting, while the latter doesn't.

Thanks in advance,

-Alex





More information about the Kernelnewbies mailing list