diff options
author | Willem de Bruijn <willemb@google.com> | 2015-05-12 11:56:49 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-05-13 15:43:00 -0400 |
commit | 3b3a5b0aab5b9ad345d4beb9a364a7dd02c23d40 (patch) | |
tree | 07714d34021e3505276c82d8c84c39324c4ddc97 /net/packet/internal.h | |
parent | 2ccdbaa6d55b0656244ba57c4b56765a0af76c0a (diff) | |
download | linux-3b3a5b0aab5b9ad345d4beb9a364a7dd02c23d40.tar.bz2 |
packet: rollover huge flows before small flows
Migrate flows from a socket to another socket in the fanout group not
only when the socket is full. Start migrating huge flows early, to
divert possible 4-tuple attacks without affecting normal traffic.
Introduce fanout_flow_is_huge(). This detects huge flows, which are
defined as taking up more than half the load. It does so cheaply, by
storing the rxhashes of the N most recent packets. If over half of
these are the same rxhash as the current packet, then drop it. This
only protects against 4-tuple attacks. N is chosen to fit all data in
a single cache line.
Tested:
Ran bench_rollover for 10 sec with 1.5 Mpps of single flow input.
lpbb5:/export/hda3/willemb# ./bench_rollover -l 1000 -r -s
cpu rx rx.k drop.k rollover r.huge r.failed
0 14 14 0 0 0 0
1 20 20 0 0 0 0
2 16 16 0 0 0 0
3 6168824 6168824 0 4867721 4867721 0
4 4867741 4867741 0 0 0 0
5 12 12 0 0 0 0
6 15 15 0 0 0 0
7 17 17 0 0 0 0
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet/internal.h')
-rw-r--r-- | net/packet/internal.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/net/packet/internal.h b/net/packet/internal.h index 22d7d778c5b7..a9d30a17c714 100644 --- a/net/packet/internal.h +++ b/net/packet/internal.h @@ -89,6 +89,8 @@ struct packet_fanout { struct packet_rollover { int sock; +#define ROLLOVER_HLEN (L1_CACHE_BYTES / sizeof(u32)) + u32 history[ROLLOVER_HLEN] ____cacheline_aligned; } ____cacheline_aligned_in_smp; struct packet_sock { |