1. 12 5月, 2014 1 次提交
  2. 08 4月, 2013 1 次提交
    • D
      selftests: net: add PF_PACKET TPACKET v1/v2/v3 selftests · 23a95442
      Daniel Borkmann 提交于
      This patch adds a simple test case that probes the packet socket's
      TPACKET_V1, TPACKET_V2 and TPACKET_V3 behavior regarding mmap(2)'ed
      I/O for a small burst of 100 packets. The test currently runs for ...
      
        TPACKET_V1: RX_RING, TX_RING
        TPACKET_V2: RX_RING, TX_RING
        TPACKET_V3: RX_RING
      
      ... and will output on success:
      
        test: TPACKET_V1 with PACKET_RX_RING .................... 100 pkts (9600 bytes)
        test: TPACKET_V1 with PACKET_TX_RING .................... 100 pkts (9600 bytes)
        test: TPACKET_V2 with PACKET_RX_RING .................... 100 pkts (9600 bytes)
        test: TPACKET_V2 with PACKET_TX_RING .................... 100 pkts (9600 bytes)
        test: TPACKET_V3 with PACKET_RX_RING .................... 100 pkts (9600 bytes)
        OK. All tests passed
      
      Reusable parts of psock_fanout.c have been put into a psock_lib.h
      file for common usage. Test case successfully tested on x86_64.
      Signed-off-by: NDaniel Borkmann <dborkman@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      23a95442
  3. 21 3月, 2013 1 次提交
  4. 20 3月, 2013 1 次提交
    • W
      packet: packet fanout rollover during socket overload · 77f65ebd
      Willem de Bruijn 提交于
      Changes:
        v3->v2: rebase (no other changes)
                passes selftest
        v2->v1: read f->num_members only once
                fix bug: test rollover mode + flag
      
      Minimize packet drop in a fanout group. If one socket is full,
      roll over packets to another from the group. Maintain flow
      affinity during normal load using an rxhash fanout policy, while
      dispersing unexpected traffic storms that hit a single cpu, such
      as spoofed-source DoS flows. Rollover breaks affinity for flows
      arriving at saturated sockets during those conditions.
      
      The patch adds a fanout policy ROLLOVER that rotates between sockets,
      filling each socket before moving to the next. It also adds a fanout
      flag ROLLOVER. If passed along with any other fanout policy, the
      primary policy is applied until the chosen socket is full. Then,
      rollover selects another socket, to delay packet drop until the
      entire system is saturated.
      
      Probing sockets is not free. Selecting the last used socket, as
      rollover does, is a greedy approach that maximizes chance of
      success, at the cost of extreme load imbalance. In practice, with
      sufficiently long queues to absorb bursts, sockets are drained in
      parallel and load balance looks uniform in `top`.
      
      To avoid contention, scales counters with number of sockets and
      accesses them lockfree. Values are bounds checked to ensure
      correctness.
      
      Tested using an application with 9 threads pinned to CPUs, one socket
      per thread and sufficient busywork per packet operation to limits each
      thread to handling 32 Kpps. When sent 500 Kpps single UDP stream
      packets, a FANOUT_CPU setup processes 32 Kpps in total without this
      patch, 270 Kpps with the patch. Tested with read() and with a packet
      ring (V1).
      
      Also, passes psock_fanout.c unit test added to selftests.
      Signed-off-by: NWillem de Bruijn <willemb@google.com>
      Reviewed-by: NEric Dumazet <edumazet@google.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      77f65ebd