From patchwork Mon Apr 11 13:38:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809116 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A657EC433EF for ; Mon, 11 Apr 2022 13:38:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344612AbiDKNlJ (ORCPT ); Mon, 11 Apr 2022 09:41:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343774AbiDKNlJ (ORCPT ); Mon, 11 Apr 2022 09:41:09 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F02D1222AE for ; Mon, 11 Apr 2022 06:38:54 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id h14so21563815lfl.2 for ; Mon, 11 Apr 2022 06:38:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=WN01e0l1+WdxQJa+iowT/x59ccthHRPG+MX9yqwnNBA=; b=k6eQUW56l8UrIWz2VghKJwhoP+InVqCMGkWpqHj8IB5vnlckcn1NfXqeDIn++xGzlB TZpLNsGKadS121SKMl1/k7fKlFEG8nt1DuoJyoovAJ4f16DqP+RGMaqdt9BCzUmJaNj/ +PFK+YGtiPdrBSE//1i+jCmxh6PUDJcj0lps/RZsXNS8R3lWzTWXmB8CK8G+j5ylrI9N E4NMTCIFy70mWuO4uo4gQFAZgjKKBPfKBiGA5ZHWieT6Tg7ncfYvtUPJWIv09VaCCNSO ek/MIL8VLbZaIbMON+6Q3Iw2BXmg1QF5zg1J0MHa2v7Cx+iFzYL2FzrNP9mbYxMNgZAp Jtaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=WN01e0l1+WdxQJa+iowT/x59ccthHRPG+MX9yqwnNBA=; b=1UFgstYDYb1cgMPhYPEHfaRdbaCPJ1Nfql7lLcT1A0rjWKtz4FZJKFJEbK4nYSTPq3 bVyuB9q3JvjXWmu/amESEy/pEWsnYEOLb/FYzKKigTK9XJa0tlKVjkMe2Qu9h6ZaCTfz tDG2TQiJscnQxtM6W/MDCjIx9ipwctoudwMxT6XehzZDnSSceN3oI/C2ndhiP9gfjdWg 8LN6aXXxKxwU4NUDMOeMInlXN7N4zhicnZFHktzYGBhj8ok/H8mU4c5mnCPn+NChA53g cP46oMDJ7bwc7HaRArPaLZ8m1gK21oG/6oRQObpMr5UCzbZfHUT5qMA4zfUBEuYMKJBB J9zA== X-Gm-Message-State: AOAM533qXpU5mg6gUEP5O3Scr2T+Qs4IvtCTLBkDzUkZPZiE5inxI1LJ QDzq/3cabpv3azyl3/s5yB4= X-Google-Smtp-Source: ABdhPJxL1DL50hKc+7ns26+XXgUelg2bDzOAYxg04ol0LvoKPy/1y7xh9WY/lhwoxpLiyuj+09tBTg== X-Received: by 2002:a05:6512:3046:b0:44b:121:4541 with SMTP id b6-20020a056512304600b0044b01214541mr21189810lfb.313.1649684333105; Mon, 11 Apr 2022 06:38:53 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:52 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 01/13] net: bridge: add control of bum flooding to bridge itself Date: Mon, 11 Apr 2022 15:38:25 +0200 Message-Id: <20220411133837.318876-2-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The bridge itself is also a port, but unfortunately it does not (yet) have a 'struct net_bridge_port'. However, in many cases we want to treat it as a proper port so concessions have been made, e.g., NULL port or host_joined attributes. This patch is an attempt to more of the same by adding support for controlling flooding of unknown broadcast/unicast/multicast to the bridge. Something we often also want to control in an offloaded switching fabric. Signed-off-by: Joachim Wiberg --- net/bridge/br_device.c | 4 ++++ net/bridge/br_input.c | 11 ++++++++--- net/bridge/br_private.h | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index 8d6bab244c4a..0aa7d21ac82c 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -526,6 +526,10 @@ void br_dev_setup(struct net_device *dev) br->bridge_ageing_time = br->ageing_time = BR_DEFAULT_AGEING_TIME; dev->max_mtu = ETH_MAX_MTU; + br_opt_toggle(br, BROPT_UNICAST_FLOOD, 1); + br_opt_toggle(br, BROPT_MCAST_FLOOD, 1); + br_opt_toggle(br, BROPT_BCAST_FLOOD, 1); + br_netfilter_rtable_init(br); br_stp_timer_init(br); br_multicast_init(br); diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index 196417859c4a..d439b876bdf5 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -118,7 +118,8 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb /* by definition the broadcast is also a multicast address */ if (is_broadcast_ether_addr(eth_hdr(skb)->h_dest)) { pkt_type = BR_PKT_BROADCAST; - local_rcv = true; + if (br_opt_get(br, BROPT_BCAST_FLOOD)) + local_rcv = true; } else { pkt_type = BR_PKT_MULTICAST; if (br_multicast_rcv(&brmctx, &pmctx, vlan, skb, vid)) @@ -161,12 +162,16 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb } mcast_hit = true; } else { - local_rcv = true; - br->dev->stats.multicast++; + if (br_opt_get(br, BROPT_MCAST_FLOOD)) { + local_rcv = true; + br->dev->stats.multicast++; + } } break; case BR_PKT_UNICAST: dst = br_fdb_find_rcu(br, eth_hdr(skb)->h_dest, vid); + if (!dst && br_opt_get(br, BROPT_UNICAST_FLOOD)) + local_rcv = true; break; default: break; diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 18ccc3d5d296..683bd0ee4c64 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -449,6 +449,9 @@ enum net_bridge_opts { BROPT_VLAN_BRIDGE_BINDING, BROPT_MCAST_VLAN_SNOOPING_ENABLED, BROPT_MST_ENABLED, + BROPT_UNICAST_FLOOD, + BROPT_MCAST_FLOOD, + BROPT_BCAST_FLOOD, }; struct net_bridge { From patchwork Mon Apr 11 13:38:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809118 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1941C433EF for ; Mon, 11 Apr 2022 13:39:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346589AbiDKNlM (ORCPT ); Mon, 11 Apr 2022 09:41:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343774AbiDKNlK (ORCPT ); Mon, 11 Apr 2022 09:41:10 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD777222B0 for ; Mon, 11 Apr 2022 06:38:55 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id o16so14261582ljp.3 for ; Mon, 11 Apr 2022 06:38:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=c2Hxf+Qd4VDlf3RyTcZ7u6PSE6ckvu4bfuQ6dUJjbnI=; b=dUNS3ltsPrnQGHh8Qf2VDr2VwLlBywJMd8CzsUSUVQtAzwupM2mqlPeuT3AWAGOMSj yvg0DBq5zwVVyWyOADLHtTHJQobKUiLz5Pxo6H1gdQ7epVI1VvvIlFQo48J9lixiWTSQ NjxX1hEeC6LHMkfcXHvnVCsE7+5Fwjm/sS7NbNINMiRUXkID17v7gAceggPr0Ig5LHmV IPPbGJ8SCmjY3ful/7pM26xjH3WSg5VpxABl+sGKdRRAf8GR56yDXdjTYAGo0rKtTfdK hw9F65Lc3XDw6Lpc+k3/MzH+Xh14LtESEtAlX6rO8pHaZaS+/sRITde0PYRfmlEIyHDk VV6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=c2Hxf+Qd4VDlf3RyTcZ7u6PSE6ckvu4bfuQ6dUJjbnI=; b=C2IpASw2ac0V1JhG/Jd0g/y/3f0R4sesH1/BRQSGuSTVtwUDwJGTyMZaNJtxRigoRo 0+8imgCTDxLEXChrgXGVMKcvhIf+6t1XDjUvWDU71lIthubTkvSPmeHM/rPTYCSh/3/E ZTg5xjFlkQC9m2/hGzpciU5rzOVlcSbenvcHnWRnHkqkCnHoOzY0xCbmVRxSJ6Z4rB0p kwSOg9gaulj5Bc4UT50eSY/0Iwl+jfPtvfTfkmS2jnM8+co2Kq2VecwnFqo3rL3W4Tje SA93/RQgYd4EZpW80tWdDMwunyvmAeaXBqIbOe+p33rlY//POdiARrCKuyKfUAcQPQy6 x+yg== X-Gm-Message-State: AOAM533Q/BWkMFpZcaORvvQtwRpKdEYOCoBorOPWKrQPWLV8ClDATfOo b32tjSCDD5Df9Q+sId63jkvvK6JboCqbRTkE X-Google-Smtp-Source: ABdhPJxN2mL7iTx2J06MCeT8oLkZN2Gf/0grFXW54mHhvTegORZPIn9cHNTNg8NPU/m7q+cCFGoxKA== X-Received: by 2002:a05:651c:1203:b0:24b:58c9:e1e3 with SMTP id i3-20020a05651c120300b0024b58c9e1e3mr7135103lja.127.1649684334132; Mon, 11 Apr 2022 06:38:54 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:53 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 02/13] net: bridge: rename br_switchdev_set_port_flag() to .._dev_flag() Date: Mon, 11 Apr 2022 15:38:26 +0200 Message-Id: <20220411133837.318876-3-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The br_switchdev_set_port_flag() function only uses the `p->dev` member of the port, and we also want to reuse it for the bridge itself. Change the first argument and the name of the function to match. Signed-off-by: Joachim Wiberg --- net/bridge/br_netlink.c | 2 +- net/bridge/br_private.h | 4 ++-- net/bridge/br_switchdev.c | 8 ++++---- net/bridge/br_sysfs_if.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 200ad05b296f..7fca8ff13ec7 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -942,7 +942,7 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[], changed_mask = old_flags ^ p->flags; - err = br_switchdev_set_port_flag(p, p->flags, changed_mask, extack); + err = br_switchdev_set_dev_flag(p->dev, p->flags, changed_mask, extack); if (err) { p->flags = old_flags; return err; diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 683bd0ee4c64..6c230be6fbf5 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -2038,7 +2038,7 @@ void nbp_switchdev_frame_mark(const struct net_bridge_port *p, struct sk_buff *skb); bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, const struct sk_buff *skb); -int br_switchdev_set_port_flag(struct net_bridge_port *p, +int br_switchdev_set_dev_flag(struct net_device *dev, unsigned long flags, unsigned long mask, struct netlink_ext_ack *extack); @@ -2108,7 +2108,7 @@ static inline bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, return true; } -static inline int br_switchdev_set_port_flag(struct net_bridge_port *p, +static inline int br_switchdev_set_dev_flag(struct net_device *dev, unsigned long flags, unsigned long mask, struct netlink_ext_ack *extack) diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c index 8cc44c367231..3b4df63e96a6 100644 --- a/net/bridge/br_switchdev.c +++ b/net/bridge/br_switchdev.c @@ -74,13 +74,13 @@ bool nbp_switchdev_allowed_egress(const struct net_bridge_port *p, #define BR_PORT_FLAGS_HW_OFFLOAD (BR_LEARNING | BR_FLOOD | \ BR_MCAST_FLOOD | BR_BCAST_FLOOD | BR_PORT_LOCKED) -int br_switchdev_set_port_flag(struct net_bridge_port *p, +int br_switchdev_set_dev_flag(struct net_device *dev, unsigned long flags, unsigned long mask, struct netlink_ext_ack *extack) { struct switchdev_attr attr = { - .orig_dev = p->dev, + .orig_dev = dev, }; struct switchdev_notifier_port_attr_info info = { .attr = &attr, @@ -96,7 +96,7 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p, attr.u.brport_flags.mask = mask; /* We run from atomic context here */ - err = call_switchdev_notifiers(SWITCHDEV_PORT_ATTR_SET, p->dev, + err = call_switchdev_notifiers(SWITCHDEV_PORT_ATTR_SET, dev, &info.info, extack); err = notifier_to_errno(err); if (err == -EOPNOTSUPP) @@ -112,7 +112,7 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p, attr.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS; attr.flags = SWITCHDEV_F_DEFER; - err = switchdev_port_attr_set(p->dev, &attr, extack); + err = switchdev_port_attr_set(dev, &attr, extack); if (err) { if (extack && !extack->_msg) NL_SET_ERR_MSG_MOD(extack, diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c index 07fa76080512..c222c68105f1 100644 --- a/net/bridge/br_sysfs_if.c +++ b/net/bridge/br_sysfs_if.c @@ -69,7 +69,7 @@ static int store_flag(struct net_bridge_port *p, unsigned long v, flags &= ~mask; if (flags != p->flags) { - err = br_switchdev_set_port_flag(p, flags, mask, &extack); + err = br_switchdev_set_dev_flag(p->dev, flags, mask, &extack); if (err) { netdev_err(p->dev, "%s\n", extack._msg); return err; From patchwork Mon Apr 11 13:38:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809119 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9ADD2C433F5 for ; Mon, 11 Apr 2022 13:39:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346597AbiDKNlT (ORCPT ); Mon, 11 Apr 2022 09:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343598AbiDKNlK (ORCPT ); Mon, 11 Apr 2022 09:41:10 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43EB21E15 for ; Mon, 11 Apr 2022 06:38:56 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id z17so2182729lfj.11 for ; Mon, 11 Apr 2022 06:38:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=15O42YcTjpmDhDPvSQqOizS3ABZbH38ENN7jhBTnn4Q=; b=IaBb4jkSWIxICG3VJbssykTGz95G7zDiifz0RBjL7GZ0tpIylTl8B5PNRmMO5lYyW9 u4I8tQzRMFBFmViPiEgTzX9uNrJ0bvNsnj9b6BxHtlJnbk6D/3daKgMX+7/zPJ9688lV UXkLUnEF2gFdok5cQjofcP4nnSwFnnoI+P+WEUmEjDG2/byd8dBjrlFJjcKhvr32ZbY5 KB3pT6TLB8YBzk/xlcdHO/I0xOZtmpYImmemgxjl48DHu5Sk7WeWYbpTz/1IQiKiimzG mSROXfhet++r3kzANHZrmtF51DKjmziKgj1dg8TOPZeE8u7wm/G65hAMbS7VVbMX3uGv E3bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=15O42YcTjpmDhDPvSQqOizS3ABZbH38ENN7jhBTnn4Q=; b=4711b+JTvhC5nkqv+sFSOGIjdtA2XCSUJfNJyxEhP6EI50nSApSy9xdJO57anCQPRW 1FLb26Kmo2+BBCUmC6s1CuRFu4I5Hp9gZ0UIN+3BgVIVmhLFXGlgiMU4HSIpqz7xZW3c 25XWPxXXhVfRI5jwN/f52mD/4y74FjqhUkHi8uoG8clYesBW27HOnJGniyVVs8DXecO7 BwI/Ex/PTJWYN8LkRJDm8ArK6Qw8zYPAweRYVdqm2PfNdrHHFXWUhis2afLrNWvdidxb ZrRSQWDVnao1RlHChD7fkdvE3pz1Rn7B5JdbS6fuff7y6XVva67dZEgFUwaXRGb3pMcO aM3g== X-Gm-Message-State: AOAM530CCaYz9vUyusIg2mUQk+z4bdIiGKVEgUC/+yT9MPoU3p60alT7 bZtIjZjRj725bpujA7pwtis= X-Google-Smtp-Source: ABdhPJwVX0p4K8mGxFlbxBh0ugRbtpmk0aqkD7A7QNIJgZPtnwRRD6Kal5WfasVud0lNUC7kiIzQ2g== X-Received: by 2002:a05:6512:3402:b0:448:c29:ce8a with SMTP id i2-20020a056512340200b004480c29ce8amr22242644lfr.633.1649684335092; Mon, 11 Apr 2022 06:38:55 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:54 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 03/13] net: bridge: minor refactor of br_setlink() for readability Date: Mon, 11 Apr 2022 15:38:27 +0200 Message-Id: <20220411133837.318876-4-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC The br_setlink() function extracts the struct net_bridge pointer a bit sloppy. It's easy to interpret the code wrong. This patch attempts to clear things up a bit. Signed-off-by: Joachim Wiberg --- net/bridge/br_netlink.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 7fca8ff13ec7..8f4297287b32 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -1040,6 +1040,8 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags, return 0; p = br_port_get_rtnl(dev); + if (p) + br = p->br; /* We want to accept dev as bridge itself if the AF_SPEC * is set to see if someone is setting vlan info on the bridge */ @@ -1055,17 +1057,17 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags, if (err) return err; - spin_lock_bh(&p->br->lock); + spin_lock_bh(&br->lock); err = br_setport(p, tb, extack); - spin_unlock_bh(&p->br->lock); + spin_unlock_bh(&br->lock); } else { /* Binary compatibility with old RSTP */ if (nla_len(protinfo) < sizeof(u8)) return -EINVAL; - spin_lock_bh(&p->br->lock); + spin_lock_bh(&br->lock); err = br_set_port_state(p, nla_get_u8(protinfo)); - spin_unlock_bh(&p->br->lock); + spin_unlock_bh(&br->lock); } if (err) goto out; From patchwork Mon Apr 11 13:38:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809122 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14C05C433F5 for ; Mon, 11 Apr 2022 13:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346609AbiDKNlY (ORCPT ); Mon, 11 Apr 2022 09:41:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346570AbiDKNlM (ORCPT ); Mon, 11 Apr 2022 09:41:12 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDB66222B3 for ; Mon, 11 Apr 2022 06:38:57 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id bn33so20132563ljb.6 for ; Mon, 11 Apr 2022 06:38:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=DSRcc4cQuRQfjO5ws3ys+XQ4CrSo1tNDaNbQ7j9cAHE=; b=AUEdjlBM7ypyirvB5ZGOPXA9+wdMGwDzlWRxJUW2YESDOXXAhx29foqjE2BZwX6F4X ppeYtNJRg1uY9mqnSpLa4BmGrwoafD427QNp/3wI6He/bIUaDT0N7tA0ZwXS+zMbykZH kAVmlbp+UG2hfQCvBflsLla6crUMmMSKAkHbxtoNWthJFC2/PdFiHBrDGWf2LipayZSh ZnyhPEp6PWqBAiLmPBjFycMpZO9mrM+hryVf48XQS0UZyHHeoHA+pgVjiREO9fHcAXbc fiTJt1zsZhKY5pupgIz9lGz2n1ezkYM0c7Ow02JphNuxkheWU65FuFuqIjaELxZyV7Sj k0WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=DSRcc4cQuRQfjO5ws3ys+XQ4CrSo1tNDaNbQ7j9cAHE=; b=2UU0Qen9U4xwwZP/CJ/ir+ceEfOuw2lMm4+pziGWX4sKetIVBOHLSCjC49bYWnQHpa xGRpjLedziHlU04N8jr2+s9L3FtR+z6MXu2LnfxPG8G6TEXKsTT4QEcYumOvV7CZlpKo Uqp29rX2h+vM/sb6foEyGeumXt/Aj8UpQxl1wdNjzrj77rpaWtuTov1ov9jrbThzmQZA UvDMpJwC6iHizq+jnOk5+AHQHVJxXh8CDmPJ6kSEPDttNxCDjgDp89cCP8IyZvu1N8VX tx0X6LVLqdb5w3YwRBlcVZau49dqHlrt0I9+eC9gj/Xl4g2ZK2BJtCCxAePA4NNL35/F ssCA== X-Gm-Message-State: AOAM530Nu16bWCKdkynYPixlSVyFP6voQW19YgtOO4xuN3xnbK/5U/E8 Nj8CkPdfFSVHpPutDXe0GPs= X-Google-Smtp-Source: ABdhPJzFVd+o/fG8WImDGh0V3CGrdKyAxclb2kQMHcgQRzaDb3tCfi7H+2vhH48BPlGQwvhPC1ZzMw== X-Received: by 2002:a05:651c:b14:b0:24b:638d:dfe4 with SMTP id b20-20020a05651c0b1400b0024b638ddfe4mr3152246ljr.314.1649684335985; Mon, 11 Apr 2022 06:38:55 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:55 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 04/13] net: bridge: netlink support for controlling BUM flooding to bridge Date: Mon, 11 Apr 2022 15:38:28 +0200 Message-Id: <20220411133837.318876-5-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This patch adds netlink support for controlling the new broadcast, unicast, and multicast flooding flags to the bridge itself. The messy part is in br_setport(), which re-indents a large block of code for the port settings. To reduce code duplication a few new variables have been added; new_flags and dev. The latter is used for the recently renamed br_switchdev_set_dev_flag(), which can now be used by underlying switching fabric drivers as another source of information when controlling flooding of unknown BUM traffic to the CPU port. Signed-off-by: Joachim Wiberg --- net/bridge/br_netlink.c | 160 ++++++++++++++++++++++++++++++---------- 1 file changed, 123 insertions(+), 37 deletions(-) diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 8f4297287b32..68bbf703b31a 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -225,13 +225,29 @@ static inline size_t br_nlmsg_size(struct net_device *dev, u32 filter_mask) + nla_total_size(4); /* IFLA_BRPORT_BACKUP_PORT */ } -static int br_port_fill_attrs(struct sk_buff *skb, +static int br_port_fill_attrs(struct sk_buff *skb, const struct net_bridge *br, const struct net_bridge_port *p) { - u8 mode = !!(p->flags & BR_HAIRPIN_MODE); struct net_bridge_port *backup_p; u64 timerval; + u8 mode; + if (!p) { + if (!br) + return -EINVAL; + + if (nla_put_u8(skb, IFLA_BRPORT_UNICAST_FLOOD, + br_opt_get(br, BROPT_UNICAST_FLOOD)) || + nla_put_u8(skb, IFLA_BRPORT_MCAST_FLOOD, + br_opt_get(br, BROPT_MCAST_FLOOD)) || + nla_put_u8(skb, IFLA_BRPORT_BCAST_FLOOD, + br_opt_get(br, BROPT_BCAST_FLOOD))) + return -EMSGSIZE; + + return 0; + } + + mode = !!(p->flags & BR_HAIRPIN_MODE); if (nla_put_u8(skb, IFLA_BRPORT_STATE, p->state) || nla_put_u16(skb, IFLA_BRPORT_PRIORITY, p->priority) || nla_put_u32(skb, IFLA_BRPORT_COST, p->path_cost) || @@ -475,11 +491,11 @@ static int br_fill_ifinfo(struct sk_buff *skb, nla_put_u32(skb, IFLA_LINK, dev_get_iflink(dev)))) goto nla_put_failure; - if (event == RTM_NEWLINK && port) { + if (event == RTM_NEWLINK) { struct nlattr *nest; nest = nla_nest_start(skb, IFLA_PROTINFO); - if (nest == NULL || br_port_fill_attrs(skb, port) < 0) + if (!nest || br_port_fill_attrs(skb, br, port) < 0) goto nla_put_failure; nla_nest_end(skb, nest); } @@ -911,43 +927,113 @@ static void br_set_port_flag(struct net_bridge_port *p, struct nlattr *tb[], p->flags &= ~mask; } +/* Map bridge options to brport flags */ +static unsigned long br_boolopt_map_flags(struct br_boolopt_multi *bm) +{ + unsigned long bitmap = bm->optmask; + unsigned long bitmask = 0; + int opt_id; + + for_each_set_bit(opt_id, &bitmap, BR_BOOLOPT_MAX) { + if (!(bm->optval & BIT(opt_id))) + continue; + + switch (opt_id) { + case BROPT_UNICAST_FLOOD: + bitmask |= BR_FLOOD; + break; + case BROPT_MCAST_FLOOD: + bitmask |= BR_MCAST_FLOOD; + break; + case BROPT_BCAST_FLOOD: + bitmask |= BR_BCAST_FLOOD; + break; + } + } + + return bitmask; +} + +static void br_set_bropt(struct net_bridge *br, struct nlattr *tb[], + int attrtype, enum net_bridge_opts opt) +{ + if (!tb[attrtype]) + return; + + br_opt_toggle(br, opt, !!nla_get_u8(tb[attrtype])); +} + +#define BROPT_MASK (BROPT_UNICAST_FLOOD | BROPT_MCAST_FLOOD | BROPT_MCAST_FLOOD) + /* Process bridge protocol info on port */ -static int br_setport(struct net_bridge_port *p, struct nlattr *tb[], - struct netlink_ext_ack *extack) +static int br_setport(struct net_bridge *br, struct net_bridge_port *p, + struct nlattr *tb[], struct netlink_ext_ack *extack) { - unsigned long old_flags, changed_mask; + unsigned long old_flags, new_flags, changed_mask; + struct br_boolopt_multi old_opts = { + .optmask = BROPT_MASK + }; bool br_vlan_tunnel_old; + struct net_device *dev; int err; - old_flags = p->flags; - br_vlan_tunnel_old = (old_flags & BR_VLAN_TUNNEL) ? true : false; - - br_set_port_flag(p, tb, IFLA_BRPORT_MODE, BR_HAIRPIN_MODE); - br_set_port_flag(p, tb, IFLA_BRPORT_GUARD, BR_BPDU_GUARD); - br_set_port_flag(p, tb, IFLA_BRPORT_FAST_LEAVE, - BR_MULTICAST_FAST_LEAVE); - br_set_port_flag(p, tb, IFLA_BRPORT_PROTECT, BR_ROOT_BLOCK); - br_set_port_flag(p, tb, IFLA_BRPORT_LEARNING, BR_LEARNING); - br_set_port_flag(p, tb, IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD); - br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD); - br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_TO_UCAST, - BR_MULTICAST_TO_UNICAST); - br_set_port_flag(p, tb, IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD); - br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP, BR_PROXYARP); - br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP_WIFI, BR_PROXYARP_WIFI); - br_set_port_flag(p, tb, IFLA_BRPORT_VLAN_TUNNEL, BR_VLAN_TUNNEL); - br_set_port_flag(p, tb, IFLA_BRPORT_NEIGH_SUPPRESS, BR_NEIGH_SUPPRESS); - br_set_port_flag(p, tb, IFLA_BRPORT_ISOLATED, BR_ISOLATED); - br_set_port_flag(p, tb, IFLA_BRPORT_LOCKED, BR_PORT_LOCKED); - - changed_mask = old_flags ^ p->flags; - - err = br_switchdev_set_dev_flag(p->dev, p->flags, changed_mask, extack); + if (p) { + old_flags = p->flags; + br_vlan_tunnel_old = (old_flags & BR_VLAN_TUNNEL) ? true : false; + + br_set_port_flag(p, tb, IFLA_BRPORT_MODE, BR_HAIRPIN_MODE); + br_set_port_flag(p, tb, IFLA_BRPORT_GUARD, BR_BPDU_GUARD); + br_set_port_flag(p, tb, IFLA_BRPORT_FAST_LEAVE, + BR_MULTICAST_FAST_LEAVE); + br_set_port_flag(p, tb, IFLA_BRPORT_PROTECT, BR_ROOT_BLOCK); + br_set_port_flag(p, tb, IFLA_BRPORT_LEARNING, BR_LEARNING); + br_set_port_flag(p, tb, IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD); + br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD); + br_set_port_flag(p, tb, IFLA_BRPORT_MCAST_TO_UCAST, + BR_MULTICAST_TO_UNICAST); + br_set_port_flag(p, tb, IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD); + br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP, BR_PROXYARP); + br_set_port_flag(p, tb, IFLA_BRPORT_PROXYARP_WIFI, BR_PROXYARP_WIFI); + br_set_port_flag(p, tb, IFLA_BRPORT_VLAN_TUNNEL, BR_VLAN_TUNNEL); + br_set_port_flag(p, tb, IFLA_BRPORT_NEIGH_SUPPRESS, BR_NEIGH_SUPPRESS); + br_set_port_flag(p, tb, IFLA_BRPORT_ISOLATED, BR_ISOLATED); + br_set_port_flag(p, tb, IFLA_BRPORT_LOCKED, BR_PORT_LOCKED); + + new_flags = p->flags; + dev = p->dev; + } else { + struct br_boolopt_multi opts = { + .optmask = BROPT_MASK + }; + + br_boolopt_multi_get(br, &old_opts); + old_flags = br_boolopt_map_flags(&old_opts); + + br_set_bropt(br, tb, IFLA_BRPORT_UNICAST_FLOOD, BROPT_UNICAST_FLOOD); + br_set_bropt(br, tb, IFLA_BRPORT_MCAST_FLOOD, BROPT_MCAST_FLOOD); + br_set_bropt(br, tb, IFLA_BRPORT_BCAST_FLOOD, BROPT_BCAST_FLOOD); + + br_boolopt_multi_get(br, &opts); + new_flags = br_boolopt_map_flags(&opts); + dev = br->dev; + } + + changed_mask = old_flags ^ new_flags; + + err = br_switchdev_set_dev_flag(dev, new_flags, changed_mask, extack); if (err) { - p->flags = old_flags; + if (!p) + br_boolopt_multi_toggle(br, &old_opts, extack); + else + p->flags = old_flags; + return err; } + /* Skip the rest for the bridge itself, for now */ + if (!p) + return 0; + if (br_vlan_tunnel_old && !(p->flags & BR_VLAN_TUNNEL)) nbp_vlan_tunnel_info_flush(p); @@ -1048,7 +1134,7 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags, if (!p && !afspec) return -EINVAL; - if (p && protinfo) { + if (protinfo) { if (protinfo->nla_type & NLA_F_NESTED) { err = nla_parse_nested_deprecated(tb, IFLA_BRPORT_MAX, protinfo, @@ -1058,9 +1144,9 @@ int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags, return err; spin_lock_bh(&br->lock); - err = br_setport(p, tb, extack); + err = br_setport(br, p, tb, extack); spin_unlock_bh(&br->lock); - } else { + } else if (p) { /* Binary compatibility with old RSTP */ if (nla_len(protinfo) < sizeof(u8)) return -EINVAL; @@ -1153,7 +1239,7 @@ static int br_port_slave_changelink(struct net_device *brdev, return 0; spin_lock_bh(&br->lock); - ret = br_setport(br_port_get_rtnl(dev), data, extack); + ret = br_setport(br, br_port_get_rtnl(dev), data, extack); spin_unlock_bh(&br->lock); return ret; @@ -1163,7 +1249,7 @@ static int br_port_fill_slave_info(struct sk_buff *skb, const struct net_device *brdev, const struct net_device *dev) { - return br_port_fill_attrs(skb, br_port_get_rtnl(dev)); + return br_port_fill_attrs(skb, NULL, br_port_get_rtnl(dev)); } static size_t br_port_get_slave_size(const struct net_device *brdev, From patchwork Mon Apr 11 13:38:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809121 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4617C433EF for ; Mon, 11 Apr 2022 13:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346596AbiDKNlW (ORCPT ); Mon, 11 Apr 2022 09:41:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346591AbiDKNlM (ORCPT ); Mon, 11 Apr 2022 09:41:12 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B561C2251A for ; Mon, 11 Apr 2022 06:38:58 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id b21so26707932lfb.5 for ; Mon, 11 Apr 2022 06:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=8qjm9wLjph4c7kZ9jfundVdGQ8PpnhtD4gzzvkqBGsw=; b=o88XnttxQH1grWq83aF2OyYu/OVtodv2bsFld55tVD1cJ7zPXGbYuugXvLyv7S+paa w0T63kWHbWtByKFbWpp1T7hfyoGLYImSlR+vYNnTiDx2UYFt/91qCMm3I/6XbtZgNuZo KQf3aXihjAxbi5uLLb0AEs63L+PANYYdNk0sAdnZCVm9cWq50FBqGHxSb0hAYyViqc/r a0YxqHm8hwzcwD6Vw/R33J0quvtAa0l4q2EeuW5scdocpR8W7MQtgM/U/zebSyh4nUXB AI0f2RRWbVh9JOQLwldxiBlXthrz5wUHe/pRZ3NY2yji2tiI5xNpSH5wKQ2qTWNTYvpp gU6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=8qjm9wLjph4c7kZ9jfundVdGQ8PpnhtD4gzzvkqBGsw=; b=2YczwTiAgjwERqdVKr9vi983fMYow7i/w2MxNaS2Qq7/iJY+TEBgg7K3Vn9NubhtVe 5MwWRftnnxxPn49R1YoefRmGgl8EcYUojjf9Sgtu+K/SuDEC3XTQD0nqtFBS02bEeWwo hhA999zzMkHVKRwyraoBBSCi+oupANj0ecRBz2CKSULYpRZQdHSKGbhBM4i5wROj5m3E w11LrT6CFqibqBZQTz2vreuLDQ/9RIYhSSlUs0QKl0NVR9GMnudduDCnS0ENUlaHCJnS ybo0AYznx5zgql6QrNKcQu6HhEyEawlHU11iyochm4VI5j7jkEEoX52ecctUw9IJTzSU MFdg== X-Gm-Message-State: AOAM533MVnL0lXBqQVo870LlqSff1CIhYgSnKDR23NtvxJubV2pte91A XirSMh/9DtDgH03F6aHXKSZxKWIXHSplIQkM X-Google-Smtp-Source: ABdhPJwEOg1f2YmvXtYOnsziJ1SVjzWn4o3G3iIGap8DrSs5yqqUzx3XzMrdEHCraarWTUKt67rZ1w== X-Received: by 2002:a05:6512:24a:b0:46b:ad98:88db with SMTP id b10-20020a056512024a00b0046bad9888dbmr1816704lfo.304.1649684336982; Mon, 11 Apr 2022 06:38:56 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:56 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 05/13] selftests: forwarding: add TCPDUMP_EXTRA_FLAGS to lib.sh Date: Mon, 11 Apr 2022 15:38:29 +0200 Message-Id: <20220411133837.318876-6-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC For some use-cases we may want to change the tcpdump flags used in tcpdump_start(). For instance, observing interfaces without the PROMISC flag, e.g. to see what's really being forwarded to the bridge interface. Signed-off-by: Joachim Wiberg --- tools/testing/selftests/net/forwarding/lib.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) mode change 100644 => 100755 tools/testing/selftests/net/forwarding/lib.sh diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh old mode 100644 new mode 100755 index 664b9ecaf228..00cdcab7accf --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1369,7 +1369,13 @@ tcpdump_start() capuser="-Z $SUDO_USER" fi - $ns_cmd tcpdump -e -n -Q in -i $if_name \ + if [ -z $TCPDUMP_EXTRA_FLAGS ]; then + extra_flags="" + else + extra_flags="$TCPDUMP_EXTRA_FLAGS" + fi + + $ns_cmd tcpdump $extra_flags -e -n -Q in -i $if_name \ -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & cappid=$! From patchwork Mon Apr 11 13:38:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809120 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94A0BC433EF for ; Mon, 11 Apr 2022 13:39:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346612AbiDKNlV (ORCPT ); Mon, 11 Apr 2022 09:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346592AbiDKNlN (ORCPT ); Mon, 11 Apr 2022 09:41:13 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9EA922530 for ; Mon, 11 Apr 2022 06:38:59 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id o16so14261838ljp.3 for ; Mon, 11 Apr 2022 06:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=7+9AQPsj4qe+ej9vd9ZSEydjVfvWzHGKKHrVDnEiVdU=; b=QCrNRd94foqMNxVskGlMwCCfRXRjQeQ+pp6t1LBGrm9LEuIGq4N4GXTvyNQx4uEUBh ++f6ASOqDQLBns5t1I9IMVfxzR6IlWEZIBxk2DBCYDNGcHdL8vyzwCZz4q4YfpIoyC4T VZQKvlUgbx+I8b9kNSG2LhpqWaUYBRyHkWKvbeh1lltsD0OniLu8Ay/4e/2S/wAIJH52 CHAaf8fTEqBgk8G76MuGXEHS/WUiYcZ0SKLtEAqXdZmov79e5faGdOsziIPbICPZ5zfi 9T71AKcCSUNE8Dcg7JSOKdCjUQV8IStq7GGOVkNQ2z4KX+WjiWa2kQF1PNysKiFnVtvR B/PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=7+9AQPsj4qe+ej9vd9ZSEydjVfvWzHGKKHrVDnEiVdU=; b=Eg7AZj3TDxp0wXXePqkU/IWfrw7+pNWUd1DTf3BmFUsq3MrJnhF7dY1CpdupoyAsIN 5Shmt27vU+52e7msO+fUHKIeIrq+Qu6QiyH/lZvT67rIJfHxXh+s7cxEymLuuWtiFwdQ QnnPSWL47JKirn7MCSl2wmjSLEHB5N0X2AAznxLXsn3JeQLf4Lj6A4zr8orvCMTUkWl4 XSdilFlCFtQb49bJhblMrZ62C6c5q8NTTeLu8GltLOHscC6KvfgQiJZb1AzL0sofhPig 0bxqqn8aEnRcNRalJI/RCv+HVD/M8Dg3PX1AXVTU43Arg6lFwsene4I4kJkxyOSBONGu bqpQ== X-Gm-Message-State: AOAM530T5mncpS4oTt7gUujqpbZRhr6Ov80H7DruW0qenH0JUcRzBn5K xNDnfgPAHnIsgXP0qKzZomY= X-Google-Smtp-Source: ABdhPJxvN7ailgrYMIamCFTGsgBi/osE36m/CuR7LqQ7S1vJdTd54IN4IAHq3rUPQql+D5A36XfYYw== X-Received: by 2002:a05:651c:555:b0:24b:15b7:74ad with SMTP id q21-20020a05651c055500b0024b15b774admr20055797ljp.239.1649684337910; Mon, 11 Apr 2022 06:38:57 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:57 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 06/13] selftests: forwarding: multiple instances in tcpdump helper Date: Mon, 11 Apr 2022 15:38:30 +0200 Message-Id: <20220411133837.318876-7-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Extend tcpdump_start() & C:o to handle multiple instances. Useful when observing bridge operation, e.g., unicast learning/flooding, and any case of multicast distribution (to these ports but not that one ...). This means the interface argument is now a mandatory argument to all tcpdump_*() functions, hence the changes to the ocelot flower test. Signed-off-by: Joachim Wiberg Reviewed-by: Vladimir Oltean --- .../drivers/net/ocelot/tc_flower_chains.sh | 24 +++++++++--------- tools/testing/selftests/net/forwarding/lib.sh | 25 +++++++++++++------ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh b/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh index eaf8a04a7ca5..7e684e27a682 100755 --- a/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh +++ b/tools/testing/selftests/drivers/net/ocelot/tc_flower_chains.sh @@ -215,15 +215,15 @@ test_vlan_pop() sleep 1 - tcpdump_stop + tcpdump_stop $eth2 - if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4"; then + if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, ethertype IPv4"; then echo "OK" else echo "FAIL" fi - tcpdump_cleanup + tcpdump_cleanup $eth2 } test_vlan_push() @@ -236,15 +236,15 @@ test_vlan_push() sleep 1 - tcpdump_stop + tcpdump_stop $eth3.100 - if tcpdump_show | grep -q "$eth2_mac > $eth3_mac"; then + if tcpdump_show $eth3.100 | grep -q "$eth2_mac > $eth3_mac"; then echo "OK" else echo "FAIL" fi - tcpdump_cleanup + tcpdump_cleanup $eth3.100 } test_vlan_ingress_modify() @@ -267,15 +267,15 @@ test_vlan_ingress_modify() sleep 1 - tcpdump_stop + tcpdump_stop $eth2 - if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then + if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then echo "OK" else echo "FAIL" fi - tcpdump_cleanup + tcpdump_cleanup $eth2 tc filter del dev $eth0 ingress chain $(IS1 2) pref 3 @@ -305,15 +305,15 @@ test_vlan_egress_modify() sleep 1 - tcpdump_stop + tcpdump_stop $eth2 - if tcpdump_show | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then + if tcpdump_show $eth2 | grep -q "$eth3_mac > $eth2_mac, .* vlan 300"; then echo "OK" else echo "FAIL" fi - tcpdump_cleanup + tcpdump_cleanup $eth2 tc filter del dev $eth1 egress chain $(ES0) pref 3 tc qdisc del dev $eth1 clsact diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 00cdcab7accf..20a6d6b2f389 100755 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -1349,13 +1349,17 @@ stop_traffic() { kill %% && wait %%; } 2>/dev/null } +declare -A cappid +declare -A capfile +declare -A capout + tcpdump_start() { local if_name=$1; shift local ns=$1; shift - capfile=$(mktemp) - capout=$(mktemp) + capfile[$if_name]=$(mktemp) + capout[$if_name]=$(mktemp) if [ -z $ns ]; then ns_cmd="" @@ -1376,26 +1380,33 @@ tcpdump_start() fi $ns_cmd tcpdump $extra_flags -e -n -Q in -i $if_name \ - -s 65535 -B 32768 $capuser -w $capfile > "$capout" 2>&1 & - cappid=$! + -s 65535 -B 32768 $capuser -w ${capfile[$if_name]} > "${capout[$if_name]}" 2>&1 & + cappid[$if_name]=$! sleep 1 } tcpdump_stop() { - $ns_cmd kill $cappid + local if_name=$1 + local pid=${cappid[$if_name]} + + $ns_cmd kill "$pid" && wait "$pid" sleep 1 } tcpdump_cleanup() { - rm $capfile $capout + local if_name=$1 + + rm ${capfile[$if_name]} ${capout[$if_name]} } tcpdump_show() { - tcpdump -e -n -r $capfile 2>&1 + local if_name=$1 + + tcpdump -e -n -r ${capfile[$if_name]} 2>&1 } # return 0 if the packet wasn't seen on host2_if or 1 if it was From patchwork Mon Apr 11 13:38:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809123 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7EDDC433FE for ; Mon, 11 Apr 2022 13:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346616AbiDKNlZ (ORCPT ); Mon, 11 Apr 2022 09:41:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346601AbiDKNlS (ORCPT ); Mon, 11 Apr 2022 09:41:18 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F017022B07 for ; Mon, 11 Apr 2022 06:39:00 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id q189so3563624ljb.13 for ; Mon, 11 Apr 2022 06:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=m14KfFMNBJMj3DAuyjsFtzaOxg7nS8IZJkNu+xhWBoQ=; b=CF/kSL/5S4j/4pPmpoLhhNdCrfZHMeBh9sE/2PJE0HqUOCEgafv5S1xncVTcNldYka bujyLGn0wSb5IBpMJm+DjbZcofg5/n1pMDuRJcjcyGtYVModUHJBdPWkNUMBzWxB+6Y6 7XTL1f9ut0IvB8D8LnbeO3VpuapMphxnK6rwcZ8l5muQmDpnS0A6jMN9b1twOzMAjnnV CEM6/CdcQV2cA1N2paU8GuKa33A+GOVIFImxq5tUYQEVYgkVcsPZnmaiRKU5QsPIo5mY mxmshyVaRmPnCK/qBqOPDhh7da9zMkNNLfLGBgyeVVVlKpHWokexKZ+VU2d8v27C0lO8 Ob7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=m14KfFMNBJMj3DAuyjsFtzaOxg7nS8IZJkNu+xhWBoQ=; b=YafhF2QhAWLIiYPrJtyIng2pZ3Q9vfPgqBCGh3B9be8DwjLTFtCXEqB2tMHHr/WVdW 79HSjy8ccWkbON55+0Bl0+M1+wHpzxpafPso4NtayFjTTcN6S8ypKFLxYgRJBc0JbpWZ 7jQcz8G7552m3r0fd+zRn8jrgSNIciat11v38kcu6/5W0et0ciLBJNZ/CQMhxMlDGd2H JpPBKR5k5aTPXc0txj6yZLYpWH4JzRC7qdAO8S5Sj+F1H9uh/B+QEUVuY0DbzVCBo4+z 7LxW69xCbtjoXEmMPvrr3f9z4+DLe449qImkz8RQgLASqrUGF3FUzfCeijJ8O5yXbK5R rKsg== X-Gm-Message-State: AOAM531E+KcHBCnkU2mGaslhWlHcYj7ETE9mOJFS/qOFW+kJ3jTX/F2N zV06DJmtTNk6nlzUzTA65vU= X-Google-Smtp-Source: ABdhPJwssNZ+az2E808C2bVCmUF81dwyAbsp7RBf0OX5v/o1yXDs6cq18a4hcqoxMpWUEUwzjxJQwA== X-Received: by 2002:a2e:9d19:0:b0:24b:4bd:3f68 with SMTP id t25-20020a2e9d19000000b0024b04bd3f68mr19588588lji.418.1649684338833; Mon, 11 Apr 2022 06:38:58 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:58 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 07/13] selftests: forwarding: new test, verify bridge flood flags Date: Mon, 11 Apr 2022 15:38:31 +0200 Message-Id: <20220411133837.318876-8-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Test per-port flood control flags of unknown BUM traffic by injecting bc/uc/mc on one bridge port and verifying it being forwarded to both the bridge itself and another regular bridge port. Signed-off-by: Joachim Wiberg --- .../testing/selftests/net/forwarding/Makefile | 3 +- .../selftests/net/forwarding/bridge_flood.sh | 170 ++++++++++++++++++ 2 files changed, 172 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/net/forwarding/bridge_flood.sh diff --git a/tools/testing/selftests/net/forwarding/Makefile b/tools/testing/selftests/net/forwarding/Makefile index ae80c2aef577..873fa61d1ee1 100644 --- a/tools/testing/selftests/net/forwarding/Makefile +++ b/tools/testing/selftests/net/forwarding/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ OR MIT -TEST_PROGS = bridge_igmp.sh \ +TEST_PROGS = bridge_flood.sh \ + bridge_igmp.sh \ bridge_locked_port.sh \ bridge_mdb.sh \ bridge_port_isolation.sh \ diff --git a/tools/testing/selftests/net/forwarding/bridge_flood.sh b/tools/testing/selftests/net/forwarding/bridge_flood.sh new file mode 100755 index 000000000000..1966c960d705 --- /dev/null +++ b/tools/testing/selftests/net/forwarding/bridge_flood.sh @@ -0,0 +1,170 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Verify per-port flood control flags of unknown BUM traffic. +# +# br0 +# / \ +# h1 h2 +# +# We inject bc/uc/mc on h1, toggle the three flood flags for +# both br0 and h2, then verify that traffic is flooded as per +# the flags, and nowhere else. +# +#set -x + +ALL_TESTS="br_flood_unknown_bc_test br_flood_unknown_uc_test br_flood_unknown_mc_test" +NUM_NETIFS=4 + +SRC_MAC="00:de:ad:be:ef:00" +GRP_IP4="225.1.2.3" +GRP_MAC="01:00:01:c0:ff:ee" +GRP_IP6="ff02::42" + +BC_PKT="ff:ff:ff:ff:ff:ff $SRC_MAC 00:04 48:45:4c:4f" +UC_PKT="02:00:01:c0:ff:ee $SRC_MAC 00:04 48:45:4c:4f" +MC_PKT="01:00:5e:01:02:03 $SRC_MAC 08:00 45:00 00:20 c2:10 00:00 ff 11 12:b2 01:02:03:04 e1:01:02:03 04:d2 10:e1 00:0c 6e:84 48:45:4c:4f" + +# Disable promisc to ensure we only receive flooded frames +export TCPDUMP_EXTRA_FLAGS="-pl" + +source lib.sh + +h1=${NETIFS[p1]} +h2=${NETIFS[p3]} +swp1=${NETIFS[p2]} +swp2=${NETIFS[p4]} + +# +# Port mappings and flood flag pattern to set/detect +# +declare -A ports=([br0]=br0 [$swp1]=$h1 [$swp2]=$h2) +declare -A flag1=([$swp1]=off [$swp2]=off [br0]=off) +declare -A flag2=([$swp1]=off [$swp2]=on [br0]=off) +declare -A flag3=([$swp1]=off [$swp2]=on [br0]=on ) +declare -A flag4=([$swp1]=off [$swp2]=off [br0]=on ) + +switch_create() +{ + ip link add dev br0 type bridge + + for port in ${!ports[@]}; do + [ "$port" != "br0" ] && ip link set dev $port master br0 + ip link set dev $port up + done +} + +switch_destroy() +{ + for port in ${!ports[@]}; do + ip link set dev $port down + done + ip link del dev br0 +} + +setup_prepare() +{ + vrf_prepare + + let i=1 + for iface in ${ports[@]}; do + [ "$iface" = "br0" ] && continue + simple_if_init $iface 192.0.2.$i/24 2001:db8:1::$i/64 + let i=$((i + 1)) + done + + switch_create +} + +cleanup() +{ + pre_cleanup + switch_destroy + + let i=1 + for iface in ${ports[@]}; do + [ "$iface" = "br0" ] && continue + simple_if_fini $iface 192.0.2.$i/24 2001:db8:1::$i/64 + let i=$((i + 1)) + done + + vrf_cleanup +} + +do_flood_unknown() +{ + local type=$1 + local pass=$2 + local flag=$3 + local pkt=$4 + local -n flags=$5 + + RET=0 + for port in ${!ports[@]}; do + if [ "$port" = "br0" ]; then + self="self" + else + self="" + fi + bridge link set dev $port $flag ${flags[$port]} $self + check_err $? "Failed setting $port $flag ${flags[$port]}" + done + + for iface in ${ports[@]}; do + tcpdump_start $iface + done + + $MZ -q $h1 "$pkt" + sleep 1 + + for iface in ${ports[@]}; do + tcpdump_stop $iface + done + + for port in ${!ports[@]}; do + iface=${ports[$port]} + +# echo "Dumping PCAP from $iface, expecting ${flags[$port]}:" +# tcpdump_show $iface + tcpdump_show $iface |grep -q "$SRC_MAC" + rc=$? + + check_err_fail "${flags[$port]} = on" $? "failed flooding from $h1 to port $port" + check_err_fail "${flags[$port]} = off" $? "flooding from $h1 to port $port" + done + + log_test "flood unknown $type pass $pass/4" +} + +br_flood_unknown_bc_test() +{ + do_flood_unknown BC 1 bcast_flood "$BC_PKT" flag1 + do_flood_unknown BC 2 bcast_flood "$BC_PKT" flag2 + do_flood_unknown BC 3 bcast_flood "$BC_PKT" flag3 + do_flood_unknown BC 4 bcast_flood "$BC_PKT" flag4 +} + +br_flood_unknown_uc_test() +{ + do_flood_unknown UC 1 flood "$UC_PKT" flag1 + do_flood_unknown UC 2 flood "$UC_PKT" flag2 + do_flood_unknown UC 3 flood "$UC_PKT" flag3 + do_flood_unknown UC 4 flood "$UC_PKT" flag4 +} + +br_flood_unknown_mc_test() +{ + do_flood_unknown MC 1 mcast_flood "$MC_PKT" flag1 + do_flood_unknown MC 2 mcast_flood "$MC_PKT" flag2 + do_flood_unknown MC 3 mcast_flood "$MC_PKT" flag3 + do_flood_unknown MC 4 mcast_flood "$MC_PKT" flag4 +} + +trap cleanup EXIT + +setup_prepare +setup_wait + +tests_run + +exit $EXIT_STATUS From patchwork Mon Apr 11 13:38:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809124 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1998C433EF for ; Mon, 11 Apr 2022 13:39:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346603AbiDKNl0 (ORCPT ); Mon, 11 Apr 2022 09:41:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346602AbiDKNlS (ORCPT ); Mon, 11 Apr 2022 09:41:18 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ADE612A for ; Mon, 11 Apr 2022 06:39:01 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id p10so26631056lfa.12 for ; Mon, 11 Apr 2022 06:39:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=TFNOjZAXZon/4fuYvoXX/NbbTAf3VntOhKR6DBqpfYk=; b=kvB+hyM6e8RNZhoXuBQ/tSpmItfGCHtV/80UPZA2wcqsSJle472+AMQJQkqTSKG1zm 9Ts/A1anN1MHNODDAuUPyykcEu1h3TncWzzTNf9nyt/TVZtmY+pPFG7NFuUeJhHrhKXa g9WqrFGvVVpE5OLbkZ64U+QIwjL7mx5bxxM82hWCDKNkDygEjR9jbQoxAPm6i/8W5kPR RzHZi9JYFT+8ZqGHUqK4lCk6QIv67edRLjOnrYh6wQB2mGbwq+hC0jyLJCtINGFhAInp U08yaJaXH9DmG3bSRD4IyKJK0gv0HkZDmsae+6ULbupzhH0+WDlM2Kp1QSlSlOP6Jn3H itWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=TFNOjZAXZon/4fuYvoXX/NbbTAf3VntOhKR6DBqpfYk=; b=iRwYMCHAk88Ocp8xBAc7ShYTXUojTxhaHVr1WiDixiIQFJFseWA9Cq0EmWQw8FpD7p 51F/n1qyRfHmbHhDz9GchwuwK6Inn80NirNgQ0HZYa/dFsLCpm6g1ckBJo3+3ABOcoPx J3taxNSnOjBDkhU01a+rk5HQ1tjNEJgdUgVb4+GXHrsXHXbw0dCXXuXOF1RbAN7fuzBE qea8snWvOXRP9hDkpMdCBecYf9oK4YWzkcq0uDLeD+YvqYY3mYUF4WMi/jJQfl1wBZIN 1Nc9XZS1UIVXJCUeRLGJ1UIL2qh9Hl4+jEO+CmhdBoo3BB4XPYdonnff0qwPIpSbOidF QlRw== X-Gm-Message-State: AOAM533jJxKU28OWxObqg1hmh6qmLMciUkcbo+LvgFP1tgUQ8HBpuUws KKYrMCGjIIxw53sqHADO7RE= X-Google-Smtp-Source: ABdhPJz8VyAgDW/b+e3V8a/isVm7gzC8dVXcgQJDNS04+ThstRMLoxnxLoypvvmLCJqc1Rsk2tMNoQ== X-Received: by 2002:ac2:4194:0:b0:442:ed9e:4a25 with SMTP id z20-20020ac24194000000b00442ed9e4a25mr20779404lfh.629.1649684339767; Mon, 11 Apr 2022 06:38:59 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:38:59 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 08/13] net: bridge: avoid classifying unknown multicast as mrouters_only Date: Mon, 11 Apr 2022 15:38:32 +0200 Message-Id: <20220411133837.318876-9-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Unknown multicast, MAC/IPv4/IPv6, should always be flooded according to the per-port mcast_flood setting, as well as to detected and configured mcast_router ports. This patch drops the mrouters_only classifier of unknown IP multicast and moves the flow handling from br_multicast_flood() to br_flood(). This in turn means br_flood() must know about multicast router ports. Signed-off-by: Joachim Wiberg --- net/bridge/br_forward.c | 11 +++++++++++ net/bridge/br_multicast.c | 6 +----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index 02bb620d3b8d..ab5b97a8c12e 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c @@ -199,9 +199,15 @@ static struct net_bridge_port *maybe_deliver( void br_flood(struct net_bridge *br, struct sk_buff *skb, enum br_pkt_type pkt_type, bool local_rcv, bool local_orig) { + struct net_bridge_mcast *brmctx = &br->multicast_ctx; + struct net_bridge_port *rport = NULL; struct net_bridge_port *prev = NULL; + struct hlist_node *rp = NULL; struct net_bridge_port *p; + if (pkt_type == BR_PKT_MULTICAST) + rp = br_multicast_get_first_rport_node(brmctx, skb); + list_for_each_entry_rcu(p, &br->port_list, list) { /* Do not flood unicast traffic to ports that turn it off, nor * other traffic if flood off, except for traffic we originate @@ -212,6 +218,11 @@ void br_flood(struct net_bridge *br, struct sk_buff *skb, continue; break; case BR_PKT_MULTICAST: + rport = br_multicast_rport_from_node_skb(rp, skb); + if (rport == p) { + rp = rcu_dereference(hlist_next_rcu(rp)); + break; + } if (!(p->flags & BR_MCAST_FLOOD) && skb->dev != br->dev) continue; break; diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index db4f2641d1cd..c57e3bbb00ad 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c @@ -3643,9 +3643,7 @@ static int br_multicast_ipv4_rcv(struct net_bridge_mcast *brmctx, err = ip_mc_check_igmp(skb); if (err == -ENOMSG) { - if (!ipv4_is_local_multicast(ip_hdr(skb)->daddr)) { - BR_INPUT_SKB_CB(skb)->mrouters_only = 1; - } else if (pim_ipv4_all_pim_routers(ip_hdr(skb)->daddr)) { + if (pim_ipv4_all_pim_routers(ip_hdr(skb)->daddr)) { if (ip_hdr(skb)->protocol == IPPROTO_PIM) br_multicast_pim(brmctx, pmctx, skb); } else if (ipv4_is_all_snoopers(ip_hdr(skb)->daddr)) { @@ -3712,8 +3710,6 @@ static int br_multicast_ipv6_rcv(struct net_bridge_mcast *brmctx, err = ipv6_mc_check_mld(skb); if (err == -ENOMSG || err == -ENODATA) { - if (!ipv6_addr_is_ll_all_nodes(&ipv6_hdr(skb)->daddr)) - BR_INPUT_SKB_CB(skb)->mrouters_only = 1; if (err == -ENODATA && ipv6_addr_is_all_snoopers(&ipv6_hdr(skb)->daddr)) br_ip6_multicast_mrd_rcv(brmctx, pmctx, skb); From patchwork Mon Apr 11 13:38:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809127 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2039C433EF for ; Mon, 11 Apr 2022 13:39:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346610AbiDKNld (ORCPT ); Mon, 11 Apr 2022 09:41:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346606AbiDKNlS (ORCPT ); Mon, 11 Apr 2022 09:41:18 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0209130F for ; Mon, 11 Apr 2022 06:39:02 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id b21so650809ljf.4 for ; Mon, 11 Apr 2022 06:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=z5/W5d8ndtvXDnyj0JyTra9alKgaGGYDMc0cdYTNV+Y=; b=PrNADXRvCHQzEChEPZg2kZj2LmA3yA1kD5ofn6xym7Neu/ROj+Tf88BEBnHcTrX6zN QA+RXn7FIQd2kWEQ6ciFFhyLUIJaYhBKJ4HgU31OE6xHtbMkGZrgQioXycEHo5wN21Af fW7sXUhV8TThK665pAO8Yg8HmweuI9KaHu/7QTVsOFfZj0NwTfKK1o4UaCmFMLLgO59z VYxD1emxfusy5Hutf+hzI6e64uTHPyYv/MDGVwGZZkI98effVZyPQmceUjp8KlRn/UtF n6QTT0FCD65iAkEO1MRKAoN+w2NM7HBb4iy4sTXlUB1U26NLYF52XQkiYWYAY0hDSU9s l9Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=z5/W5d8ndtvXDnyj0JyTra9alKgaGGYDMc0cdYTNV+Y=; b=y42P1/87UJaUhyoxu4R1TQFY3N39aE7Q15BTpBQ4K4kH/QfAIjrU8SFm9F+nCWQyn2 RtSYtoMz9V/UV3uZ5RZLk2nZDvojrtRmTxHD8SORe8Z1WJrBg+SKfcveZC5oPHyKQrgK d/K5EDrBBo68OjjIYn2qCBxF4aGKE+VTjnYa5yVvrIn+mGM6Q80cd2LM8ygRiA9LTghO O8q92cpdpvg+9x7wivXyMhBg4MGdYSdVnxAlmPVdsEZJZdtGLXa+QKJXTYZ7Nc0AhcFb bBD2AsU/Zp7EVw8G+p7BKvm7tXvk1lSzvV7SuYViyk8UeZsr0WUIa+H+XT3OZlX8cPIL iLEg== X-Gm-Message-State: AOAM531hyfKeSFRJP8SSgCZFfxrMRvKmbzfkfEv/PRFznNpXPB+FW+qp AHV+azk9IWJzkkEeLd1Da9o= X-Google-Smtp-Source: ABdhPJzQsThOV+obcF51ZdbEECKXTvk7EJ2ggIeeWtcSxu+TM3BAO/EUQdy8+lJnQJzoNqN7/S2pCg== X-Received: by 2002:a2e:b5aa:0:b0:24b:519f:d21f with SMTP id f10-20020a2eb5aa000000b0024b519fd21fmr9949878ljn.35.1649684340759; Mon, 11 Apr 2022 06:39:00 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:39:00 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 09/13] selftests: forwarding: rename test groups for next bridge mdb tests Date: Mon, 11 Apr 2022 15:38:33 +0200 Message-Id: <20220411133837.318876-10-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Rename test groups to PASS and FAIL, respectively, for upcoming changes to test suite. Signed-off-by: Joachim Wiberg --- .../selftests/net/forwarding/bridge_mdb.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh index b1ba6876dd86..c0b84b7d4364 100755 --- a/tools/testing/selftests/net/forwarding/bridge_mdb.sh +++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh @@ -7,9 +7,15 @@ ALL_TESTS="mdb_add_del_test" NUM_NETIFS=2 -TEST_GROUP_IP4="225.1.2.3" -TEST_GROUP_IP6="ff02::42" -TEST_GROUP_MAC="01:00:01:c0:ff:ee" +PASS_GRP_IP4="225.1.2.3" +FAIL_GRP_IP4="225.1.2.4" + +PASS_GRP_MAC="01:00:01:c0:ff:ee" +FAIL_GRP_MAC="01:00:01:c0:ff:ef" + +PASS_GRP_IP6="ff02::42" +FAIL_GRP_IP6="ff02::43" + source lib.sh @@ -88,9 +94,9 @@ do_mdb_add_del() mdb_add_del_test() { - do_mdb_add_del $TEST_GROUP_MAC permanent - do_mdb_add_del $TEST_GROUP_IP4 - do_mdb_add_del $TEST_GROUP_IP6 + do_mdb_add_del $PASS_GRP_MAC permanent + do_mdb_add_del $PASS_GRP_IP4 + do_mdb_add_del $PASS_GRP_IP6 } trap cleanup EXIT From patchwork Mon Apr 11 13:38:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809125 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D1CBC433F5 for ; Mon, 11 Apr 2022 13:39:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346604AbiDKNl3 (ORCPT ); Mon, 11 Apr 2022 09:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343774AbiDKNlS (ORCPT ); Mon, 11 Apr 2022 09:41:18 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 761E4BA6 for ; Mon, 11 Apr 2022 06:39:03 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id p10so26631262lfa.12 for ; Mon, 11 Apr 2022 06:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=nqbOmZU5eRZ/5dvOqIFsFAOGgG76eQOYLqqyaQWHdcQ=; b=FJuOlY+7YXJgldvEmB8NUIn16A6H3oodoYf/O+sUuMCNv8ISHnTbPIYP88j7Ybkiys ErbxqMwRfCUa+/4QMlylMI5wbAblbrBH33Jn8UWnIbFU/+HvyxT2ol9Z+BwxnY32smcT AqUIloFZGpxmxIpfvGBM0Gz9LRPixscaFWoFSgDvlyxdknyxmbukPahj+E4z3Z04ZWSa Oh6bRSagDGioRHJLaR958qKYeXJ2j3cDGkIifUwlYfeKEsACZlC2DTP/nmm//53Yq6N0 GDvhC+OTS9nGt89g4bXEE2E0n1g6F420nJSk683TLxt6Yxunt+DcH6htuwHkiMp4/0Xy lwwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=nqbOmZU5eRZ/5dvOqIFsFAOGgG76eQOYLqqyaQWHdcQ=; b=vHZHfnOHVA2vsZNOPPacZbcmLfIchP7gKwnr7/Q3F14cW8Mfx9yOMOhIXzg5Ao0Hk1 FVCJ6voH4cCkAwQqJQCXE2iIDAkVpxlbYlwjEyW4yYxG3o/Brnf75En8+zQjP5OxK39f bOGV3sIzBwvFXJFp0KX9guXYkcSQzXSCxRR9yZTRok8aarUNKu3kpdHY19ZQgRtZZS01 Om6VVqco6qeyRwq9xxXqpsFBMCoTYqvL+KBxxRUU9K1lW7AKX5YxMrbEqzNnnyWv887O iJBTTWc1uwXOOHtlSpJasJHfwb3EVpvI3QCqB0Y49w3iH84rltTrb0RPfZuJdDUJBASE 7C6g== X-Gm-Message-State: AOAM530plNGapmCBXe5vHsai04LkEQQ6BS4CtiMLcJGPN0GK2l8zBAyA ezSbqazN6mKpKkPQ3yhbteA= X-Google-Smtp-Source: ABdhPJwOq4pW7EG4/zJcvvFJGtvJ+7LEQ6vcMLmvGFvytfFf3S+IgUKXLcmLaiE/zMI63oyBdSXLjg== X-Received: by 2002:ac2:521b:0:b0:46b:82a9:b888 with SMTP id a27-20020ac2521b000000b0046b82a9b888mr11412189lfl.578.1649684341614; Mon, 11 Apr 2022 06:39:01 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.39.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:39:01 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 10/13] selftests: forwarding: verify flooding of unknown multicast Date: Mon, 11 Apr 2022 15:38:34 +0200 Message-Id: <20220411133837.318876-11-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This patch adds forwarding test to bridge_mdb.sh, using groups and group names that make little sense right now. Ensure flooding of unknown multicast works as intended after the initial grace period when we don't know if we are the querier or if someone else on the LAN is. Hence the reduced timers. Signed-off-by: Joachim Wiberg --- .../selftests/net/forwarding/bridge_mdb.sh | 135 +++++++++++++++++- 1 file changed, 131 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh index c0b84b7d4364..6de98c59a620 100755 --- a/tools/testing/selftests/net/forwarding/bridge_mdb.sh +++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh @@ -3,22 +3,50 @@ # # Verify that adding host mdb entries work as intended for all types of # multicast filters: ipv4, ipv6, and mac +# +# Verify forwarding (default flooding behavior) to all ports of unknown +# multicast: MAC, IPv4, IPv6. +# +# Note: this test completely disables IPv6 auto-configuration to avoid +# any type of dynamic behavior outside of MLD and IGMP protocols. +# Static IPv6 addresses are used to ensure consistent behavior, +# even in the startup phase when multicast snooping is enabled. +# -ALL_TESTS="mdb_add_del_test" -NUM_NETIFS=2 +ALL_TESTS="mdb_add_del_test mdb_compat_fwd_test" +NUM_NETIFS=4 +SRC_PORT="1234" +DST_PORT="4321" + +SRC_ADDR_IP4="1.2.3.4" PASS_GRP_IP4="225.1.2.3" FAIL_GRP_IP4="225.1.2.4" +SRC_ADDR_MAC="00:de:ad:be:ef:00" PASS_GRP_MAC="01:00:01:c0:ff:ee" FAIL_GRP_MAC="01:00:01:c0:ff:ef" +PASS_PKT_MAC="$PASS_GRP_MAC $SRC_ADDR_MAC 00:04 48:45:4c:4f" +FAIL_PKT_MAC="$FAIL_GRP_MAC $SRC_ADDR_MAC 00:04 46:41:49:4c" + +PASS_PKT_IP4="01:00:5e:01:02:03 $SRC_ADDR_MAC 08:00 45:00 00:20 c2:10 00:00 ff 11 12:b2 01:02:03:04 e1:01:02:03 04:d2 10:e1 00:0c 6e:84 48:45:4c:4f" +FAIL_PKT_IP4="01:00:5e:01:02:04 $SRC_ADDR_MAC 08:00 45:00 00:20 dc:e4 00:00 ff 11 f7:dc 01:02:03:04 e1:01:02:04 04:d2 10:e1 00:0c 73:8a 46:41:49:4c" + +SRC_ADDR_IP6="ff2e::42" PASS_GRP_IP6="ff02::42" FAIL_GRP_IP6="ff02::43" +PASS_PKT_IP6="33 33 00 00 00 42 36 1e b4 04 cd e8 86 dd 60 00 01 01 00 08 11 ff ff 2e 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ff 02 00 00 00 00 00 00 00 00 00 00 00 00 00 42 04 d2 10 e1 00 08 eb 75" +FAIL_PKT_IP6="33 33 00 00 00 43 36 1e b4 04 cd e8 86 dd 60 00 01 01 00 08 11 ff ff 2e 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ff 02 00 00 00 00 00 00 00 00 00 00 00 00 00 43 04 d2 10 e1 00 08 eb 74" + +# Disable promisc to ensure we only receive $TEST_GROUP* +export TCPDUMP_EXTRA_FLAGS="-pl" source lib.sh +require_command tcpdump + h1_create() { simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64 @@ -29,20 +57,51 @@ h1_destroy() simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64 } +h2_create() +{ + simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64 +} + +h2_destroy() +{ + simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64 +} + switch_create() { - # Enable multicast filtering - ip link add dev br0 type bridge mcast_snooping 1 + # Enable multicast filtering w/ querier, reduce query response + # and startup interval to speed up test a bit. + ip link add dev br0 type bridge mcast_snooping 1 \ + mcast_startup_query_interval 400 mcast_query_response_interval 200 + + # Set static IPv6 address before we enable the multicast querier + # function. This, along with disabling IPv6 address auto config + # (previously), ensures correct forwarding according to the MDB + # even when per-port flooding is disabled, *after* the initial + # startup phase when the bridge floods all multicast (according + # to its per-port mcast_flood settings. + ip addr add 2001:db8:1::42/64 dev br0 + ip link set br0 type bridge mcast_querier 1 ip link set dev $swp1 master br0 + ip link set dev $swp2 master br0 ip link set dev br0 up ip link set dev $swp1 up + ip link set dev $swp2 up + + # Initial delay, when bridge floods all mcast, is set to 200 + # above (2 sec.) We wait 3 sec to handle the case when a single + # strict fwd test is run directly after the initial setup, e.g., + # TESTS=mdb_ip6_fwd_test + sleep 3 } switch_destroy() { + ip link set dev $swp2 down ip link set dev $swp1 down + ip link del dev br0 } @@ -51,9 +110,17 @@ setup_prepare() h1=${NETIFS[p1]} swp1=${NETIFS[p2]} + swp2=${NETIFS[p3]} + h2=${NETIFS[p4]} + + # Disable all IPv6 autoconfiguration during test, we want + # full control of when MLD queries start etc. + sysctl_set net.ipv6.conf.default.accept_ra 0 vrf_prepare h1_create + h2_create + switch_create } @@ -62,9 +129,12 @@ cleanup() pre_cleanup switch_destroy + + h2_destroy h1_destroy vrf_cleanup + sysctl_restore net.ipv6.conf.default.accept_ra } do_mdb_add_del() @@ -99,6 +169,63 @@ mdb_add_del_test() do_mdb_add_del $PASS_GRP_IP6 } +do_compat_fwd() +{ + port=$1 + RET=0 + + # Ensure default settings, regardless of test start order + bridge link set dev "$swp1" mcast_flood on + bridge link set dev "$swp2" mcast_flood on + bridge link set dev "br0" mcast_flood on self + + tcpdump_start "$port" + + $MZ -q $h1 "$PASS_PKT_MAC" + $MZ -q $h1 "$FAIL_PKT_MAC" + + $MZ -q $h1 "$PASS_PKT_IP4" + $MZ -q $h1 "$FAIL_PKT_IP4" + + $MZ -q $h1 "$PASS_PKT_IP6" + $MZ -q $h1 "$FAIL_PKT_IP6" + + sleep 1 + tcpdump_stop "$port" + + tcpdump_show "$port" |grep -q "${SRC_ADDR_MAC} > ${PASS_GRP_MAC}" + check_err $? "Failed forwarding multicast group $PASS_GRP_MAC from $h1 to port $port" + + tcpdump_show "$port" |grep -q "${SRC_ADDR_MAC} > ${FAIL_GRP_MAC}" + check_err $? "Failed forwarding multicast group ${FAIL_GRP_MAC} from $h1 to port $port" + + tcpdump_show "$port" |grep -q "${SRC_ADDR_IP4}.${SRC_PORT} > ${PASS_GRP_IP4}.${DST_PORT}" + check_err $? "Failed forwarding multicast group $PASS_GRP_IP4 from $h1 to port $port" + + tcpdump_show "$port" |grep -q "${SRC_ADDR_IP4}.${SRC_PORT} > ${FAIL_GRP_IP4}.${DST_PORT}" + check_err $? "Failed forwarding multicast group ${FAIL_GRP_IP4} from $h1 to port $port" + + tcpdump_show "$port" |grep -q "${SRC_ADDR_IP6}.${SRC_PORT} > ${PASS_GRP_IP6}.${DST_PORT}" + check_err $? "Failed forwarding multicast group $PASS_GRP_IP6 from $h1 to port $port" + + tcpdump_show "$port" |grep -q "${SRC_ADDR_IP6}.${SRC_PORT} > ${FAIL_GRP_IP6}.${DST_PORT}" + check_err $? "Failed forwarding multicast group ${FAIL_GRP_IP6} from $h1 to port $port" + + log_test "MDB forward unknown MAC/IPv4/IPv6 multicast to port $port" + tcpdump_cleanup "$port" +} + +# +# Verify default behavior, unknown multicast is flooded, to both +# regular bridge ports and the bridge itself (also a port). +# +mdb_compat_fwd_test() +{ + do_compat_fwd "$h2" + do_compat_fwd "br0" +} +} + trap cleanup EXIT setup_prepare From patchwork Mon Apr 11 13:38:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809126 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB0E0C433EF for ; Mon, 11 Apr 2022 13:39:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346605AbiDKNlc (ORCPT ); Mon, 11 Apr 2022 09:41:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346598AbiDKNlU (ORCPT ); Mon, 11 Apr 2022 09:41:20 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44EDE26 for ; Mon, 11 Apr 2022 06:39:04 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id z17so2183381lfj.11 for ; Mon, 11 Apr 2022 06:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=3ST1LQFgjHw1X814y3v8X3zhxYcmyjbfmqY6gmtBi2s=; b=PciXyWy7sfQT1Cb4pldae1jHis/zw+whQml4tbIBKpJw8zyvsdhehWOjQWWj2Pa8HH ySbrQ1fIKgOW4ooICblPfOFyNHLhltPna9lS9T3Zl0Ohb0kc+CP61NrTLeQSYW43sOzq VntJ72Nqw/MzMs3QU+JAsvXVPHT0Tn9GZCKsUpFIaQbO1vUG6MtfYo0DM9TYWP28FrID 0vY4TVbk37yHL8CDZYdl4JCAfx8GTnAFT1pXN6AactT6T3BfKSAUVhxaP7IYMureoeFH I5cFCASnevu5YvytGHAx1VlAfxCf7/A+1Qu6m7VJ1/pvhq3cThMMo6CEh2fR0X2HYyd1 qqrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=3ST1LQFgjHw1X814y3v8X3zhxYcmyjbfmqY6gmtBi2s=; b=Q+/DXD3D6Auq+cEZ2MWVFMOM9bOOMxbTY9wXCL0lHmGcOZjzYHn4OUA9sCqsks2mhZ SYLRh/J1afd2IP8WPv5wIWjN3ZlFdV/tDGGW9EtHptZ+dcl6KvF7GMegFBtO7FhsqP0I Z4By+bUXi1Xxusp9X9tkuMqqBazS9DX6Blg5GxmdxI9Cz1XUo1lEC48jJMCqi48BW4+W Q2xZUaH9aUzx/BjEqB54VFZDnRzfoHqQSxonD2fSDprEAJ+CmfSN7+F9FIgXiQSUnIB5 x35BkVwMkbPszcGDwc5XsNPGK0ktpdLUjjDM2AtYl/QrwqA+aat683dGNp4GMSBETUj9 ERdg== X-Gm-Message-State: AOAM533xuADHWqm/Vgcw0Wg/w1QCh/RgM+fPomIcBlhN90VcVg0ZiCyP 9TEBRNZtZ9hJGs71cWoeVmc= X-Google-Smtp-Source: ABdhPJyfbHorWayOmG/eTGIhhma9xzYbX2vuPhRXVgHzLU8+6SItj9kP+LuJrVVlSEYIjslANhGK8Q== X-Received: by 2002:ac2:5f4d:0:b0:448:7d37:5838 with SMTP id 13-20020ac25f4d000000b004487d375838mr21607127lfz.419.1649684342572; Mon, 11 Apr 2022 06:39:02 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:39:02 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 11/13] selftests: forwarding: verify strict mdb fwd of known multicast Date: Mon, 11 Apr 2022 15:38:35 +0200 Message-Id: <20220411133837.318876-12-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC When mcast_flood is disabled forwarding of multicast should strictly follow the mdb, and mcast_router ports, dedicated test added later. This patch updates bridge_mdb.sh with MAC, IPv4 and IPv6 strict MDB forwarding tests. The bulk of the work is done by do_mdb_fwd(); one MC packet to a known group is verified to reach its destination port, and one MC packet to an unknown group is verified to not be forwarded. Signed-off-by: Joachim Wiberg --- .../selftests/net/forwarding/bridge_mdb.sh | 88 ++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh index 6de98c59a620..4e3bb950263f 100755 --- a/tools/testing/selftests/net/forwarding/bridge_mdb.sh +++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh @@ -7,13 +7,16 @@ # Verify forwarding (default flooding behavior) to all ports of unknown # multicast: MAC, IPv4, IPv6. # +# Verify selective multicast forwarding (strict mdb), when bridge port +# mcast_flood is disabled, of known MAC, IPv4, IPv6 traffic. +# # Note: this test completely disables IPv6 auto-configuration to avoid # any type of dynamic behavior outside of MLD and IGMP protocols. # Static IPv6 addresses are used to ensure consistent behavior, # even in the startup phase when multicast snooping is enabled. # -ALL_TESTS="mdb_add_del_test mdb_compat_fwd_test" +ALL_TESTS="mdb_add_del_test mdb_compat_fwd_test mdb_mac_fwd_test mdb_ip4_fwd_test mdb_ip6_fwd_test" NUM_NETIFS=4 SRC_PORT="1234" @@ -224,6 +227,89 @@ mdb_compat_fwd_test() do_compat_fwd "$h2" do_compat_fwd "br0" } + +do_mdb_fwd() +{ + type=$1 + port=$2 + swp=$port + src=$3 + pass_grp=$4 + fail_grp=$5 + pass_pkt=$6 + fail_pkt=$7 + RET=0 + + if [ "$type" = "MAC" ]; then + flag="permanent" + else + flag="" + spt=".$SRC_PORT" + dpt=".$DST_PORT" + fi + if [ "$port" = "$h2" ]; then + swp=$swp2 + fi + + # Disable flooding of unknown multicast, strict MDB forwarding + bridge link set dev "$swp1" mcast_flood off + bridge link set dev "$swp2" mcast_flood off + bridge link set dev "br0" mcast_flood off self + + # Static filter only to this port + bridge mdb add dev br0 port "$swp" grp "$pass_grp" $flag + check_err $? "Failed adding $type multicast group $pass_grp to bridge port $swp" + + tcpdump_start "$port" + + # Real data we're expecting + $MZ -q "$h1" "$pass_pkt" + # This should not pass + $MZ -q "$h1" "$fail_pkt" + + sleep 1 + tcpdump_stop "$port" + + tcpdump_show "$port" |grep -q "$src$spt > $pass_grp$dpt" + check_err $? "Failed forwarding $type multicast $pass_grp from $h1 to port $port" + + tcpdump_show "$port" |grep -q "$src$spt > $fail_grp$dpt" + check_err_fail 1 $? "Received $type multicast group $fail_grp from $h1 to port $port" + + bridge mdb del dev br0 port "$swp" grp "$pass_grp" + + log_test "MDB forward $type multicast to bridge port $port" + tcpdump_cleanup "$port" +} + +# +# Forwarding of known MAC multicast according to mdb, verify blocking +# unknown MAC multicast (flood off) +# +mdb_mac_fwd_test() +{ + do_mdb_fwd MAC "br0" $SRC_ADDR_MAC $PASS_GRP_MAC $FAIL_GRP_MAC "$PASS_PKT_MAC" "$FAIL_PKT_MAC" + do_mdb_fwd MAC "$h2" $SRC_ADDR_MAC $PASS_GRP_MAC $FAIL_GRP_MAC "$PASS_PKT_MAC" "$FAIL_PKT_MAC" +} + +# +# Forwarding of known IPv4 UDP multicast according to mdb, verify +# blocking unknown IPv4 UDP multicast (flood off) +# +mdb_ip4_fwd_test() +{ + do_mdb_fwd IPv4 br0 $SRC_ADDR_IP4 $PASS_GRP_IP4 $FAIL_GRP_IP4 "$PASS_PKT_IP4" "$FAIL_PKT_IP4" + do_mdb_fwd IPv4 $h2 $SRC_ADDR_IP4 $PASS_GRP_IP4 $FAIL_GRP_IP4 "$PASS_PKT_IP4" "$FAIL_PKT_IP4" +} + +# +# Forwarding of known IPv6 UDP multicast according to mdb, verify +# blocking unknown IPv6 UDP multicast (flood off) +# +mdb_ip6_fwd_test() +{ + do_mdb_fwd IPv6 br0 $SRC_ADDR_IP6 $PASS_GRP_IP6 $FAIL_GRP_IP6 "$PASS_PKT_IP6" "$FAIL_PKT_IP6" + do_mdb_fwd IPv6 $h2 $SRC_ADDR_IP6 $PASS_GRP_IP6 $FAIL_GRP_IP6 "$PASS_PKT_IP6" "$FAIL_PKT_IP6" } trap cleanup EXIT From patchwork Mon Apr 11 13:38:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809129 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF22FC433F5 for ; Mon, 11 Apr 2022 13:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346607AbiDKNli (ORCPT ); Mon, 11 Apr 2022 09:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346611AbiDKNlU (ORCPT ); Mon, 11 Apr 2022 09:41:20 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A43610A9 for ; Mon, 11 Apr 2022 06:39:05 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id q189so3563910ljb.13 for ; Mon, 11 Apr 2022 06:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=q+s8pq7+mxXhYAN0HYAAMlwmmRXM/+hxH/iXox3zYsM=; b=gdo0pS8M3mZcu6zMtF4X72sjJJqTcx5UQwbKFqReNhLgiXxnh2ISjb2yBJVIMrlQIa DSQmq4HxJNFezf/5uWJTQpnjWBRLOoZryE1tpiydETCDQFoDwZTh1Dq4cchaP9qYnbvd /GM7Y2vcPZ2pQggoBLHKuImTqcscnNPRjHYTawbAe9ndgi5nnl2oMnZh2nto5LqbJPAN 46Gq00yyVLTLl1EehcDBJfV0zyQ0I8gIx1Ci9zNw8WMay9Mp25jHUF6ClIzRZodbCQ+G NuW19d2pkOyNDN3niO9heQrfNeTX54+tGnrtxEp7bruLXtvEEzaoEVqCTrjabKnpN3eY 2Kug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=q+s8pq7+mxXhYAN0HYAAMlwmmRXM/+hxH/iXox3zYsM=; b=UxmYyROTpvImPHb5L2ZvI+/I/Vy18um7H9/bt9HZmTy490I5/3mZULKSIFCrWRxD5J UtEfp5uvwgJhu+hHSSn1iNtC5hjzUMdnDZcz/PmDhJYMENsik3kUlsC28CL5Vipf0sje 21dj9uzlEi+zfxApPU1DEaW1SWm1+GitiSenR+9PqKgDSSqBblaEsAnz7/Ln0ZALPjy+ NJrLKZYSpvsaFMKS+ATgCdRxZ2DWs6u997Adse1I4nin2F8Y7QMzqt9MuCvza67wV4Oq s2XD/vA2u9Lbj/Q9tdHDgigulAh0UkdLuz5Pq58p9oMEe98EDVgImDzaukb2UkxJwmIi 84ZA== X-Gm-Message-State: AOAM533J2LxDcnDb45kKEtitAHvmaJ1vhJP0zlZPxgaVktncutyoDVtl riZGY13Li86wlWsKp6dbcrHs75QgrxQolhE5 X-Google-Smtp-Source: ABdhPJxoeeE+BEZplY/9jIvtkpxorjrLWXx31/h0HfvOx/segsFUmb12dz3EoHK1iaXU71IyDMURMQ== X-Received: by 2002:a05:651c:54f:b0:24b:6b48:cce5 with SMTP id q15-20020a05651c054f00b0024b6b48cce5mr335435ljp.506.1649684343437; Mon, 11 Apr 2022 06:39:03 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.39.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:39:03 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 12/13] selftests: forwarding: verify strict filtering doesn't leak Date: Mon, 11 Apr 2022 15:38:36 +0200 Message-Id: <20220411133837.318876-13-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Add a another veth pair to get a dedicated canary port. This to help us verify that multicast is received by only a subset of the ports in the MDB filter. Signed-off-by: Joachim Wiberg --- .../selftests/net/forwarding/bridge_mdb.sh | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh index 4e3bb950263f..137bc79fd677 100755 --- a/tools/testing/selftests/net/forwarding/bridge_mdb.sh +++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh @@ -17,7 +17,7 @@ # ALL_TESTS="mdb_add_del_test mdb_compat_fwd_test mdb_mac_fwd_test mdb_ip4_fwd_test mdb_ip6_fwd_test" -NUM_NETIFS=4 +NUM_NETIFS=6 SRC_PORT="1234" DST_PORT="4321" @@ -70,6 +70,16 @@ h2_destroy() simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64 } +h3_create() +{ + simple_if_init $h3 192.0.2.3/24 2001:db8:1::3/64 +} + +h3_destroy() +{ + simple_if_fini $h3 192.0.2.3/24 2001:db8:1::3/64 +} + switch_create() { # Enable multicast filtering w/ querier, reduce query response @@ -88,10 +98,12 @@ switch_create() ip link set dev $swp1 master br0 ip link set dev $swp2 master br0 + ip link set dev $swp3 master br0 ip link set dev br0 up ip link set dev $swp1 up ip link set dev $swp2 up + ip link set dev $swp3 up # Initial delay, when bridge floods all mcast, is set to 200 # above (2 sec.) We wait 3 sec to handle the case when a single @@ -102,6 +114,7 @@ switch_create() switch_destroy() { + ip link set dev $swp3 down ip link set dev $swp2 down ip link set dev $swp1 down @@ -116,6 +129,9 @@ setup_prepare() swp2=${NETIFS[p3]} h2=${NETIFS[p4]} + swp3=${NETIFS[p5]} + h3=${NETIFS[p6]} + # Disable all IPv6 autoconfiguration during test, we want # full control of when MLD queries start etc. sysctl_set net.ipv6.conf.default.accept_ra 0 @@ -123,6 +139,7 @@ setup_prepare() h1_create h2_create + h3_create switch_create } @@ -133,6 +150,7 @@ cleanup() switch_destroy + h3_destroy h2_destroy h1_destroy @@ -249,11 +267,15 @@ do_mdb_fwd() fi if [ "$port" = "$h2" ]; then swp=$swp2 + nop="$h3" + else + nop="$h2" fi # Disable flooding of unknown multicast, strict MDB forwarding bridge link set dev "$swp1" mcast_flood off bridge link set dev "$swp2" mcast_flood off + bridge link set dev "$swp3" mcast_flood off bridge link set dev "br0" mcast_flood off self # Static filter only to this port @@ -261,6 +283,7 @@ do_mdb_fwd() check_err $? "Failed adding $type multicast group $pass_grp to bridge port $swp" tcpdump_start "$port" + tcpdump_start "$nop" # Real data we're expecting $MZ -q "$h1" "$pass_pkt" @@ -268,6 +291,7 @@ do_mdb_fwd() $MZ -q "$h1" "$fail_pkt" sleep 1 + tcpdump_stop "$nop" tcpdump_stop "$port" tcpdump_show "$port" |grep -q "$src$spt > $pass_grp$dpt" @@ -276,6 +300,12 @@ do_mdb_fwd() tcpdump_show "$port" |grep -q "$src$spt > $fail_grp$dpt" check_err_fail 1 $? "Received $type multicast group $fail_grp from $h1 to port $port" + # Verify we don't get multicast to the canary port + tcpdump_show "$nop" |grep -q "$src$spt > $pass_grp$dpt" + check_err_fail 1 $? "Received $type multicast group $pass_grp from $h1 to port $nop" + tcpdump_show "$nop" |grep -q "$src$spt > $fail_grp$dpt" + check_err_fail 1 $? "Received $type multicast group $fail_grp from $h1 to port $nop" + bridge mdb del dev br0 port "$swp" grp "$pass_grp" log_test "MDB forward $type multicast to bridge port $port" From patchwork Mon Apr 11 13:38:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Wiberg X-Patchwork-Id: 12809128 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44954C433F5 for ; Mon, 11 Apr 2022 13:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346618AbiDKNlg (ORCPT ); Mon, 11 Apr 2022 09:41:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346626AbiDKNlV (ORCPT ); Mon, 11 Apr 2022 09:41:21 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4548F42 for ; Mon, 11 Apr 2022 06:39:06 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id z17so2183547lfj.11 for ; Mon, 11 Apr 2022 06:39:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:organization:content-transfer-encoding; bh=50MJkKhlS1J2AvfKZSt0Jb7+m5hEUpZE6Hebck0fg/A=; b=JXCw9oiD2WnF+/dOWbCKR30QwHOFYeeIGFnoSQa3rk8zCXJGF9WjRf21JEaJS7JlFW oJYl9mRBvdtaftLg5HYDs6a1KOlfipXmEgYHv64nyqOgOdKBy5dw93enKmSLyOTC8vDJ W/UW3b6tEh2yZBB1eEDy309N1pFBTEJEpmWVM2F45VroybbBgx/7sQzUz5QgrIDKfitW cMnHAf+Q4TDrbb1nkoIJQXMsvEtII4Ikv0y/qk+3qrMBfUp2W8kEQjfFaQdohb1DjTE1 sqAvuH9qb9id5HA7h3y0VaR/F/YMRqh2KrrJV6qs859EreZyHh+T2yEXN41++YTzd4wl zeKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:organization:content-transfer-encoding; bh=50MJkKhlS1J2AvfKZSt0Jb7+m5hEUpZE6Hebck0fg/A=; b=JQ5q88RYGj1gVixPegxJ22O7wCCUnv/bF7IrJgbBlKhSj2S61yTtNLvIiyX2Ouym3B JXmq3Q/WeKX9VXLWi3alKZQmP+BgOHQov9kSTmRjZ1ozQfqguG00IVRQVisvFFxv9NQY 74Xw65zlqmOSc7VY+KHQ9GiA6pjHNmxOh4Nc3dEbgqO0rzrs8//+29KnaBn5QKrTp+4a cLiM+HQoORjVPfzcZkkj7hjhgpYYKMj6LLGlfGynMWFm8/Xe/GQWANNvotCWRgPC8/O1 /4RNVxLao9YTNVUJbL/HK5NoeZhoN8Z607vM8/0lTti30e+QzK3DeZ0aCFrI7WiFx0kN xerQ== X-Gm-Message-State: AOAM531y2HTUnx+EN6SwClMyvWlMXuewYV/pGcs8Jg03e7THw2bAEbz1 ECfXhU7/SnSEe+zVYX01PJM= X-Google-Smtp-Source: ABdhPJygk8gDfsKgwEqOQRFbO6IgRWDrD1xWTXDdJhj6rrgjNMQxB602CKesPbTFsnNmR3wr9M9wzQ== X-Received: by 2002:ac2:5119:0:b0:450:d4e7:99ca with SMTP id q25-20020ac25119000000b00450d4e799camr21456161lfb.95.1649684344648; Mon, 11 Apr 2022 06:39:04 -0700 (PDT) Received: from wbg.labs.westermo.se (h-158-174-22-128.NA.cust.bahnhof.se. [158.174.22.128]) by smtp.gmail.com with ESMTPSA id p12-20020a056512138c00b0044833f1cd85sm3336847lfa.62.2022.04.11.06.39.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 06:39:04 -0700 (PDT) From: Joachim Wiberg To: Roopa Prabhu , Nikolay Aleksandrov Cc: netdev@vger.kernel.org, bridge@lists.linux-foundation.org, "David S . Miller" , Jakub Kicinski , Joachim Wiberg , Tobias Waldekranz , Vladimir Oltean Subject: [PATCH RFC net-next 13/13] selftests: forwarding: verify flood of known mc on mcast_router port Date: Mon, 11 Apr 2022 15:38:37 +0200 Message-Id: <20220411133837.318876-14-troglobit@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220411133837.318876-1-troglobit@gmail.com> References: <20220411133837.318876-1-troglobit@gmail.com> MIME-Version: 1.0 Organization: Westermo Network Technologies AB Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC This test verifies that both known (in mdb) and unknown IP multicast is forwarded to a mcast_router port. Signed-off-by: Joachim Wiberg --- .../selftests/net/forwarding/bridge_mdb.sh | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/forwarding/bridge_mdb.sh b/tools/testing/selftests/net/forwarding/bridge_mdb.sh index 137bc79fd677..3fd7d68bca09 100755 --- a/tools/testing/selftests/net/forwarding/bridge_mdb.sh +++ b/tools/testing/selftests/net/forwarding/bridge_mdb.sh @@ -10,13 +10,16 @@ # Verify selective multicast forwarding (strict mdb), when bridge port # mcast_flood is disabled, of known MAC, IPv4, IPv6 traffic. # +# Verify flooding towards mcast_router ports of known IP multicast. +# # Note: this test completely disables IPv6 auto-configuration to avoid # any type of dynamic behavior outside of MLD and IGMP protocols. # Static IPv6 addresses are used to ensure consistent behavior, # even in the startup phase when multicast snooping is enabled. # -ALL_TESTS="mdb_add_del_test mdb_compat_fwd_test mdb_mac_fwd_test mdb_ip4_fwd_test mdb_ip6_fwd_test" +ALL_TESTS="mdb_add_del_test mdb_compat_fwd_test mdb_rport_fwd_test \ + mdb_mac_fwd_test mdb_ip4_fwd_test mdb_ip6_fwd_test" NUM_NETIFS=6 SRC_PORT="1234" @@ -246,6 +249,55 @@ mdb_compat_fwd_test() do_compat_fwd "br0" } +# +# Verify fwd of IP multicast to router ports. A detected multicast +# router should always receive both known and unknown multicast. +# +mdb_rport_fwd_test() +{ + pass_grp=$PASS_GRP_IP4 + fail_grp=$FAIL_GRP_IP4 + pass_pkt=$PASS_PKT_IP4 + fail_pkt=$FAIL_PKT_IP4 + decoy="br0" + port=$h1 + type="IPv4" + + # Disable flooding of unknown multicast, strict MDB forwarding + bridge link set dev "$swp1" mcast_flood off + bridge link set dev "$swp2" mcast_flood off + bridge link set dev "br0" mcast_flood off self + + # Let h2 act as a multicast router + ip link set dev "$swp1" type bridge_slave mcast_router 2 + + # Static filter only to this decoy port + bridge mdb add dev br0 port $decoy grp "$pass_grp" + check_err $? "Failed adding multicast group $pass_grp to bridge port $decoy" + + tcpdump_start "$port" + + # Real data we're expecting + $MZ -q "$h2" "$pass_pkt" + # This should not pass + $MZ -q "$h2" "$fail_pkt" + + sleep 1 + tcpdump_stop "$port" + + tcpdump_show "$port" |grep -q "$src$spt > $pass_grp$dpt" + check_err $? "Failed forwarding $type multicast $pass_grp from $h2 to port $port" + + tcpdump_show "$port" |grep -q "$src$spt > $fail_grp$dpt" + check_err $? "Failed forwarding $type multicast $fail_grp from $h2 to port $port" + + bridge mdb del dev br0 port br0 grp "$pass_grp" + ip link set dev "$swp1" type bridge_slave mcast_router 1 + + log_test "MDB forward all $type multicast to multicast router on $port" + tcpdump_cleanup "$port" +} + do_mdb_fwd() { type=$1