Linux TUN Network Driver May See A "1000x Speedup" With New, One-Line Patch

Written by Michael Larabel in Linux Networking on 21 October 2022 at 08:30 AM EDT. 28 Comments
LINUX NETWORKING
Linux's universal TUN driver that provides packet reception and transmission for user-space programs may soon see a 1000x speed-up with a proposed patch sent out today for this network driver.

This TUN/TAP "tunneling" driver has long been available within the Linux kernel for packet receive/send for user-space programs via /dev/net/tun that can be used by VPNs, Open vSwitch, and other purposes. Those unfamiliar with the TUN driver can see the kernel documentation.

Nearly two decades ago the Linux TUN driver set an advertised speed of a 10Mbps link... That was good back then but since then the Linux networking stack has advanced a great deal as has hardware. Ilya Maximets of Open Virtual Network (OVN) sent out a patch in aiming to finally raise that limit.

Ilya commented in his patch entitled "[RFE net-next] net: tun: 1000x speed up" sent out this morning:
"The 10Mbps link speed was set in 2004 when the ethtool interface was initially added to the tun driver. It might have been a good assumption 18 years ago, but CPUs and network stack came a long way since then.

Other virtual ports typically report much higher speeds. For example, veth reports 10Gbps since its introduction in 2007.

Some userspace applications rely on the current link speed in certain situations. For example, Open vSwitch is using link speed as an upper bound for QoS configuration if user didn't specify the maximum rate. Advertised 10Mbps doesn't match reality in a modern world, so users have to always manually override the value with something more sensible to avoid configuration issues, e.g. limiting the traffic too much. This also creates additional confusion among users.

Bump the advertised speed to at least match the veth. 10Gbps also seems like a more or less fair assumption these days, even though CPUs can do more. Alternative might be to explicitly report UNKNOWN and let the application/user decide on a right value for them."

So for some users/configurations at least, the one-line patch to the TUN driver may prove very beneficial in a better out-of-the-box experience.

Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week