[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
@@ -298,13 +298,10 @@ void rawv6_err(struct sock *sk, struct sk_buff *skb,
|
||||
static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb)
|
||||
{
|
||||
if ((raw6_sk(sk)->checksum || sk->sk_filter) &&
|
||||
skb->ip_summed != CHECKSUM_UNNECESSARY) {
|
||||
if ((unsigned short)csum_fold(skb_checksum(skb, 0, skb->len, skb->csum))) {
|
||||
/* FIXME: increment a raw6 drops counter here */
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
}
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
skb_checksum_complete(skb)) {
|
||||
/* FIXME: increment a raw6 drops counter here */
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Charge it to the socket. */
|
||||
@@ -337,32 +334,25 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
|
||||
if (!rp->checksum)
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
|
||||
if (skb->ip_summed != CHECKSUM_UNNECESSARY) {
|
||||
if (skb->ip_summed == CHECKSUM_HW) {
|
||||
skb_postpull_rcsum(skb, skb->nh.raw,
|
||||
skb->h.raw - skb->nh.raw);
|
||||
if (skb->ip_summed == CHECKSUM_HW) {
|
||||
skb_postpull_rcsum(skb, skb->nh.raw,
|
||||
skb->h.raw - skb->nh.raw);
|
||||
if (!csum_ipv6_magic(&skb->nh.ipv6h->saddr,
|
||||
&skb->nh.ipv6h->daddr,
|
||||
skb->len, inet->num, skb->csum))
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
|
||||
&skb->nh.ipv6h->daddr,
|
||||
skb->len, inet->num, skb->csum)) {
|
||||
LIMIT_NETDEBUG(KERN_DEBUG "raw v6 hw csum failure.\n");
|
||||
skb->ip_summed = CHECKSUM_NONE;
|
||||
}
|
||||
}
|
||||
if (skb->ip_summed == CHECKSUM_NONE)
|
||||
skb->csum = ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
|
||||
&skb->nh.ipv6h->daddr,
|
||||
skb->len, inet->num, 0);
|
||||
}
|
||||
if (skb->ip_summed != CHECKSUM_UNNECESSARY)
|
||||
skb->csum = ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
|
||||
&skb->nh.ipv6h->daddr,
|
||||
skb->len, inet->num, 0);
|
||||
|
||||
if (inet->hdrincl) {
|
||||
if (skb->ip_summed != CHECKSUM_UNNECESSARY &&
|
||||
(unsigned short)csum_fold(skb_checksum(skb, 0, skb->len, skb->csum))) {
|
||||
if (skb_checksum_complete(skb)) {
|
||||
/* FIXME: increment a raw6 drops counter here */
|
||||
kfree_skb(skb);
|
||||
return 0;
|
||||
}
|
||||
skb->ip_summed = CHECKSUM_UNNECESSARY;
|
||||
}
|
||||
|
||||
rawv6_rcv_skb(sk, skb);
|
||||
@@ -407,7 +397,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
|
||||
if (skb->ip_summed==CHECKSUM_UNNECESSARY) {
|
||||
err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
|
||||
} else if (msg->msg_flags&MSG_TRUNC) {
|
||||
if ((unsigned short)csum_fold(skb_checksum(skb, 0, skb->len, skb->csum)))
|
||||
if (__skb_checksum_complete(skb))
|
||||
goto csum_copy_err;
|
||||
err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user