Skip to content

Commit

Permalink
net/mlx5: fix LRO TCP checksum
Browse files Browse the repository at this point in the history
[ upstream commit 776209c4b865ad3e0eaff202c5ff7358b8f5ab57 ]

The variable csum is the sum of three 16 bits integers, the max value
is 0x2FFFD. The corner case of sum of 3 is 0x1FFFF gives the wrong
result: 0x1 + 0xFFFF = 0x10000, the upper 16 bits are not 0.
It must be folded again to ensure that the upper 16 bits are 0.

Fixes: e4c2a16 ("net/mlx5: handle LRO packets in Rx queue")

Signed-off-by: Heng Jiang <jiangheng14@huawei.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  • Loading branch information
Heng Jiang authored and kevintraynor committed Jul 21, 2023
1 parent bdcd430 commit 2788848
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ Helin Zhang <helin.zhang@intel.com>
Hemant Agrawal <hemant.agrawal@nxp.com> <hemant@freescale.com>
Heng Ding <hengx.ding@intel.com>
Hengjian Zhang <hengjianx.zhang@intel.com>
Heng Jiang <jiangheng14@huawei.com>
Heng Wang <heng.wang@ericsson.com>
Henning Schild <henning.schild@siemens.com>
Henry Cai <caihe@huawei.com>
Expand Down
1 change: 1 addition & 0 deletions drivers/net/mlx5/mlx5_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ mlx5_lro_update_tcp_hdr(struct rte_tcp_hdr *__rte_restrict tcp,
tcp->cksum = 0;
csum += rte_raw_cksum(tcp, (tcp->data_off >> 4) * 4);
csum = ((csum & 0xffff0000) >> 16) + (csum & 0xffff);
csum = ((csum & 0xffff0000) >> 16) + (csum & 0xffff);
csum = (~csum) & 0xffff;
if (csum == 0)
csum = 0xffff;
Expand Down

0 comments on commit 2788848

Please sign in to comment.