Skip to content
Snippets Groups Projects
  1. Aug 20, 2021
  2. Nov 10, 2020
  3. Jul 27, 2020
  4. May 30, 2019
  5. Feb 23, 2018
    • Willem de Bruijn's avatar
      selftests/net: ignore background traffic in psock_fanout · cc30c93f
      Willem de Bruijn authored
      
      The packet fanout test generates UDP traffic and reads this with
      a pair of packet sockets, testing the various fanout algorithms.
      
      Avoid non-determinism from reading unrelated background traffic.
      Fanout decisions are made before unrelated packets can be dropped with
      a filter, so that is an insufficient strategy [*]. Run the packet
      socket tests in a network namespace, similar to msg_zerocopy.
      
      It it still good practice to install a filter on a packet socket
      before accepting traffic. Because this is example code, demonstrate
      that pattern. Open the socket initially bound to no protocol, install
      a filter, and only then bind to ETH_P_IP.
      
      Another source of non-determinism is hash collisions in FANOUT_HASH.
      The hash function used to select a socket in the fanout group includes
      the pseudorandom number hashrnd, which is not visible from userspace.
      To work around this, the test tries to find a pair of UDP source ports
      that do not collide. It gives up too soon (5 times, every 32 runs) and
      output is confusing. Increase tries to 20 and revise the error msg.
      
      [*] another approach would be to add a third socket to the fanout
          group and direct all unexpected traffic here. This is possible
          only when reimplementing methods like RR or HASH alongside this
          extra catch-all bucket, using the BPF fanout method.
      
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cc30c93f
  6. Feb 15, 2018
  7. Apr 25, 2017
  8. Apr 24, 2017
  9. Apr 20, 2017
    • Mike Maloney's avatar
      selftests/net: Fixes psock_fanout CBPF test case · c1f8d0f9
      Mike Maloney authored
      
      'psock_fanout' has been failing since commit 4d7b9dc1 ("tools:
      psock_lib: harden socket filter used by psock tests").  That commit
      changed the CBPF filter to examine the full ethernet frame, and was
      tested on 'psock_tpacket' which uses SOCK_RAW.  But 'psock_fanout' was
      also using this same CBPF in two places, for filtering and fanout, on a
      SOCK_DGRAM socket.
      
      Change 'psock_fanout' to use SOCK_RAW so that the CBPF program used with
      SO_ATTACH_FILTER can examine the entire frame.  Create a new CBPF
      program for use with PACKET_FANOUT_DATA which ignores the header, as it
      cannot see the ethernet header.
      
      Tested: Ran tools/testing/selftests/net/psock_{fanout,tpacket} 10 times,
      and they all passed.
      
      Fixes: 4d7b9dc1 ("tools: psock_lib: harden socket filter used by psock tests")
      Signed-off-by: default avatar'Mike Maloney <maloneykernel@gmail.com&gt;'>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c1f8d0f9
  10. Aug 17, 2015
  11. May 18, 2015
  12. Nov 12, 2014
  13. Apr 07, 2013
    • Daniel Borkmann's avatar
      selftests: net: add PF_PACKET TPACKET v1/v2/v3 selftests · 23a95442
      Daniel Borkmann authored
      
      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: default avatarDaniel Borkmann <dborkman@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      23a95442
  14. Mar 21, 2013
  15. Mar 20, 2013
  16. Mar 19, 2013
    • David S. Miller's avatar
    • Willem de Bruijn's avatar
      packet: packet fanout rollover during socket overload · 77f65ebd
      Willem de Bruijn authored
      
      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: default avatarWillem de Bruijn <willemb@google.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      77f65ebd
Loading