Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp740917rwb; Sat, 17 Sep 2022 14:10:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QeJhY6PmzER7qs1Ri6080x3NCGaMGHAIxkNrnrxu0LPn+7Bxd+FddVVvY99zIElsEX7Fb X-Received: by 2002:a05:6402:1b06:b0:44e:a073:1dd8 with SMTP id by6-20020a0564021b0600b0044ea0731dd8mr8802608edb.391.1663449019414; Sat, 17 Sep 2022 14:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663449019; cv=none; d=google.com; s=arc-20160816; b=OCsUNm79AfrvfFGUts0KcR65eo+cYFktTUxXOeCxtQ7xDxLNWrRcaWPy0mMFr8OUfm zqLWmugoMU6GQnaH/cx+Zp6dCPCs5zy/TydWWyapXDpyC9qGpMzABtuq6fXFrXYKUHHA GuJ4nrAEd2/SF+LwYJLNBXFlnEigEAmtbnsdUoHH76K6nuGfXhsudfX+caM3YTSeeNVJ ekUD4Im1aQ4Be6gn2xWTjMO67KBNySaqGWgO496X8+D1Lw+alRYrormU9qlTYZ70DsAk AfHq0C5/mL7+f3am/dcuzlcATl4GzKCI9RHMgOu/lnHl+d5kEPhh5SGfG3Jvp4SFRr5N jcnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=00Tw4Iguiga6FIJOQTAU2+b9Codsgvfv3AG/3wKNVqM=; b=AdYC9D9clso7O//ZcnTFCdMwT0l6w86bMiTgJ+4ApLlyuLqttC9DtaOas3/QeNt0v6 ys16rIgzI6gzxjRYs4K83Oy3yIB46GEIouuEUx9MnmNscZ7VkGEzZque1zkIM5FpVTbP Bk1x1jkAaZ3LUCIPGKQ6HADCog6hYPZmiZeBgRAx6LSH8QBHgfhXt+avHZO203P8xqdt 06hPRqqO+F9hSf0MfzJ2oRcWbrDyslpa5F91HIlP1lOgq2OyHyR6TRHzuX6OMasQnWJs L5RiQO4hbyFtf9YDnWC0UtfbXSn6oH4vcwP6Gr3aCfv4+4+R/NlJCyHdj4QvtMprXSOZ pbZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="FZ7G+W/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020a170906135000b0078109a2a6a0si1120625ejb.86.2022.09.17.14.09.52; Sat, 17 Sep 2022 14:10:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="FZ7G+W/t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbiIQUSm (ORCPT + 99 others); Sat, 17 Sep 2022 16:18:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbiIQUSW (ORCPT ); Sat, 17 Sep 2022 16:18:22 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 782302ED51; Sat, 17 Sep 2022 13:18:20 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id z9so7710876qvn.9; Sat, 17 Sep 2022 13:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=00Tw4Iguiga6FIJOQTAU2+b9Codsgvfv3AG/3wKNVqM=; b=FZ7G+W/tFDZsg5m8et+ZfWZX+4PjaCgi1eksG5u4CCRchWpmUEt0I9eG42xBA6HxzT QrStOK1km8P3bBa6dBMtGK8g5roVU03R/aPWl2v+GNYPN+NQAXum8o6fWr6UGnN4DEKS 4pUa6MJqvPGMaE95CrmUwMhtL9PlDy6kvS+rWlujoGhNcCMe/rfMjIwSYeTQ8/SvcOud gGCSxfMpapJPzvRqtt+CXvjcoc5ftKp/egs1LDyErvMbwJs9/yyUVmyDqyU0d6To4HQy JudEstUVnQdsOG3q55dmFOlfRmqZa6iEMFQ9CiVeeil4neoDiRXj1IlqAi4mxb1KAJCl TxnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=00Tw4Iguiga6FIJOQTAU2+b9Codsgvfv3AG/3wKNVqM=; b=4dMWhpYphs84DQ+D6Hd91Zf5W1fazsw+gVJsRz1YTiTc82SVWYYtDnP9OcEOPEHKUQ yqpObK9vxOyuDsAKUL5LH0Yn/aLsLo4fVP43+ZH/263Yoqs/+V9S7RSMILeqqMiXOrLm ORPyeuxFUxuvcW6H1Os9opzC4DdHjxXjffECe398Ki9cqXA4y9EFWevODtmoFkEs7ph6 Y8PjyPJrtyaYrGF67OpDiq8jVls1tWpG48g0m294LzoNRaYMl0rZXRbhUROQ0nvHIrhO 79z0GJrzRizJV+VJe58cV81AFNTzSk9UjC3iCOiRNj4/Iy0ahcFNoehzc6uteM4ovK8G GIrA== X-Gm-Message-State: ACrzQf1stkA4kDJhNCblbLeBXcv6+xPwUpaCt+FeEPZ16/3JaeObtpBp IwJ113C/NYbTxG6kt4cTkT8= X-Received: by 2002:a05:6214:4006:b0:48d:3f52:52e7 with SMTP id kd6-20020a056214400600b0048d3f5252e7mr9262865qvb.113.1663445899504; Sat, 17 Sep 2022 13:18:19 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id x8-20020ac85388000000b0035bafecff78sm7280790qtp.74.2022.09.17.13.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 13:18:19 -0700 (PDT) From: Sevinj Aghayeva To: netdev@vger.kernel.org Cc: "David S. Miller" , aroulin@nvidia.com, sbrivio@redhat.com, roopa@nvidia.com, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nikolay Aleksandrov , linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Sevinj Aghayeva Subject: [PATCH RFC net-next 5/5] selftests: net: tests for bridge binding behavior Date: Sat, 17 Sep 2022 16:18:01 -0400 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds two tests in a single file. The first of these is in function run_test_late_bridge_binding_set, which tests that when a vlan interface is created with bridge binding turned off, and later bridge binding is turned on (using ip link set... command), the vlan interface behaves accordingly, that is, it tracks the status of the ports in its vlan. The second test, which is in function run_test_multiple_vlan, tests that when there are two vlan interfaces with bridge binding turned on, turning off the bridge binding in one of the vlan interfaces does not affect the bridge binding on the other interface. Signed-off-by: Sevinj Aghayeva --- tools/testing/selftests/net/Makefile | 1 + .../selftests/net/bridge_vlan_binding_test.sh | 143 ++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100755 tools/testing/selftests/net/bridge_vlan_binding_test.sh diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index f5ac1433c301..48443928c3dd 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -44,6 +44,7 @@ TEST_PROGS += arp_ndisc_untracked_subnets.sh TEST_PROGS += stress_reuseport_listen.sh TEST_PROGS += l2_tos_ttl_inherit.sh TEST_PROGS += bind_bhash.sh +TEST_PROGS += bridge_vlan_binding_test.sh TEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh TEST_GEN_FILES = socket nettest diff --git a/tools/testing/selftests/net/bridge_vlan_binding_test.sh b/tools/testing/selftests/net/bridge_vlan_binding_test.sh new file mode 100755 index 000000000000..d094d847800c --- /dev/null +++ b/tools/testing/selftests/net/bridge_vlan_binding_test.sh @@ -0,0 +1,143 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +cleanup() { + # Remove interfaces created by the previous run + ip link delete veth10 2>/dev/null + ip link delete veth20 2>/dev/null + ip link delete veth30 2>/dev/null + ip link delete br_default 2>/dev/null +} + +trap cleanup EXIT + +setup() { + cleanup + + # Create a bridge and add three ports to it. + ip link add dev br_default type bridge + ip link add dev veth10 type veth peer name veth11 + ip link add dev veth20 type veth peer name veth21 + ip link add dev veth30 type veth peer name veth31 + ip link set dev veth10 master br_default + ip link set dev veth20 master br_default + ip link set dev veth30 master br_default + + # Create VLAN 10 and VLAN 20. + bridge vlan add vid 10 dev br_default self + bridge vlan add vid 20 dev br_default self + + # Add veth10 to VLAN 10 and veth20 to VLAN 20. + bridge vlan add vid 10 dev veth10 + bridge vlan add vid 20 dev veth20 + + # Bring up the ports and the bridge. + ip link set veth10 up + ip link set veth11 up + ip link set veth20 up + ip link set veth21 up + ip link set veth30 up + ip link set veth31 up + ip link set br_default up +} + +# This test checks that when a vlan interface is created with bridge +# binding off, and then bridge binding turned on using "ip link set" +# command, bridge binding is actually turned on -- this hasn't been +# the case in the past. +run_test_late_bridge_binding_set() { + setup + + # Add VLAN interface vlan10 to VLAN 10 with bridge binding off. + ip link add link br_default name vlan10 type vlan id 10 protocol \ + 802.1q bridge_binding off + + # Bring up VLAN interface. + ip link set vlan10 up + + # Turn bridge binding on for vlan10. + ip link set vlan10 type vlan bridge_binding on + + # Bring down the port in vlan 10. + ip link set veth10 down + + # Since bridge binding is turned on for vlan10 interface, it + # should be tracking only the port, veth10 in its vlan. Since + # veth10 is down, vlan10 should be down as well. + if ! ip link show vlan10 | grep -q 'state LOWERLAYERDOWN'; then + echo "FAIL - vlan10 should be LOWERLAYERDOWN but it is not" + exit 1 + fi + + # Bringe the port back up. + ip link set veth10 up + + # The vlan 10 interface should be up now. + if ! ip link show vlan10 | grep -q 'state UP'; then + echo "FAIL - vlan10 should be UP but it is not" + exit 1 + fi + + echo "OK" +} + +# This test checks that when there are multiple vlan interfaces with +# bridge binding on, turning off bride binding in one of the vlan +# interfaces does not affect the bridge binding of the other +# interface. +run_test_multiple_vlan() { + setup + + # Add VLAN interface vlan10 to VLAN 10 with bridge binding on. + ip link add link br_default name vlan10 type vlan id 10 protocol \ + 802.1q bridge_binding on + # Add VLAN interface vlan20 to VLAN 20 with bridge binding on. + ip link add link br_default name vlan20 type vlan id 20 protocol \ + 802.1q bridge_binding on + + # Bring up VLAN interfaces. + ip link set vlan10 up + ip link set vlan20 up + + # Turn bridge binding off for vlan10. + ip link set vlan10 type vlan bridge_binding off + + # Bring down the ports in vlans 10 and 20. + ip link set veth10 down + ip link set veth20 down + + # Since bridge binding is off for vlan10 interface, it should + # be tracking all of the ports in the bridge; since veth30 is + # still up, vlan10 should also be up. + if ! ip link show vlan10 | grep -q 'state UP'; then + echo "FAIL - vlan10 should be UP but it is not" + exit 1 + fi + + # Since bridge binding is on for vlan20 interface, it should + # be tracking only the ports in its vlan. This port is veth20, + # and it is down; therefore, vlan20 should be down as well. + if ! ip link show vlan20 | grep -q 'state LOWERLAYERDOWN'; then + echo "FAIL - vlan20 should be LOWERLAYERDOWN but it is not" + exit 1 + fi + + # Bring the ports back up. + ip link set veth10 up + ip link set veth20 up + + # Both vlan interfaces should be up now. + if ! ip link show vlan10 | grep -q 'state UP'; then + echo "FAIL - vlan10 should be UP but it is not" + exit 1 + fi + if ! ip link show vlan20 | grep -q 'state UP' ; then + echo "FAIL - vlan20 should be UP but it is not" + exit 1 + fi + + echo "OK" +} + +run_test_late_bridge_binding_set +run_test_multiple_vlan -- 2.34.1