Skip to contentSkip to conversation

tun: add --tun-backpressure option for Linux

PATCH In review Simon Schippers 4 participants 11 messages Oct 28 – Nov 3

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tun: add --tun-backpressure option for Linux

When the internal ring of a TUN/TAP device is full, the kernel silently drops packets, bypassing any qdisc. TCP then sees loss, retransmits and shrinks its congestion window.

My series "tun/tap & vhost-net: apply qdisc backpressure on full ptr_ring to reduce TX drops" [1] adds IFF_BACKPRESSURE in Linux 7.3 (commit d00c7369ef24 "tun/tap & vhost-net: stop tail-drop when IFF_BACKPRESSURE is set"). It stops the TX queue instead, so the qdisc holds the packets and applies its AQM and fairness.

Our paper [2] evaluated this with OpenVPN: over a 120 ms RTT link between Germany and the USA, TCP throughput without the patch was up to 36% worse, and with it no retransmissions occurred. With higher latencies, throughput without the patch can be even worse.

Unfortunately, stopping and waking the queue can reduce throughput with many parallel senders: in a synthetic test with eight iperf3 senders, throughput dropped from 13.5 to 9.13 Gbit/s [3]. The flag is therefore disabled by default and can be enabled with the new --tun-backpressure option.

The option is only available when the headers define IFF_BACKPRESSURE, and older kernels ignore the flag. The DCO path uses no TUN device and is unaffected.

Tested on Linux 7.3-rc3: with --tun-backpressure, /sys/class/net/<dev>/tun_flags has IFF_BACKPRESSURE set, without it the flag stays clear. Builds without warnings with and without IFF_BACKPRESSURE in the headers, and make check passes.

[1] https://lore.kernel.org/netdev/[email protected]/T/#u
[2] https://cni.etit.tu-dortmund.de/storages/cni-etit/r/Research/Publications/2025/Gebauer_2025_VTCFall/Gebauer_VTCFall2025_AuthorsVersion.pdf
[3] https://lore.kernel.org/netdev/[email protected]/

Assisted-by Claude:claude-opus-5-5
---
 doc/man-sections/advanced-options.rst |  7 +++++++
 src/openvpn/options.c                 | 12 ++++++++++++
 src/openvpn/tun.c                     |  7 +++++++
 src/openvpn/tun.h                     |  1 +
 4 files changed, 27 insertions(+)
doc/man-sections/advanced-options.rst +7 -0
index 32008d58f..c578a5c2c 100644
@@ -100,6 +100,13 @@ used when debugging or testing out special usage scenarios.
   *(Linux only)* Set the TX queue length on the TUN/TAP interface.
   Currently defaults to operating system default.
 
+--tun-backpressure
+  *(Linux only)* Set :code:`IFF_BACKPRESSURE` on the TUN/TAP interface.
+  When OpenVPN falls behind reading from the interface, the kernel then
+  stops the TX queue instead of dropping packets, so the attached qdisc
+  can apply its queue management. This can reduce throughput with many
+  parallel senders. Requires Linux 7.3 or later; older kernels ignore it.
+
 --disable-dco
   Disables the opportunistic use of data channel offloading if available.
   Without this option, OpenVPN will opportunistically use DCO mode if
src/openvpn/options.c +12 -0
index 8e0c6029e..241f3891c 100644
@@ -333,6 +333,8 @@ static const char usage_message[] =
     "                  via a VRF present on the system.\n"
 #endif
     "--txqueuelen n  : Set the tun/tap TX queue length to n (Linux only).\n"
+    "--tun-backpressure : Apply qdisc backpressure instead of dropping packets\n"
+    "                  on the tun/tap device (Linux only).\n"
     "--mlock         : Disable Paging -- ensures key material and tunnel\n"
     "                  data will never be written to disk.\n"
     "--up cmd        : Run command cmd after successful tun device open.\n"
@@ -5129,6 +5131,16 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
 #else
         msg(msglevel, "--txqueuelen not supported on this OS");
         goto err;
+#endif
+    }
+    else if (streq(p[0], "tun-backpressure") && !p[1])
+    {
+        VERIFY_PERMISSION(OPT_P_GENERAL);
+#if defined(TARGET_LINUX) && defined(IFF_BACKPRESSURE)
+        options->tuntap_options.backpressure = true;
+#else
+        msg(msglevel, "--tun-backpressure not supported on this platform");
+        goto err;
 #endif
     }
     else if (streq(p[0], "shaper") && p[1] && !p[2])
src/openvpn/tun.c +7 -0
index fdd13ae7e..5d6184e55 100644
@@ -2100,6 +2100,13 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
         ifr.ifr_flags |= IFF_ONE_QUEUE;
 #endif
 
+#ifdef IFF_BACKPRESSURE
+        if (tt->options.backpressure)
+        {
+            ifr.ifr_flags |= IFF_BACKPRESSURE;
+        }
+#endif
+
         /*
          * Figure out if tun or tap device
          */
src/openvpn/tun.h +1 -0
index 61fe943b0..bd2107a78 100644
@@ -150,6 +150,7 @@ struct tuntap_options
 struct tuntap_options
 {
     int txqueuelen;
+    bool backpressure;
 };
 
 #else  /* if defined(_WIN32) || defined(TARGET_ANDROID) */
Signature · 8 lines
2.43.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
#1 lore raw

Hi Simon,

thank you for your patch and congratulations for the research work!

Quoted 9 lines · Simon Schippers

When the internal ring of a TUN/TAP device is full, the kernel silently drops packets, bypassing any qdisc. TCP then sees loss, retransmits and shrinks its congestion window.

