aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/test_bpf.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index f8d2b2a13131..ea60ad8d5242 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -158,6 +158,18 @@ static struct bpf_test tests[] = {
158 { { 0, 0x800000ff }, { 1, 0x800000ff } }, 158 { { 0, 0x800000ff }, { 1, 0x800000ff } },
159 }, 159 },
160 { 160 {
161 "LD_IMM_0",
162 .u.insns = {
163 BPF_STMT(BPF_LD | BPF_IMM, 0), /* ld #0 */
164 BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, 0, 1, 0),
165 BPF_STMT(BPF_RET | BPF_K, 0),
166 BPF_STMT(BPF_RET | BPF_K, 1),
167 },
168 CLASSIC,
169 { },
170 { { 1, 1 } },
171 },
172 {
161 "LD_IND", 173 "LD_IND",
162 .u.insns = { 174 .u.insns = {
163 BPF_STMT(BPF_LDX | BPF_LEN, 0), 175 BPF_STMT(BPF_LDX | BPF_LEN, 0),
@@ -1734,12 +1746,11 @@ static int probe_filter_length(struct sock_filter *fp)
1734{ 1746{
1735 int len = 0; 1747 int len = 0;
1736 1748
1737 while (fp->code != 0 || fp->k != 0) { 1749 for (len = MAX_INSNS - 1; len > 0; --len)
1738 fp++; 1750 if (fp[len].code != 0 || fp[len].k != 0)
1739 len++; 1751 break;
1740 }
1741 1752
1742 return len; 1753 return len + 1;
1743} 1754}
1744 1755
1745static struct sk_filter *generate_filter(int which, int *err) 1756static struct sk_filter *generate_filter(int which, int *err)