Skip to content

net/packet: better behavior under DDOS

Eric Dumazet netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest8 patches 3 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8net/packet: constify __packet_get_status() argumentnet/packet/af_packet.c+1 -10 replies
2/8net/packet: constify packet_lookup_frame() and __tpacket_has_room()net/packet/af_packet.c+7 -70 replies
3/8net/packet: constify prb_lookup_block() and __tpacket_v3_has_room()net/packet/af_packet.c+7 -70 replies
4/8net/packet: constify __packet_rcv_has_room()net/packet/af_packet.c+8 -50 replies
5/8net/packet: make tp_drops atomicnet/packet/af_packet.c net/packet/internal.h+12 -90 replies
6/8net/packet: implement shortcut in tpacket_rcv()net/packet/af_packet.c+6 -00 replies
7/8net/packet: remove locking from packet_rcv_has_room()net/packet/af_packet.c+9 -110 replies
8/8net/packet: introduce packet_rcv_try_clear_pressure() helpernet/packet/af_packet.c+9 -41 reply

Reviews trailers per patch

1 of 8 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchWillem de BruijnVinicius Costa Gomes
SeriesA-b
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH net-next 0/8] net/packet: better behavior under DDOS

Using tcpdump (or other af_packet user) on a busy host can lead to catastrophic consequences, because suddenly, potentially all cpus are spinning on a contended spinlock.

Both packet_rcv() and tpacket_rcv() grab the spinlock to eventually find there is no room for an additional packet.

This patch series align packet_rcv() and tpacket_rcv() to both check if the queue is full before grabbing the spinlock.

If the queue is full, they both increment a new atomic counter placed on a separate cache line to let readers drain the queue faster.

There is still false sharing on this new atomic counter, we might in the future make it per cpu if there is interest.

Eric Dumazet (8):
net/packet: constify __packet_get_status() argument net/packet: constify packet_lookup_frame() and __tpacket_has_room() net/packet: constify prb_lookup_block() and __tpacket_v3_has_room() net/packet: constify __packet_rcv_has_room()
net/packet: make tp_drops atomic
net/packet: implement shortcut in tpacket_rcv() net/packet: remove locking from packet_rcv_has_room() net/packet: introduce packet_rcv_try_clear_pressure() helper

 net/packet/af_packet.c | 96 ++++++++++++++++++++++++------------------
 net/packet/internal.h  |  1 +
 2 files changed, 56 insertions(+), 41 deletions(-)
Signature · 1 line
2.22.0.rc2.383.gf4fbbf30c2-goog