Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"eth0: hw csum failure" logging #2723

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions drivers/net/usb/lan78xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3106,6 +3106,23 @@ static void lan78xx_rx_csum_offload(struct lan78xx_net *dev,
skb->ip_summed = CHECKSUM_NONE;
} else {
skb->csum = ntohs((u16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT_));

{
/* skb->len - ETH_HLEN - 4 as the ethernet header and
* FCS are still present
*/
__wsum rsum = csum_partial(skb->data + ETH_HLEN,
skb->len - ETH_HLEN - 4, 0);

if ((skb->csum ^ 0xFFFF) != csum_fold(rsum) &&
net_ratelimit()) {
pr_err("lan78xx wrong csum : %x/%x, len %u bytes\n",
skb->csum, csum_fold(rsum), skb->len);
print_hex_dump(KERN_ERR, "raw data: ",
DUMP_PREFIX_OFFSET, 16, 1,
skb->data, skb->len, true);
}
}
skb->ip_summed = CHECKSUM_COMPLETE;
}
}
Expand Down
16 changes: 16 additions & 0 deletions drivers/net/usb/smsc95xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,22 @@ static void smsc95xx_rx_csum_offload(struct sk_buff *skb)
skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2);
skb->ip_summed = CHECKSUM_COMPLETE;
skb_trim(skb, skb->len - 2);
{
/* skb->len - ETH_HLEN - 4 as the ethernet header and
* FCS are still present
*/
__wsum rsum = csum_partial(skb->data + ETH_HLEN,
skb->len - ETH_HLEN - 4, 0);

if ((skb->csum ^ 0xFFFF) != csum_fold(rsum) &&
net_ratelimit()) {
pr_err("lan78xx wrong csum : %x/%x, len %u bytes\n",
skb->csum, csum_fold(rsum), skb->len);
print_hex_dump(KERN_ERR, "raw data: ",
DUMP_PREFIX_OFFSET, 16, 1, skb->data,
skb->len, true);
}
}
}

static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
Expand Down
5 changes: 2 additions & 3 deletions include/linux/skbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -3134,6 +3134,7 @@ static inline void *skb_push_rcsum(struct sk_buff *skb, unsigned int len)
return skb->data;
}

int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len);
/**
* pskb_trim_rcsum - trim received skb and update checksum
* @skb: buffer to trim
Expand All @@ -3147,9 +3148,7 @@ static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
{
if (likely(len >= skb->len))
return 0;
if (skb->ip_summed == CHECKSUM_COMPLETE)
skb->ip_summed = CHECKSUM_NONE;
return __pskb_trim(skb, len);
return pskb_trim_rcsum_slow(skb, len);
}

static inline int __skb_trim_rcsum(struct sk_buff *skb, unsigned int len)
Expand Down
14 changes: 14 additions & 0 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1838,6 +1838,20 @@ int ___pskb_trim(struct sk_buff *skb, unsigned int len)
}
EXPORT_SYMBOL(___pskb_trim);

/* Note : use pskb_trim_rcsum() instead of calling this directly
*/
int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)
{
if (skb->ip_summed == CHECKSUM_COMPLETE) {
int delta = skb->len - len;

skb->csum = csum_sub(skb->csum,
skb_checksum(skb, len, delta, 0));
}
return __pskb_trim(skb, len);
}
EXPORT_SYMBOL(pskb_trim_rcsum_slow);

/**
* __pskb_pull_tail - advance tail of skb header
* @skb: buffer to reallocate
Expand Down