system-linux: enable by default ignore encaplimit for grev6 tunnels
authorHans Dedecker <dedeckeh@gmail.com>
Wed, 17 Oct 2018 07:35:11 +0000 (09:35 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Wed, 17 Oct 2018 07:58:59 +0000 (09:58 +0200)
Similar as for ip6 tunnels ignore encaplimit by default as not all ISPs
support the destination option header containing the tunnel encapsulation
limit resulting into broken connectivity

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
system-linux.c
system.c
system.h

index 8cfad3c848e6a415a4b4a39985b2bfe4ed588279..60f55ee5ac5e5c5194c73e74dcc0489e9c0c9660 100644 (file)
@@ -2456,10 +2456,11 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
        struct nl_msg *nlm;
        struct ifinfomsg ifi = { .ifi_family = AF_UNSPEC, };
        struct blob_attr *cur;
-       uint32_t ikey = 0, okey = 0, flags = 0, flowinfo = 0;
+       uint32_t ikey = 0, okey = 0, flowinfo = 0, flags6 = IP6_TNL_F_IGN_ENCAP_LIMIT;
        uint16_t iflags = 0, oflags = 0;
        uint8_t tos = 0;
        int ret = 0, ttl = 0;
+       unsigned encap_limit = 0;
 
        nlm = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_REPLACE | NLM_F_CREATE);
        if (!nlm)
@@ -2503,7 +2504,7 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
                                tos = uval;
                } else {
                        if (v6)
-                               flags |= IP6_TNL_F_USE_ORIG_TCLASS;
+                               flags6 |= IP6_TNL_F_USE_ORIG_TCLASS;
                        else
                                tos = 1;
                }
@@ -2544,6 +2545,23 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
                        if (blobmsg_get_bool(cur))
                                oflags |= GRE_SEQ;
                }
+
+               if ((cur = tb_data[GRE_DATA_ENCAPLIMIT])) {
+                       char *str = blobmsg_get_string(cur);
+
+                       if (strcmp(str, "ignore")) {
+                               char *e;
+
+                               encap_limit = strtoul(str, &e, 0);
+
+                               if (e == str || *e || encap_limit > 255) {
+                                       ret = -EINVAL;
+                                       goto failure;
+                               }
+
+                               flags6 &= ~IP6_TNL_F_IGN_ENCAP_LIMIT;
+                       }
+               }
        }
 
        if (v6) {
@@ -2563,13 +2581,15 @@ static int system_add_gre_tunnel(const char *name, const char *kind,
                        }
                        nla_put(nlm, IFLA_GRE_REMOTE, sizeof(in6buf), &in6buf);
                }
-               nla_put_u8(nlm, IFLA_GRE_ENCAP_LIMIT, 4);
+
+               if (!(flags6 & IP6_TNL_F_IGN_ENCAP_LIMIT))
+                       nla_put_u8(nlm, IFLA_GRE_ENCAP_LIMIT, encap_limit);
 
                if (flowinfo)
                        nla_put_u32(nlm, IFLA_GRE_FLOWINFO, flowinfo);
 
-               if (flags)
-                       nla_put_u32(nlm, IFLA_GRE_FLAGS, flags);
+               if (flags6)
+                       nla_put_u32(nlm, IFLA_GRE_FLAGS, flags6);
 
                if (!ttl)
                        ttl = 64;
index f96708dfb57a874f64baf89ff9954da3022edaeb..dd9ab50d6e7fb93235b1e25b413ab5150d252e89 100644 (file)
--- a/system.c
+++ b/system.c
@@ -52,6 +52,7 @@ static const struct blobmsg_policy gre_data_attrs[__GRE_DATA_ATTR_MAX] = {
        [GRE_DATA_OCSUM] = { .name = "ocsum", .type = BLOBMSG_TYPE_BOOL },
        [GRE_DATA_ISEQNO] = { .name = "iseqno", .type = BLOBMSG_TYPE_BOOL },
        [GRE_DATA_OSEQNO] = { .name = "oseqno", .type = BLOBMSG_TYPE_BOOL },
+       [GRE_DATA_ENCAPLIMIT] = { .name = "encaplimit", .type = BLOBMSG_TYPE_STRING },
 };
 
 const struct uci_blob_param_list gre_data_attr_list = {
index 683dc186afb71355060c5571e59019add45774c5..4d4cf6e443b38045866c9c93e2d81b8943b27713 100644 (file)
--- a/system.h
+++ b/system.h
@@ -53,6 +53,7 @@ enum gre_data {
        GRE_DATA_OCSUM,
        GRE_DATA_ISEQNO,
        GRE_DATA_OSEQNO,
+       GRE_DATA_ENCAPLIMIT,
        __GRE_DATA_ATTR_MAX
 };