My series "tun/tap & vhost-net: apply qdisc backpressure on full ptr_ring to reduce TX drops" [1] adds IFF_BACKPRESSURE in Linux 7.3 (commit d00c7369ef24 "tun/tap & vhost-net: stop tail-drop when IFF_BACKPRESSURE is set"). It stops the TX queue instead, so the qdisc holds the packets and applies its AQM and fairness.

Inside the linux kernel this works reasonably well.
We are just playing with several of this knobs in DCO at the moment.

Quoted 11 lines

Our paper [2] evaluated this with OpenVPN: over a 120 ms RTT link between Germany and the USA, TCP throughput without the patch was up to 36% worse, and with it no retransmissions occurred. With higher latencies, throughput without the patch can be even worse.

Unfortunately, stopping and waking the queue can reduce throughput with many parallel senders: in a synthetic test with eight iperf3 senders, throughput dropped from 13.5 to 9.13 Gbit/s [3]. The flag is therefore disabled by default and can be enabled with the new --tun-backpressure option.

Given what you just said above, don't you think users will normally want this off all the time?

A VPN tunnel spends most of its time forwarding multiple streams from the host (in case of a roadwarrior setup) or from its LAN clients (in case of a VPN client installed on a router).

Do you foresee any reasonable scenario when a user would enable this flag and keep it on all the time?

Regards,

Quoted 101 lines

The option is only available when the headers define IFF_BACKPRESSURE, and older kernels ignore the flag. The DCO path uses no TUN device and is unaffected.

Tested on Linux 7.3-rc3: with --tun-backpressure, /sys/class/net/<dev>/tun_flags has IFF_BACKPRESSURE set, without it the flag stays clear. Builds without warnings with and without IFF_BACKPRESSURE in the headers, and make check passes.

[1] https://lore.kernel.org/netdev/[email protected]/T/#u
[2] https://cni.etit.tu-dortmund.de/storages/cni-etit/r/Research/Publications/2025/Gebauer_2025_VTCFall/Gebauer_VTCFall2025_AuthorsVersion.pdf
[3] https://lore.kernel.org/netdev/[email protected]/

Assisted-by Claude:claude-opus-5-5
---
  doc/man-sections/advanced-options.rst |  7 +++++++
  src/openvpn/options.c                 | 12 ++++++++++++
  src/openvpn/tun.c                     |  7 +++++++
  src/openvpn/tun.h                     |  1 +
  4 files changed, 27 insertions(+)
doc/man-sections/advanced-options.rst +7 -0
index 32008d58f..c578a5c2c 100644
@@ -100,6 +100,13 @@ used when debugging or testing out special usage scenarios.
    *(Linux only)* Set the TX queue length on the TUN/TAP interface.
    Currently defaults to operating system default.
 
+--tun-backpressure
+  *(Linux only)* Set :code:`IFF_BACKPRESSURE` on the TUN/TAP interface.
+  When OpenVPN falls behind reading from the interface, the kernel then
+  stops the TX queue instead of dropping packets, so the attached qdisc
+  can apply its queue management. This can reduce throughput with many
+  parallel senders. Requires Linux 7.3 or later; older kernels ignore it.
+
  --disable-dco
    Disables the opportunistic use of data channel offloading if available.
    Without this option, OpenVPN will opportunistically use DCO mode if
src/openvpn/options.c +12 -0
index 8e0c6029e..241f3891c 100644
@@ -333,6 +333,8 @@ static const char usage_message[] =
      "                  via a VRF present on the system.\n"
  #endif
      "--txqueuelen n  : Set the tun/tap TX queue length to n (Linux only).\n"
+    "--tun-backpressure : Apply qdisc backpressure instead of dropping packets\n"
+    "                  on the tun/tap device (Linux only).\n"
      "--mlock         : Disable Paging -- ensures key material and tunnel\n"
      "                  data will never be written to disk.\n"
      "--up cmd        : Run command cmd after successful tun device open.\n"
@@ -5129,6 +5131,16 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
  #else
          msg(msglevel, "--txqueuelen not supported on this OS");
          goto err;
+#endif
+    }
+    else if (streq(p[0], "tun-backpressure") && !p[1])
+    {
+        VERIFY_PERMISSION(OPT_P_GENERAL);
+#if defined(TARGET_LINUX) && defined(IFF_BACKPRESSURE)
+        options->tuntap_options.backpressure = true;
+#else
+        msg(msglevel, "--tun-backpressure not supported on this platform");
+        goto err;
  #endif
      }
      else if (streq(p[0], "shaper") && p[1] && !p[2])
src/openvpn/tun.c +7 -0
index fdd13ae7e..5d6184e55 100644
@@ -2100,6 +2100,13 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
          ifr.ifr_flags |= IFF_ONE_QUEUE;
  #endif
 
+#ifdef IFF_BACKPRESSURE
+        if (tt->options.backpressure)
+        {
+            ifr.ifr_flags |= IFF_BACKPRESSURE;
+        }
+#endif
+
          /*
           * Figure out if tun or tap device
           */
src/openvpn/tun.h +1 -0
index 61fe943b0..bd2107a78 100644
@@ -150,6 +150,7 @@ struct tuntap_options
  struct tuntap_options
  {
      int txqueuelen;
+    bool backpressure;
  };
 
  #else  /* if defined(_WIN32) || defined(TARGET_ANDROID) */
Signature · 8 lines
Antonio Quartulli



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
#2 lore raw
Quoted 4 lines · Antonio Quartulli

