@@ -228,6 +228,9 @@ static int verify_xsk_metadata(struct xsk *xsk)
if (!ASSERT_EQ(meta->rx_vlan_proto, VLAN_PID, "rx_vlan_proto"))
return -1;
+ if (!ASSERT_EQ(meta->rx_csum_status, XDP_CHECKSUM_MAGIC, "rx_csum_status"))
+ return -1;
+
xsk_ring_cons__release(&xsk->rx, 1);
refill_rx(xsk, comp_addr);
@@ -26,6 +26,9 @@ extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash,
extern int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx,
__u16 *vlan_tci,
__be16 *vlan_proto) __ksym;
+extern int bpf_xdp_metadata_rx_csum(const struct xdp_md *ctx,
+ enum xdp_csum_status *csum_status,
+ __wsum *csum) __ksym;
SEC("xdp")
int rx(struct xdp_md *ctx)
@@ -63,6 +66,14 @@ int rx(struct xdp_md *ctx)
bpf_xdp_metadata_rx_vlan_tag(ctx, &meta->rx_vlan_tci,
&meta->rx_vlan_proto);
+ /* This is supposed to fail on veth, so tell userspace
+ * everything is OK by passing a magic status.
+ */
+ ret = bpf_xdp_metadata_rx_csum(ctx, &meta->rx_csum_status,
+ &meta->rx_csum);
+ if (ret)
+ meta->rx_csum_status = XDP_CHECKSUM_MAGIC;
+
return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS);
}
Verify, whether kfunc in xdp_metadata test correctly represent veth metadata state. Signed-off-by: Larysa Zaremba <larysa.zaremba@intel.com> --- tools/testing/selftests/bpf/prog_tests/xdp_metadata.c | 3 +++ tools/testing/selftests/bpf/progs/xdp_metadata.c | 11 +++++++++++ 2 files changed, 14 insertions(+)