selftests/net: Fixes psock_fanout CBPF test case
authorMike Maloney <maloney@google.com>
Tue, 18 Apr 2017 15:14:16 +0000 (11:14 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Apr 2017 19:39:19 +0000 (15:39 -0400)
commitc1f8d0f98c3bc12393821c1bf00d8eaa0bd58bd8
tree71f19fe662ccc3a778346ffd4c3b43c291ca0ac0
parent3018e947d7fd536d57e2b550c33e456d921fff8c
selftests/net: Fixes psock_fanout CBPF test case

'psock_fanout' has been failing since commit 4d7b9dc1f36a9 ("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: 4d7b9dc1f36a9 ("tools: psock_lib: harden socket filter used by psock tests")
Signed-off-by: 'Mike Maloney <maloneykernel@gmail.com>'
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/psock_fanout.c
tools/testing/selftests/net/psock_lib.h