From patchwork Thu Jun 6 13:50:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Valentin?= X-Patchwork-Id: 1111146 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=none (p=none dis=none) header.from=marcant.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ah2e4C0M"; 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 45KRsj1LKHz9sND for ; Thu, 6 Jun 2019 23:51:53 +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:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9+eR+mLJn713H3OaoQYVOtY3Xj0wBlgO+9Zymxlamuc=; b=ah2e4C0Mcr1k08 TmhNREtFwY97gU+/uIXKABVReUelXhGBzqzE/z+v9Y293RSgBZ+rvXLCZ5PRONsBXuNtvqHNRg1DD S04gn0EXs8ryru+9PJpsUKuaWy7RJtUJqx6AWp2JHRGaqZ2vUWzHYU2bV+/bpq1ZolP5aYXYUzfUF raIh+ZrROWO8e8sCUtqIskZQJkGVaNadF8d/pDiJCJH92Nk9a/mddmw2dK/93yNuP53WTlgy4+Tws nwrzNxF1SJiJtqASiBASXIc4cLpXF/H8JXkC6sasX/m3o2L2ZpQRGSAmo6FSC6YvFLavtF4o32kjb 90h3Rh2bIGSaxbJG7ACg==; 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 1hYsnv-0000WV-7i; Thu, 06 Jun 2019 13:51:43 +0000 Received: from mail3.marcant.net ([217.14.160.188]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYsnP-0008IM-Un for openwrt-devel@lists.openwrt.org; Thu, 06 Jun 2019 13:51:14 +0000 Received: from [192.168.180.1] (port=35596 helo=admins.marcant.net) by mail3.marcant.net with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1hYsnE-0006tM-1B for openwrt-devel@lists.openwrt.org; Thu, 06 Jun 2019 15:51:00 +0200 Received: from varus.marcant.loc (unknown [192.168.3.44]) by admins.marcant.net (Postfix) with ESMTPA id 47F8C2802CE; Thu, 6 Jun 2019 15:51:00 +0200 (CEST) From: =?utf-8?q?Andr=C3=A9_Valentin?= To: openwrt-devel@lists.openwrt.org Date: Thu, 6 Jun 2019 15:50:53 +0200 Message-Id: <20190606135055.30432-2-avalentin@marcant.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190606135055.30432-1-avalentin@marcant.net> References: <20190606135055.30432-1-avalentin@marcant.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190606_065112_138847_7D5116EF X-CRM114-Status: UNSURE ( 6.44 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.14.160.188 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH 1/3] netsupport: add xfrmi interface support 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: =?utf-8?q?Andr=C3=A9_Valentin?= MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Add support for xfrm interfaces in kernel. XFRM interfaces are used by the IPsec stack for tunneling. XFRM interfaces are available since linux 4.19. --- package/kernel/linux/modules/netsupport.mk | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/package/kernel/linux/modules/netsupport.mk b/package/kernel/linux/modules/netsupport.mk index 1b6247643f..385c1c65ec 100644 --- a/package/kernel/linux/modules/netsupport.mk +++ b/package/kernel/linux/modules/netsupport.mk @@ -380,6 +380,20 @@ endef $(eval $(call KernelPackage,ip6-vti)) +define KernelPackage/xfrm-interface + SUBMENU:=$(NETWORK_SUPPORT_MENU) + TITLE:=IPsec XFRM Interface + DEPENDS:=+kmod-ipsec4 +kmod-ipsec6 @LINUX_4_19 + KCONFIG:=CONFIG_XFRM_INTERFACE + FILES:=$(LINUX_DIR)/net/xfrm/xfrm_interface.ko + AUTOLOAD:=$(call AutoLoad,33,xfrm_interface) +endef + +define KernelPackage/xfrm-interface/description + Kernel modules for XFRM Interface +endef + +$(eval $(call KernelPackage,xfrm-interface)) define KernelPackage/iptunnel4 SUBMENU:=$(NETWORK_SUPPORT_MENU) From patchwork Thu Jun 6 13:50:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Valentin?= X-Patchwork-Id: 1111147 X-Patchwork-Delegate: dedeckeh@gmail.com 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=none (p=none dis=none) header.from=marcant.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oL1Axn+2"; 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 45KRt53CsCz9sDX for ; Thu, 6 Jun 2019 23:52:13 +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:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ud9xVDkyp4zxDRkSV+/jqx9szjOoP/MzyUqBEM6QqmA=; b=oL1Axn+2m7fcR+ uvTsZJgySLOVlBinYs2zDwk5UtsyTLj61VCaX9Tf2ApKYKDS1VXOyg5mkBC36l/sE4KUocFe2UKCU 2fKhKD4NOt9gemUNY7CzSit0sRUs0NzBqU7IAUvvwWcQzcUT9srN73Ki6avrbcHjcFNwvwOcKT8Eh 5K12R0KJWztsV269KWASh5s9RTbIKLl8x5g6ok9U3wuzYxNU08S29OB+JgySROPVEfLCVq34Nt7xq tIQnnubGQac8SY3ytKhp7q+Fhy7v19BnMwnWYH9YZRlBxEWv3Zmu7BeKBzm2NSb3/+EBeP4BpaNUJ RzUDQXaisX+4ZK69fXsA==; 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 1hYso7-0000mj-MY; Thu, 06 Jun 2019 13:51:55 +0000 Received: from mail3.marcant.net ([217.14.160.188]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYsnP-0008IL-Uo for openwrt-devel@lists.openwrt.org; Thu, 06 Jun 2019 13:51:14 +0000 Received: from [192.168.180.1] (port=35600 helo=admins.marcant.net) by mail3.marcant.net with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1hYsnE-0006tN-1T for openwrt-devel@lists.openwrt.org; Thu, 06 Jun 2019 15:51:00 +0200 Received: from varus.marcant.loc (unknown [192.168.3.44]) by admins.marcant.net (Postfix) with ESMTPA id 592322802D0; Thu, 6 Jun 2019 15:51:00 +0200 (CEST) From: =?utf-8?q?Andr=C3=A9_Valentin?= To: openwrt-devel@lists.openwrt.org Date: Thu, 6 Jun 2019 15:50:54 +0200 Message-Id: <20190606135055.30432-3-avalentin@marcant.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190606135055.30432-1-avalentin@marcant.net> References: <20190606135055.30432-1-avalentin@marcant.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190606_065112_147671_648365A4 X-CRM114-Status: UNSURE ( 9.36 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.14.160.188 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH 2/3] netifd: add xfrm interface support scripts 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: =?utf-8?q?Andr=C3=A9_Valentin?= MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This package adds scripts for xfrm interfaces support. Example configuration via /etc/config/network: config interface 'xfrm0' option proto 'xfrm' option mtu '1300' option zone 'VPN' option tunlink 'wan' option ifid 30 config interface 'xfrm0_static' option proto 'static' option ifname '@xfrm0' option ip6addr 'fe80::1/64' option ipaddr '10.0.0.1/30' --- package/network/config/xfrm/Makefile | 44 +++++++++++++++++++++++++ package/network/config/xfrm/files/xfrm.sh | 54 +++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 package/network/config/xfrm/Makefile create mode 100755 package/network/config/xfrm/files/xfrm.sh diff --git a/package/network/config/xfrm/Makefile b/package/network/config/xfrm/Makefile new file mode 100644 index 0000000000..943a4ba326 --- /dev/null +++ b/package/network/config/xfrm/Makefile @@ -0,0 +1,44 @@ +# +# Copyright (C) 2014 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=xfrm +PKG_VERSION:=1 +PKG_RELEASE:=3 +PKG_LICENSE:=GPL-2.0 + +include $(INCLUDE_DIR)/package.mk + +define Package/xfrm/Default + SECTION:=net + CATEGORY:=Network + MAINTAINER:=Andre Valentin +endef + +define Package/xfrm +$(call Package/xfrm/Default) + TITLE:=XFRM IPsec Tunnel Interface config support + DEPENDS:=+kmod-xfrm-interface +endef + +define Package/xfrm/description + XFRM IPsec Tunnel Interface config support (IPv4 and IPv6) in /etc/config/network. +endef + +define Build/Compile +endef + +define Build/Configure +endef + +define Package/xfrm/install + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/xfrm.sh $(1)/lib/netifd/proto/xfrm.sh +endef + +$(eval $(call BuildPackage,xfrm)) diff --git a/package/network/config/xfrm/files/xfrm.sh b/package/network/config/xfrm/files/xfrm.sh new file mode 100755 index 0000000000..b93e090e90 --- /dev/null +++ b/package/network/config/xfrm/files/xfrm.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +[ -n "$INCLUDE_ONLY" ] || { + . /lib/functions.sh + . /lib/functions/network.sh + . ../netifd-proto.sh + init_proto "$@" +} + +proto_xfrm_setup() { + local cfg="$1" + local mode="xfrm" + + local df tunlink ifid mtu zone + json_get_vars df tunlink ifid mtu zone + + proto_init_update "$cfg" 1 + + proto_add_tunnel + json_add_string mode "$mode" + json_add_int mtu "${mtu:-1280}" + [ -n "$tunlink" ] && json_add_string link "$tunlink" + + json_add_object 'data' + [ -n "$ifid" ] && json_add_int ifid "$ifid" + json_close_object + + proto_close_tunnel + + proto_add_data + [ -n "$zone" ] && json_add_string zone "$zone" + proto_close_data + + proto_send_update "$cfg" +} + +proto_xfrm_teardown() { + local cfg="$1" +} + +proto_xfrm_init_config() { + no_device=1 + available=1 + + proto_config_add_int "mtu" + proto_config_add_string "tunlink" + proto_config_add_string "zone" + proto_config_add_int "ifid" +} + + +[ -n "$INCLUDE_ONLY" ] || { + [ -f /lib/modules/$(uname -r)/xfrm_interface.ko -o -d /sys/module/xfrm_interface ] && add_protocol xfrm +} From patchwork Thu Jun 6 13:50:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Valentin?= X-Patchwork-Id: 1111145 X-Patchwork-Delegate: dedeckeh@gmail.com 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=none (p=none dis=none) header.from=marcant.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ym0ZHk9E"; 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 45KRsd4Y13z9s4V for ; Thu, 6 Jun 2019 23:51:49 +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:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=015iatPJhxIjmG2ci3PVJW5e4H0D+/p6aQRk4cRfauY=; b=Ym0ZHk9EJa3jTy Nvq3o/w+d0JBhu4BqFKUPI4ADApLfZbBd4cxHPoAZsdsnJMWGxh+2Z1kq5dSprDSCRMKAdKDS4fGf 3ZVdnUvbZL2Bwi3oTo5kO5913B8bbqMhxWohnyiiPZ4z1VOQ3EMY7esLUozb1ErkbDZfUNl2TV8vF BTX6GR8CrNLR9DW/T8xngLgkhdJOxfZZA9B74VfhPRAJvHvJu7aVcuIDDT6QYOHcH7lpMbGfWOI1O ZHV704cd47snvwUPY/GvoG4sZSIZqI7HLZtxZO+IqNRJoDLilFR3E0bwx19jaqRCPBK955cJ0Q+rZ JrbfWytFLj3pwuwyVBCQ==; 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 1hYsnj-0000ET-7d; Thu, 06 Jun 2019 13:51:31 +0000 Received: from mail3.marcant.net ([217.14.160.188]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hYsnP-0008IK-Um for openwrt-devel@lists.openwrt.org; Thu, 06 Jun 2019 13:51:14 +0000 Received: from [192.168.180.1] (port=35604 helo=admins.marcant.net) by mail3.marcant.net with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1hYsnE-0006tm-1l for openwrt-devel@lists.openwrt.org; Thu, 06 Jun 2019 15:51:00 +0200 Received: from varus.marcant.loc (unknown [192.168.3.44]) by admins.marcant.net (Postfix) with ESMTPA id 6F44D2802C0; Thu, 6 Jun 2019 15:51:00 +0200 (CEST) From: =?utf-8?q?Andr=C3=A9_Valentin?= To: openwrt-devel@lists.openwrt.org Date: Thu, 6 Jun 2019 15:50:55 +0200 Message-Id: <20190606135055.30432-4-avalentin@marcant.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190606135055.30432-1-avalentin@marcant.net> References: <20190606135055.30432-1-avalentin@marcant.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190606_065112_138156_C8737F08 X-CRM114-Status: GOOD ( 10.52 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [217.14.160.188 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record Subject: [OpenWrt-Devel] [PATCH 3/3] netifd: add xfrm tunnel interface support 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: =?utf-8?q?Andr=C3=A9_Valentin?= MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This adds support for xfrm interfaces. These interfaces can be used since linux 4.19 for IPsec traffic, like VTI interface. XFRM interfaces are less complicated compared to VTI because they need no tunnel endpoints. --- system-linux.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ system.c | 9 +++++++++ system.h | 6 ++++++ 3 files changed, 76 insertions(+) diff --git a/system-linux.c b/system-linux.c index 2f5bbe1..c63d8d8 100644 --- a/system-linux.c +++ b/system-linux.c @@ -2877,6 +2877,63 @@ failure: } #endif +#ifdef IFLA_XFRM_MAX +static int system_add_xfrm_tunnel(const char *name, const char *kind, + const unsigned int link, struct blob_attr **tb) +{ + struct nl_msg *nlm; + struct ifinfomsg ifi = { .ifi_family = AF_UNSPEC, }; + struct blob_attr *cur; + int ret = 0; + + nlm = nlmsg_alloc_simple(RTM_NEWLINK, NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | NLM_F_EXCL); + if (!nlm) + return -1; + + nlmsg_append(nlm, &ifi, sizeof(ifi), 0); + nla_put_string(nlm, IFLA_IFNAME, name); + + struct nlattr *linkinfo = nla_nest_start(nlm, IFLA_LINKINFO); + if (!linkinfo) { + ret = -ENOMEM; + goto failure; + } + + nla_put_string(nlm, IFLA_INFO_KIND, kind); + struct nlattr *infodata = nla_nest_start(nlm, IFLA_INFO_DATA); + if (!infodata) { + ret = -ENOMEM; + goto failure; + } + + if (link) + nla_put_u32(nlm, IFLA_XFRM_LINK, link); + + if ((cur = tb[TUNNEL_ATTR_DATA])) { + struct blob_attr *tb_data[__XFRM_DATA_ATTR_MAX]; + uint32_t if_id = 0; + + blobmsg_parse(xfrm_data_attr_list.params, __XFRM_DATA_ATTR_MAX, tb_data, + blobmsg_data(cur), blobmsg_len(cur)); + + if ((cur = tb_data[XFRM_DATA_IF_ID])) { + if ((if_id = blobmsg_get_u32(cur))) + nla_put_u32(nlm, IFLA_XFRM_IF_ID, if_id); + } + + } + + nla_nest_end(nlm, infodata); + nla_nest_end(nlm, linkinfo); + + return system_rtnl_call(nlm); + +failure: + nlmsg_free(nlm); + return ret; +} +#endif + #ifdef IFLA_VXLAN_MAX static int system_add_vxlan(const char *name, const unsigned int link, struct blob_attr **tb, bool v6) { @@ -3259,6 +3316,10 @@ int system_add_ip_tunnel(const char *name, struct blob_attr *attr) } else if (!strcmp(str, "vtiip6")) { return system_add_vti_tunnel(name, "vti6", link, tb, true); #endif +#ifdef IFLA_XFRM_MAX + } else if (!strcmp(str, "xfrm")) { + return system_add_xfrm_tunnel(name, "xfrm", link, tb); +#endif #ifdef IFLA_VXLAN_MAX } else if(!strcmp(str, "vxlan")) { return system_add_vxlan(name, link, tb, false); diff --git a/system.c b/system.c index dd9ab50..bbdfef7 100644 --- a/system.c +++ b/system.c @@ -70,6 +70,15 @@ const struct uci_blob_param_list vti_data_attr_list = { .params = vti_data_attrs, }; +static const struct blobmsg_policy xfrm_data_attrs[__XFRM_DATA_ATTR_MAX] = { + [XFRM_DATA_IF_ID] = { .name = "ifid", .type = BLOBMSG_TYPE_INT32 }, +}; + +const struct uci_blob_param_list xfrm_data_attr_list = { + .n_params = __XFRM_DATA_ATTR_MAX, + .params = xfrm_data_attrs, +}; + static const struct blobmsg_policy sixrd_data_attrs[__SIXRD_DATA_ATTR_MAX] = { [SIXRD_DATA_PREFIX] = { .name = "prefix", .type = BLOBMSG_TYPE_STRING }, [SIXRD_DATA_RELAY_PREFIX] = { .name = "relay-prefix", .type = BLOBMSG_TYPE_STRING }, diff --git a/system.h b/system.h index 9fefcae..61c4046 100644 --- a/system.h +++ b/system.h @@ -63,6 +63,11 @@ enum vti_data { __VTI_DATA_ATTR_MAX }; +enum xfrm_data { + XFRM_DATA_IF_ID, + __XFRM_DATA_ATTR_MAX +}; + enum sixrd_data { SIXRD_DATA_PREFIX, SIXRD_DATA_RELAY_PREFIX, @@ -86,6 +91,7 @@ enum fmr_data { 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 xfrm_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;