From patchwork Sat Jun 8 11:48:07 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: 1112463 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="tkJg3zta"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Ld2y3H9Mz9sR6 for ; Sat, 8 Jun 2019 21:48:58 +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=B0Mdt3C0qbFls0POrHJyrc1yhx5gtTC88+oJq3NNeYw=; b=tkJg3ztaaPNch9 oad0BZEAznvrKcm8m5jcKdtxaTsq+7ZIhVvLitp32uf1aB2wWysR8RGTLAJ/jkDBThgON24zmzv6i BWXD3UsPs728ZWBUUVuzH1LioCJxvlKtnErQzOmTX0vPdjiiKHABra0SWJfndjWlaq16x9MdOGUR7 ZaW8ZhVdsEZJjm7Yvr2v+wIQDyUZQJAdtVSQqmnD0IECU1+71YDkUFpt4VGhLUijG8J3HmHZtEO2V smR86xnsykc2rE1K7AwsECN+GxHR2tXYD2W1IjBA68H/mmI93RpJ4Fs+ViRm3NiTLcwSJOyt6WkZZ hs4TKBEBuF965fasSBDA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hZZq5-0002gl-K4; Sat, 08 Jun 2019 11:48:49 +0000 Received: from mail3.marcant.net ([217.14.160.188]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hZZpi-0002Ch-Hq for openwrt-devel@lists.openwrt.org; Sat, 08 Jun 2019 11:48:30 +0000 Received: from [192.168.180.1] (port=50378 helo=admins.marcant.net) by mail3.marcant.net with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1hZZpV-0001fA-2P for openwrt-devel@lists.openwrt.org; Sat, 08 Jun 2019 13:48:13 +0200 Received: from varus.marcant.loc (unknown [192.168.3.44]) by admins.marcant.net (Postfix) with ESMTPA id 969FC280306; Sat, 8 Jun 2019 13:48:13 +0200 (CEST) From: =?utf-8?q?Andr=C3=A9_Valentin?= To: openwrt-devel@lists.openwrt.org Date: Sat, 8 Jun 2019 13:48:07 +0200 Message-Id: <20190608114809.9480-2-avalentin@marcant.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190608114809.9480-1-avalentin@marcant.net> References: <20190608114809.9480-1-avalentin@marcant.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190608_044826_769053_DB64AB12 X-CRM114-Status: UNSURE ( 6.17 ) 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 v3 1/3] kernel/netsupport: add xfrmi interface support X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 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,22 @@ 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_14 + 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 module for XFRM interface support +endef + +$(eval $(call KernelPackage,xfrm-interface)) + define KernelPackage/iptunnel4 SUBMENU:=$(NETWORK_SUPPORT_MENU) From patchwork Sat Jun 8 11:48:08 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: 1112461 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="n/9QWa77"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Ld2r5Qtzz9sPZ for ; Sat, 8 Jun 2019 21:48:52 +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=P9+N551QVdQcO6acIqi7DP+4TF8IoDNMGFD7GGR+mhY=; b=n/9QWa77Ye7zpX acJCM+p5Ga8l0PGpoMSYsXldEOsNKlETyojWkSprBHEdOQf0oX7IBMDr84moHY//jRoNNcECbuVNZ lAtdi535TN2fB6k88N55UYOtDfqsJplWxdSMqTCiye7KCrPEZl2+fMC0UuKAYRNHbRRAEFZLK1bP9 Uz3ibD2HEgWiqhe62+XmLgjcB0DvQD8msqd4tzTSIGBrox6hc4UBc3pHc3zabCkLokSpYsISSWEFy HirvlbspNQEVqj9ygoD+WvxPEP37LstS+2afRFWJnIJVjv914G4jITlDUV0xc8LRoujI8VW9Am9Bs TmOsa5G+d0w/8C7Y1tAQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hZZpu-0002OV-Mb; Sat, 08 Jun 2019 11:48:38 +0000 Received: from mail3.marcant.net ([217.14.160.188]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hZZpi-0002Ck-Hi for openwrt-devel@lists.openwrt.org; Sat, 08 Jun 2019 11:48:29 +0000 Received: from [192.168.180.1] (port=50382 helo=admins.marcant.net) by mail3.marcant.net with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1hZZpV-0001fF-2f for openwrt-devel@lists.openwrt.org; Sat, 08 Jun 2019 13:48:13 +0200 Received: from varus.marcant.loc (unknown [192.168.3.44]) by admins.marcant.net (Postfix) with ESMTPA id B66502802B7; Sat, 8 Jun 2019 13:48:13 +0200 (CEST) From: =?utf-8?q?Andr=C3=A9_Valentin?= To: openwrt-devel@lists.openwrt.org Date: Sat, 8 Jun 2019 13:48:08 +0200 Message-Id: <20190608114809.9480-3-avalentin@marcant.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190608114809.9480-1-avalentin@marcant.net> References: <20190608114809.9480-1-avalentin@marcant.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190608_044826_749687_922B204B X-CRM114-Status: UNSURE ( 9.37 ) 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 v3 2/3] network/config: add xfrm interface support scripts X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 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' Now set in strongswan IPsec policy: if_id_in = 30 if_id_out = 30 --- package/network/config/xfrm/Makefile | 38 ++++++++++++++++++ package/network/config/xfrm/files/xfrm.sh | 65 +++++++++++++++++++++++++++++++ 2 files changed, 103 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..efc90cf318 --- /dev/null +++ b/package/network/config/xfrm/Makefile @@ -0,0 +1,38 @@ + +include $(TOPDIR)/rules.mk + +PKG_NAME:=xfrm +PKG_VERSION:=1 +PKG_RELEASE:=1 +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..df28d38613 --- /dev/null +++ b/package/network/config/xfrm/files/xfrm.sh @@ -0,0 +1,65 @@ +#!/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 tunlink ifid mtu zone + json_get_vars tunlink ifid mtu zone + + proto_init_update "$cfg" 1 + + proto_add_tunnel + json_add_string mode "$mode" + json_add_int mtu "${mtu:-1280}" + + [ -z "$tunlink" ] && { + proto_notify_error "$cfg" NO_TUNLINK + proto_block_restart "$cfg" + exit + } + json_add_string link "$tunlink" + + [ -z "$ifid" ] && { + proto_notify_error "$cfg" NO_IFID + proto_block_restart "$cfg" + exit + } + 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 Sat Jun 8 11:48:09 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: 1112464 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="GeR7oqB5"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Ld3645J1z9sPZ for ; Sat, 8 Jun 2019 21:49:06 +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=d9s/p+FmYzpSFdn9W47Ibz+iSoLaXsKQ67Rj/1pO+Js=; b=GeR7oqB5C+2snz jq8e1pGHg2c1hHeqRGarxLbtmPFYl0p96TMcSQv73nQqk1Odb8j+lD6shhNafEMV+6JjOgnmSBnBt uvJK3DN1AsSvnA6Pe2YktJsjshfsMBzLtgbAtMWN16MXweQCtOVhYj+fBWd6sBOdV4D/ppz+bXUCF MyaV+2RGwXhPTyJCPPhEJo9hvWOWt165k4uCbxKjiUtKtcLNaGT/dDLR7VmOT1U6WNM+RPzHevT26 gnLYrIp/Fh5fNfK9e/wvhat6N7yV535uX0eNfkDrivFIOQOnlRu9YrF65inmd4rE41eurnJRBBqlO 5cIyUN/ZbWsHjG0DdyFA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hZZqE-0002wg-1k; Sat, 08 Jun 2019 11:48:58 +0000 Received: from mail3.marcant.net ([217.14.160.188]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hZZpi-0002Ci-Hn for openwrt-devel@lists.openwrt.org; Sat, 08 Jun 2019 11:48:30 +0000 Received: from [192.168.180.1] (port=50388 helo=admins.marcant.net) by mail3.marcant.net with esmtp (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1hZZpV-0001fG-2v for openwrt-devel@lists.openwrt.org; Sat, 08 Jun 2019 13:48:13 +0200 Received: from varus.marcant.loc (unknown [192.168.3.44]) by admins.marcant.net (Postfix) with ESMTPA id CA10F2802FC; Sat, 8 Jun 2019 13:48:13 +0200 (CEST) From: =?utf-8?q?Andr=C3=A9_Valentin?= To: openwrt-devel@lists.openwrt.org Date: Sat, 8 Jun 2019 13:48:09 +0200 Message-Id: <20190608114809.9480-4-avalentin@marcant.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190608114809.9480-1-avalentin@marcant.net> References: <20190608114809.9480-1-avalentin@marcant.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190608_044826_754393_EC1F78FA X-CRM114-Status: GOOD ( 10.15 ) 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 v3 3/3] netifd: add xfrm tunnel interface support X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 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 IP 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;