bpf: making bpf_prog_test run aware of possible data_end ptr change
authorNikita V. Shirokov <tehnerd@tehnerd.com>
Wed, 18 Apr 2018 04:42:21 +0000 (21:42 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 18 Apr 2018 21:34:16 +0000 (23:34 +0200)
after introduction of bpf_xdp_adjust_tail helper packet length
could be changed not only if xdp->data pointer has been changed
but xdp->data_end as well. making bpf_prog_test_run aware of this
possibility

Signed-off-by: Nikita V. Shirokov <tehnerd@tehnerd.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/bpf/test_run.c

index 2ced48662c1faaa41998fb875ef5d5aa1d20aaab..68c3578343b4b4d026e9df40fda98a7850757877 100644 (file)
@@ -170,7 +170,8 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
        xdp.rxq = &rxqueue->xdp_rxq;
 
        retval = bpf_test_run(prog, &xdp, repeat, &duration);
-       if (xdp.data != data + XDP_PACKET_HEADROOM + NET_IP_ALIGN)
+       if (xdp.data != data + XDP_PACKET_HEADROOM + NET_IP_ALIGN ||
+           xdp.data_end != xdp.data + size)
                size = xdp.data_end - xdp.data;
        ret = bpf_test_finish(kattr, uattr, xdp.data, size, retval, duration);
        kfree(data);