Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-block.git] / net / bpf / test_run.c
index 6a8b33a103a40bed2a79ee60cc905cc45828f42c..d350f31c7a3df2c1b7a656cced8f377c87380307 100644 (file)
@@ -97,8 +97,11 @@ reset:
 struct xdp_page_head {
        struct xdp_buff orig_ctx;
        struct xdp_buff ctx;
-       struct xdp_frame frm;
-       u8 data[];
+       union {
+               /* ::data_hard_start starts here */
+               DECLARE_FLEX_ARRAY(struct xdp_frame, frame);
+               DECLARE_FLEX_ARRAY(u8, data);
+       };
 };
 
 struct xdp_test_data {
@@ -113,6 +116,10 @@ struct xdp_test_data {
        u32 frame_cnt;
 };
 
+/* tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c:%MAX_PKT_SIZE
+ * must be updated accordingly this gets changed, otherwise BPF selftests
+ * will fail.
+ */
 #define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head))
 #define TEST_XDP_MAX_BATCH 256
 
@@ -132,8 +139,8 @@ static void xdp_test_run_init_page(struct page *page, void *arg)
        headroom -= meta_len;
 
        new_ctx = &head->ctx;
-       frm = &head->frm;
-       data = &head->data;
+       frm = head->frame;
+       data = head->data;
        memcpy(data + headroom, orig_ctx->data_meta, frm_len);
 
        xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq);
@@ -223,7 +230,7 @@ static void reset_ctx(struct xdp_page_head *head)
        head->ctx.data = head->orig_ctx.data;
        head->ctx.data_meta = head->orig_ctx.data_meta;
        head->ctx.data_end = head->orig_ctx.data_end;
-       xdp_update_frame_from_buff(&head->ctx, &head->frm);
+       xdp_update_frame_from_buff(&head->ctx, head->frame);
 }
 
 static int xdp_recv_frames(struct xdp_frame **frames, int nframes,
@@ -285,7 +292,7 @@ static int xdp_test_run_batch(struct xdp_test_data *xdp, struct bpf_prog *prog,
                head = phys_to_virt(page_to_phys(page));
                reset_ctx(head);
                ctx = &head->ctx;
-               frm = &head->frm;
+               frm = head->frame;
                xdp->frame_cnt++;
 
                act = bpf_prog_run_xdp(prog, ctx);