Hi Simon,

thank you for your patch and congratulations for the research work!

Thank you!

Quoted 5 lines · Simon Schippers
Quoted 4 lines

When the internal ring of a TUN/TAP device is full, the kernel silently drops packets, bypassing any qdisc. TCP then sees loss, retransmits and shrinks its congestion window.

Quoted 9 lines
Quoted 5 lines

My series "tun/tap & vhost-net: apply qdisc backpressure on full ptr_ring to reduce TX drops" [1] adds IFF_BACKPRESSURE in Linux 7.3 (commit d00c7369ef24 "tun/tap & vhost-net: stop tail-drop when IFF_BACKPRESSURE is set"). It stops the TX queue instead, so the qdisc holds the packets and applies its AQM and fairness.

Inside the linux kernel this works reasonably well.
We are just playing with several of this knobs in DCO at the moment.

I see. The ovpn driver never calls netif_tx_stop_queue(), so DCO has no qdisc backpressure either, right?

Quoted 12 lines
Quoted 11 lines

Our paper [2] evaluated this with OpenVPN: over a 120 ms RTT link between Germany and the USA, TCP throughput without the patch was up to 36% worse, and with it no retransmissions occurred. With higher latencies, throughput without the patch can be even worse.

Unfortunately, stopping and waking the queue can reduce throughput with many parallel senders: in a synthetic test with eight iperf3 senders, throughput dropped from 13.5 to 9.13 Gbit/s [3]. The flag is therefore disabled by default and can be enabled with the new --tun-backpressure option.

Quoted 5 lines

Given what you just said above, don't you think users will normally want this off all the time?

A VPN tunnel spends most of its time forwarding multiple streams from the host (in case of a roadwarrior setup) or from its LAN clients (in case of a VPN client installed on a router).

Do you foresee any reasonable scenario when a user would enable this flag and keep it on all the time?

I think most users should. The TUN/TAP device is usually not the bottleneck, the encryption or the network is. Dropping packets in the TUN/TAP driver for no good reason hurts real-world TCP throughput, as shown in our paper [1] (it has an old implementation). That is why users often raise the queue length (--txqueuelen in OpenVPN). This mostly fixes the throughput, but causes bufferbloat. Also, the qdisc's ECN marking and flow fairness only work with IFF_BACKPRESSURE.

Regards,
Simon

Quoted 94 lines

Regards,

Quoted 90 lines

The option is only available when the headers define IFF_BACKPRESSURE, and older kernels ignore the flag. The DCO path uses no TUN device and is unaffected.

Tested on Linux 7.3-rc3: with --tun-backpressure, /sys/class/net/<dev>/tun_flags has IFF_BACKPRESSURE set, without it the flag stays clear. Builds without warnings with and without IFF_BACKPRESSURE in the headers, and make check passes.

[1] https://lore.kernel.org/netdev/[email protected]/T/#u
[2] https://cni.etit.tu-dortmund.de/storages/cni-etit/r/Research/Publications/2025/Gebauer_2025_VTCFall/Gebauer_VTCFall2025_AuthorsVersion.pdf
[3] https://lore.kernel.org/netdev/[email protected]/

Assisted-by Claude:claude-opus-5-5
---
  doc/man-sections/advanced-options.rst |  7 +++++++
  src/openvpn/options.c                 | 12 ++++++++++++
  src/openvpn/tun.c                     |  7 +++++++
  src/openvpn/tun.h                     |  1 +
  4 files changed, 27 insertions(+)
doc/man-sections/advanced-options.rst +6 -0
index 32008d58f..c578a5c2c 100644
@@ -100,6 +100,13 @@ used when debugging or testing out special usage scenarios.
    *(Linux only)* Set the TX queue length on the TUN/TAP interface.
    Currently defaults to operating system default.
  +--tun-backpressure
+  *(Linux only)* Set :code:`IFF_BACKPRESSURE` on the TUN/TAP interface.
+  When OpenVPN falls behind reading from the interface, the kernel then
+  stops the TX queue instead of dropping packets, so the attached qdisc
+  can apply its queue management. This can reduce throughput with many
+  parallel senders. Requires Linux 7.3 or later; older kernels ignore it.
+
  --disable-dco
    Disables the opportunistic use of data channel offloading if available.
    Without this option, OpenVPN will opportunistically use DCO mode if
src/openvpn/options.c +12 -0
index 8e0c6029e..241f3891c 100644
@@ -333,6 +333,8 @@ static const char usage_message[] =
      "                  via a VRF present on the system.\n"
  #endif
      "--txqueuelen n  : Set the tun/tap TX queue length to n (Linux only).\n"
+    "--tun-backpressure : Apply qdisc backpressure instead of dropping packets\n"
+    "                  on the tun/tap device (Linux only).\n"
      "--mlock         : Disable Paging -- ensures key material and tunnel\n"
      "                  data will never be written to disk.\n"
      "--up cmd        : Run command cmd after successful tun device open.\n"
@@ -5129,6 +5131,16 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
  #else
          msg(msglevel, "--txqueuelen not supported on this OS");
          goto err;
+#endif
+    }
+    else if (streq(p[0], "tun-backpressure") && !p[1])
+    {
+        VERIFY_PERMISSION(OPT_P_GENERAL);
+#if defined(TARGET_LINUX) && defined(IFF_BACKPRESSURE)
+        options->tuntap_options.backpressure = true;
+#else
+        msg(msglevel, "--tun-backpressure not supported on this platform");
+        goto err;
  #endif
      }
      else if (streq(p[0], "shaper") && p[1] && !p[2])
