Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers: net: xgene: Fix regression in CRC stripping

All packets on ingress (except for jumbo) are terminated with a 4-bytes
CRC checksum. It's the responsability of the driver to strip those 4
bytes. Unfortunately a change dating back to March 2017 re-shuffled some
code and made the CRC stripping code effectively dead.

This change re-orders that part a bit such that the datalen is
immediately altered if needed.

Fixes: 4902a92270fb ("drivers: net: xgene: Add workaround for errata 10GE_8/ENET_11")
Cc: stable@vger.kernel.org
Signed-off-by: Stephane Graber <stgraber@ubuntu.com>
Tested-by: Stephane Graber <stgraber@ubuntu.com>
Link: https://lore.kernel.org/r/20220322224205.752795-1-stgraber@ubuntu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Stephane Graber and committed by
Jakub Kicinski
e9e6faea 36c2e31a

+7 -5
+7 -5
drivers/net/ethernet/apm/xgene/xgene_enet_main.c
··· 696 696 buf_pool->rx_skb[skb_index] = NULL; 697 697 698 698 datalen = xgene_enet_get_data_len(le64_to_cpu(raw_desc->m1)); 699 + 700 + /* strip off CRC as HW isn't doing this */ 701 + nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0)); 702 + if (!nv) 703 + datalen -= 4; 704 + 699 705 skb_put(skb, datalen); 700 706 prefetch(skb->data - NET_IP_ALIGN); 701 707 skb->protocol = eth_type_trans(skb, ndev); ··· 723 717 } 724 718 } 725 719 726 - nv = GET_VAL(NV, le64_to_cpu(raw_desc->m0)); 727 - if (!nv) { 728 - /* strip off CRC as HW isn't doing this */ 729 - datalen -= 4; 720 + if (!nv) 730 721 goto skip_jumbo; 731 - } 732 722 733 723 slots = page_pool->slots - 1; 734 724 head = page_pool->head;