[LEDE-DEV] [PATCH netifd] system-linux: Don't set gre tunnel ttl by default to 64 (#FS312)

Hans Dedecker dedeckeh at gmail.com
Fri Dec 23 06:52:32 PST 2016


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 at gmail.com>
---
 system-linux.c | 23 +++++++++++++++--------
 1 file 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);
 
-- 
1.9.1




More information about the Lede-dev mailing list