src/openvpn/tun.c +6 -0
index fdd13ae7e..5d6184e55 100644
@@ -2100,6 +2100,13 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
          ifr.ifr_flags |= IFF_ONE_QUEUE;
  #endif
  +#ifdef IFF_BACKPRESSURE
+        if (tt->options.backpressure)
+        {
+            ifr.ifr_flags |= IFF_BACKPRESSURE;
+        }
+#endif
+
          /*
           * Figure out if tun or tap device
           */
src/openvpn/tun.h +0 -1
index 61fe943b0..bd2107a78 100644
--- a/src/openvpn/tun.h
Quoted 9 lines

src/openvpn/tun.h struct tuntap_options · line 155

Quoted 8 lines

+++ b/src/openvpn/tun.h

src/openvpn/tun.h +1 -0
@@ -150,6 +150,7 @@ struct tuntap_options
  struct tuntap_options
  {
      int txqueuelen;
+    bool backpressure;
  };
    #else  /* if defined(_WIN32) || defined(TARGET_ANDROID) */

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#3 lore raw

Hi,

Quoted 19 lines · Simon Schippers
Quoted 4 lines · Antonio Quartulli

Hi Simon,

thank you for your patch and congratulations for the research work!

Thank you!

Quoted 11 lines · Simon Schippers
Quoted 9 lines

When the internal ring of a TUN/TAP device is full, the kernel silently drops packets, bypassing any qdisc. TCP then sees loss, retransmits and shrinks its congestion window.

My series "tun/tap & vhost-net: apply qdisc backpressure on full ptr_ring to reduce TX drops" [1] adds IFF_BACKPRESSURE in Linux 7.3 (commit d00c7369ef24 "tun/tap & vhost-net: stop tail-drop when IFF_BACKPRESSURE is set"). It stops the TX queue instead, so the qdisc holds the packets and applies its AQM and fairness.

Quoted 7 lines
Quoted 3 lines

Inside the linux kernel this works reasonably well.
We are just playing with several of this knobs in DCO at the moment.

I see. The ovpn driver never calls netif_tx_stop_queue(), so DCO has no qdisc backpressure either, right?

Not quite. The current ovpn UDP datapath has no bounded driver ring analogous to tun's ptr_ring: the device is IFF_NO_QUEUE, and ndo_start_xmit consumes the skb and performs or submits encryption directly. Therefore there is no full ovpn queue whose availability needs to be signalled with netif_tx_stop_queue. In this design, synchronous processing naturally paces the caller.

TCP transport and asynchronous crypto have separate queueing considerations, but I think they are not the tun problem addressed by IFF_BACKPRESSURE.

Signature · 8 lines
Ralf Lici
Mandelbit Srl


_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
#4 lore raw
In reply to Simon Schippers
Quoted 6 lines · Simon Schippers
Quoted 3 lines

Inside the linux kernel this works reasonably well.
We are just playing with several of this knobs in DCO at the moment.

I see. The ovpn driver never calls netif_tx_stop_queue(), so DCO has no qdisc backpressure either, right?

I think Ralf gave a pretty clear explanation of the status here :-) Adding queue comes with various problems.

Bufferbloat to start with.

Quoted 19 lines
Quoted 13 lines
Quoted 7 lines

Our paper [2] evaluated this with OpenVPN: over a 120 ms RTT link between Germany and the USA, TCP throughput without the patch was up to 36% worse, and with it no retransmissions occurred. With higher latencies, throughput without the patch can be even worse.

Quoted 5 lines

Unfortunately, stopping and waking the queue can reduce throughput with many parallel senders: in a synthetic test with eight iperf3 senders, throughput dropped from 13.5 to 9.13 Gbit/s [3]. The flag is therefore disabled by default and can be enabled with the new --tun-backpressure option.

Quoted 5 lines

Given what you just said above, don't you think users will normally want this off all the time?

A VPN tunnel spends most of its time forwarding multiple streams from the host (in case of a roadwarrior setup) or from its LAN clients (in case of a VPN client installed on a router).

Do you foresee any reasonable scenario when a user would enable this flag and keep it on all the time?

Quoted 7 lines

I think most users should. The TUN/TAP device is usually not the bottleneck, the encryption or the network is. Dropping packets in the TUN/TAP driver for no good reason hurts real-world TCP throughput, as shown in our paper [1] (it has an old implementation). That is why users often raise the queue length (--txqueuelen in OpenVPN). This mostly fixes the throughput, but causes bufferbloat. Also, the qdisc's ECN marking and flow fairness only work with IFF_BACKPRESSURE.

The internet is going towards "avoid bufferbloat, even if it costs a little throughput" and to be honest I strongly agree here.

On top of that, if people wants performance on Linux, they should just switch to DCO - that's where our effort is going nowadays.

Adding more complexity for tun, only for linux and only for a very small niche is not really acceptable. Especially if complexity comes with yet another option knob.

I hope you can understand!

Regards,

Quoted 113 lines

Regards,
Simon

Quoted 94 lines

Regards,

Quoted 90 lines

The option is only available when the headers define IFF_BACKPRESSURE, and older kernels ignore the flag. The DCO path uses no TUN device and is unaffected.

Tested on Linux 7.3-rc3: with --tun-backpressure, /sys/class/net/<dev>/tun_flags has IFF_BACKPRESSURE set, without it the flag stays clear. Builds without warnings with and without IFF_BACKPRESSURE in the headers, and make check passes.

