forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bpf: sockmap, test FIONREAD returns correct bytes in rx buffer with d…
…rops When BPF program drops pkts the sockmap logic 'eats' the packet and updates copied_seq. In the PASS case where the sk_buff is accepted we update copied_seq from recvmsg path so we need a new test to handle the drop case. Original patch series broke this resulting in test_sockmap_skb_verdict_fionread:PASS:ioctl(FIONREAD) error 0 nsec test_sockmap_skb_verdict_fionread:FAIL:ioctl(FIONREAD) unexpected ioctl(FIONREAD): actual 1503041772 != expected 256 torvalds#176/17 sockmap_basic/sockmap skb_verdict fionread on drop:FAIL After updated patch with fix. torvalds#176/16 sockmap_basic/sockmap skb_verdict fionread:OK torvalds#176/17 sockmap_basic/sockmap skb_verdict fionread on drop:OK Reviewed-by: Jakub Sitnicki <[email protected]> Signed-off-by: John Fastabend <[email protected]>
- Loading branch information
1 parent
35944b3
commit 73e7943
Showing
2 changed files
with
66 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tools/testing/selftests/bpf/progs/test_sockmap_drop_prog.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <linux/bpf.h> | ||
#include <bpf/bpf_helpers.h> | ||
#include <bpf/bpf_endian.h> | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_SOCKMAP); | ||
__uint(max_entries, 20); | ||
__type(key, int); | ||
__type(value, int); | ||
} sock_map_rx SEC(".maps"); | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_SOCKMAP); | ||
__uint(max_entries, 20); | ||
__type(key, int); | ||
__type(value, int); | ||
} sock_map_tx SEC(".maps"); | ||
|
||
struct { | ||
__uint(type, BPF_MAP_TYPE_SOCKMAP); | ||
__uint(max_entries, 20); | ||
__type(key, int); | ||
__type(value, int); | ||
} sock_map_msg SEC(".maps"); | ||
|
||
SEC("sk_skb") | ||
int prog_skb_verdict(struct __sk_buff *skb) | ||
{ | ||
return SK_DROP; | ||
} | ||
|
||
char _license[] SEC("license") = "GPL"; |