[Intel-wired-lan] [PATCH bpf-next v3 2/5] net: veth: Add xmo_rx_checksum callback to veth driver

Lorenzo Bianconi
2026-02-17T08:34:44Z

Implement xmo_rx_checksum callback in veth driver to report RX checksum
result to the eBPF program bounded to the veth device.

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
drivers/net/veth.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 9982412fd7f238e996ccdff24342974cb25094bf..de67c98a995112a931dd871a71d84333b045fd62 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1697,6 +1697,34 @@ static int veth_xdp_rx_vlan_tag(const struct xdp_md *ctx, __be16 *vlan_proto,
return err;
}

+static int veth_xdp_rx_checksum(const struct xdp_md *ctx,
+ enum xdp_checksum *ip_summed,
+ u32 *cksum_meta)
+{
+ const struct veth_xdp_buff *_ctx = (void *)ctx;
+ const struct sk_buff *skb = _ctx->skb;
+
+ if (!skb)
+ return -ENODATA;
+
+ switch (skb->ip_summed) {
+ case CHECKSUM_COMPLETE:
+ *ip_summed = XDP_CHECKSUM_COMPLETE;
+ *cksum_meta = skb->csum;
+ break;
+ case CHECKSUM_UNNECESSARY:
+ *ip_summed = XDP_CHECKSUM_UNNECESSARY;
+ *cksum_meta = skb->csum_level;
+ break;
+ default:
+ *ip_summed = XDP_CHECKSUM_NONE;
+ *cksum_meta = 0;
+ break;
+ }
+
+ return 0;
+}
+
static const struct net_device_ops veth_netdev_ops = {
.ndo_init = veth_dev_init,
.ndo_open = veth_open,
@@ -1722,6 +1750,7 @@ static const struct xdp_metadata_ops veth_xdp_metadata_ops = {
.xmo_rx_timestamp = veth_xdp_rx_timestamp,
.xmo_rx_hash = veth_xdp_rx_hash,
.xmo_rx_vlan_tag = veth_xdp_rx_vlan_tag,
+ .xmo_rx_checksum = veth_xdp_rx_checksum,
};

#define VETH_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HW_CSUM | \

--
2.53.0