From patchwork Wed Jul 21 14:01:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 483733 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 11885C636CA for ; Wed, 21 Jul 2021 14:02:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E756761244 for ; Wed, 21 Jul 2021 14:02:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237799AbhGUNWE (ORCPT ); Wed, 21 Jul 2021 09:22:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236045AbhGUNWC (ORCPT ); Wed, 21 Jul 2021 09:22:02 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24943C061575 for ; Wed, 21 Jul 2021 07:02:39 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id l26so2515852eda.10 for ; Wed, 21 Jul 2021 07:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=izEfJ/KGkE+i5p7nm0OMKr/U+Dh/Kvr88MAgLxOg9FI=; b=xe3rsvbtLytiTTGZU+f9ptfPJvujq5qBa9eHBlu8RnNzOhrv6LpJ+LuLusZOBJ3H8E G/+JOU2AMfIs5vrP+1U/K+xkwl0d/be28C0HlY50bFS1Zyi5nxMl/6aTXs7189uajGc1 qxOvZ0HjS9CKOpS+HJ3WFp16WKC/VdwXMC25t5ryBkExWtdwHFuMSdh2hjRGd5DDH+QS uT2zSDH9jn1v+94Ey8mYcbZrmHUL894KkI31z3zc/Hz7rgtQrQJ8M1vHp2mDo90/io6+ uS2pP+zmKF688OXxNwxrk14nWaUCHteJXh4Ikh2HmtR6qmQGT5CpsuDME2GLB61TmJk/ Wzdg== 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=izEfJ/KGkE+i5p7nm0OMKr/U+Dh/Kvr88MAgLxOg9FI=; b=AnPnTzHmXDp8WYSxUqIPFidiUPuyL+KtS5OklzO96D002utlVkcdY91M2NubsBWKw7 f31eV3+VGKvvlxSRaghzwmFnHiWT35KCIBJNBRQWVP70vJusQq5X2ByJjHu3fwc+LwFN rMXvPM1PyHedDrOfxLfiY2wYK8qb5GXsDGvMsHvKLueF+8le+SVBajIJhMlZhUQJ37E5 y7u5gry4Uibp6oET+adisAg/qtHFS/TNJeEgunrFAPXjf/QTNTY096n6ySawxlZ6yqU2 PflGg7UpSepAEFeGm/k2Fy3HYryk2K+GEusZJBUUyj7GL0OKGbRtHTT2QpZEa15AE9SY Xv1g== X-Gm-Message-State: AOAM531dltCurCZjTqmlljyGRbyzWTflitTh+VV6aafBxlEc7jXFUin1 0i/dHUcw301mqfwb4mT+OeGf1XMCpCgIYyGYCrM= X-Google-Smtp-Source: ABdhPJwFhGeRUEfQv75I6+/MDh6l6tgzt7VyVPRYzSIBm5Ne/qzvmELY+lf1hTr57KH4WX1szZiibQ== X-Received: by 2002:aa7:c5c3:: with SMTP id h3mr48901673eds.376.1626876157506; Wed, 21 Jul 2021 07:02:37 -0700 (PDT) Received: from debil.vdiclient.nvidia.com (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id f15sm8362925ejc.61.2021.07.21.07.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 07:02:37 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: roopa@nvidia.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net-next 1/2] net: bridge: multicast: add mdb context support Date: Wed, 21 Jul 2021 17:01:26 +0300 Message-Id: <20210721140127.773194-2-razor@blackwall.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210721140127.773194-1-razor@blackwall.org> References: <20210721140127.773194-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nikolay Aleksandrov Choose the proper bridge multicast context when user-spaces is adding mdb entries. Currently we require the vlan to be configured on at least one device (port or bridge) in order to add an mdb entry if vlan mcast snooping is enabled (vlan snooping implies vlan filtering). Note that we always allow deleting an entry, regardless of the vlan state. Signed-off-by: Nikolay Aleksandrov --- net/bridge/br_mdb.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index d3383a47a2f2..7b6c3b91d272 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -1019,14 +1019,47 @@ static int br_mdb_parse(struct sk_buff *skb, struct nlmsghdr *nlh, return 0; } +static struct net_bridge_mcast * +__br_mdb_choose_context(struct net_bridge *br, + const struct br_mdb_entry *entry, + struct netlink_ext_ack *extack) +{ + struct net_bridge_mcast *brmctx = NULL; + struct net_bridge_vlan *v; + + if (!br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED)) { + brmctx = &br->multicast_ctx; + goto out; + } + + if (!entry->vid) { + NL_SET_ERR_MSG_MOD(extack, "Cannot add an entry without a vlan when vlan snooping is enabled"); + goto out; + } + + v = br_vlan_find(br_vlan_group(br), entry->vid); + if (!v) { + NL_SET_ERR_MSG_MOD(extack, "Vlan is not configured"); + goto out; + } + if (br_multicast_ctx_vlan_global_disabled(&v->br_mcast_ctx)) { + NL_SET_ERR_MSG_MOD(extack, "Vlan's multicast processing is disabled"); + goto out; + } + brmctx = &v->br_mcast_ctx; +out: + return brmctx; +} + static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, struct br_mdb_entry *entry, struct nlattr **mdb_attrs, struct netlink_ext_ack *extack) { struct net_bridge_mdb_entry *mp, *star_mp; - struct net_bridge_port_group *p; struct net_bridge_port_group __rcu **pp; + struct net_bridge_port_group *p; + struct net_bridge_mcast *brmctx; struct br_ip group, star_group; unsigned long now = jiffies; unsigned char flags = 0; @@ -1035,6 +1068,10 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, __mdb_entry_to_br_ip(entry, &group, mdb_attrs); + brmctx = __br_mdb_choose_context(br, entry, extack); + if (!brmctx) + return -EINVAL; + /* host join errors which can happen before creating the group */ if (!port) { /* don't allow any flags for host-joined groups */ @@ -1100,14 +1137,14 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, rcu_assign_pointer(*pp, p); if (entry->state == MDB_TEMPORARY) mod_timer(&p->timer, - now + br->multicast_ctx.multicast_membership_interval); + now + brmctx->multicast_membership_interval); br_mdb_notify(br->dev, mp, p, RTM_NEWMDB); /* if we are adding a new EXCLUDE port group (*,G) it needs to be also * added to all S,G entries for proper replication, if we are adding * a new INCLUDE port (S,G) then all of *,G EXCLUDE ports need to be * added to it for proper replication */ - if (br_multicast_should_handle_mode(&br->multicast_ctx, group.proto)) { + if (br_multicast_should_handle_mode(brmctx, group.proto)) { switch (filter_mode) { case MCAST_EXCLUDE: br_multicast_star_g_handle_mode(p, MCAST_EXCLUDE); From patchwork Wed Jul 21 14:01:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Aleksandrov X-Patchwork-Id: 484378 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 266B6C636C9 for ; Wed, 21 Jul 2021 14:02:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DAE760FED for ; Wed, 21 Jul 2021 14:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237827AbhGUNWG (ORCPT ); Wed, 21 Jul 2021 09:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237641AbhGUNWD (ORCPT ); Wed, 21 Jul 2021 09:22:03 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0669DC061575 for ; Wed, 21 Jul 2021 07:02:40 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id ee25so2532117edb.5 for ; Wed, 21 Jul 2021 07:02:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=blackwall-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LfptcPBAYX0XhZdNHSy9bCep6fygv+/dGc7yUbbpivY=; b=tPzfUROJpfPxtn5NDGuRsLr0LgX/7zCT7p3xJLZyn3uh+3WOwUSpPJJ/q1B6jKZ2ih vNOUeLRiLOUfVBaUjvw8fMtJDXgDfUyaT+DBst12kTsRkoFioi8BiBH0LSpYkVNBclW1 ZJ0ZpdbUdv0cSHZHvHgs1C9WJnj4MBWREsneHrPFg4F4bYBxsUnfYg95JXAfrq67nKE1 Ek/VPnGlT2T5TK6/zUFeT+WZZ2cHqiuNjOFsTtC0vo6Mo5YjywW0Z3UqPV1+SrFBuMHL 4J6epLZZRO5+PQ/saO9eeQiS2f25Y7EM+ub5LStvSsQnVbGMhySMQFtiev50zRVR8E0h YNQA== 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=LfptcPBAYX0XhZdNHSy9bCep6fygv+/dGc7yUbbpivY=; b=fcXIllgDvHP0dKzL/5ZxCI+kOLBHbP20z8ETu6eYNgez//h1Hv5qKdmAD45Jrdx56l BW9+WVmKP8E6a2K5udhWfhXulV0TLo+66cfapPetdOgl8c5tWXX790FOavUwgQTn/oB0 Ywo+56+bt+Lu4iw8vF4US5KagFhuJM4w6RO9bCoaMmgpz0UWDFcv8xLnnfQOrahm7FP8 wg4FLvb7ZA4Ti1buXSq+om8gaEPg3zS0iTjMZlVvyqAPdkNLSo99Y/khmYpkP1CcWVdN cuexx5+32mgI+pFYspUmBAO1NBIqO7/rRXLhobG0sro8cenTgGG93B+MsvYFGUNKfWeM WKtQ== X-Gm-Message-State: AOAM531ZUD1WhRVTvqb00pAQKxqe7Vzp99kYHURpudMDZHjSghd4R45n VkpoZyXQc7GCJNqWu3xi9AifGpvr2dZTz51c1WU= X-Google-Smtp-Source: ABdhPJxZXQrVmrNF5JExcv2srRYuC902Expj95CbBopvl0rNECDdB2m65ran5yLzVh3POG6EROrD1g== X-Received: by 2002:a05:6402:1bc6:: with SMTP id ch6mr49123596edb.267.1626876158376; Wed, 21 Jul 2021 07:02:38 -0700 (PDT) Received: from debil.vdiclient.nvidia.com (84-238-136-197.ip.btc-net.bg. [84.238.136.197]) by smtp.gmail.com with ESMTPSA id f15sm8362925ejc.61.2021.07.21.07.02.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jul 2021 07:02:38 -0700 (PDT) From: Nikolay Aleksandrov To: netdev@vger.kernel.org Cc: roopa@nvidia.com, bridge@lists.linux-foundation.org, Nikolay Aleksandrov Subject: [PATCH net-next 2/2] net: bridge: multicast: add context support for host-joined groups Date: Wed, 21 Jul 2021 17:01:27 +0300 Message-Id: <20210721140127.773194-3-razor@blackwall.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210721140127.773194-1-razor@blackwall.org> References: <20210721140127.773194-1-razor@blackwall.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Nikolay Aleksandrov Adding bridge multicast context support for host-joined groups is easy because we only need the proper timer value. We pass the already chosen context and use its timer value. Signed-off-by: Nikolay Aleksandrov --- net/bridge/br_mdb.c | 2 +- net/bridge/br_multicast.c | 8 ++++---- net/bridge/br_private.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c index 7b6c3b91d272..25d690b96cec 100644 --- a/net/bridge/br_mdb.c +++ b/net/bridge/br_mdb.c @@ -1105,7 +1105,7 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port, return -EEXIST; } - br_multicast_host_join(mp, false); + br_multicast_host_join(brmctx, mp, false); br_mdb_notify(br->dev, mp, NULL, RTM_NEWMDB); return 0; diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index 214d1bf854ad..470f1ec3b579 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -1312,7 +1312,8 @@ struct net_bridge_port_group *br_multicast_new_port_group( return p; } -void br_multicast_host_join(struct net_bridge_mdb_entry *mp, bool notify) +void br_multicast_host_join(const struct net_bridge_mcast *brmctx, + struct net_bridge_mdb_entry *mp, bool notify) { if (!mp->host_joined) { mp->host_joined = true; @@ -1325,8 +1326,7 @@ void br_multicast_host_join(struct net_bridge_mdb_entry *mp, bool notify) if (br_group_is_l2(&mp->addr)) return; - mod_timer(&mp->timer, - jiffies + mp->br->multicast_ctx.multicast_membership_interval); + mod_timer(&mp->timer, jiffies + brmctx->multicast_membership_interval); } void br_multicast_host_leave(struct net_bridge_mdb_entry *mp, bool notify) @@ -1363,7 +1363,7 @@ __br_multicast_add_group(struct net_bridge_mcast *brmctx, return ERR_CAST(mp); if (!pmctx) { - br_multicast_host_join(mp, true); + br_multicast_host_join(brmctx, mp, true); goto out; } diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index af1f5c1c6b88..30fb56637049 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -900,7 +900,8 @@ void br_multicast_get_stats(const struct net_bridge *br, struct br_mcast_stats *dest); void br_mdb_init(void); void br_mdb_uninit(void); -void br_multicast_host_join(struct net_bridge_mdb_entry *mp, bool notify); +void br_multicast_host_join(const struct net_bridge_mcast *brmctx, + struct net_bridge_mdb_entry *mp, bool notify); void br_multicast_host_leave(struct net_bridge_mdb_entry *mp, bool notify); void br_multicast_star_g_handle_mode(struct net_bridge_port_group *pg, u8 filter_mode);