From patchwork Tue May 29 20:40:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 922375 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cPjDYH8N"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QTESGRW7"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40wQcc5G1Mz9s0q for ; Wed, 30 May 2018 06:41:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=gephzNbEmGTM8HWhj0OxQfKs5ezMhnXjHf6DdTn1Vxg=; b=cPjDYH8NtxJuLb YhinMuFDAm7mXezdHoXoSPkNYfIBegT1dwDw0vRc0JtHeAU7OZDYdqi+K1FkTiiezrnLzbuUy2EhH B0HbP3+uVG1FrM9geWtgsGzLgbL3UEVb2tofDsfrEkDBD6Ek2ZxB9caJuSnBNE0YQns1z5V59eF/b mHjRSmElp1Vzm2XpV9jkiNHwMWNWmEpXRiqMTjpeRz/Vzpux3KOT8TE889AN/1lJDn8IZznvSzAIh 8Uy5UA2vONDRexcDgZBYcUymU8e+0DhmobNzZZDd2+UL2yrgGGWzCy3IzaCajSHU950Fd0WJYiuDZ xy9k0OMFexwl2Jui1B4g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNlQn-0001pg-39; Tue, 29 May 2018 20:41:21 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fNlPk-0008G2-2b for openwrt-devel@lists.openwrt.org; Tue, 29 May 2018 20:40:29 +0000 Received: by mail-wm0-x243.google.com with SMTP id f8-v6so43838101wmc.4 for ; Tue, 29 May 2018 13:40:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Hnxe5JJQRHMX3n92J0S6cd4d/ywAOCrihFGv7IrQcZE=; b=QTESGRW7/usuKI2RMQr2L7MNfdDj7znXb6eL2mNs2PMwZwBVnVX9SW/Am17XwvyXGs 1iJNBYPuaXNa0Bs1l6/YyNuQixwo9R2ZMkPgTdmMj8elWQVEU0FKWH5SCqN/Xes76+k7 lZ2XxEGrcXcs7mTcCvt7hqsbeOliaK8jtWqW1HpDXpis406y6gjXjIVYJmt/49vxTaxq IqQ4PRRI6dSqQ7T8jcsFrWspVxGMgiUNg2DYM/PuLuyydMK2W/PGLkOoBn+AG+NRqqH6 OTD/JcvL5MLJIMQ28lHGJ4u1ApBiItj2Ji/XWjJSYkRaAe2gYQjT1uY9cysaeu+OSnJ3 6RiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Hnxe5JJQRHMX3n92J0S6cd4d/ywAOCrihFGv7IrQcZE=; b=VnUQr67nektUoaz7HLQtgLezbaR5pR7Iy9uRpoM8FyJg6WZ+/6QA6v7sfzWSY4xBCv +SQ+uPwNeOL+pO9vnaV/XCqjBgFValA1Mkpp+J1M3vjOXzuRobTyKFdEp7vBojdvOD2Q LJgwcMhJ32SkipzWQ+tVHUa06aEeqZs35UC1uQItzhuPELtn2kmK2nc93OA3mYdH3SOO JWck4vQEbDiarY4XcV92R9/ReRS5/bE2D7XG1vqUh9az8O5SHscrWNiHW5nOI94hcq1S SNkEoIXaFU4tQjRVaKQo1cMtxyQmoX5SDnsQoa7OqVF92l2WI30kgBSxWuDLR4/zLUZq vNjg== X-Gm-Message-State: ALKqPwd/4fU6eOw2e3wRZDUw6DJumdHmDXqdFm+A0jJvGOodB1hxyfFe Nm8FLLAjdQXzl5hv5gqg0cxVRA== X-Google-Smtp-Source: ADUXVKJGVCtZIImAZqw2b5u4yTBx5AxqxD2+rdqwMRLqggCOK38hF+4BMxEHsJg1tdNpZKKZOWtg0A== X-Received: by 2002:a50:94ce:: with SMTP id t14-v6mr390673eda.146.1527626403882; Tue, 29 May 2018 13:40:03 -0700 (PDT) Received: from linux-5g1g.lan (ptr-fvl7vteb6vjd542m2s0.18120a2.ip6.access.telenet.be. [2a02:1812:1128:fb00:ffc7:aef4:4f01:1990]) by smtp.gmail.com with ESMTPSA id k9-v6sm9942472edh.61.2018.05.29.13.40.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 13:40:03 -0700 (PDT) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org Date: Tue, 29 May 2018 22:40:00 +0200 Message-Id: <20180529204000.562-1-dedeckeh@gmail.com> X-Mailer: git-send-email 2.16.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180529_134016_164189_A5A37B5F X-CRM114-Status: GOOD ( 14.01 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c09:0:0:0:243 listed in] [list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dedeckeh[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [PATCH netifd] system-linux: make encaplimit configurable for ip6 tunnels (FS#1501) X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans Dedecker MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Make encapsulation limit of IP6 tunnels configurable for the ds-lite/map proto shell handlers as not all ISPs support the destination option header containing the tunnel encapsulation limit value as reported in FS#1501. The IP6 tunnel specific setting encaplimit is parsed as a nested json data object; setting it to ignore disables the insertion of the destination option header while a value from 0 till 255 sets the tunnel encapsulation limit accordingly in the destination option header. Signed-off-by: Hans Dedecker --- system-linux.c | 51 +++++++++++++++++++++++++++++++++------------------ system.c | 10 ++++++++++ system.h | 7 +++++++ 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/system-linux.c b/system-linux.c index 2a108e2..0127b01 100644 --- a/system-linux.c +++ b/system-linux.c @@ -2300,7 +2300,6 @@ static int system_add_ip6_tunnel(const char *name, const unsigned int link, nla_put_u8(nlm, IFLA_IPTUN_PROTO, IPPROTO_IPIP); nla_put_u8(nlm, IFLA_IPTUN_TTL, (ttl) ? ttl : 64); - nla_put_u8(nlm, IFLA_IPTUN_ENCAP_LIMIT, 4); struct in6_addr in6buf; if ((cur = tb[TUNNEL_ATTR_LOCAL])) { @@ -2319,26 +2318,41 @@ static int system_add_ip6_tunnel(const char *name, const unsigned int link, nla_put(nlm, IFLA_IPTUN_REMOTE, sizeof(in6buf), &in6buf); } -#ifdef IFLA_IPTUN_FMR_MAX if ((cur = tb[TUNNEL_ATTR_DATA])) { - struct blob_attr *dcur; - unsigned drem, fmrcnt = 0; - struct nlattr *fmrs = nla_nest_start(nlm, IFLA_IPTUN_FMRS); + struct blob_attr *tb_data[__IPIP6_DATA_ATTR_MAX]; - if (!fmrs) { - ret = -ENOMEM; - goto failure; - } + blobmsg_parse(ipip6_data_attr_list.params, __IPIP6_DATA_ATTR_MAX, tb_data, + blobmsg_data(cur), blobmsg_len(cur)); - blobmsg_for_each_attr(dcur, cur, drem) { - if (blobmsg_type(dcur) != BLOBMSG_TYPE_ARRAY || - strcmp(blobmsg_name(dcur), "fmrs") || - blobmsg_check_array(dcur, BLOBMSG_TYPE_UNSPEC) <= 0) - continue; + if ((cur = tb_data[IPIP6_DATA_ENCAPLIMIT])) { + char *str = blobmsg_get_string(cur); + + if (strcmp(str, "ignore")) { + char *e; + unsigned encap_limit = strtoul(str, &e, 0); + + if (e == str || *e || encap_limit > 255) { + ret = -EINVAL; + goto failure; + } + nla_put_u8(nlm, IFLA_IPTUN_ENCAP_LIMIT, encap_limit); + } else + nla_put_u32(nlm, IFLA_IPTUN_FLAGS, IP6_TNL_F_IGN_ENCAP_LIMIT); + } + +#ifdef IFLA_IPTUN_FMR_MAX + if ((cur = tb_data[IPIP6_DATA_FMRS])) { struct blob_attr *rcur; - unsigned rrem; - blobmsg_for_each_attr(rcur, dcur, rrem) { + unsigned rrem, fmrcnt = 0; + struct nlattr *fmrs = nla_nest_start(nlm, IFLA_IPTUN_FMRS); + + if (!fmrs) { + ret = -ENOMEM; + goto failure; + } + + blobmsg_for_each_attr(rcur, cur, rrem) { struct blob_attr *tb_fmr[__FMR_DATA_ATTR_MAX], *tb_cur; struct in6_addr ip6prefix; struct in_addr ip4prefix; @@ -2390,10 +2404,11 @@ static int system_add_ip6_tunnel(const char *name, const unsigned int link, nla_nest_end(nlm, rule); } + + nla_nest_end(nlm, fmrs); } - nla_nest_end(nlm, fmrs); - } #endif + } nla_nest_end(nlm, infodata); nla_nest_end(nlm, linkinfo); diff --git a/system.c b/system.c index e236e96..f96708d 100644 --- a/system.c +++ b/system.c @@ -79,6 +79,16 @@ const struct uci_blob_param_list sixrd_data_attr_list = { .params = sixrd_data_attrs, }; +static const struct blobmsg_policy ipip6_data_attrs[__SIXRD_DATA_ATTR_MAX] = { + [IPIP6_DATA_ENCAPLIMIT] = { .name = "encaplimit", .type = BLOBMSG_TYPE_STRING }, + [IPIP6_DATA_FMRS] = { .name = "fmrs", .type = BLOBMSG_TYPE_ARRAY }, +}; + +const struct uci_blob_param_list ipip6_data_attr_list = { + .n_params = __IPIP6_DATA_ATTR_MAX, + .params = ipip6_data_attrs, +}; + static const struct blobmsg_policy fmr_data_attrs[__FMR_DATA_ATTR_MAX] = { [FMR_DATA_PREFIX6] = { .name = "prefix6", .type = BLOBMSG_TYPE_STRING }, [FMR_DATA_PREFIX4] = { .name = "prefix4", .type = BLOBMSG_TYPE_STRING }, diff --git a/system.h b/system.h index 371a524..683dc18 100644 --- a/system.h +++ b/system.h @@ -68,6 +68,12 @@ enum sixrd_data { __SIXRD_DATA_ATTR_MAX }; +enum ipip6_data { + IPIP6_DATA_ENCAPLIMIT, + IPIP6_DATA_FMRS, + __IPIP6_DATA_ATTR_MAX +}; + enum fmr_data { FMR_DATA_PREFIX6, FMR_DATA_PREFIX4, @@ -80,6 +86,7 @@ extern const struct uci_blob_param_list vxlan_data_attr_list; extern const struct uci_blob_param_list gre_data_attr_list; extern const struct uci_blob_param_list vti_data_attr_list; extern const struct uci_blob_param_list sixrd_data_attr_list; +extern const struct uci_blob_param_list ipip6_data_attr_list; extern const struct uci_blob_param_list fmr_data_attr_list; enum bridge_opt {