On Fri, Jun 24, 2016 at 7:21 PM, Subash Abhinov Kasiviswanathan
<subas...@codeaurora.org> wrote:
> Userspace applications might sometimes process packets from hardware
> which has already validated checksum, perform trivial operations and
> then queue them back to the network stack. By not recomputing the
> checksum here, we can see significant improvement in performance.
>
> Sample application here is CLAT which does IPv6 to IPv4 translation.
> IPv6 packets for which checksum is validated in hardware are captured
> in CLAT and then translated to IPv4 and then queued back to network
> stack. In this case, it is expected that the application would not
> corrupt the packet and recomputing the checksum would be redundant.
>
> Pass the hint to kernel to skip checksum validation if
> VIRTIO_NET_HDR_F_DATA_VALID is set from userspace.
>
CHECKSUM_UNNECESSARY is not a hint, the interface is very specific. It
means that a checksum(s) has been verified to be correct. There is no
way here to validate that the userspace code is doing the right thing.
virtionet interface really should also pass checksum-complete values
to be up with the times, this would be more robust and harder to
silently get wrong.

Tom

> Signed-off-by: Subash Abhinov Kasiviswanathan <subas...@codeaurora.org>
> ---
>  drivers/net/tun.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index e16487c..a5828a5 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1263,6 +1263,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, 
> struct tun_file *tfile,
>                 }
>         }
>
> +       if (gso.flags & VIRTIO_NET_HDR_F_DATA_VALID)
> +               skb->ip_summed = CHECKSUM_UNNECESSARY;
> +
>         switch (tun->flags & TUN_TYPE_MASK) {
>         case IFF_TUN:
>                 if (tun->flags & IFF_NO_PI) {
> --
> 1.9.1
>

Reply via email to