From patchwork Fri Sep 4 02:59:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Kimmel X-Patchwork-Id: 1357146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.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=bareminimum.eu Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=VrOlVmD6; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4BjMsZ5lryz9sVK for ; Fri, 4 Sep 2020 13:02:10 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=1KOx/JQ4LWncN5V7hmLmlSYGgp5CM68RKPmJC44Kzws=; b=VrOlVmD67Xqt524k9QHPcIYmRu krA/1umUwE/+aZO3gLT1ROOUS5KKoqM60V6Tq/IPDRXNpa7jozhffHPjwdrdBfgqomf3H6hAKtqqT UcFFN43dLcZ4egfD2dONfde/DuBl8JgPSLcBdidykVwseKIRlS6Phsn7Sw4ipzqWtlLxVJVB91JBU 4yapb4MP8RTmJ27xxNvpnKPQwYb+3dAGzhD53iv1xOIngX/x1OCKC3Fd/cH0TbboCAtBZM/XDBU/D qHxQSjg0gumCRtEr+ZZubc6yTKAu1p1mGQDo3eKO8iRXdbQIrfOgDG4Mu/ONrPEA18BbaAKT/Jqcj odwyBcJQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE1xf-0008BM-8t; Fri, 04 Sep 2020 03:00:23 +0000 Received: from mail.nerd2nerd.org ([2a01:4f8:190:3211::25]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE1xc-00089z-Gt for openwrt-devel@lists.openwrt.org; Fri, 04 Sep 2020 03:00:21 +0000 Received: from kosch.limbus.lpm.pw (200116b828f1af0276d435fffe9b7588.dip.versatel-1u1.de [IPv6:2001:16b8:28f1:af02:76d4:35ff:fe9b:7588]) by mail.nerd2nerd.org (Postfix) with ESMTPA id 585CB606E9; Fri, 4 Sep 2020 05:00:14 +0200 (CEST) From: Johannes Kimmel To: openwrt-devel@lists.openwrt.org Subject: [PATCH 1/4] netifd: vxlan: handle srcport range Date: Fri, 4 Sep 2020 04:59:40 +0200 Message-Id: <20200904025943.9067-1-fff@bareminimum.eu> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Authentication-Results: mail.nerd2nerd.org; auth=pass smtp.auth=info@bareminimum.eu smtp.mailfrom=fff@bareminimum.eu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_230020_679316_45196F0D X-CRM114-Status: GOOD ( 14.16 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Kimmel Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This adds adds the ability to set the source port range for vxlan interfaces. By default vxlans will use a random port within the ephermal range as source ports for packets. This is done to aid scaleability within a datacenter. But with these defaults it's impossible to punch through NATs or traverese most stateful firewalls easily. One solution is to fix the srcport to the same as dstport. If only srcportmin is specified, then srcportmax is set in a way that outgoing packets will only use srcportmin. If a range is to be specified, srcportmin and srcportmax have to be specified. srcportmax is exclusive. If only srcportmax is specified, the value is ignored and defaults are used. Signed-off-by: Johannes Kimmel --- system-linux.c | 26 ++++++++++++++++++++++++++ system.c | 2 ++ system.h | 2 ++ 3 files changed, 30 insertions(+) diff --git a/system-linux.c b/system-linux.c index c5583e0..5ff8749 100644 --- a/system-linux.c +++ b/system-linux.c @@ -3184,6 +3184,32 @@ static int system_add_vxlan(const char *name, const unsigned int link, struct bl } nla_put_u16(msg, IFLA_VXLAN_PORT, htons(port)); + if ((cur = tb_data[VXLAN_DATA_ATTR_SRCPORTMIN])) { + struct ifla_vxlan_port_range srcports = {0,0}; + + uint32_t low = blobmsg_get_u32(cur); + if (low < 1 || low > 65535 - 1) { + ret = -EINVAL; + goto failure; + } + + srcports.low = htons((uint16_t) low); + srcports.high = htons((uint16_t) (low+1)); + + if ((cur = tb_data[VXLAN_DATA_ATTR_SRCPORTMAX])) { + uint32_t high = blobmsg_get_u32(cur); + if (high < 1 || high > 65535) { + ret = -EINVAL; + goto failure; + } + if (high > low) { + srcports.high = htons((uint16_t) high); + } + } + + nla_put(msg, IFLA_VXLAN_PORT_RANGE, sizeof(srcports), &srcports); + } + if ((cur = tb_data[VXLAN_DATA_ATTR_RXCSUM])) { bool rxcsum = blobmsg_get_bool(cur); nla_put_u8(msg, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, !rxcsum); diff --git a/system.c b/system.c index bbdfef7..4133e55 100644 --- a/system.c +++ b/system.c @@ -38,6 +38,8 @@ static const struct blobmsg_policy vxlan_data_attrs[__VXLAN_DATA_ATTR_MAX] = { [VXLAN_DATA_ATTR_MACADDR] = { .name = "macaddr", .type = BLOBMSG_TYPE_STRING }, [VXLAN_DATA_ATTR_RXCSUM] = { .name = "rxcsum", .type = BLOBMSG_TYPE_BOOL }, [VXLAN_DATA_ATTR_TXCSUM] = { .name = "txcsum", .type = BLOBMSG_TYPE_BOOL }, + [VXLAN_DATA_ATTR_SRCPORTMIN] = { .name = "srcportmin", .type = BLOBMSG_TYPE_INT32 }, + [VXLAN_DATA_ATTR_SRCPORTMAX] = { .name = "srcportmax", .type = BLOBMSG_TYPE_INT32 }, }; const struct uci_blob_param_list vxlan_data_attr_list = { diff --git a/system.h b/system.h index 015987f..bf9e1d7 100644 --- a/system.h +++ b/system.h @@ -44,6 +44,8 @@ enum vxlan_data { VXLAN_DATA_ATTR_MACADDR, VXLAN_DATA_ATTR_RXCSUM, VXLAN_DATA_ATTR_TXCSUM, + VXLAN_DATA_ATTR_SRCPORTMIN, + VXLAN_DATA_ATTR_SRCPORTMAX, __VXLAN_DATA_ATTR_MAX }; From patchwork Fri Sep 4 02:59:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Kimmel X-Patchwork-Id: 1357149 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.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=bareminimum.eu Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=YnTMwdxX; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4BjMsd42ZPz9sVK for ; Fri, 4 Sep 2020 13:02:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2g19gc2pZq+JheP+2eIX4zFWzvOlNxW5f3zLUGvJvhw=; b=YnTMwdxX0Osym0zaPXGuvKB9u l+sOS76907wWpMcWT1IkJJ3b+cGi0doGz86JhG6C21iUk9P1GFZ3JrHZArIlHISigrvBiwsHKBIwY XQBcch5812k7G1n+GgGgoCg0JZxMD+8dlSkZXMiCiKSahm8YMWpI2fgySYwfmP6wtmZmpUf5zBR2v jQqDbiUFF9TQQQEUI/1JHsL5hIpVO6FOHv3pFvf/K2t6ux+kd7i+CEpzXAG6w/Ek6Yivu0cRH40s0 SpmQBm74BI95P5NOo2PwSV1SPcMUKQTzCsvkWIrbIQzcNyhVOkzBeDl+EN2a/PqjN+QptfNbg1tBQ 2ItquCaeg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE1xj-0008C2-7g; Fri, 04 Sep 2020 03:00:27 +0000 Received: from mail.nerd2nerd.org ([2a01:4f8:190:3211::25]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE1xc-00089x-Nq for openwrt-devel@lists.openwrt.org; Fri, 04 Sep 2020 03:00:22 +0000 Received: from kosch.limbus.lpm.pw (200116b828f1af0276d435fffe9b7588.dip.versatel-1u1.de [IPv6:2001:16b8:28f1:af02:76d4:35ff:fe9b:7588]) by mail.nerd2nerd.org (Postfix) with ESMTPA id CFB0C6091B; Fri, 4 Sep 2020 05:00:14 +0200 (CEST) From: Johannes Kimmel To: openwrt-devel@lists.openwrt.org Subject: [PATCH 2/4] netifd: vxlan: refactor mapping of boolean attrs Date: Fri, 4 Sep 2020 04:59:41 +0200 Message-Id: <20200904025943.9067-2-fff@bareminimum.eu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904025943.9067-1-fff@bareminimum.eu> References: <20200904025943.9067-1-fff@bareminimum.eu> MIME-Version: 1.0 Authentication-Results: mail.nerd2nerd.org; auth=pass smtp.auth=info@bareminimum.eu smtp.mailfrom=fff@bareminimum.eu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_230020_892688_F1A9BA5D X-CRM114-Status: GOOD ( 11.06 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Kimmel Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Add a small function to handle boolean options and make use of it to handle: - rxcsum - txcsum Signed-off-by: Johannes Kimmel --- system-linux.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/system-linux.c b/system-linux.c index 5ff8749..88b064c 100644 --- a/system-linux.c +++ b/system-linux.c @@ -3073,6 +3073,17 @@ failure: #endif #ifdef IFLA_VXLAN_MAX +static void system_vxlan_map_bool_attr(struct nl_msg *msg, struct blob_attr **tb_data, int attrtype, int vxlandatatype, bool invert) { + struct blob_attr *cur; + if ((cur = tb_data[vxlandatatype])) { + bool val = blobmsg_get_bool(cur); + if (invert) { + val = !val; + } + nla_put_u8(msg, attrtype, val); + } +} + static int system_add_vxlan(const char *name, const unsigned int link, struct blob_attr **tb, bool v6) { struct blob_attr *tb_data[__VXLAN_DATA_ATTR_MAX]; @@ -3210,16 +3221,9 @@ static int system_add_vxlan(const char *name, const unsigned int link, struct bl nla_put(msg, IFLA_VXLAN_PORT_RANGE, sizeof(srcports), &srcports); } - if ((cur = tb_data[VXLAN_DATA_ATTR_RXCSUM])) { - bool rxcsum = blobmsg_get_bool(cur); - nla_put_u8(msg, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, !rxcsum); - } - - if ((cur = tb_data[VXLAN_DATA_ATTR_TXCSUM])) { - bool txcsum = blobmsg_get_bool(cur); - nla_put_u8(msg, IFLA_VXLAN_UDP_CSUM, txcsum); - nla_put_u8(msg, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, !txcsum); - } + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_UDP_CSUM, VXLAN_DATA_ATTR_TXCSUM, false); + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, VXLAN_DATA_ATTR_RXCSUM, true); + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, VXLAN_DATA_ATTR_TXCSUM, true); if ((cur = tb[TUNNEL_ATTR_TOS])) { char *str = blobmsg_get_string(cur); From patchwork Fri Sep 4 02:59:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Kimmel X-Patchwork-Id: 1357148 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.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=bareminimum.eu Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=hma+Z4E4; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4BjMsd0Cnjz9sV7 for ; Fri, 4 Sep 2020 13:02:13 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=lZRQiuwFTOs14jxUp418AwhHKosAuOa2nJPW7AgWRL0=; b=hma+Z4E41mGzBrTZWYRxEsIx3 S9Krtqy2DnmcbWJ/P73jPL3Dibqx9+oLUG6z/obPpTyM4TQeBaxnfc1ItcYCDlZOzusCiCT8+OSfh tSyybvrZLBLZ3XHXnSx7Rbn6s2IUfkylQRvXzL9lRl3u5y4wfoibj5BufF+tjfwTo8lL+CE6zUlDQ o/SbqJkEHIPQ6u53yMKo8OLMHKDUc0Ni1m/u169JLYB3GzKl7Pe7//71sFKjab5f+9slqTU2SE3Zt AYSRKUfGcBNCPdadh0cfaghLDGuILBtvDliaY12CtEf5890U28LUXCuNdsPTHSAq/s0yUwwxg+Bfl FgUqaL8mQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE1xg-0008BV-AA; Fri, 04 Sep 2020 03:00:24 +0000 Received: from mail.nerd2nerd.org ([148.251.171.25]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE1xc-00089w-HO for openwrt-devel@lists.openwrt.org; Fri, 04 Sep 2020 03:00:21 +0000 Received: from kosch.limbus.lpm.pw (200116b828f1af0276d435fffe9b7588.dip.versatel-1u1.de [IPv6:2001:16b8:28f1:af02:76d4:35ff:fe9b:7588]) by mail.nerd2nerd.org (Postfix) with ESMTPA id 045E16128A; Fri, 4 Sep 2020 05:00:14 +0200 (CEST) From: Johannes Kimmel To: openwrt-devel@lists.openwrt.org Subject: [PATCH 3/4] netifd: vxlan: add most missing boolean options Date: Fri, 4 Sep 2020 04:59:42 +0200 Message-Id: <20200904025943.9067-3-fff@bareminimum.eu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904025943.9067-1-fff@bareminimum.eu> References: <20200904025943.9067-1-fff@bareminimum.eu> MIME-Version: 1.0 Authentication-Results: mail.nerd2nerd.org; auth=pass smtp.auth=info@bareminimum.eu smtp.mailfrom=fff@bareminimum.eu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_230020_711082_FCD7253D X-CRM114-Status: GOOD ( 13.16 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 LOTS_OF_MONEY Huge... sums of money X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Kimmel Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org adds the folloing missing options: - learning - rsc - proxy - l2miss - l3miss - gbp See ip-link(3) for their meaning. still missing: - external - gpe I'm not sure how to handle them at the moment. It's unclear to me what IFLA_VXLAN_* value corresponds to the 'external' option and according to the manpage, gpe depends on it. Signed-off-by: Johannes Kimmel --- system-linux.c | 12 +++++++++++- system.c | 6 ++++++ system.h | 6 ++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/system-linux.c b/system-linux.c index 88b064c..a68af63 100644 --- a/system-linux.c +++ b/system-linux.c @@ -3080,7 +3080,11 @@ static void system_vxlan_map_bool_attr(struct nl_msg *msg, struct blob_attr **tb if (invert) { val = !val; } - nla_put_u8(msg, attrtype, val); + if ((attrtype == IFLA_VXLAN_GBP) && val) { + nla_put_flag(msg, attrtype); + } else { + nla_put_u8(msg, attrtype, val); + } } } @@ -3224,6 +3228,12 @@ static int system_add_vxlan(const char *name, const unsigned int link, struct bl system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_UDP_CSUM, VXLAN_DATA_ATTR_TXCSUM, false); system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, VXLAN_DATA_ATTR_RXCSUM, true); system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, VXLAN_DATA_ATTR_TXCSUM, true); + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_LEARNING, VXLAN_DATA_ATTR_LEARNING, false); + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_RSC , VXLAN_DATA_ATTR_RSC, false); + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_PROXY , VXLAN_DATA_ATTR_PROXY, false); + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_L2MISS , VXLAN_DATA_ATTR_L2MISS, false); + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_L3MISS , VXLAN_DATA_ATTR_L3MISS, false); + system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_GBP , VXLAN_DATA_ATTR_GBP, false); if ((cur = tb[TUNNEL_ATTR_TOS])) { char *str = blobmsg_get_string(cur); diff --git a/system.c b/system.c index 4133e55..95721e1 100644 --- a/system.c +++ b/system.c @@ -40,6 +40,12 @@ static const struct blobmsg_policy vxlan_data_attrs[__VXLAN_DATA_ATTR_MAX] = { [VXLAN_DATA_ATTR_TXCSUM] = { .name = "txcsum", .type = BLOBMSG_TYPE_BOOL }, [VXLAN_DATA_ATTR_SRCPORTMIN] = { .name = "srcportmin", .type = BLOBMSG_TYPE_INT32 }, [VXLAN_DATA_ATTR_SRCPORTMAX] = { .name = "srcportmax", .type = BLOBMSG_TYPE_INT32 }, + [VXLAN_DATA_ATTR_LEARNING] = { .name = "learning", .type = BLOBMSG_TYPE_BOOL }, + [VXLAN_DATA_ATTR_RSC] = { .name = "rsc", .type = BLOBMSG_TYPE_BOOL }, + [VXLAN_DATA_ATTR_PROXY] = { .name = "proxy", .type = BLOBMSG_TYPE_BOOL }, + [VXLAN_DATA_ATTR_L2MISS] = { .name = "l2miss", .type = BLOBMSG_TYPE_BOOL }, + [VXLAN_DATA_ATTR_L3MISS] = { .name = "l3miss", .type = BLOBMSG_TYPE_BOOL }, + [VXLAN_DATA_ATTR_GBP] = { .name = "gbp", .type = BLOBMSG_TYPE_BOOL }, }; const struct uci_blob_param_list vxlan_data_attr_list = { diff --git a/system.h b/system.h index bf9e1d7..290c2e5 100644 --- a/system.h +++ b/system.h @@ -46,6 +46,12 @@ enum vxlan_data { VXLAN_DATA_ATTR_TXCSUM, VXLAN_DATA_ATTR_SRCPORTMIN, VXLAN_DATA_ATTR_SRCPORTMAX, + VXLAN_DATA_ATTR_LEARNING, + VXLAN_DATA_ATTR_RSC, + VXLAN_DATA_ATTR_PROXY, + VXLAN_DATA_ATTR_L2MISS, + VXLAN_DATA_ATTR_L3MISS, + VXLAN_DATA_ATTR_GBP, __VXLAN_DATA_ATTR_MAX }; From patchwork Fri Sep 4 02:59:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Kimmel X-Patchwork-Id: 1357147 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.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=bareminimum.eu Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=qvuH5HmS; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (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 4BjMsY332Hz9sV7 for ; Fri, 4 Sep 2020 13:02:05 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KChm/YkMOk4mST4NXZPNQTaUVHys8Duf8cHUeGLBx+8=; b=qvuH5HmSx+E7eUpEHMK9mz52C M6/pVNWCQ3a0yB7K5/33Y9xefLCTOwSckzZckAeTXmrv26RuzLJUC1ivNScXAaMMtEwmi2yN+Ao6r KpV89gpbf59rnvExhgU1AYhP+z8hZOqT5Tfk2xq5DtLhPfWSrx4kmzEwH66om3iQCmw1QZz4eJ1D7 AglUdz/qcWgb4JfEvSBWJF7gk4xZtSOB/V3ZPd9bex2/pNUOuE1ke9rg8I9wU7TLhyTbJE4cGHs4o Exn2Ey2tMHIEDxWKhizMg71KBgkLH5y2C68KklrT3jQJHzv0v88KPXRLG7PfSdL5udHsMBgiSIB4G y5lWp6Enw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE1xh-0008Bi-Qm; Fri, 04 Sep 2020 03:00:25 +0000 Received: from mail.nerd2nerd.org ([2a01:4f8:190:3211::25]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE1xc-00089y-Os for openwrt-devel@lists.openwrt.org; Fri, 04 Sep 2020 03:00:22 +0000 Received: from kosch.limbus.lpm.pw (200116b828f1af0276d435fffe9b7588.dip.versatel-1u1.de [IPv6:2001:16b8:28f1:af02:76d4:35ff:fe9b:7588]) by mail.nerd2nerd.org (Postfix) with ESMTPA id 57A84612FF; Fri, 4 Sep 2020 05:00:15 +0200 (CEST) From: Johannes Kimmel To: openwrt-devel@lists.openwrt.org Subject: [PATCH 4/4] netifd: vxlan: add aging and maxaddress options Date: Fri, 4 Sep 2020 04:59:43 +0200 Message-Id: <20200904025943.9067-4-fff@bareminimum.eu> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904025943.9067-1-fff@bareminimum.eu> References: <20200904025943.9067-1-fff@bareminimum.eu> MIME-Version: 1.0 Authentication-Results: mail.nerd2nerd.org; auth=pass smtp.auth=info@bareminimum.eu smtp.mailfrom=fff@bareminimum.eu X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_230020_925707_3DDBD87A X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 LOTS_OF_MONEY Huge... sums of money X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Kimmel Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org For both options the values can just be passed to the kernel. All unsigned values are accepted, thus no range checking required. Signed-off-by: Johannes Kimmel --- system-linux.c | 10 ++++++++++ system.c | 2 ++ system.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/system-linux.c b/system-linux.c index a68af63..c497509 100644 --- a/system-linux.c +++ b/system-linux.c @@ -3235,6 +3235,16 @@ static int system_add_vxlan(const char *name, const unsigned int link, struct bl system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_L3MISS , VXLAN_DATA_ATTR_L3MISS, false); system_vxlan_map_bool_attr(msg, tb_data, IFLA_VXLAN_GBP , VXLAN_DATA_ATTR_GBP, false); + if ((cur = tb_data[VXLAN_DATA_ATTR_AGEING])) { + uint32_t ageing = blobmsg_get_u32(cur); + nla_put_u32(msg, IFLA_VXLAN_AGEING, ageing); + } + + if ((cur = tb_data[VXLAN_DATA_ATTR_LIMIT])) { + uint32_t maxaddress = blobmsg_get_u32(cur); + nla_put_u32(msg, IFLA_VXLAN_LIMIT, maxaddress); + } + if ((cur = tb[TUNNEL_ATTR_TOS])) { char *str = blobmsg_get_string(cur); unsigned tos = 1; diff --git a/system.c b/system.c index 95721e1..834748e 100644 --- a/system.c +++ b/system.c @@ -46,6 +46,8 @@ static const struct blobmsg_policy vxlan_data_attrs[__VXLAN_DATA_ATTR_MAX] = { [VXLAN_DATA_ATTR_L2MISS] = { .name = "l2miss", .type = BLOBMSG_TYPE_BOOL }, [VXLAN_DATA_ATTR_L3MISS] = { .name = "l3miss", .type = BLOBMSG_TYPE_BOOL }, [VXLAN_DATA_ATTR_GBP] = { .name = "gbp", .type = BLOBMSG_TYPE_BOOL }, + [VXLAN_DATA_ATTR_AGEING] = { .name = "ageing", .type = BLOBMSG_TYPE_INT32 }, + [VXLAN_DATA_ATTR_LIMIT] = { .name = "maxaddress", .type = BLOBMSG_TYPE_INT32 }, }; const struct uci_blob_param_list vxlan_data_attr_list = { diff --git a/system.h b/system.h index 290c2e5..52161a8 100644 --- a/system.h +++ b/system.h @@ -52,6 +52,8 @@ enum vxlan_data { VXLAN_DATA_ATTR_L2MISS, VXLAN_DATA_ATTR_L3MISS, VXLAN_DATA_ATTR_GBP, + VXLAN_DATA_ATTR_AGEING, + VXLAN_DATA_ATTR_LIMIT, __VXLAN_DATA_ATTR_MAX };