]> git.baikalelectronics.ru Git - kernel.git/commit
tools: psock_tpacket: block Rx until socket filter has been added and socket has...
authorSowmini Varadhan <sowmini.varadhan@oracle.com>
Thu, 5 Jan 2017 19:06:22 +0000 (11:06 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Jan 2017 20:03:41 +0000 (15:03 -0500)
commit0f9042a7fc6445f7c3c856b500b1f2da1dd37c77
tree04dab5c2650cddd666620ca3972d8e8b9634e78e
parentfbfa4bedf833c0778021c3e2c8740e13cf15412e
tools: psock_tpacket: block Rx until socket filter has been added and socket has been bound to loopback.

Packets from any/all interfaces may be queued up on the PF_PACKET socket
before it is bound to the loopback interface by psock_tpacket, and
when these are passed up by the kernel, they could interfere
with the Rx tests.

Avoid interference from spurious packet by blocking Rx until the
socket filter has been set up, and the packet has been bound to the
desired (lo) interface. The effective sequence is
socket(PF_PACKET, SOCK_RAW, 0);
set up ring
Invoke SO_ATTACH_FILTER
bind to sll_protocol set to ETH_P_ALL, sll_ifindex for lo
After this sequence, the only packets that will be passed up are
those received on loopback that pass the attached filter.

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/psock_tpacket.c