From patchwork Tue Sep 5 19:13:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valerio X-Patchwork-Id: 1830092 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=dLOnrK3o; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 4RgFXJ5QtDz1yg7 for ; Wed, 6 Sep 2023 05:13:20 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 49BB381EDA; Tue, 5 Sep 2023 19:13:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 49BB381EDA Authentication-Results: smtp1.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=dLOnrK3o X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FaQ8fjjPz-HK; Tue, 5 Sep 2023 19:13:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4BE9C81678; Tue, 5 Sep 2023 19:13:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4BE9C81678 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 21326C0071; Tue, 5 Sep 2023 19:13:16 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 11ADEC0032 for ; Tue, 5 Sep 2023 19:13:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id DA9E281755 for ; Tue, 5 Sep 2023 19:13:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org DA9E281755 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vz9-wljNXz5o for ; Tue, 5 Sep 2023 19:13:14 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id D5C8181678 for ; Tue, 5 Sep 2023 19:13:13 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D5C8181678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693941192; 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=+bnbIce779aYDmqoUCPWic+b076lTTCz1HtBRr6YFbU=; b=dLOnrK3o/NApXEIVLL4J+gvJip8Hgg1oBEKW/icBNI3chwJ7xog1uSQUHa6d6Mviqu6FxS UvYr2hkSOvrsSkFQgYnV79q5mtqop2/DPiVq7v8R9w4kL6UpSN2L7pl73R1eJ7ACmVJbL2 2IBWrjjsMrUgrfjw1D3OeUv+3qvi1uQ= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-gxPvXVi_O_GB_vSAOx0Mpw-1; Tue, 05 Sep 2023 15:13:11 -0400 X-MC-Unique: gxPvXVi_O_GB_vSAOx0Mpw-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-5010a5fb7bdso731443e87.1 for ; Tue, 05 Sep 2023 12:13:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693941188; x=1694545988; h=content-transfer-encoding:mime-version:user-agent:message-id:date :cc:to:from:subject:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+bnbIce779aYDmqoUCPWic+b076lTTCz1HtBRr6YFbU=; b=cFpFfoPEBO8ngC0D66GnJhsBhMaaAdBFusJ2Q5OxpJyqG1Go3MnTN2RWWwpI3nI+Yq 3nFXNpfG31TKaWdeUXVbEuEtJxYhHWvo0zBz+vrbb4b9QRczk34K1WQgIVmKzL9o6jWW 4wQ/Xm4AHm1jLrchPgpXa7J4YQbzlM+QawcTdVd+YeSUVCh7KE36P4oN3DUyvg7H7tXE Hkqx94I2OdC1Q/P+0qL6m3jwacCPt01pqJCYkdcswVzaN3K/4j6TopO2ut715ucHzxVJ ulvyBp7ID03xRVinB3XECJ932IfdKVrz+rYAX2ESYoPJuxJnGNXBJ1sCwEFvcO4p1AaO wDAw== X-Gm-Message-State: AOJu0YxSOPHYeZUcX36W1cvHPVDsaIqbnOmwtNEUoh6sS0c1R3OtKoOA B8P7iebhpEDku0X1vMQdU6HFXyrMBXWDsYtqpJtlYTrNJIEPC2GGwH3Cvn7/erDiO5D85VjsVgD Rd2si2LofK2XZLLmy4VfyRGZh+Z8LvQG46OovXub4F0QCrZOY1m7Td0tENMqVhhOYXHSh/j9jxB SeUg== X-Received: by 2002:a05:6512:3b91:b0:501:be72:93cf with SMTP id g17-20020a0565123b9100b00501be7293cfmr2500029lfv.4.1693941188699; Tue, 05 Sep 2023 12:13:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEoWvUn/ZlX7f/Vfxqfrq+98SlPzcEEFkPgJ+igczz+wlck81Pc4cNANwjcVJIDm9C9TeD0hA== X-Received: by 2002:a05:6512:3b91:b0:501:be72:93cf with SMTP id g17-20020a0565123b9100b00501be7293cfmr2500007lfv.4.1693941188275; Tue, 05 Sep 2023 12:13:08 -0700 (PDT) Received: from localhost (net-2-44-218-197.cust.vodafonedsl.it. [2.44.218.197]) by smtp.gmail.com with ESMTPSA id r14-20020a056402034e00b00523d2a1626esm7515948edw.6.2023.09.05.12.13.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Sep 2023 12:13:07 -0700 (PDT) From: Paolo Valerio To: ovs-dev@openvswitch.org Date: Tue, 05 Sep 2023 21:13:02 +0200 Message-ID: <169394118209.2946148.11773928893766161946.stgit@rawp> User-Agent: StGit/1.5 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: i.maximets@ovn.org Subject: [ovs-dev] [PATCH v2] ofproto-dpif-xlate: Fix recirculation with patch port and controller. 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" If a packet originating from the controller recirculates after going through a patch port, it gets dropped with the following message: ofproto_dpif_upcall(handler8)|INFO|received packet on unassociated datapath port 4294967295 This happens because there's no xport_uuid in the recirculation node and at the same type in_port refers to the patch port. The patch, in the case of zeroed uuid, checks that in_port belongs to the bridge and returns the related ofproto. Signed-off-by: Paolo Valerio --- ofproto/ofproto-dpif-xlate.c | 12 +++++++++++- tests/ofproto-dpif.at | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 47ea0f47e..fcd547645 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1615,7 +1615,8 @@ xlate_lookup_ofproto_(const struct dpif_backer *backer, } ofp_port_t in_port = recirc_id_node->state.metadata.in_port; - if (in_port != OFPP_NONE && in_port != OFPP_CONTROLLER) { + if (in_port != OFPP_NONE && in_port != OFPP_CONTROLLER && + !uuid_is_zero(&recirc_id_node->state.xport_uuid)) { struct uuid xport_uuid = recirc_id_node->state.xport_uuid; xport = xport_lookup_by_uuid(xcfg, &xport_uuid); if (xport && xport->xbridge && xport->xbridge->ofproto) { @@ -1626,11 +1627,19 @@ xlate_lookup_ofproto_(const struct dpif_backer *backer, * that the packet originated from the controller via an OpenFlow * "packet-out". The right thing to do is to find just the * ofproto. There is no xport, which is OK. + * Also a zeroed xport_uuid with a valid in_port, means that + * the packet originated from OFPP_CONTROLLER passed + * through a patch port. * * OFPP_NONE can also indicate that a bond caused recirculation. */ struct uuid uuid = recirc_id_node->state.ofproto_uuid; const struct xbridge *bridge = xbridge_lookup_by_uuid(xcfg, &uuid); + if (bridge && bridge->ofproto) { + if (in_port != OFPP_CONTROLLER && in_port != OFPP_NONE && + !get_ofp_port(bridge, in_port)) { + goto xport_lookup; + } if (errorp) { *errorp = NULL; } @@ -1643,6 +1652,7 @@ xlate_lookup_ofproto_(const struct dpif_backer *backer, } } +xport_lookup: xport = xport_lookup(xcfg, tnl_port_should_receive(flow) ? tnl_port_receive(flow) : odp_port_to_ofport(backer, flow->in_port.odp_port)); diff --git a/tests/ofproto-dpif.at b/tests/ofproto-dpif.at index f242f77f3..a0a4aaf5d 100644 --- a/tests/ofproto-dpif.at +++ b/tests/ofproto-dpif.at @@ -5854,6 +5854,40 @@ OVS_WAIT_UNTIL([check_flows], [ovs-ofctl dump-flows br0]) OVS_VSWITCHD_STOP AT_CLEANUP +# Checks for regression against a bug in which OVS dropped packets +# originating from the the controller passing through a patch port +AT_SETUP([ofproto-dpif - packet-out recirculation OFPP_CONTROLLER and patch port]) +OVS_VSWITCHD_START( + [add-port br0 patch-br1 -- \ + set interface patch-br1 type=patch options:peer=patch-br0 -- \ + add-br br1 -- set bridge br1 datapath-type=dummy fail-mode=secure -- \ + add-port br1 patch-br0 -- set interface patch-br0 type=patch options:peer=patch-br1 +]) + +add_of_ports --pcap br1 1 + +AT_DATA([flows-br0.txt], [dnl +table=0 icmp actions=output:patch-br1 +]) +AT_CHECK([ovs-ofctl add-flows br0 flows-br0.txt]) + +AT_DATA([flows-br1.txt], [dnl +table=0, icmp actions=ct(table=1,zone=1) +table=1, ct_state=+trk, icmp actions=p1 +]) +AT_CHECK([ovs-ofctl add-flows br1 flows-br1.txt]) + +packet=50540000000750540000000508004500005c000000008001b94dc0a80001c0a80002080013fc00000000000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f +AT_CHECK([ovs-ofctl packet-out br0 "in_port=CONTROLLER packet=$packet actions=table"]) + +OVS_WAIT_UNTIL_EQUAL([ovs-ofctl dump-flows -m br1 | grep "ct_state" | ofctl_strip], [dnl + table=1, n_packets=1, n_bytes=106, ct_state=+trk,icmp actions=output:2]) + +OVS_WAIT_UNTIL([ovs-pcap p1-tx.pcap | grep -q "$packet"]) + +OVS_VSWITCHD_STOP +AT_CLEANUP + AT_SETUP([ofproto-dpif - debug_slow action]) OVS_VSWITCHD_START add_of_ports br0 1 2 3