[1] https://lore.kernel.org/netdev/[email protected]/T/#u
[2] https://cni.etit.tu-dortmund.de/storages/cni-etit/r/Research/Publications/2025/Gebauer_2025_VTCFall/Gebauer_VTCFall2025_AuthorsVersion.pdf
[3] https://lore.kernel.org/netdev/[email protected]/

Assisted-by Claude:claude-opus-5-5
---
   doc/man-sections/advanced-options.rst |  7 +++++++
   src/openvpn/options.c                 | 12 ++++++++++++
   src/openvpn/tun.c                     |  7 +++++++
   src/openvpn/tun.h                     |  1 +
   4 files changed, 27 insertions(+)
doc/man-sections/advanced-options.rst +6 -0
index 32008d58f..c578a5c2c 100644
@@ -100,6 +100,13 @@ used when debugging or testing out special usage scenarios.
     *(Linux only)* Set the TX queue length on the TUN/TAP interface.
     Currently defaults to operating system default.
   +--tun-backpressure
+  *(Linux only)* Set :code:`IFF_BACKPRESSURE` on the TUN/TAP interface.
+  When OpenVPN falls behind reading from the interface, the kernel then
+  stops the TX queue instead of dropping packets, so the attached qdisc
+  can apply its queue management. This can reduce throughput with many
+  parallel senders. Requires Linux 7.3 or later; older kernels ignore it.
+
   --disable-dco
     Disables the opportunistic use of data channel offloading if available.
     Without this option, OpenVPN will opportunistically use DCO mode if
src/openvpn/options.c +12 -0
index 8e0c6029e..241f3891c 100644
@@ -333,6 +333,8 @@ static const char usage_message[] =
       "                  via a VRF present on the system.\n"
   #endif
       "--txqueuelen n  : Set the tun/tap TX queue length to n (Linux only).\n"
+    "--tun-backpressure : Apply qdisc backpressure instead of dropping packets\n"
+    "                  on the tun/tap device (Linux only).\n"
       "--mlock         : Disable Paging -- ensures key material and tunnel\n"
       "                  data will never be written to disk.\n"
       "--up cmd        : Run command cmd after successful tun device open.\n"
@@ -5129,6 +5131,16 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
   #else
           msg(msglevel, "--txqueuelen not supported on this OS");
           goto err;
+#endif
+    }
+    else if (streq(p[0], "tun-backpressure") && !p[1])
+    {
+        VERIFY_PERMISSION(OPT_P_GENERAL);
+#if defined(TARGET_LINUX) && defined(IFF_BACKPRESSURE)
+        options->tuntap_options.backpressure = true;
+#else
+        msg(msglevel, "--tun-backpressure not supported on this platform");
+        goto err;
   #endif
       }
       else if (streq(p[0], "shaper") && p[1] && !p[2])
src/openvpn/tun.c +6 -0
index fdd13ae7e..5d6184e55 100644
@@ -2100,6 +2100,13 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
           ifr.ifr_flags |= IFF_ONE_QUEUE;
   #endif
   +#ifdef IFF_BACKPRESSURE
+        if (tt->options.backpressure)
+        {
+            ifr.ifr_flags |= IFF_BACKPRESSURE;
+        }
+#endif
+
           /*
            * Figure out if tun or tap device
            */
src/openvpn/tun.h +0 -1
index 61fe943b0..bd2107a78 100644
--- a/src/openvpn/tun.h
Quoted 9 lines

src/openvpn/tun.h struct tuntap_options · line 155

Quoted 8 lines

+++ b/src/openvpn/tun.h

src/openvpn/tun.h +1 -0
@@ -150,6 +150,7 @@ struct tuntap_options
   struct tuntap_options
   {
       int txqueuelen;
+    bool backpressure;
   };
     #else  /* if defined(_WIN32) || defined(TARGET_ANDROID) */

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Signature · 8 lines
Antonio Quartulli



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
#5 lore raw
Quoted 5 lines · Antonio Quartulli
Quoted 4 lines · Simon Schippers
Quoted 3 lines

Inside the linux kernel this works reasonably well.
We are just playing with several of this knobs in DCO at the moment.

Quoted 7 lines
Quoted 2 lines

I see. The ovpn driver never calls netif_tx_stop_queue(), so DCO has no qdisc backpressure either, right?

I think Ralf gave a pretty clear explanation of the status here :-) Adding queue comes with various problems.

Bufferbloat to start with.

I understand it now, thanks Ralf!

Quoted 28 lines
Quoted 20 lines
Quoted 14 lines
Quoted 8 lines

Our paper [2] evaluated this with OpenVPN: over a 120 ms RTT link between Germany and the USA, TCP throughput without the patch was up to 36% worse, and with it no retransmissions occurred. With higher latencies, throughput without the patch can be even worse.

Quoted 5 lines

Unfortunately, stopping and waking the queue can reduce throughput with many parallel senders: in a synthetic test with eight iperf3 senders, throughput dropped from 13.5 to 9.13 Gbit/s [3]. The flag is therefore disabled by default and can be enabled with the new --tun-backpressure option.

Quoted 5 lines

Given what you just said above, don't you think users will normally want this off all the time?

A VPN tunnel spends most of its time forwarding multiple streams from the host (in case of a roadwarrior setup) or from its LAN clients (in case of a VPN client installed on a router).

Do you foresee any reasonable scenario when a user would enable this flag and keep it on all the time?

Quoted 7 lines

