tun: Support VIRTIO_NET_HDR_F_DATA_VALID in tun_get_user
Subsystems (3)
RFC 1/1 tun: Support VIRTIO_NET_HDR_F_DATA_VALID in tun_get_user
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.
--- drivers/net/tun.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/tun.c +3 -0
@@ -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 ) {
Signature · 1 line
1.9.1
Quoted 5 lines · Subash Abhinov Kasiviswanathan
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.
Quoted 9 lines
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_VALIDis 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
Quoted 22 lines
Signed-off-by Subash Abhinov Kasiviswanathan <[email protected]>--- drivers/net/tun.c | 3 +++ 1 file changed, 3 insertions(+)drivers/net/tun.c +3
-1@@ -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