summaryrefslogtreecommitdiff
path: root/samples/sockmap/sockmap_kern.c
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2018-03-18 22:58:07 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2018-03-19 23:14:41 +0300
commite6373ce70a01292424a118d9457d927349dad51d (patch)
tree3ee302cbffd8e46184c11465ec0e00e48ce69d6f /samples/sockmap/sockmap_kern.c
parent468b3fdea8826b232a570d95ba45272eb38919cb (diff)
downloadlinux-e6373ce70a01292424a118d9457d927349dad51d.tar.xz
bpf: sockmap add SK_DROP tests
Add tests for SK_DROP. Signed-off-by: John Fastabend <john.fastabend@gmail.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'samples/sockmap/sockmap_kern.c')
-rw-r--r--samples/sockmap/sockmap_kern.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/samples/sockmap/sockmap_kern.c b/samples/sockmap/sockmap_kern.c
index 735226794ce1..8b6c34cd5f46 100644
--- a/samples/sockmap/sockmap_kern.c
+++ b/samples/sockmap/sockmap_kern.c
@@ -236,4 +236,19 @@ int bpf_prog9(struct sk_msg_md *msg)
return SK_PASS;
}
+SEC("sk_msg7")
+int bpf_prog10(struct sk_msg_md *msg)
+{
+ int *bytes, zero = 0;
+
+ bytes = bpf_map_lookup_elem(&sock_apply_bytes, &zero);
+ if (bytes)
+ bpf_msg_apply_bytes(msg, *bytes);
+ bytes = bpf_map_lookup_elem(&sock_cork_bytes, &zero);
+ if (bytes)
+ bpf_msg_cork_bytes(msg, *bytes);
+ return SK_DROP;
+}
+
+
char _license[] SEC("license") = "GPL";