From patchwork Tue Mar 14 20:36:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 738924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3vjRPZ5N2gz9s06 for ; Wed, 15 Mar 2017 07:37:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="urenxzVI"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kKBHma3Q"; dkim-atps=neutral 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=MxPpAi9OhCy/c8b1N6jT2dUmDT6zJOgaLSRcJ12xSDs=; b=urenxzVIbUSf6C NsomHQChuYOq6aTYF8IDWdlTFVHVR+oRolo7FQXMvBscD3TK5qDzzGVr1b+ALlW0via0s6AGScB7H paRj7VbCuZBUiMb68a+WftSCxQxyOimC1vBo5Ezl/jFnUMd0d5shWCtS/e39gt6vpe9wAGMWHWWdX 8VglXj4HXKtjvdT9AVBUai+o9WopDZ1QuYpLAC2zlrK9zf4uHrOXygAOrtTHBsWEKa1t7Z9nPCuy3 YntCIMEEKNXwo+jJqqTQxAaGxTNb/cNfxmJAOCc+RO+MMz9aH+N/YdmTYM5QOHH2jUXG1EOkQnWat uEuCJh5zpVZhHSRAlYEg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cntBx-0006tO-LS; Tue, 14 Mar 2017 20:37:13 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cntBs-0006rz-IU for lede-dev@lists.infradead.org; Tue, 14 Mar 2017 20:37:10 +0000 Received: by mail-wr0-x243.google.com with SMTP id u48so25382788wrc.1 for ; Tue, 14 Mar 2017 13:36:47 -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=l9GKG+oByYGk3UhvEj746ZcDyuI2CBCneH3vZB3RTxs=; b=kKBHma3QndImH+UYVPZu0NrWpHRR/gEA8wf6WuBUf8ijWu66cs0JxBQM31NF0+1Mws //UamH/gOs2PSZFw7K0yyIAF9Y79yJyBcK0zmz+CIc0sGXdPMmwHZ4q8fZQBhcgdkp1p 4HifPzYyR+J/CA6x1L4JYvo1jUQlt2//oBAVjgFjd9Pl8flqzPLgR4QdwbacLZS3y0Sc IzImNtankLNaZH0hjLb4hkqFtvOZiIQUyAh9IWv+J4W5DTgSEz+XCjWsHrD/y5cPgPDg jqvNGDoYHi+CleD8E7+3oOjt+k0Hpr20Nb9LqZwTTxAlFwJL5WNo4Ctf7al1GSM/MFgJ SvaA== 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=l9GKG+oByYGk3UhvEj746ZcDyuI2CBCneH3vZB3RTxs=; b=NObSgSXf+G2bTvumVc/yjyjVMubD7j7TTsWJy8006aHgOJtFSX98Vf/jtkP156Ntjb HOXy8z4otV/EtYyt8rACGN+ak/h6BJkNE7XoCGflBAZENOqL1W03tJXY8dnzG/e2fiAR qNjJ/NY+xgyar2QfBd1kqFMj5rDTKJLDHdxdC55cly+oDWtiNTDMIshQxGH87R4x50Jz IU3vKpVm4jlkvMiLz7EYHC+8zskK24IabIznmqRP1WasDNIEmtT+LAoLpl2DPdU3Xhfc NN+GnxC2lwrCzEl6+pLDb807LlSNnA75UKJEu7TkJwGSTGsd2Vc5P48Fpey/NakGYUzx YT9g== X-Gm-Message-State: AMke39lpTlSpA5852jZsaHxwo52GCBZc4StXZcqZseFD9nbJDXvjA1Gw6jsdulnTpOdrBA== X-Received: by 10.223.151.138 with SMTP id s10mr37750238wrb.35.1489523805826; Tue, 14 Mar 2017 13:36:45 -0700 (PDT) Received: from linux-5g1g.lan (ptr-fvflmy8bncogcgbxomy.18120a2.ip6.access.telenet.be. [2a02:1812:1103:ff00:76df:bfff:feac:e5fa]) by smtp.gmail.com with ESMTPSA id u184sm1126898wmb.29.2017.03.14.13.36.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Mar 2017 13:36:44 -0700 (PDT) From: Hans Dedecker To: lede-dev@lists.infradead.org, nbd@nbd.name Date: Tue, 14 Mar 2017 21:36:38 +0100 Message-Id: <20170314203639.4236-1-dedeckeh@gmail.com> X-Mailer: git-send-email 2.12.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170314_133708_796348_1EB3852C X-CRM114-Status: GOOD ( 12.29 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:400c:c0c: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 -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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 Subject: [LEDE-DEV] [PATCH netifd 1/2] system-linux: parse gre specific settings as nested json data object X-BeenThere: lede-dev@lists.infradead.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: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Parse gre specific settings ikey, okey, icsum, ocsum, iseqno and oseqno as nested json data object Signed-off-by: Hans Dedecker --- system-linux.c | 48 +++++++++++++++++++++++++++++------------------- system.c | 14 ++++++++++++++ system.h | 11 +++++++++++ 3 files changed, 54 insertions(+), 19 deletions(-) diff --git a/system-linux.c b/system-linux.c index 8888047..b7297fd 100644 --- a/system-linux.c +++ b/system-linux.c @@ -2316,31 +2316,41 @@ static int system_add_gre_tunnel(const char *name, const char *kind, } } - if ((cur = tb[TUNNEL_ATTR_INFO]) && (blobmsg_type(cur) == BLOBMSG_TYPE_STRING)) { - uint8_t icsum, ocsum, iseqno, oseqno; - if (sscanf(blobmsg_get_string(cur), "%u,%u,%hhu,%hhu,%hhu,%hhu", - &ikey, &okey, &icsum, &ocsum, &iseqno, &oseqno) < 6) { - ret = -EINVAL; - goto failure; - } + if ((cur = tb[TUNNEL_ATTR_DATA])) { + struct blob_attr *tb_data[__GRE_DATA_ATTR_MAX]; + + blobmsg_parse(gre_data_attr_list.params, __GRE_DATA_ATTR_MAX, tb_data, + blobmsg_data(cur), blobmsg_len(cur)); - if (ikey) - iflags |= GRE_KEY; + if ((cur = tb_data[GRE_DATA_IKEY])) { + if ((ikey = blobmsg_get_u32(cur))) + iflags |= GRE_KEY; + } - if (okey) - oflags |= GRE_KEY; + if ((cur = tb_data[GRE_DATA_OKEY])) { + if ((okey = blobmsg_get_u32(cur))) + oflags |= GRE_KEY; + } - if (icsum) - iflags |= GRE_CSUM; + if ((cur = tb_data[GRE_DATA_ICSUM])) { + if (blobmsg_get_bool(cur)) + iflags |= GRE_CSUM; + } - if (ocsum) - oflags |= GRE_CSUM; + if ((cur = tb_data[GRE_DATA_OCSUM])) { + if (blobmsg_get_bool(cur)) + oflags |= GRE_CSUM; + } - if (iseqno) - iflags |= GRE_SEQ; + if ((cur = tb_data[GRE_DATA_ISEQNO])) { + if (blobmsg_get_bool(cur)) + iflags |= GRE_SEQ; + } - if (oseqno) - oflags |= GRE_SEQ; + if ((cur = tb[GRE_DATA_OSEQNO])) { + if (blobmsg_get_bool(cur)) + oflags |= GRE_SEQ; + } } if (v6) { diff --git a/system.c b/system.c index 52172c3..f899c7b 100644 --- a/system.c +++ b/system.c @@ -47,6 +47,20 @@ const struct uci_blob_param_list vxlan_data_attr_list = { .params = vxlan_data_attrs, }; +static const struct blobmsg_policy gre_data_attrs[__GRE_DATA_ATTR_MAX] = { + [GRE_DATA_IKEY] = { .name = "ikey", .type = BLOBMSG_TYPE_INT32 }, + [GRE_DATA_OKEY] = { .name = "okey", .type = BLOBMSG_TYPE_INT32 }, + [GRE_DATA_ICSUM] = { .name = "icsum", .type = BLOBMSG_TYPE_BOOL }, + [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 }, +}; + +const struct uci_blob_param_list gre_data_attr_list = { + .n_params = __GRE_DATA_ATTR_MAX, + .params = gre_data_attrs, +}; + void system_fd_set_cloexec(int fd) { #ifdef FD_CLOEXEC diff --git a/system.h b/system.h index 6501d15..14b1e53 100644 --- a/system.h +++ b/system.h @@ -48,7 +48,18 @@ enum vxlan_data { __VXLAN_DATA_ATTR_MAX }; +enum gre_data { + GRE_DATA_IKEY, + GRE_DATA_OKEY, + GRE_DATA_ICSUM, + GRE_DATA_OCSUM, + GRE_DATA_ISEQNO, + GRE_DATA_OSEQNO, + __GRE_DATA_ATTR_MAX +}; + extern const struct uci_blob_param_list vxlan_data_attr_list; +extern const struct uci_blob_param_list gre_data_attr_list; enum bridge_opt { /* stp and forward delay always set */