|SUCCESS| net/hns3: fix L4 checksum incorrect for tunnel packets

dpdklab at iol.unh.edu dpdklab at iol.unh.edu
Sat May 9 13:09:48 CEST 2026


Test-Label: ai-code-review
Test-Status: SUCCESS
https://dpdk.org/patch/163831

_AI Code Review_

=== Patch Review: series.patch (via Claude) ===
Review date: 2026-05-09

I'll review this patch against the DPDK coding standards and contribution guidelines.

```
commit 6393fc0b823 ("net/hns3: simplify hardware checksum offloading")
Author: Xingui Yang <yangxingui at huawei.com>

[PATCH] net/hns3: fix L4 checksum incorrect for tunnel packets

The patch fixes incorrect L4 checksum calculation for tunnel packets in
HIP09 simple BD mode by adding outer header lengths to the L4_START
position calculation.

> diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
> index 573604b0cd..4d48cbdc11 100644
> --- a/drivers/net/hns3/hns3_rxtx.c
> +++ b/drivers/net/hns3/hns3_rxtx.c
> @@ -3982,6 +3982,7 @@ hns3_handle_simple_bd(struct hns3_tx_queue *txq, struct hns3_desc *desc,
>  {
>  #define HNS3_TCP_CSUM_OFFSET	16
>  #define HNS3_UDP_CSUM_OFFSET	6
> +	uint32_t l4_start;

The new variable l4_start should be declared at the top of the function
block, before any code, to comply with C89 variable declaration rules
enforced by DPDK coding standards. Currently it's declared after the
#define macros but should be at the very beginning of the function.

[ ... ]

> @@ -4003,9 +4004,13 @@ hns3_handle_simple_bd(struct hns3_tx_queue *txq, struct hns3_desc *desc,
>  	    ((m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_TCP_CKSUM ||
>  	     (m->ol_flags & RTE_MBUF_F_TX_L4_MASK) == RTE_MBUF_F_TX_UDP_CKSUM)) {
>  		/* set checksum start and offset, defined in 2 Bytes */
> +		l4_start = m->l2_len + m->l3_len;
> +		if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
> +			l4_start += m->outer_l2_len + m->outer_l3_len;

Does this code properly handle potential integer overflow when adding
multiple length fields? The mbuf length fields are typically uint8_t or
uint16_t, but l4_start is uint32_t. While overflow seems unlikely in
practice, should there be validation that the sum doesn't exceed the
packet buffer size or hardware limits?

Also, regarding the conditional check: does the code need to verify that
the tunnel flags are set correctly before using outer_l2_len and
outer_l3_len? Can these fields contain stale/garbage values if
RTE_MBUF_F_TX_TUNNEL_MASK is not set properly by the application?

> +
>  		hns3_set_field(desc->tx.type_cs_vlan_tso_len,
>  			       HNS3_TXD_L4_START_M, HNS3_TXD_L4_START_S,
> -			       (m->l2_len + m->l3_len) >> HNS3_SIMPLE_BD_UNIT);
> +			       l4_start >> HNS3_SIMPLE_BD_UNIT);

The calculation now depends on outer header lengths when processing
tunnel packets. Does the hardware or driver enforce that outer_l2_len
and outer_l3_len are properly set by applications? If these fields are
zero or incorrect, would this result in silent checksum corruption
rather than failing visibly?

```


More information about the test-report mailing list