I think most users should. The TUN/TAP device is usually not the bottleneck, the encryption or the network is. Dropping packets in the TUN/TAP driver for no good reason hurts real-world TCP throughput, as shown in our paper [1] (it has an old implementation). That is why users often raise the queue length (--txqueuelen in OpenVPN). This mostly fixes the throughput, but causes bufferbloat. Also, the qdisc's ECN marking and flow fairness only work with IFF_BACKPRESSURE.

Quoted 5 lines

The internet is going towards "avoid bufferbloat, even if it costs a little throughput" and to be honest I strongly agree here.

On top of that, if people wants performance on Linux, they should just switch to DCO - that's where our effort is going nowadays.

Adding more complexity for tun, only for linux and only for a very small niche is not really acceptable. Especially if complexity comes with yet another option knob.

I am not sure if I understand correctly. Wouldn't simply enabling it without a new OpenVPN option be fine then?

#ifdef IFF_BACKPRESSURE
    ifr.ifr_flags |= IFF_BACKPRESSURE;

#endif

From my POV, this would reduce complexity. Users like me would no longer have to raise --txqueuelen (and get bufferbloat) to get full throughput.

Thanks!

Quoted 120 lines

I hope you can understand!

Regards,

Quoted 113 lines

Regards,
Simon

Quoted 94 lines

Regards,

Quoted 90 lines

The option is only available when the headers define IFF_BACKPRESSURE, and older kernels ignore the flag. The DCO path uses no TUN device and is unaffected.

Tested on Linux 7.3-rc3: with --tun-backpressure, /sys/class/net/<dev>/tun_flags has IFF_BACKPRESSURE set, without it the flag stays clear. Builds without warnings with and without IFF_BACKPRESSURE in the headers, and make check passes.

[1] https://lore.kernel.org/netdev/[email protected]/T/#u
[2] https://cni.etit.tu-dortmund.de/storages/cni-etit/r/Research/Publications/2025/Gebauer_2025_VTCFall/Gebauer_VTCFall2025_AuthorsVersion.pdf
[3] https://lore.kernel.org/netdev/[email protected]/

Assisted-by Claude:claude-opus-5-5
---
   doc/man-sections/advanced-options.rst |  7 +++++++
   src/openvpn/options.c                 | 12 ++++++++++++
   src/openvpn/tun.c                     |  7 +++++++
   src/openvpn/tun.h                     |  1 +
   4 files changed, 27 insertions(+)
doc/man-sections/advanced-options.rst +6 -0
index 32008d58f..c578a5c2c 100644
@@ -100,6 +100,13 @@ used when debugging or testing out special usage scenarios.
     *(Linux only)* Set the TX queue length on the TUN/TAP interface.
     Currently defaults to operating system default.
   +--tun-backpressure
+  *(Linux only)* Set :code:`IFF_BACKPRESSURE` on the TUN/TAP interface.
+  When OpenVPN falls behind reading from the interface, the kernel then
+  stops the TX queue instead of dropping packets, so the attached qdisc
+  can apply its queue management. This can reduce throughput with many
+  parallel senders. Requires Linux 7.3 or later; older kernels ignore it.
+
   --disable-dco
     Disables the opportunistic use of data channel offloading if available.
     Without this option, OpenVPN will opportunistically use DCO mode if
src/openvpn/options.c +12 -0
index 8e0c6029e..241f3891c 100644
@@ -333,6 +333,8 @@ static const char usage_message[] =
       "                  via a VRF present on the system.\n"
   #endif
       "--txqueuelen n  : Set the tun/tap TX queue length to n (Linux only).\n"
+    "--tun-backpressure : Apply qdisc backpressure instead of dropping packets\n"
+    "                  on the tun/tap device (Linux only).\n"
       "--mlock         : Disable Paging -- ensures key material and tunnel\n"
       "                  data will never be written to disk.\n"
       "--up cmd        : Run command cmd after successful tun device open.\n"
@@ -5129,6 +5131,16 @@ add_option(struct options *options, char *p[], bool is_inline, const char *file,
   #else
           msg(msglevel, "--txqueuelen not supported on this OS");
           goto err;
+#endif
+    }
+    else if (streq(p[0], "tun-backpressure") && !p[1])
+    {
+        VERIFY_PERMISSION(OPT_P_GENERAL);
+#if defined(TARGET_LINUX) && defined(IFF_BACKPRESSURE)
+        options->tuntap_options.backpressure = true;
+#else
+        msg(msglevel, "--tun-backpressure not supported on this platform");
+        goto err;
   #endif
       }
       else if (streq(p[0], "shaper") && p[1] && !p[2])
src/openvpn/tun.c +6 -0
index fdd13ae7e..5d6184e55 100644
@@ -2100,6 +2100,13 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
           ifr.ifr_flags |= IFF_ONE_QUEUE;
   #endif
   +#ifdef IFF_BACKPRESSURE
+        if (tt->options.backpressure)
+        {
+            ifr.ifr_flags |= IFF_BACKPRESSURE;
+        }
+#endif
+
           /*
            * Figure out if tun or tap device
            */
src/openvpn/tun.h +0 -1
index 61fe943b0..bd2107a78 100644
--- a/src/openvpn/tun.h
Quoted 9 lines

src/openvpn/tun.h struct tuntap_options · line 155

Quoted 8 lines

+++ b/src/openvpn/tun.h

src/openvpn/tun.h +1 -0
@@ -150,6 +150,7 @@ struct tuntap_options
   struct tuntap_options
   {
       int txqueuelen;
+    bool backpressure;
   };
     #else  /* if defined(_WIN32) || defined(TARGET_ANDROID) */

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#6 lore raw
Quoted 53 lines · Simon Schippers
Quoted 5 lines · Antonio Quartulli
Quoted 4 lines · Simon Schippers
Quoted 3 lines

