[NET]: Detect hardware rx checksum faults correctly
Here is the patch that introduces the generic skb_checksum_complete which also checks for hardware RX checksum faults. If that happens, it'll call netdev_rx_csum_fault which currently prints out a stack trace with the device name. In future it can turn off RX checksum. I've converted every spot under net/ that does RX checksum checks to use skb_checksum_complete or __skb_checksum_complete with the exceptions of: * Those places where checksums are done bit by bit. These will call netdev_rx_csum_fault directly. * The following have not been completely checked/converted: ipmr ip_vs netfilter dccp This patch is based on patches and suggestions from Stephen Hemminger and David S. Miller. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
1064e944d0
commit
fb286bb299
@@ -1110,24 +1110,18 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
|
||||
static int tcp_v4_checksum_init(struct sk_buff *skb)
|
||||
{
|
||||
if (skb->ip_summed == CHECKSUM_HW) {
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
if (!tcp_v4_check(skb->h.th, skb->len, skb->nh.iph->saddr,
|
||||
skb->nh.iph->daddr, skb->csum))
|
||||
skb->nh.iph->daddr, skb->csum)) {
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
return 0;
|
||||
|
||||
LIMIT_NETDEBUG(KERN_DEBUG "hw tcp v4 csum failed\n");
|
||||
skb->ip_summed = CHECKSUM_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
skb->csum = csum_tcpudp_nofold(skb->nh.iph->saddr, skb->nh.iph->daddr,
|
||||
skb->len, IPPROTO_TCP, 0);
|
||||
|
||||
if (skb->len <= 76) {
|
||||
if (tcp_v4_check(skb->h.th, skb->len, skb->nh.iph->saddr,
|
||||
skb->nh.iph->daddr,
|
||||
skb_checksum(skb, 0, skb->len, 0)))
|
||||
return -1;
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
} else {
|
||||
skb->csum = ~tcp_v4_check(skb->h.th, skb->len,
|
||||
skb->nh.iph->saddr,
|
||||
skb->nh.iph->daddr, 0);
|
||||
return __skb_checksum_complete(skb);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1219,7 +1213,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
|
||||
* provided case of th->doff==0 is elimineted.
|
||||
* So, we defer the checks. */
|
||||
if ((skb->ip_summed != CHECKSUM_UNNECESSARY &&
|
||||
tcp_v4_checksum_init(skb) < 0))
|
||||
tcp_v4_checksum_init(skb)))
|
||||
goto bad_packet;
|
||||
|
||||
th = skb->h.th;
|
||||
|
Reference in New Issue
Block a user