aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-05-29 04:22:49 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-02 01:16:58 -0400
commitd50bc1575096250aa37f17299c86ea548156efe8 (patch)
treef606b52b3a98a9a3a9514dcf774cdff0b83b3499 /lib
parent9fe13baad6b1e8d3063dd48faf1b9be9b7c5e92c (diff)
net: filter: add test for loading SKF_AD_OFF limits
This check tests that overloading BPF_LD | BPF_ABS with an always invalid BPF extension, that is SKF_AD_MAX, fails to make sure classic BPF behaviour is correct in filter checker. Also, we add a test for loading at packet offset SKF_AD_OFF-1 which should pass the filter, but later on fail during runtime. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Acked-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/test_bpf.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 2d0a0d141793..f8d2b2a13131 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -1655,6 +1655,28 @@ static struct bpf_test tests[] = {
1655 { }, 1655 { },
1656 { { 0, 0x2a5a5e5 } }, 1656 { { 0, 0x2a5a5e5 } },
1657 }, 1657 },
1658 {
1659 "check: SKF_AD_MAX",
1660 .u.insns = {
1661 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
1662 SKF_AD_OFF + SKF_AD_MAX),
1663 BPF_STMT(BPF_RET | BPF_A, 0),
1664 },
1665 CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL,
1666 { },
1667 { },
1668 },
1669 { /* Passes checker but fails during runtime. */
1670 "LD [SKF_AD_OFF-1]",
1671 .u.insns = {
1672 BPF_STMT(BPF_LD | BPF_W | BPF_ABS,
1673 SKF_AD_OFF - 1),
1674 BPF_STMT(BPF_RET | BPF_K, 1),
1675 },
1676 CLASSIC,
1677 { },
1678 { { 1, 0 } },
1679 },
1658}; 1680};
1659 1681
1660static struct net_device dev; 1682static struct net_device dev;