Inside the linux kernel this works reasonably well.
We are just playing with several of this knobs in DCO at the moment.

Quoted 7 lines
Quoted 2 lines

I see. The ovpn driver never calls netif_tx_stop_queue(), so DCO has no qdisc backpressure either, right?

I think Ralf gave a pretty clear explanation of the status here :-) Adding queue comes with various problems.

Bufferbloat to start with.

I understand it now, thanks Ralf!

Quoted 28 lines
Quoted 20 lines
Quoted 14 lines
Quoted 8 lines

Our paper [2] evaluated this with OpenVPN: over a 120 ms RTT link between Germany and the USA, TCP throughput without the patch was up to 36% worse, and with it no retransmissions occurred. With higher latencies, throughput without the patch can be even worse.

Quoted 5 lines

Unfortunately, stopping and waking the queue can reduce throughput with many parallel senders: in a synthetic test with eight iperf3 senders, throughput dropped from 13.5 to 9.13 Gbit/s [3]. The flag is therefore disabled by default and can be enabled with the new --tun-backpressure option.

Quoted 5 lines

Given what you just said above, don't you think users will normally want this off all the time?

A VPN tunnel spends most of its time forwarding multiple streams from the host (in case of a roadwarrior setup) or from its LAN clients (in case of a VPN client installed on a router).

Do you foresee any reasonable scenario when a user would enable this flag and keep it on all the time?

Quoted 7 lines

I think most users should. The TUN/TAP device is usually not the bottleneck, the encryption or the network is. Dropping packets in the TUN/TAP driver for no good reason hurts real-world TCP throughput, as shown in our paper [1] (it has an old implementation). That is why users often raise the queue length (--txqueuelen in OpenVPN). This mostly fixes the throughput, but causes bufferbloat. Also, the qdisc's ECN marking and flow fairness only work with IFF_BACKPRESSURE.

Quoted 5 lines

The internet is going towards "avoid bufferbloat, even if it costs a little throughput" and to be honest I strongly agree here.

On top of that, if people wants performance on Linux, they should just switch to DCO - that's where our effort is going nowadays.

Adding more complexity for tun, only for linux and only for a very small niche is not really acceptable. Especially if complexity comes with yet another option knob.

I am not sure if I understand correctly. Wouldn't simply enabling it without a new OpenVPN option be fine then?

Quoted 6 lines
#ifdef IFF_BACKPRESSURE
     ifr.ifr_flags |= IFF_BACKPRESSURE;

#endif

From my POV, this would reduce complexity. Users like me would no longer
have to raise --txqueuelen (and get bufferbloat) to get full throughput.

This would be better, yes.

But earlier you said that with many flows/senders (which is often the case in a VPN scenario, isn't it?) throughput is reduced.

So aren't we going to reduce throughput for most people by doing this?

On top of this, why not using DCO to get better performance overall? (throughput, CPU usage, etc..)

Regards,

Signature · 8 lines
Antonio Quartulli



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
#7 lore raw
Quoted 58 lines · Antonio Quartulli
Quoted 57 lines · Simon Schippers
Quoted 5 lines · Antonio Quartulli
Quoted 4 lines · Simon Schippers
Quoted 3 lines

Inside the linux kernel this works reasonably well.
We are just playing with several of this knobs in DCO at the moment.

Quoted 7 lines
Quoted 2 lines

I see. The ovpn driver never calls netif_tx_stop_queue(), so DCO has no qdisc backpressure either, right?

I think Ralf gave a pretty clear explanation of the status here :-) Adding queue comes with various problems.

Bufferbloat to start with.

I understand it now, thanks Ralf!

Quoted 28 lines
Quoted 20 lines
Quoted 14 lines
Quoted 8 lines

Our paper [2] evaluated this with OpenVPN: over a 120 ms RTT link between Germany and the USA, TCP throughput without the patch was up to 36% worse, and with it no retransmissions occurred. With higher latencies, throughput without the patch can be even worse.

Quoted 5 lines

Unfortunately, stopping and waking the queue can reduce throughput with many parallel senders: in a synthetic test with eight iperf3 senders, throughput dropped from 13.5 to 9.13 Gbit/s [3]. The flag is therefore disabled by default and can be enabled with the new --tun-backpressure option.

Quoted 5 lines

Given what you just said above, don't you think users will normally want this off all the time?

A VPN tunnel spends most of its time forwarding multiple streams from the host (in case of a roadwarrior setup) or from its LAN clients (in case of a VPN client installed on a router).

Do you foresee any reasonable scenario when a user would enable this flag and keep it on all the time?

Quoted 7 lines

I think most users should. The TUN/TAP device is usually not the bottleneck, the encryption or the network is. Dropping packets in the TUN/TAP driver for no good reason hurts real-world TCP throughput, as shown in our paper [1] (it has an old implementation). That is why users often raise the queue length (--txqueuelen in OpenVPN). This mostly fixes the throughput, but causes bufferbloat. Also, the qdisc's ECN marking and flow fairness only work with IFF_BACKPRESSURE.

Quoted 5 lines

The internet is going towards "avoid bufferbloat, even if it costs a little throughput" and to be honest I strongly agree here.

On top of that, if people wants performance on Linux, they should just switch to DCO - that's where our effort is going nowadays.

Adding more complexity for tun, only for linux and only for a very small niche is not really acceptable. Especially if complexity comes with yet another option knob.

I am not sure if I understand correctly. Wouldn't simply enabling it without a new OpenVPN option be fine then?

