From patchwork Tue Mar 17 12:08:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 222404 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EB04C10F29 for ; Tue, 17 Mar 2020 12:09:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78E912074D for ; Tue, 17 Mar 2020 12:09:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="eKcVYTc9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726916AbgCQMJj (ORCPT ); Tue, 17 Mar 2020 08:09:39 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:46586 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbgCQMJi (ORCPT ); Tue, 17 Mar 2020 08:09:38 -0400 Received: by mail-lf1-f68.google.com with SMTP id a28so5125309lfr.13 for ; Tue, 17 Mar 2020 05:09:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GmTVCUwzP2sd2RegUgToB05hVf+yztMs1t67J5XMm00=; b=eKcVYTc9qQYhkE1Vi/Z417hbDiE3GtdPrKO4Cc7c/JdRPco1QtbXeyKIXljk94UweA LTetgFdKrdZOFkrN7hdUXTWpNrqcvY5Pz4QRsrPOcGKC9x8gSPMQrBTChuqmK/PLJHmh vBSF/AmONyIBLVQh/KL85aHRRSZ45u20es0rk= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=GmTVCUwzP2sd2RegUgToB05hVf+yztMs1t67J5XMm00=; b=Oc8khcVUa+t5QA+0Nf5UQI1PtyMh687LKMjIA48u+KTS/QAFoHx+bJpKaYJuIJ/PRc 9e8BApLlXSDz4CdF1KJLCEpSB8ciddhsCDpko6nR85xL1KZOjKfNywaLc841uGbtLN0j sYYORIKFfshe+CmSLgzF7n6ytMYVekj8irGRcwIe57XRGdRT21xSv5XyiAXSScq8fcsE 5v3B/yD048eMONto94dqPE1Ae1CdtlEVMlg9xyneexDIc2HR6Qrg+5/Cw1Lm2iaAgsRN GF3RqUGFyryjdGW75mM1k6iF2affLLKJyZIt179VbybfCmftam76CKlNhht84irUKg+6 3SXg== X-Gm-Message-State: ANhLgQ2RxUfWLAwnqzXVLc1YtfmraERuP/2uOuxvRXhzLc/FF1QUhade DilUi+DXXoHIZNStb2f2uSnsHnmhyGI= X-Google-Smtp-Source: ADFU+vugWFGwwJhKQb9eK8dDenWdlgqg6g78daI30SkEmNCvy1L/n8cHoAWcl04YtE4oKVZcRUEurw== X-Received: by 2002:a05:6512:68b:: with SMTP id t11mr2772915lfe.214.1584446974151; Tue, 17 Mar 2020 05:09:34 -0700 (PDT) Received: from localhost.localdomain (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id 23sm2389208lfa.28.2020.03.17.05.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 05:09:26 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: davem@davemloft.net, roopa@cumulusnetworks.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net-next 1/4] net: bridge: vlan options: rename br_vlan_opts_eq to br_vlan_opts_eq_range Date: Tue, 17 Mar 2020 14:08:33 +0200 Message-Id: <20200317120836.1765164-2-nikolay@cumulusnetworks.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200317120836.1765164-1-nikolay@cumulusnetworks.com> References: <20200317120836.1765164-1-nikolay@cumulusnetworks.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org It is more appropriate name as it shows the intent of why we need to check the options' state. It also allows us to give meaning to the two arguments of the function: the first is the current vlan (v_curr) being checked if it could enter the range ending in the second one (range_end). Signed-off-by: Nikolay Aleksandrov --- net/bridge/br_private.h | 4 ++-- net/bridge/br_vlan.c | 2 +- net/bridge/br_vlan_options.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 5153ffe79a01..1f97703a52ff 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1199,8 +1199,8 @@ static inline void br_vlan_notify(const struct net_bridge *br, /* br_vlan_options.c */ #ifdef CONFIG_BRIDGE_VLAN_FILTERING -bool br_vlan_opts_eq(const struct net_bridge_vlan *v1, - const struct net_bridge_vlan *v2); +bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr, + const struct net_bridge_vlan *range_end); bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v); size_t br_vlan_opts_nl_size(void); int br_vlan_process_options(const struct net_bridge *br, diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 6b5deca08b89..09bfda47fbbf 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -1694,7 +1694,7 @@ bool br_vlan_can_enter_range(const struct net_bridge_vlan *v_curr, { return v_curr->vid - range_end->vid == 1 && range_end->flags == v_curr->flags && - br_vlan_opts_eq(v_curr, range_end); + br_vlan_opts_eq_range(v_curr, range_end); } static int br_vlan_dump_dev(const struct net_device *dev, diff --git a/net/bridge/br_vlan_options.c b/net/bridge/br_vlan_options.c index cd2eb194eb98..24cf2a621df9 100644 --- a/net/bridge/br_vlan_options.c +++ b/net/bridge/br_vlan_options.c @@ -7,11 +7,11 @@ #include "br_private.h" -/* check if the options between two vlans are equal */ -bool br_vlan_opts_eq(const struct net_bridge_vlan *v1, - const struct net_bridge_vlan *v2) +/* check if the options' state of v_curr allow it to enter the range */ +bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr, + const struct net_bridge_vlan *range_end) { - return v1->state == v2->state; + return v_curr->state == range_end->state; } bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v) From patchwork Tue Mar 17 12:08:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 222403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47DD6C10F29 for ; Tue, 17 Mar 2020 12:10:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F26E02076A for ; Tue, 17 Mar 2020 12:10:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b="YnbWaU5H" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726494AbgCQMKL (ORCPT ); Tue, 17 Mar 2020 08:10:11 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:35051 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbgCQMKK (ORCPT ); Tue, 17 Mar 2020 08:10:10 -0400 Received: by mail-lj1-f196.google.com with SMTP id u12so22545470ljo.2 for ; Tue, 17 Mar 2020 05:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hmS/lQhsaapFOz3Rfd3WQVjsqoU/mKBs+PwdwTNRXZA=; b=YnbWaU5HFKkQE0O2UF9IguWnTH+xB5zhYfVL5nBQYnADtdqonEKycJX8G14iWU15lx LoDa5+bcd+BNfqQUF3YQN4+ZcRLBb6vlTaLTv1TH8Uq341Mzm7LG5hnNEbvUQb/ZrseT G30ePB7bsxSdBa+4RYAyZuXcLd0gjFwwKqKRs= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=hmS/lQhsaapFOz3Rfd3WQVjsqoU/mKBs+PwdwTNRXZA=; b=qIj4L3lVuVOi7Ml70offK4LeShGgpUrdhIdLMGZ1ekg4f5npnMvp88CRftKPccVVgq 0fM3T2Sfre1unqhBZ6DG6TjInC0DxrTztml6HnHIHCVwnWQQ5AHTrvWymVhVNFjvpYkL rJkWk99mFwPIgH64DcDKlptCcABriSC+HRgTNtfzJKX62joHd5J6GcF9obOvkwFYPiGp S3V+aAIfX4mJMyxZNkB4BqJfXx9NXHrYpxl2glHMDhQYbRFT99YrbQB78riPTdNnF1zt qlZi7hYmecGzYHjl71omTETgZ7rFN/hjgBO1x5wilgXrKmde/j8rAGflhDltd7USjNCs kFcA== X-Gm-Message-State: ANhLgQ3tW4Z6AdtioDK+CAmfBpzcGTVQJEWRPvyY2Fh/jC9HJmbCPokL XA+0VIWLBT8BgMqXqpQOqInJs1Fjutk= X-Google-Smtp-Source: ADFU+vvFzDIeCzARd3j7cNRTFcuhRMMToVklCLXu+kCO4Qp+GKVIoWIwTjwMIjPjn4qvWbm4Ed3LFw== X-Received: by 2002:a2e:920c:: with SMTP id k12mr2473964ljg.209.1584447007393; Tue, 17 Mar 2020 05:10:07 -0700 (PDT) Received: from localhost.localdomain (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id 23sm2389208lfa.28.2020.03.17.05.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 05:09:58 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: davem@davemloft.net, roopa@cumulusnetworks.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net-next 3/4] net: bridge: vlan options: add support for tunnel id dumping Date: Tue, 17 Mar 2020 14:08:35 +0200 Message-Id: <20200317120836.1765164-4-nikolay@cumulusnetworks.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200317120836.1765164-1-nikolay@cumulusnetworks.com> References: <20200317120836.1765164-1-nikolay@cumulusnetworks.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a new option - BRIDGE_VLANDB_ENTRY_TUNNEL_ID which is used to dump the tunnel id mapping. Since they're unique per vlan they can enter a vlan range if they're consecutive, thus we can calculate the tunnel id range map simply as: vlan range end id - vlan range start id. The starting point is the tunnel id in BRIDGE_VLANDB_ENTRY_TUNNEL_ID. This is similar to how the tunnel entries can be created in a range via the old API (a vlan range maps to a tunnel range). Signed-off-by: Nikolay Aleksandrov --- include/uapi/linux/if_bridge.h | 1 + net/bridge/br_netlink_tunnel.c | 4 ++-- net/bridge/br_private_tunnel.h | 2 ++ net/bridge/br_vlan_options.c | 29 ++++++++++++++++++++++++++--- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h index 42f7ca38ad80..36760ff69711 100644 --- a/include/uapi/linux/if_bridge.h +++ b/include/uapi/linux/if_bridge.h @@ -192,6 +192,7 @@ enum { BRIDGE_VLANDB_ENTRY_INFO, BRIDGE_VLANDB_ENTRY_RANGE, BRIDGE_VLANDB_ENTRY_STATE, + BRIDGE_VLANDB_ENTRY_TUNNEL_ID, __BRIDGE_VLANDB_ENTRY_MAX, }; #define BRIDGE_VLANDB_ENTRY_MAX (__BRIDGE_VLANDB_ENTRY_MAX - 1) diff --git a/net/bridge/br_netlink_tunnel.c b/net/bridge/br_netlink_tunnel.c index beea08b8c422..996a77620814 100644 --- a/net/bridge/br_netlink_tunnel.c +++ b/net/bridge/br_netlink_tunnel.c @@ -26,8 +26,8 @@ static size_t __get_vlan_tinfo_size(void) nla_total_size(sizeof(u16)); /* IFLA_BRIDGE_VLAN_TUNNEL_FLAGS */ } -static bool vlan_tunid_inrange(struct net_bridge_vlan *v_curr, - struct net_bridge_vlan *v_last) +bool vlan_tunid_inrange(const struct net_bridge_vlan *v_curr, + const struct net_bridge_vlan *v_last) { __be32 tunid_curr = tunnel_id_to_key32(v_curr->tinfo.tunnel_id); __be32 tunid_last = tunnel_id_to_key32(v_last->tinfo.tunnel_id); diff --git a/net/bridge/br_private_tunnel.h b/net/bridge/br_private_tunnel.h index a9b818fc8b6c..b27a0c0371f2 100644 --- a/net/bridge/br_private_tunnel.h +++ b/net/bridge/br_private_tunnel.h @@ -43,6 +43,8 @@ int br_handle_ingress_vlan_tunnel(struct sk_buff *skb, struct net_bridge_vlan_group *vg); int br_handle_egress_vlan_tunnel(struct sk_buff *skb, struct net_bridge_vlan *vlan); +bool vlan_tunid_inrange(const struct net_bridge_vlan *v_curr, + const struct net_bridge_vlan *v_last); #else static inline int vlan_tunnel_init(struct net_bridge_vlan_group *vg) { diff --git a/net/bridge/br_vlan_options.c b/net/bridge/br_vlan_options.c index 24cf2a621df9..d3618da32b8e 100644 --- a/net/bridge/br_vlan_options.c +++ b/net/bridge/br_vlan_options.c @@ -4,25 +4,48 @@ #include #include #include +#include #include "br_private.h" +#include "br_private_tunnel.h" + +static bool __vlan_tun_put(struct sk_buff *skb, const struct net_bridge_vlan *v) +{ + __be32 tid = tunnel_id_to_key32(v->tinfo.tunnel_id); + + if (!v->tinfo.tunnel_dst) + return true; + + return !nla_put_u32(skb, BRIDGE_VLANDB_ENTRY_TUNNEL_ID, + be32_to_cpu(tid)); +} + +static bool __vlan_tun_can_enter_range(const struct net_bridge_vlan *v_curr, + const struct net_bridge_vlan *range_end) +{ + return (!v_curr->tinfo.tunnel_dst && !range_end->tinfo.tunnel_dst) || + vlan_tunid_inrange(v_curr, range_end); +} /* check if the options' state of v_curr allow it to enter the range */ bool br_vlan_opts_eq_range(const struct net_bridge_vlan *v_curr, const struct net_bridge_vlan *range_end) { - return v_curr->state == range_end->state; + return v_curr->state == range_end->state && + __vlan_tun_can_enter_range(v_curr, range_end); } bool br_vlan_opts_fill(struct sk_buff *skb, const struct net_bridge_vlan *v) { return !nla_put_u8(skb, BRIDGE_VLANDB_ENTRY_STATE, - br_vlan_get_state(v)); + br_vlan_get_state(v)) && + __vlan_tun_put(skb, v); } size_t br_vlan_opts_nl_size(void) { - return nla_total_size(sizeof(u8)); /* BRIDGE_VLANDB_ENTRY_STATE */ + return nla_total_size(sizeof(u8)) /* BRIDGE_VLANDB_ENTRY_STATE */ + + nla_total_size(sizeof(u32)); /* BRIDGE_VLANDB_ENTRY_TUNNEL_ID */ } static int br_vlan_modify_state(struct net_bridge_vlan_group *vg,