Skip to content

Commit e4f774a

Browse files
oleremkuba-moo
authored andcommitted
net: usb: lan78xx: fix silent drop of packets with checksum errors
Do not drop packets with checksum errors at the USB driver level; pass them to the network stack. Previously, the driver dropped all packets where the 'Receive Error Detected' (RED) bit was set, regardless of the specific error type. This caused packets with only IP or TCP/UDP checksum errors to be dropped before reaching the kernel, preventing the network stack from accounting for them or performing software fallback. Add a mask for hard hardware errors to safely drop genuinely corrupt frames, while allowing checksum-errored frames to pass with their ip_summed field explicitly set to CHECKSUM_NONE. Fixes: 55d7de9 ("Microchip's LAN7800 family USB 2/3 to 10/100/1000 Ethernet device driver") Cc: [email protected] Signed-off-by: Oleksij Rempel <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7a85d37 commit e4f774a

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/net/usb/lan78xx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3829,6 +3829,7 @@ static void lan78xx_rx_csum_offload(struct lan78xx_net *dev,
38293829
*/
38303830
if (!(dev->net->features & NETIF_F_RXCSUM) ||
38313831
unlikely(rx_cmd_a & RX_CMD_A_ICSM_) ||
3832+
unlikely(rx_cmd_a & RX_CMD_A_CSE_MASK_) ||
38323833
((rx_cmd_a & RX_CMD_A_FVTG_) &&
38333834
!(dev->net->features & NETIF_F_HW_VLAN_CTAG_RX))) {
38343835
skb->ip_summed = CHECKSUM_NONE;
@@ -3901,7 +3902,8 @@ static int lan78xx_rx(struct lan78xx_net *dev, struct sk_buff *skb,
39013902
return 0;
39023903
}
39033904

3904-
if (unlikely(rx_cmd_a & RX_CMD_A_RED_)) {
3905+
if (unlikely(rx_cmd_a & RX_CMD_A_RED_) &&
3906+
(rx_cmd_a & RX_CMD_A_RX_HARD_ERRS_MASK_)) {
39053907
netif_dbg(dev, rx_err, dev->net,
39063908
"Error rx_cmd_a=0x%08x", rx_cmd_a);
39073909
} else {

drivers/net/usb/lan78xx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
#define RX_CMD_A_ICSM_ (0x00004000)
7575
#define RX_CMD_A_LEN_MASK_ (0x00003FFF)
7676

77+
#define RX_CMD_A_RX_HARD_ERRS_MASK_ \
78+
(RX_CMD_A_RX_ERRS_MASK_ & ~RX_CMD_A_CSE_MASK_)
79+
7780
/* Rx Command B */
7881
#define RX_CMD_B_CSUM_SHIFT_ (16)
7982
#define RX_CMD_B_CSUM_MASK_ (0xFFFF0000)

0 commit comments

Comments
 (0)