#ifdef IFF_BACKPRESSURE
     ifr.ifr_flags |= IFF_BACKPRESSURE;

#endif

Quoted 6 lines
Quoted 2 lines

From my POV, this would reduce complexity. Users like me would no longer
have to raise --txqueuelen (and get bufferbloat) to get full throughput.

This would be better, yes.

But earlier you said that with many flows/senders (which is often the case in a VPN scenario, isn't it?) throughput is reduced.

In that measurement, eight senders on different CPUs pushed around 10 Gbit/s to a QEMU VM, where the packets are just passed on. There, the TUN path itself uses most of the CPU, so the extra work of netif_tx_stop_queue() and netif_tx_wake_queue() shows up, also because each stop/wake has to reach the other CPUs.

Quoted 2 lines

So aren't we going to reduce throughput for most people by doing this?

I don't think so. With a VPN, the encryption or the network is the bottleneck, far below that rate, and the stop/wake cost is small compared to encrypting a packet.

I could run benchmarks if you want..

Quoted 3 lines

On top of this, why not using DCO to get better performance overall? (throughput, CPU usage, etc..)

Yes, DCO is the better choice when it is available.

Quoted 5 lines

Regards,

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#8 lore raw

Hi,

Quoted 1 line · Simon Schippers

Yes, DCO is the better choice when it is available.

This should generally be available on everything that has IFF_BACKPRESSURE, just sayin' ;-)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

#9 lore raw

PATCH v2 1/1 tun: set IFF_BACKPRESSURE on Linux

In reply to Simon Schippers

When the internal ring of a TUN/TAP device is full, the kernel silently drops packets, bypassing any qdisc. TCP then sees loss, retransmits and shrinks its congestion window.

My series "tun/tap & vhost-net: apply qdisc backpressure on full ptr_ring to reduce TX drops" [1] adds IFF_BACKPRESSURE in Linux 7.3 (commit d00c7369ef24 "tun/tap & vhost-net: stop tail-drop when IFF_BACKPRESSURE is set"). It stops the TX queue instead, so the qdisc holds the packets and applies its AQM and fairness.

Our paper [2] evaluated this with OpenVPN: over a 120 ms RTT link between Germany and the USA, TCP throughput without the patch was up to 36% worse, and with it no retransmissions occurred. With higher latencies, throughput without the patch can be even worse.

Stopping and waking the queue costs CPU time, which reduced throughput in a synthetic test with eight iperf3 senders into a QEMU VM on a Ryzen 9 9950X [3]. With OpenVPN, the encryption is the bottleneck instead. A benchmark on the same CPU with eight iperf3 streams through OpenVPN between two network namespaces [4] gives these means over 40 runs of 30 s, with the flag off and on (drops: TX drops of the client TUN device, retr: TCP retransmits):

txqueuelen off Mbit/s on Mbit/s change off drops on drops off retr on retr

         500         3971         3952    -0.5%      40226          0      36624        531
        5000         4005         3923    -2.1%       1358          0        658          0

The throughput difference is within the run-to-run standard deviation of 340 to 380 Mbit/s (about 9%), while the TUN drops are gone and the retransmits nearly so. The flag is therefore always set.

The flag is only set when the headers define IFF_BACKPRESSURE, and older kernels ignore it. The DCO path uses no TUN device and is unaffected.

[1] https://lore.kernel.org/netdev/[email protected]/T/#u
[2] https://cni.etit.tu-dortmund.de/storages/cni-etit/r/Research/Publications/2025/Gebauer_2025_VTCFall/Gebauer_VTCFall2025_AuthorsVersion.pdf
[3] https://lore.kernel.org/netdev/[email protected]/
[4] https://github.com/simoschip2000/openvpn-bench

Assisted-by Claude:claude-opus-5-5

---
v2:
- Always set the flag instead of adding a --tun-backpressure option, as discussed with Antonio.
- Add OpenVPN benchmark results.

 src/openvpn/tun.c | 4 ++++
 1 file changed, 4 insertions(+)
src/openvpn/tun.c +4 -0
index fdd13ae7e..85daefd10 100644
@@ -2100,6 +2100,10 @@ open_tun(const char *dev, const char *dev_type, const char *dev_node, struct tun
         ifr.ifr_flags |= IFF_ONE_QUEUE;
 #endif
 
+#ifdef IFF_BACKPRESSURE
+        ifr.ifr_flags |= IFF_BACKPRESSURE;
+#endif
+
         /*
          * Figure out if tun or tap device
          */
Signature · 8 lines
2.43.0



_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Acked-by on v2 1/1
#10 lore raw

[Openvpn-devel] [PATCH applied] Re: tun: set IFF_BACKPRESSURE on Linux

That one looks good. I was very reluctant on the v1, because we already have too many ill-understood and hard-to-test options - but generally having a backpressure mechanism if userspace is slow so other parts of the network can know "send slower" (and/or apply QoS) is a desirable part, so let's just turn it on when there.

This said, userland will always be slower than DCO, and there is no improvement to be made to keep up...

Since this is very localized, and still useful, I decided that it makes sense to have in 2.7 as "mini feature".

Your patch has been applied to the master and release/2.7 branch.

commit 0107bd9f267b3aaa5c8b15854610a11d4d414856 (master) commit f82875018b8a880e0b7d8241e988624073144421 (release/2.7)

Author: Simon Schippers
Date:   Fri Oct 30 12:18:06 2026 +0100

tun: set IFF_BACKPRESSURE on Linux

Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg40320.html

--
kind regards,

Gert Doering

_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel