packet: pdiag_put_ring() should return TX_RING info for TPACKET_V3
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 packet: pdiag_put_ring() should return TX_RING info for TPACKET_V3
Commit 7f953ab2ba46 ("af_packet: TX_RING support for TPACKET_V3") now makes it possible to use TX_RING with TPACKET_V3, so make the the relevant information available via 'ss -e -a --packet'
--- net/packet/diag.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
net/packet/diag.c +1 -2
@@ -73,8 +73,7 @@ static int pdiag_put_ring(struct packet_ring_buffer *ring, int ver, int nl_type, {struct packet_diag_ring pdr; -if (!ring->pg_vec || ((ver >TPACKET_V2 ) && - (nl_type ==PACKET_DIAG_TX_RING ))) +if (!ring->pg_vec)return 0 ; pdr.pdr_block_size = ring->pg_vec_pages <<PAGE_SHIFT ;
Signature · 1 line
1.7.1
From: Sowmini Varadhan <[email protected]>
Date: Tue, 10 Jan 2017 07:47:15 -0800
Quoted 5 lines
Commit
7f953ab2ba46("af_packet:TX_RINGsupport forTPACKET_V3") now makes it possible to useTX_RINGwithTPACKET_V3, so make the the relevant information available via 'ss -e -a --packet'Signed-off-by Sowmini Varadhan <[email protected]>
Applied, thanks.
PATCH 1/1 tools: psock_lib: harden socket filter used by psock tests
In reply to a message not in the archiveThe filter added by sock_setfilter is intended to only permit packets matching the pattern set up by create_payload(), but we only check the ip_len, and a single test-character in the IP packet to ensure this condition.
Harden the filter by adding additional constraints so that we only permit UDP/IPv4 packets that meet the ip_len and test-character requirements. Include the bpf_asm src as a comment, in case this needs to be enhanced in the future
--- tools/testing/selftests/net/psock_lib.h | 39 +++++++++++++++++++++++++----- 1 files changed, 32 insertions(+), 7 deletions(-)
tools/testing/selftests/net/psock_lib.h +32 -7
@@ -40,14 +40,39 @@static __maybe_unused void sock_setfilter (int fd,int lvl,int optnum) { +/* the filter below checks for all of the following conditions that +* are based on the contents of create_payload() +* ether type 0x800 and +* ip proto udp and +* skb->len == DATA_LEN and +* udp[38] == 'a' or udp[38] == 'b' +* It can be generated from the following bpf_asm input: +* ldh [12] +* jne #0x800, drop ; ETH_P_IP +* ldb [23] +* jneq #17, drop ; IPPROTO_UDP +* ld len ; ld skb->len +* jlt #100, drop ; DATA_LEN +* ldb [80] +* jeq #97, pass ; DATA_CHAR +* jne #98, drop ; DATA_CHAR_1 +* pass: +* ret #-1 +* drop: +* ret #0 +*/ struct sock_filter bpf_filter[] = { - {0x80 ,0 ,0 ,0x00000000 },/* LD pktlen */ - {0x35 ,0 ,4 ,DATA_LEN },/* JGE DATA_LEN [f goto nomatch]*/ - {0x30 ,0 ,0 ,0x00000050 },/* LD ip[80] */ - {0x15 ,1 ,0 ,DATA_CHAR },/* JEQ DATA_CHAR [t goto match]*/ - {0x15 ,0 ,1 ,DATA_CHAR_1 },/* JEQ DATA_CHAR_1 [t goto match]*/ - {0x06 ,0 ,0 ,0x00000060 },/* RET match */ - {0x06 ,0 ,0 ,0x00000000 },/* RET no match */ + {0x28 ,0 ,0 ,0x0000000c }, + {0x15 ,0 ,8 ,0x00000800 }, + {0x30 ,0 ,0 ,0x00000017 }, + {0x15 ,0 ,6 ,0x00000011 }, + {0x80 ,0 ,0 ,0000000000 }, + {0x35 ,0 ,4 ,0x00000064 }, + {0x30 ,0 ,0 ,0x00000050 }, + {0x15 ,1 ,0 ,0x00000061 }, + {0x15 ,0 ,1 ,0x00000062 }, + {0x06 ,0 ,0 ,0xffffffff }, + {0x06 ,0 ,0 ,0000000000 }, };struct sock_fprog bpf_prog;
Signature · 1 line
1.7.1
Re: [PATCH net-next] tools: psock_lib: harden socket filter used by psock tests
Quoted 11 lines · Sowmini Varadhan
The filter added by
sock_setfilteris intended to only permit packets matching the pattern set up bycreate_payload(), but we only check theip_len, and a single test-character in the IP packet to ensure this condition.Harden the filter by adding additional constraints so that we only permit UDP/IPv4 packets that meet the
ip_lenand test-character requirements. Include thebpf_asmsrc as a comment, in case this needs to be enhanced in the futureSigned-off-by Sowmini Varadhan <[email protected]>
LGTM, thanks!
Re: [PATCH net-next] tools: psock_lib: harden socket filter used by psock tests
In reply to Sowmini VaradhanFrom: Sowmini Varadhan <[email protected]>
Date: Thu, 12 Jan 2017 05:10:11 -0800
Quoted 11 lines
The filter added by
sock_setfilteris intended to only permit packets matching the pattern set up bycreate_payload(), but we only check theip_len, and a single test-character in the IP packet to ensure this condition.Harden the filter by adding additional constraints so that we only permit UDP/IPv4 packets that meet the
ip_lenand test-character requirements. Include thebpf_asmsrc as a comment, in case this needs to be enhanced in the futureSigned-off-by Sowmini Varadhan <[email protected]>
Applied, thanks.