Tunnel don't fragment bit configurable
authorHans Dedecker <dedeckeh@gmail.com>
Tue, 19 Nov 2013 11:17:06 +0000 (12:17 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 8 Dec 2013 17:43:51 +0000 (18:43 +0100)
Make tunnel don't fragment bit configurable via UCI

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

index 58210a6d3d519a27a8c55eaf6e95f3786d8e7ca2..dae98b0aa8cc324d44e03086ed8300dc9f1cacd0 100644 (file)
@@ -1418,11 +1418,11 @@ out:
        return ret;
 }
 
-
 int system_add_ip_tunnel(const char *name, struct blob_attr *attr)
 {
        struct blob_attr *tb[__TUNNEL_ATTR_MAX];
        struct blob_attr *cur;
+       bool set_df = true;
        const char *str;
 
        system_del_ip_tunnel(name);
@@ -1434,10 +1434,13 @@ int system_add_ip_tunnel(const char *name, struct blob_attr *attr)
                return -EINVAL;
        str = blobmsg_data(cur);
 
+       if ((cur = tb[TUNNEL_ATTR_DF]))
+               set_df = blobmsg_get_bool(cur);
+
        unsigned int ttl = 0;
        if ((cur = tb[TUNNEL_ATTR_TTL])) {
                ttl = blobmsg_get_u32(cur);
-               if (ttl > 255)
+               if (ttl > 255 || (!set_df && ttl))
                        return -EINVAL;
        }
 
@@ -1451,14 +1454,13 @@ int system_add_ip_tunnel(const char *name, struct blob_attr *attr)
                        link = iface->l3_dev.dev->ifindex;
        }
 
-
        if (!strcmp(str, "sit")) {
                struct ip_tunnel_parm p = {
                        .link = link,
                        .iph = {
                                .version = 4,
                                .ihl = 5,
-                               .frag_off = htons(IP_DF),
+                               .frag_off = set_df ? htons(IP_DF) : 0,
                                .protocol = IPPROTO_IPV6,
                                .ttl = ttl
                        }
index 1452f059b54b0e27b927f2673b6dbe22506dcfcb..3dd90b42505b1a4e7d64eee52a33ae3681d07652 100644 (file)
--- a/system.c
+++ b/system.c
@@ -20,6 +20,7 @@ static const struct blobmsg_policy tunnel_attrs[__TUNNEL_ATTR_MAX] = {
        [TUNNEL_ATTR_LOCAL] = { .name = "local", .type = BLOBMSG_TYPE_STRING },
        [TUNNEL_ATTR_REMOTE] = { .name = "remote", .type = BLOBMSG_TYPE_STRING },
        [TUNNEL_ATTR_MTU] = { .name = "mtu", .type = BLOBMSG_TYPE_INT32 },
+       [TUNNEL_ATTR_DF] = { .name = "df", .type = BLOBMSG_TYPE_BOOL },
        [TUNNEL_ATTR_TTL] = { .name = "ttl", .type = BLOBMSG_TYPE_INT32 },
        [TUNNEL_ATTR_6RD_PREFIX] = {.name =  "6rd-prefix", .type = BLOBMSG_TYPE_STRING },
        [TUNNEL_ATTR_6RD_RELAY_PREFIX] = { .name = "6rd-relay-prefix", .type = BLOBMSG_TYPE_STRING },
index e1d35c9206477ab418a5d811c8bdb33a6864e27c..ff83a1c93a2dbab107cc153c2e64c7b1162e956d 100644 (file)
--- a/system.h
+++ b/system.h
@@ -26,6 +26,7 @@ enum tunnel_param {
        TUNNEL_ATTR_REMOTE,
        TUNNEL_ATTR_LOCAL,
        TUNNEL_ATTR_MTU,
+       TUNNEL_ATTR_DF,
        TUNNEL_ATTR_TTL,
        TUNNEL_ATTR_6RD_PREFIX,
        TUNNEL_ATTR_6RD_RELAY_PREFIX,