From patchwork Sun Oct 8 05:26:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1844849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Tkp5pp97; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S39dW0cTBz1yqP for ; Sun, 8 Oct 2023 16:26:53 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5EFE241962; Sun, 8 Oct 2023 05:26:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5EFE241962 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Tkp5pp97 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u4j6RTP-b20b; Sun, 8 Oct 2023 05:26:49 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id D25F5415FD; Sun, 8 Oct 2023 05:26:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D25F5415FD Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 91641C0039; Sun, 8 Oct 2023 05:26:47 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 48B59C0032 for ; Sun, 8 Oct 2023 05:26:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1EB8E404B5 for ; Sun, 8 Oct 2023 05:26:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 1EB8E404B5 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Tkp5pp97 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1urX53sHpygg for ; Sun, 8 Oct 2023 05:26:45 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id C4B624033A for ; Sun, 8 Oct 2023 05:26:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C4B624033A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696742803; 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; bh=6sY3zITA2itmVleMk2Qm3Ow2C4v1PuQ08Km+EyOoV0A=; b=Tkp5pp97JR3InDqJEti62X0ONJl0b1I22lTeA8EEth7Iia/Q85SArs0NFVK/c7+mzxtxF8 B/Xjz+JnFTv+19SbH26XpURD7WnTTKE6QweKpAntdliDX8HZ5dJwaAliz2pzRWpbz5dAdY gidb9H4QMcQei0q/kzDbXUEpxZLiMPw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-497-nl2ukEVGMv6PhQ2dOHIPbw-1; Sun, 08 Oct 2023 01:26:36 -0400 X-MC-Unique: nl2ukEVGMv6PhQ2dOHIPbw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9DABA101A529 for ; Sun, 8 Oct 2023 05:26:36 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.32.74]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50481492B16; Sun, 8 Oct 2023 05:26:36 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Sun, 8 Oct 2023 01:26:32 -0400 Message-Id: <20231008052632.613791-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v3] bond: Always revalidate unbalanced bonds when active member changes X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Currently a bond will not always revalidate when an active member changes. This can result in counter-intuitive behaviors like the fact that using ovs-appctl bond/set-active-member will cause the bond to revalidate but changing other_config:bond-primary will not trigger a revalidate in the bond. When revalidation is not set but the active member changes in an unbalanced bond, OVS may send traffic out of previously active member instead of the new active member. This change will always mark unbalanced bonds for revalidation if the active member changes. Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=2214979 Signed-off-by: Mike Pattrick --- v2: Added a test v3: Made the test more reliable --- ofproto/bond.c | 8 +++++-- tests/system-traffic.at | 50 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/ofproto/bond.c b/ofproto/bond.c index cfdf44f85..fb108d30a 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -193,6 +193,7 @@ static void bond_update_post_recirc_rules__(struct bond *, bool force) static bool bond_is_falling_back_to_ab(const struct bond *); static void bond_add_lb_output_buckets(const struct bond *); static void bond_del_lb_output_buckets(const struct bond *); +static bool bond_is_balanced(const struct bond *bond) OVS_REQ_RDLOCK(rwlock); /* Attempts to parse 's' as the name of a bond balancing mode. If successful, @@ -552,11 +553,15 @@ bond_find_member_by_mac(const struct bond *bond, const struct eth_addr mac) static void bond_active_member_changed(struct bond *bond) + OVS_REQ_WRLOCK(rwlock) { if (bond->active_member) { struct eth_addr mac; netdev_get_etheraddr(bond->active_member->netdev, &mac); bond->active_member_mac = mac; + if (!bond_is_balanced(bond)) { + bond->bond_revalidate = true; + } } else { bond->active_member_mac = eth_addr_zero; } @@ -1124,7 +1129,7 @@ bond_get_recirc_id_and_hash_basis(struct bond *bond, uint32_t *recirc_id, /* Rebalancing. */ static bool -bond_is_balanced(const struct bond *bond) OVS_REQ_RDLOCK(rwlock) +bond_is_balanced(const struct bond *bond) { return bond->rebalance_interval && (bond->balance == BM_SLB || bond->balance == BM_TCP) @@ -1728,7 +1733,6 @@ bond_unixctl_set_active_member(struct unixctl_conn *conn, } if (bond->active_member != member) { - bond->bond_revalidate = true; bond->active_member = member; VLOG_INFO("bond %s: active member is now %s", bond->name, member->name); diff --git a/tests/system-traffic.at b/tests/system-traffic.at index 945037ec0..7075c35ea 100644 --- a/tests/system-traffic.at +++ b/tests/system-traffic.at @@ -291,6 +291,56 @@ NS_CHECK_EXEC([at_ns0], [ping -s 3200 -q -c 3 -i 0.3 -w 2 10.1.1.2 | FORMAT_PING OVS_TRAFFIC_VSWITCHD_STOP AT_CLEANUP +AT_SETUP([datapath - ping over active-backup bond]) +OVS_TRAFFIC_VSWITCHD_START([_ADD_BR([br1])]) + +AT_CHECK([ovs-ofctl add-flow br0 "priority=1 actions=drop"]) +AT_CHECK([ovs-ofctl add-flow br1 "priority=1 actions=drop"]) +AT_CHECK([ovs-ofctl add-flow br0 "ip,icmp actions=normal"]) +AT_CHECK([ovs-ofctl add-flow br1 "ip,icmp actions=normal"]) +AT_CHECK([ovs-ofctl add-flow br0 "arp actions=normal"]) +AT_CHECK([ovs-ofctl add-flow br1 "arp actions=normal"]) + +ADD_NAMESPACES(at_ns0, at_ns1) + +ADD_VETH(p0, at_ns0, br0, "10.1.1.1/24") +ADD_VETH(p1, at_ns1, br1, "10.1.1.2/24") +on_exit 'ip link del link0a' +on_exit 'ip link del link0b' +AT_CHECK([ip link add link0a type veth peer name link1a]) +AT_CHECK([ip link add link0b type veth peer name link1b]) + +AT_CHECK([ip link set dev link0a up]) +AT_CHECK([ip link set dev link1a up]) +AT_CHECK([ip link set dev link0b up]) +AT_CHECK([ip link set dev link1b up]) + +AT_CHECK([ovs-vsctl add-bond br0 bond0 link0a link0b bond_mode=active-backup]) +AT_CHECK([ovs-vsctl add-bond br1 bond1 link1a link1b bond_mode=active-backup]) + +dnl Set primary +AT_CHECK([ovs-vsctl set port bond0 other_config:bond-primary=link0a -- \ + set port bond1 other_config:bond-primary=link1a]) + +OVS_WAIT_UNTIL([ip netns exec at_ns0 ping -c 1 10.1.1.2]) + +NS_CHECK_EXEC([at_ns0], [ping -q -c 6 -i 0.3 -w 6 10.1.1.2 | FORMAT_PING], [0], [dnl +6 packets transmitted, 6 received, 0% packet loss, time 0ms +]) + +dnl Change primary +AT_CHECK([ovs-vsctl set port bond0 other_config:bond-primary=link0b -- \ + set port bond1 other_config:bond-primary=link1b]) + +sleep 0 + +NS_CHECK_EXEC([at_ns0], [ping -q -c 6 -i 0.5 -w 6 10.1.1.2 | FORMAT_PING], [0], [dnl +6 packets transmitted, 6 received, 0% packet loss, time 0ms +]) + +OVS_TRAFFIC_VSWITCHD_STOP +AT_CLEANUP + AT_SETUP([datapath - ping over vxlan tunnel]) OVS_CHECK_TUNNEL_TSO() OVS_CHECK_VXLAN()