summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--system-linux.c30
-rw-r--r--system.c1
-rw-r--r--system.h1
3 files changed, 27 insertions, 5 deletions
diff --git a/system-linux.c b/system-linux.c
index 8cfad3c..60f55ee 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -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;
diff --git a/system.c b/system.c
index f96708d..dd9ab50 100644
--- 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 = {
diff --git a/system.h b/system.h
index 683dc18..4d4cf6e 100644
--- 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
};