summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2016-12-23 15:52:32 +0100
committerFelix Fietkau <nbd@nbd.name>2016-12-24 10:51:58 +0100
commit0249d5f8515c13181d7995830f5a4a82eb3d70bd (patch)
treef81bdca213dac21a9f506c4535fa468395e5bbc1
parentedc15caac6c6d3b2d8ea17f98ecbaba81ba573dc (diff)
downloadnetifd-0249d5f8515c13181d7995830f5a4a82eb3d70bd.tar.gz
system-linux: Don't set gre tunnel ttl by default to 64 (#FS312)
As the ttl of a gre tunnel was set by default to 64 the gre tunnel failed to get active if don't fragment was disabled as setting nopmtudisc and ttl is incompatible. Fix this by setting the default ttl value after don't fragment and ttl config values have been parsed. Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--system-linux.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/system-linux.c b/system-linux.c
index 67fa2b1..52a1c17 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -2127,7 +2127,7 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
uint32_t ikey = 0, okey = 0, flags = 0, flowinfo = 0;
uint16_t iflags = 0, oflags = 0;
uint8_t tos = 0;
- int ret = 0, ttl = 64;
+ int ret = 0, ttl = 0;
nlm = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_CREATE);
if (!nlm)
@@ -2155,8 +2155,6 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
if ((cur = tb[TUNNEL_ATTR_TTL]))
ttl = blobmsg_get_u32(cur);
- nla_put_u8(nlm, IFLA_GRE_TTL, ttl);
-
if ((cur = tb[TUNNEL_ATTR_TOS])) {
char *str = blobmsg_get_string(cur);
if (strcmp(str, "inherit")) {
@@ -2230,6 +2228,9 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
if (flags)
nla_put_u32(nlm, IFLA_GRE_FLAGS, flags);
+
+ if (!ttl)
+ ttl = 64;
} else {
struct in_addr inbuf;
bool set_df = true;
@@ -2265,17 +2266,23 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
if ((cur = tb[TUNNEL_ATTR_DF]))
set_df = blobmsg_get_bool(cur);
- /* ttl !=0 and nopmtudisc are incompatible */
- if (ttl && !set_df) {
- ret = -EINVAL;
- goto failure;
- }
+ if (!set_df) {
+ /* ttl != 0 and nopmtudisc are incompatible */
+ if (ttl) {
+ ret = -EINVAL;
+ goto failure;
+ }
+ } else if (!ttl)
+ ttl = 64;
nla_put_u8(nlm, IFLA_GRE_PMTUDISC, set_df ? 1 : 0);
nla_put_u8(nlm, IFLA_GRE_TOS, tos);
}
+ if (ttl)
+ nla_put_u8(nlm, IFLA_GRE_TTL, ttl);
+
if (oflags)
nla_put_u16(nlm, IFLA_GRE_OFLAGS, oflags);