diff options
author | Lukas Märdian <lukas.maerdian@canonical.com> | 2021-02-24 16:01:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-24 16:01:37 +0100 |
commit | 6c8ed65df7c7f31280d5d27b67195a1e9a746e7a (patch) | |
tree | fc259a04ff0a16986ac8ab258a4d6544958d6f3e /src | |
parent | 1e0f223cc4d62338e5cceec5e98b25c3a4b5ed04 (diff) |
Added TTL option for tunnels (LP: #1846783) (#194)
Some protocols set the TTL field of the packet to 1; when passing through the tunnel, the packet is discarded. To solve the problem, the tunnel has the TTL option, but it was not in netplan.
According to https://bugs.launchpad.net/netplan/+bug/1846783 this is required for IPIP/SIT/GRE tunnels.
Co-authored-by: kev1989 <krupenevev@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/networkd.c | 2 | ||||
-rw-r--r-- | src/nm.c | 3 | ||||
-rw-r--r-- | src/parse.c | 1 | ||||
-rw-r--r-- | src/parse.h | 1 | ||||
-rw-r--r-- | src/validation.c | 2 |
5 files changed, 8 insertions, 1 deletions
diff --git a/src/networkd.c b/src/networkd.c index beb23a5..d548c35 100644 --- a/src/networkd.c +++ b/src/networkd.c @@ -142,6 +142,8 @@ write_tunnel_params(GString* s, const NetplanNetDefinition* def) g_string_append_printf(params, "Mode=%s\n", tunnel_mode_to_string(def->tunnel.mode)); g_string_append_printf(params, "Local=%s\n", def->tunnel.local_ip); g_string_append_printf(params, "Remote=%s\n", def->tunnel.remote_ip); + if (def->tunnel.ttl) + g_string_append_printf(params, "TTL=%u\n", def->tunnel.ttl); if (def->tunnel.input_key) g_string_append_printf(params, "InputKey=%s\n", def->tunnel.input_key); if (def->tunnel.output_key) @@ -401,7 +401,8 @@ write_tunnel_params(const NetplanNetDefinition* def, GString *s) g_string_append_printf(s, "mode=%d\n", def->tunnel.mode); g_string_append_printf(s, "local=%s\n", def->tunnel.local_ip); g_string_append_printf(s, "remote=%s\n", def->tunnel.remote_ip); - + if (def->tunnel.ttl) + g_string_append_printf(s, "ttl=%u\n", def->tunnel.ttl); if (def->tunnel.input_key) g_string_append_printf(s, "input-key=%s\n", def->tunnel.input_key); if (def->tunnel.output_key) diff --git a/src/parse.c b/src/parse.c index 3351696..9812209 100644 --- a/src/parse.c +++ b/src/parse.c @@ -2242,6 +2242,7 @@ static const mapping_entry_handler tunnel_def_handlers[] = { {"mode", YAML_SCALAR_NODE, handle_tunnel_mode}, {"local", YAML_SCALAR_NODE, handle_tunnel_addr, NULL, netdef_offset(tunnel.local_ip)}, {"remote", YAML_SCALAR_NODE, handle_tunnel_addr, NULL, netdef_offset(tunnel.remote_ip)}, + {"ttl", YAML_SCALAR_NODE, handle_netdef_guint, NULL, netdef_offset(tunnel.ttl)}, /* Handle key/keys for clarity in config: this can be either a scalar or * mapping of multiple keys (input and output) diff --git a/src/parse.h b/src/parse.h index 5193481..9cbc74d 100644 --- a/src/parse.h +++ b/src/parse.h @@ -359,6 +359,7 @@ struct net_definition { char *private_key; /* used for wireguard */ guint fwmark; guint port; + guint ttl; } tunnel; NetplanAuthenticationSettings auth; diff --git a/src/validation.c b/src/validation.c index 12a0231..3ec5859 100644 --- a/src/validation.c +++ b/src/validation.c @@ -205,6 +205,8 @@ validate_tunnel_grammar(NetplanNetDefinition* nd, yaml_node_t* node, GError** er return yaml_error(node, error, "%s: missing 'local' property for tunnel", nd->id); if (!nd->tunnel.remote_ip) return yaml_error(node, error, "%s: missing 'remote' property for tunnel", nd->id); + if (nd->tunnel.ttl && nd->tunnel.ttl > 255) + return yaml_error(node, error, "%s: 'ttl' property for tunnel must be in range [1...255]", nd->id); switch(nd->tunnel.mode) { case NETPLAN_TUNNEL_MODE_IPIP6: |