net: tun: Implement TUN_NOCHECKSUM

Revert the changes to TUN_NOCHECKSUM from commit 8825537521
("net: tun: convert to hw_features"). This is needed to handle
scenarios where GRO coalesced packets are passed on to userspace
with an invalid checksum to programs capturing packets using
packet sockets.

If the checksum was validated before GRO coalesced the packets,
it is unnecessary to validate the checksum again. Userspace
should be allowed to set TUN_NOCHECKSUM on the underlying tun
interface.

Change-Id: I96071e8a07a01efc71612d5a6979d493339e2735
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
This commit is contained in:
Subash Abhinov Kasiviswanathan 2015-10-10 20:05:48 -06:00 committed by Gerrit - the friendly Code Review server
parent 96a3f68ab5
commit c281fa8708
1 changed files with 6 additions and 4 deletions

View File

@ -1163,7 +1163,8 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
kfree_skb(skb);
return -EINVAL;
}
}
} else if (tun->flags & TUN_NOCHECKSUM)
skb->ip_summed = CHECKSUM_UNNECESSARY;
switch (tun->flags & TUN_TYPE_MASK) {
case TUN_TUN_DEV:
@ -1955,9 +1956,10 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
case TUNSETNOCSUM:
/* Disable/Enable checksum */
/* [unimplemented] */
tun_debug(KERN_INFO, tun, "ignored: set checksum %s\n",
arg ? "disabled" : "enabled");
if (arg)
tun->flags |= TUN_NOCHECKSUM;
else
tun->flags &= ~TUN_NOCHECKSUM;
break;
case TUNSETPERSIST: