[Openvpn-devel,03/25] dco: use specific metric when installing routes

Message ID 20220624083809.23487-4-a@unstable.cc
State Changes Requested
Headers show
Series
  • ovpn-dco: introduce data-channel offload support
Related show

Commit Message

Antonio Quartulli June 24, 2022, 8:37 a.m.
When using DCO iroutes and routes all live in the same routing table,
However, the latter should always come after the former.

for this reason assign a default metric of 200 to routes. iroutes will
later get a metric of 100.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
 src/openvpn/dco.h  |  2 ++
 src/openvpn/init.c | 10 ++++++++++
 2 files changed, 12 insertions(+)

Comments

Arne Schwabe June 27, 2022, 11:04 a.m. | #1
Am 24.06.22 um 10:37 schrieb Antonio Quartulli:
> When using DCO iroutes and routes all live in the same routing table,
> However, the latter should always come after the former.
> 
> for this reason assign a default metric of 200 to routes. iroutes will
> later get a metric of 100.

Can you also add documentation of this? (if it is not coming in a later 
patch)

Acked-By: Arne Schwabe <arne@rfc2549.org>

Patch

diff --git a/src/openvpn/dco.h b/src/openvpn/dco.h
index dcadba78..063e5028 100644
--- a/src/openvpn/dco.h
+++ b/src/openvpn/dco.h
@@ -38,6 +38,8 @@  struct event_set;
 struct options;
 struct tuntap;
 
+#define DCO_DEFAULT_METRIC  200
+
 #if defined(ENABLE_DCO)
 
 /**
diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index 638fd10c..f586bfc7 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -1385,6 +1385,11 @@  do_init_route_list(const struct options *options,
     int dev = dev_type_enum(options->dev, options->dev_type);
     int metric = 0;
 
+    if (dco_enabled(options))
+    {
+        metric = DCO_DEFAULT_METRIC;
+    }
+
     if (dev == DEV_TYPE_TUN && (options->topology == TOP_NET30 || options->topology == TOP_P2P))
     {
         gw = options->ifconfig_remote_netmask;
@@ -1421,6 +1426,11 @@  do_init_route_ipv6_list(const struct options *options,
     const char *gw = NULL;
     int metric = -1;            /* no metric set */
 
+    if (dco_enabled(options))
+    {
+        metric = DCO_DEFAULT_METRIC;
+    }
+
     gw = options->ifconfig_ipv6_remote;         /* default GW = remote end */
     if (options->route_ipv6_default_gateway)
     {