From cb41b2bfea123a90dd5adaa727e962c06f4df9ff Mon Sep 17 00:00:00 2001 From: Wei-Chun Chao Date: Wed, 12 Aug 2015 13:08:08 -0700 Subject: [PATCH] test_brb2: only account for IP and ARP packets Sometimes background noise fails the test Signed-off-by: Wei-Chun Chao --- tests/cc/test_brb2.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/cc/test_brb2.c b/tests/cc/test_brb2.c index 1077f4d..48ef97b 100644 --- a/tests/cc/test_brb2.c +++ b/tests/cc/test_brb2.c @@ -10,16 +10,20 @@ BPF_TABLE("array", u32, u32, pem_stats, 1); int pem(struct __sk_buff *skb) { u32 ifindex_in, *ifindex_p; + u8 *cursor = 0; + struct ethernet_t *ethernet = cursor_advance(cursor, sizeof(*ethernet)); ifindex_in = skb->ingress_ifindex; ifindex_p = pem_dest.lookup(&ifindex_in); if (ifindex_p) { #if 1 - /* accumulate stats */ - u32 index = 0; - u32 *value = pem_stats.lookup(&index); - if (value) - lock_xadd(value, 1); + if (ethernet->type == 0x0800 || ethernet->type == 0x0806) { + /* accumulate stats */ + u32 index = 0; + u32 *value = pem_stats.lookup(&index); + if (value) + lock_xadd(value, 1); + } #endif bpf_clone_redirect(skb, *ifindex_p, 0); } -- 2.7.4