aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-05-29 04:22:48 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-02 01:16:57 -0400
commit9fe13baad6b1e8d3063dd48faf1b9be9b7c5e92c (patch)
tree8c349d7ebf41449564655c48165e0d985b4c6702 /lib
parent019ee792d7861fde33e6c2331a8b32a2b975e865 (diff)
net: filter: add slot overlapping test with fully filled M[]
Also add a test for the scratch memory store that first fills all slots and then sucessively reads all of them back adding up to A, and eventually returning A. This and the previous M[] test with alternating fill/spill will detect possible JIT errors on M[]. Suggested-by: Alexei Starovoitov <ast@plumgrid.com> 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.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 3c4a1e3e1f50..2d0a0d141793 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -1493,7 +1493,7 @@ static struct bpf_test tests[] = {
1493 { }, 1493 { },
1494 }, 1494 },
1495 { /* Mainly checking JIT here. */ 1495 { /* Mainly checking JIT here. */
1496 "M[]: STX + LDX", 1496 "M[]: alt STX + LDX",
1497 .u.insns = { 1497 .u.insns = {
1498 BPF_STMT(BPF_LDX | BPF_IMM, 100), 1498 BPF_STMT(BPF_LDX | BPF_IMM, 100),
1499 BPF_STMT(BPF_STX, 0), 1499 BPF_STMT(BPF_STX, 0),
@@ -1582,6 +1582,79 @@ static struct bpf_test tests[] = {
1582 { }, 1582 { },
1583 { { 0, 116 } }, 1583 { { 0, 116 } },
1584 }, 1584 },
1585 { /* Mainly checking JIT here. */
1586 "M[]: full STX + full LDX",
1587 .u.insns = {
1588 BPF_STMT(BPF_LDX | BPF_IMM, 0xbadfeedb),
1589 BPF_STMT(BPF_STX, 0),
1590 BPF_STMT(BPF_LDX | BPF_IMM, 0xecabedae),
1591 BPF_STMT(BPF_STX, 1),
1592 BPF_STMT(BPF_LDX | BPF_IMM, 0xafccfeaf),
1593 BPF_STMT(BPF_STX, 2),
1594 BPF_STMT(BPF_LDX | BPF_IMM, 0xbffdcedc),
1595 BPF_STMT(BPF_STX, 3),
1596 BPF_STMT(BPF_LDX | BPF_IMM, 0xfbbbdccb),
1597 BPF_STMT(BPF_STX, 4),
1598 BPF_STMT(BPF_LDX | BPF_IMM, 0xfbabcbda),
1599 BPF_STMT(BPF_STX, 5),
1600 BPF_STMT(BPF_LDX | BPF_IMM, 0xaedecbdb),
1601 BPF_STMT(BPF_STX, 6),
1602 BPF_STMT(BPF_LDX | BPF_IMM, 0xadebbade),
1603 BPF_STMT(BPF_STX, 7),
1604 BPF_STMT(BPF_LDX | BPF_IMM, 0xfcfcfaec),
1605 BPF_STMT(BPF_STX, 8),
1606 BPF_STMT(BPF_LDX | BPF_IMM, 0xbcdddbdc),
1607 BPF_STMT(BPF_STX, 9),
1608 BPF_STMT(BPF_LDX | BPF_IMM, 0xfeefdfac),
1609 BPF_STMT(BPF_STX, 10),
1610 BPF_STMT(BPF_LDX | BPF_IMM, 0xcddcdeea),
1611 BPF_STMT(BPF_STX, 11),
1612 BPF_STMT(BPF_LDX | BPF_IMM, 0xaccfaebb),
1613 BPF_STMT(BPF_STX, 12),
1614 BPF_STMT(BPF_LDX | BPF_IMM, 0xbdcccdcf),
1615 BPF_STMT(BPF_STX, 13),
1616 BPF_STMT(BPF_LDX | BPF_IMM, 0xaaedecde),
1617 BPF_STMT(BPF_STX, 14),
1618 BPF_STMT(BPF_LDX | BPF_IMM, 0xfaeacdad),
1619 BPF_STMT(BPF_STX, 15),
1620 BPF_STMT(BPF_LDX | BPF_MEM, 0),
1621 BPF_STMT(BPF_MISC | BPF_TXA, 0),
1622 BPF_STMT(BPF_LDX | BPF_MEM, 1),
1623 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1624 BPF_STMT(BPF_LDX | BPF_MEM, 2),
1625 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1626 BPF_STMT(BPF_LDX | BPF_MEM, 3),
1627 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1628 BPF_STMT(BPF_LDX | BPF_MEM, 4),
1629 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1630 BPF_STMT(BPF_LDX | BPF_MEM, 5),
1631 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1632 BPF_STMT(BPF_LDX | BPF_MEM, 6),
1633 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1634 BPF_STMT(BPF_LDX | BPF_MEM, 7),
1635 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1636 BPF_STMT(BPF_LDX | BPF_MEM, 8),
1637 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1638 BPF_STMT(BPF_LDX | BPF_MEM, 9),
1639 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1640 BPF_STMT(BPF_LDX | BPF_MEM, 10),
1641 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1642 BPF_STMT(BPF_LDX | BPF_MEM, 11),
1643 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1644 BPF_STMT(BPF_LDX | BPF_MEM, 12),
1645 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1646 BPF_STMT(BPF_LDX | BPF_MEM, 13),
1647 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1648 BPF_STMT(BPF_LDX | BPF_MEM, 14),
1649 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1650 BPF_STMT(BPF_LDX | BPF_MEM, 15),
1651 BPF_STMT(BPF_ALU | BPF_ADD | BPF_X, 0),
1652 BPF_STMT(BPF_RET | BPF_A, 0),
1653 },
1654 CLASSIC | FLAG_NO_DATA,
1655 { },
1656 { { 0, 0x2a5a5e5 } },
1657 },
1585}; 1658};
1586 1659
1587static struct net_device dev; 1660static struct net_device dev;