Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6254675rwb; Tue, 9 Aug 2022 11:49:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7QoAWYzsJGHBVZloBtAefYzkdnYzRYIia1sqRPLeDG7Q9t+lrYk3hs31AyaPb15OvbjsQO X-Received: by 2002:aa7:d59a:0:b0:441:ecc9:f33e with SMTP id r26-20020aa7d59a000000b00441ecc9f33emr2526372edq.173.1660070995021; Tue, 09 Aug 2022 11:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660070995; cv=none; d=google.com; s=arc-20160816; b=X3EB35vQwXwlDzuCEKrt2o54nOQm0U5cebZbawXEON70zzOaiIwZHhiz+oNwrauwvD ldMh6gkyeF1M1sGxl493KPXh6oi62hhOtEmuQepRKDYwkaPB+7a9AfnpEIUtOpC+4vcb CsGwwtp39a7ERzhsS9+HCHIih0cr+5zOwq/AWJGQKw6WDP1yZhN3pa62ONdO4OabXSem JzHZqf/o5HZQrxpvXqTh5bwOC03gSDAvM7P1i1Da6W1bhaXDbAEh4jiClQmamJrl37vp VioO1KxpryO6TaQdQl1r734VhohH6HzYNStBqwRsWaV4MwYC4esawCUUkxFQnZKMC1iK 9nLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=09PduL8Bxz81WATsNd44JrQ3EwyDrrI3zDl7S+d/+nU=; b=IvllFhDnzU93e2RSJKZxozqiW4vj816kpm7E7FKm3jBSFaqjryOGP+iDg0FF7QHiTn BwinYubLPMlBTgiZulhq5AqvNwq4ECBBC7NXuQKfhOu4iGIhrz6yvrkJ2+tDiUwryHhm SlumQygHg1+glSeodqU9n+SfUvnkXzncR8goBb0tw0cvvoHQzWLFr5NspmeLH6I3YD4M Q5AXD8RS4+dufM4HT77nwN33NMHdNcwqF+5ePBI0hqwdPax5QXm9YxPB/8GqKH9fEWIX eaalPNf5dRBOoZJGP+H6B9dgDibmckz/AU4dRP5Kdm4y7oO2VG9zUUWNP4BNcydU3wv3 4aQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LlE3iROL; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o4-20020a170906974400b00732f76a97bdsi2194647ejy.907.2022.08.09.11.49.29; Tue, 09 Aug 2022 11:49:55 -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=@redhat.com header.s=mimecast20190719 header.b=LlE3iROL; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343985AbiHIR7R (ORCPT + 99 others); Tue, 9 Aug 2022 13:59:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343915AbiHIR67 (ORCPT ); Tue, 9 Aug 2022 13:58:59 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9243C253 for ; Tue, 9 Aug 2022 10:58:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660067933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=09PduL8Bxz81WATsNd44JrQ3EwyDrrI3zDl7S+d/+nU=; b=LlE3iROLxlwW/zX6ZD7jADUZUOpOFYjyars7ImwovVFwHdRnG2/6ww2AIEJsouuINEpkXw Swclr3yyi+4QGtvo2uhT0jCfzxxhWUYUXVrP6dqTRp/dYbTE7ZiVPbhhamYOd68mmIJ/a/ Xw/GhvHzagBjawOaUcNur+wZ6DTnnq8= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-621-HRtYeGIePpq33aD9M132oA-1; Tue, 09 Aug 2022 13:58:52 -0400 X-MC-Unique: HRtYeGIePpq33aD9M132oA-1 Received: by mail-qk1-f198.google.com with SMTP id v13-20020a05620a0f0d00b006b5f0ec742eso10673418qkl.2 for ; Tue, 09 Aug 2022 10:58:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=09PduL8Bxz81WATsNd44JrQ3EwyDrrI3zDl7S+d/+nU=; b=RwD80hvOCs5ImBSSvXAly95NmxD4yWiMEMWBUIkd3bDC42nCKUiaX1eY6Kyk/Ie+s9 1y9A6x8EmFGSwii4/mb3UnzApV+yjpPR7p2EOE7z7P+HNQviZ1Qyau08Fyuum6qumUsq /sgpSfmtv21KQWwr6GtAmpAViU8MI1MCmnHwFN8KUJhwBNqAAuSUPJhvJHPkVcWEuPUq YfM5Tbdta69GO+amreamygsFp/aAlMtl+Bnpqwuv00NtIEaqbePd2+sMUHWL1Gg+iBry IDOxjEn1nhapZyc1/OplZNP4sYYjnBmmnjzF6kuvPpS8dGF/lRpsV6OupfBPmq0+UTRH 1h5A== X-Gm-Message-State: ACgBeo0tdJF1mgU+t0Rg923OKwQGNLF5/KGpWar6jYpbFinayidmGhah 7bj/lHpMW3auEup+T7csQGkCglahLYQqor4EX3mMRPrk/sKfHj59OiCWnO0L9DefOzJ8st4hR9c KoqkWIsbMp/lwfW4ZOswtvf54 X-Received: by 2002:a05:6214:5098:b0:476:b536:3308 with SMTP id kk24-20020a056214509800b00476b5363308mr20615759qvb.81.1660067932212; Tue, 09 Aug 2022 10:58:52 -0700 (PDT) X-Received: by 2002:a05:6214:5098:b0:476:b536:3308 with SMTP id kk24-20020a056214509800b00476b5363308mr20615739qvb.81.1660067931874; Tue, 09 Aug 2022 10:58:51 -0700 (PDT) Received: from [192.168.98.18] ([107.12.98.143]) by smtp.gmail.com with ESMTPSA id a127-20020a379885000000b006af039ff090sm11607104qke.97.2022.08.09.10.58.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Aug 2022 10:58:51 -0700 (PDT) Message-ID: Date: Tue, 9 Aug 2022 13:58:50 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [RFC net] bonding: 802.3ad: fix no transmission of LACPDUs Content-Language: en-US To: Jay Vosburgh Cc: netdev@vger.kernel.org, Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org References: <12990.1660066616@famine> From: Jonathan Toppins In-Reply-To: <12990.1660066616@famine> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On 8/9/22 13:36, Jay Vosburgh wrote: > Jonathan Toppins wrote: > >> Running the script in >> `tools/testing/selftests/net/bonding/bond-break-lacpdu-tx.sh` puts >> bonding into a state where it never transmits LACPDUs. >> >> line 53: echo 65535 > /sys/class/net/fbond/bonding/ad_actor_sys_prio >> setting bond param: ad_actor_sys_prio >> given: >> params.ad_actor_system = 0 >> call stack: >> bond_option_ad_actor_sys_prio() >> -> bond_3ad_update_ad_actor_settings() >> -> set ad.system.sys_priority = bond->params.ad_actor_sys_prio >> -> ad.system.sys_mac_addr = bond->dev->dev_addr; because >> params.ad_actor_system == 0 >> results: >> ad.system.sys_mac_addr = bond->dev->dev_addr >> >> line 59: ip link set fbond address 52:54:00:3B:7C:A6 >> setting bond MAC addr >> call stack: >> bond->dev->dev_addr = new_mac >> >> line 63: echo 65535 > /sys/class/net/fbond/bonding/ad_actor_sys_prio >> setting bond param: ad_actor_sys_prio >> given: >> params.ad_actor_system = 0 >> call stack: >> bond_option_ad_actor_sys_prio() >> -> bond_3ad_update_ad_actor_settings() >> -> set ad.system.sys_priority = bond->params.ad_actor_sys_prio >> -> ad.system.sys_mac_addr = bond->dev->dev_addr; because >> params.ad_actor_system == 0 >> results: >> ad.system.sys_mac_addr = bond->dev->dev_addr >> >> line 71: ip link set veth1-bond down master fbond >> given: >> params.ad_actor_system = 0 >> params.mode = BOND_MODE_8023AD >> ad.system.sys_mac_addr == bond->dev->dev_addr >> call stack: >> bond_enslave >> -> bond_3ad_initialize(); because first slave >> -> if ad.system.sys_mac_addr != bond->dev->dev_addr >> return >> results: >> Nothing is run in bond_3ad_initialize() because dev_add equals >> sys_mac_addr leaving the global ad_ticks_per_sec zero as it is >> never initialized anywhere else. >> >> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") >> Signed-off-by: Jonathan Toppins >> --- >> MAINTAINERS | 1 + >> drivers/net/bonding/bond_3ad.c | 2 +- >> .../net/bonding/bond-break-lacpdu-tx.sh | 88 +++++++++++++++++++ >> 3 files changed, 90 insertions(+), 1 deletion(-) >> create mode 100644 tools/testing/selftests/net/bonding/bond-break-lacpdu-tx.sh >> >> diff --git a/MAINTAINERS b/MAINTAINERS >> index 386178699ae7..6e7cebc1bca3 100644 >> --- a/MAINTAINERS >> +++ b/MAINTAINERS >> @@ -3636,6 +3636,7 @@ F: Documentation/networking/bonding.rst >> F: drivers/net/bonding/ >> F: include/net/bond* >> F: include/uapi/linux/if_bonding.h >> +F: tools/testing/selftests/net/bonding/ >> >> BOSCH SENSORTEC BMA400 ACCELEROMETER IIO DRIVER >> M: Dan Robertson >> diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c >> index d7fb33c078e8..e357bc6b8e05 100644 >> --- a/drivers/net/bonding/bond_3ad.c >> +++ b/drivers/net/bonding/bond_3ad.c >> @@ -84,7 +84,7 @@ enum ad_link_speed_type { >> static const u8 null_mac_addr[ETH_ALEN + 2] __long_aligned = { >> 0, 0, 0, 0, 0, 0 >> }; >> -static u16 ad_ticks_per_sec; >> +static u16 ad_ticks_per_sec = 1000/AD_TIMER_INTERVAL; > > How does this resolve the problem? Does bond_3ad_initialize > actually run, or is this change sort of jump-starting things? It is jump-starting things. Really bond_3ad_initialize() should be fixed, but it seemed this change would be easier from a backporting perspective. The real issue seems to be bond_3ad_initialize() checks to make sure the "bond is not initialized yet" and if this check fails no initialization is done, which seems incorrect. Some minimal amount of initialization it seems needs to be done. This is also an order of execution bug, as I tried to layout in the commit message. Basically setting fbond's MAC and then resetting the option ad_actor_sys_prio causes the if check in bond_3ad_initialize() to not execute anything. We first saw this when using NetworkManager as for some reason NetworkManager was setting options twice, this is being looked at as well. I am open to other possible fixes, I just chose the one that appeared to be the easiest to backport, hence the RFC. > >> static const int ad_delta_in_ticks = (AD_TIMER_INTERVAL * HZ) / 1000; >> >> static const u8 lacpdu_mcast_addr[ETH_ALEN + 2] __long_aligned = >> diff --git a/tools/testing/selftests/net/bonding/bond-break-lacpdu-tx.sh b/tools/testing/selftests/net/bonding/bond-break-lacpdu-tx.sh >> new file mode 100644 >> index 000000000000..be9f1b64e89e >> --- /dev/null >> +++ b/tools/testing/selftests/net/bonding/bond-break-lacpdu-tx.sh >> @@ -0,0 +1,88 @@ >> +#!/bin/sh >> + >> +# Regression Test: >> +# Verify LACPDUs get transmitted after setting the MAC address of >> +# the bond. >> +# >> +# https://bugzilla.redhat.com/show_bug.cgi?id=2020773 >> +# >> +# +---------+ >> +# | fab-br0 | >> +# +---------+ >> +# | >> +# +---------+ >> +# | fbond | >> +# +---------+ >> +# | | >> +# +------+ +------+ >> +# |veth1 | |veth2 | >> +# +------+ +------+ >> +# >> +# We use veths instead of physical interfaces >> + >> +set -e >> +#set -x >> +tmp=$(mktemp -q dump.XXXXXX) >> +cleanup() { >> + ip link del fab-br0 >/dev/null 2>&1 || : >> + ip link del fbond >/dev/null 2>&1 || : >> + ip link del veth1-bond >/dev/null 2>&1 || : >> + ip link del veth2-bond >/dev/null 2>&1 || : >> + modprobe -r bonding >/dev/null 2>&1 || : >> + rm -f -- ${tmp} >> +} >> + >> +trap cleanup 0 1 2 >> +cleanup >> +sleep 1 >> + >> +# create the bridge >> +ip link add fab-br0 address 52:54:00:3B:7C:A6 mtu 1500 type bridge \ >> + forward_delay 15 >> + >> +# create the bond >> +ip link add fbond type bond >> +ip link set fbond up >> + >> +# set bond sysfs parameters >> +ip link set fbond down >> +echo 802.3ad > /sys/class/net/fbond/bonding/mode >> +echo 200 > /sys/class/net/fbond/bonding/miimon >> +echo 1 > /sys/class/net/fbond/bonding/xmit_hash_policy >> +echo 65535 > /sys/class/net/fbond/bonding/ad_actor_sys_prio >> +echo stable > /sys/class/net/fbond/bonding/ad_select >> +echo slow > /sys/class/net/fbond/bonding/lacp_rate >> +echo any > /sys/class/net/fbond/bonding/arp_all_targets > > Having a test case is very nice; would it be possible to avoid > using sysfs, though? I believe all of these parameters are available > via /sbin/ip. I can convert the test case to `ip link`, it doesn't appear the method of configuration would cause a difference in the result. > > Also, is setting "arp_all_targets" necessary for the test? Its probably not, I probably do not need to configure most of these options because most are default values. I can work on trimming it down even more. > > -J > >> + >> +# set bond address >> +ip link set fbond address 52:54:00:3B:7C:A6 >> +ip link set fbond up >> + >> +# set again bond sysfs parameters >> +echo 65535 > /sys/class/net/fbond/bonding/ad_actor_sys_prio >> + >> +# create veths >> +ip link add name veth1-bond type veth peer name veth1-end >> +ip link add name veth2-bond type veth peer name veth2-end >> + >> +# add ports >> +ip link set fbond master fab-br0 >> +ip link set veth1-bond down master fbond >> +ip link set veth2-bond down master fbond >> + >> +# bring up >> +ip link set veth1-end up >> +ip link set veth2-end up >> +ip link set fab-br0 up >> +ip link set fbond up >> +ip addr add dev fab-br0 10.0.0.3 >> + >> +tcpdump -n -i veth1-end -e ether proto 0x8809 >${tmp} 2>&1 & >> +sleep 60 >> +pkill tcpdump >/dev/null 2>&1 >> +num=$(grep "packets captured" ${tmp} | awk '{print $1}') >> +if test "$num" -gt 0; then >> + echo "PASS, captured ${num}" >> +else >> + echo "FAIL" >> +fi >> -- >> 2.31.1 >> > > --- > -Jay Vosburgh, jay.vosburgh@canonical.com >