From patchwork Wed May 25 06:51:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1635289 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=M9IEhRJ4; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L7MF50nsmz9sFx for ; Wed, 25 May 2022 16:52:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 2393441BA7; Wed, 25 May 2022 06:52:07 +0000 (UTC) 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 by4StpL5eTiA; Wed, 25 May 2022 06:52:06 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id CFE3B415DC; Wed, 25 May 2022 06:52:04 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EC301C0080; Wed, 25 May 2022 06:52:02 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4941BC0039 for ; Wed, 25 May 2022 06:52:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 455D882CCB for ; Wed, 25 May 2022 06:52:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 BPj2B5okNkxB for ; Wed, 25 May 2022 06:52:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 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 4D47782BF4 for ; Wed, 25 May 2022 06:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653461518; 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=lcfA45nLIB2D+/JfNelBd/5a/vLCU3SpbI3Eq42bARo=; b=M9IEhRJ4nV5TpWVIzSTyVZFh+m1H07yGNAx6qfUJV7PuiqsISBcNh0PT8JSEo5UoxqJjSs ouGlxQ9uf/+sMjqwCVnyk0CPCxUdMqasmjjsG/xl9NKtc6g7s5gwXsDkw5UwrqHYA59dkP PmSCsuTyc5d3gTwZUZXU+pj7qraxDIU= 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-582-7mzOlct-Ovu514SkBixuhQ-1; Wed, 25 May 2022 02:51:57 -0400 X-MC-Unique: 7mzOlct-Ovu514SkBixuhQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F95E18A64EA for ; Wed, 25 May 2022 06:51:57 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.34.130.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD8E41410DD5; Wed, 25 May 2022 06:51:56 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Wed, 25 May 2022 08:51:54 +0200 Message-Id: <20220525065155.293205-2-amusil@redhat.com> In-Reply-To: <20220525065155.293205-1-amusil@redhat.com> References: <20220525065155.293205-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amusil@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2 1/2] physical.c: Move localport remote output flow definition 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" The localport should always delegate traffic locally, move the definition into consider_port_binding as the physical_run is not evaluated during I-P. Reported-at: https://bugzilla.redhat.com/2076604 Signed-off-by: Ales Musil --- v2: Rebase on newer main --- controller/physical.c | 44 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/controller/physical.c b/controller/physical.c index 1fae4ef2c..ce9c7b260 100644 --- a/controller/physical.c +++ b/controller/physical.c @@ -1293,6 +1293,24 @@ consider_port_binding(struct ovsdb_idl_index *sbrec_port_binding_by_name, } } + /* Table 37, priority 150. + * ======================= + * + * Handles packets received from ports of type "localport". These + * ports are present on every hypervisor. Traffic that originates at + * one should never go over a tunnel to a remote hypervisor, + * so resubmit them to table 38 for local delivery. */ + if (!strcmp(binding->type, "localport")) { + ofpbuf_clear(ofpacts_p); + put_resubmit(OFTABLE_LOCAL_OUTPUT, ofpacts_p); + match_init_catchall(&match); + match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, + binding->tunnel_key); + match_set_metadata(&match, htonll(binding->datapath->tunnel_key)); + ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 150, + binding->header_.uuid.parts[0], &match, + ofpacts_p, &binding->header_.uuid); + } } else if (!tun && !is_ha_remote) { /* Remote port connected by localnet port */ /* Table 38, priority 100. @@ -1852,32 +1870,6 @@ physical_run(struct physical_ctx *p_ctx, ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 150, 0, &match, &ofpacts, hc_uuid); - /* Table 37, priority 150. - * ======================= - * - * Handles packets received from ports of type "localport". These ports - * are present on every hypervisor. Traffic that originates at one should - * never go over a tunnel to a remote hypervisor, so resubmit them to table - * 38 for local delivery. */ - match_init_catchall(&match); - ofpbuf_clear(&ofpacts); - put_resubmit(OFTABLE_LOCAL_OUTPUT, &ofpacts); - const char *localport; - SSET_FOR_EACH (localport, p_ctx->local_lports) { - /* Iterate over all local logical ports and insert a drop - * rule with higher priority for every localport in this - * datapath. */ - const struct sbrec_port_binding *pb = lport_lookup_by_name( - p_ctx->sbrec_port_binding_by_name, localport); - if (pb && !strcmp(pb->type, "localport")) { - match_set_reg(&match, MFF_LOG_INPORT - MFF_REG0, pb->tunnel_key); - match_set_metadata(&match, htonll(pb->datapath->tunnel_key)); - ofctrl_add_flow(flow_table, OFTABLE_REMOTE_OUTPUT, 150, - pb->header_.uuid.parts[0], - &match, &ofpacts, hc_uuid); - } - } - /* Table 37, Priority 0. * ======================= * From patchwork Wed May 25 06:51:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1635290 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=HwR2eTrK; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4L7MF82P7cz9sFx for ; Wed, 25 May 2022 16:52:12 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D4289840E7; Wed, 25 May 2022 06:52:09 +0000 (UTC) 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 cXAFMNhLw3Be; Wed, 25 May 2022 06:52:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 3049C82EB4; Wed, 25 May 2022 06:52:06 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1093FC0087; Wed, 25 May 2022 06:52:04 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 84837C002D for ; Wed, 25 May 2022 06:52:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 6487C612AE for ; Wed, 25 May 2022 06:52:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 5KYqykXvWPk3 for ; Wed, 25 May 2022 06:52:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 6407060674 for ; Wed, 25 May 2022 06:52:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653461519; 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=gRvOM+P1X24fXZ6UIzI8NuL7C5wPF58qWQ8POBIBgVQ=; b=HwR2eTrKYkvZmlLbY1OWW2Hcnrtu99u7NHTjWt/k/bdYY1K6X5UMIY5NeZCFQWd3oLk3Gi IlmYKvHCtaHsJilXuEygCzBScFXDdRfJG+MaMgx8GA1NRTDByzmePkZf0XEZokmWtVmnMd IJXVOpJbBb8BmW2YfDZr4gOUUs36GXs= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-PBM1OtVYOu-DotEn1MVhug-1; Wed, 25 May 2022 02:51:58 -0400 X-MC-Unique: PBM1OtVYOu-DotEn1MVhug-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED1793C138AE for ; Wed, 25 May 2022 06:51:57 +0000 (UTC) Received: from amusil.redhat.com (unknown [10.34.130.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 772FA1410DD5; Wed, 25 May 2022 06:51:57 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Wed, 25 May 2022 08:51:55 +0200 Message-Id: <20220525065155.293205-3-amusil@redhat.com> In-Reply-To: <20220525065155.293205-1-amusil@redhat.com> References: <20220525065155.293205-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amusil@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2 2/2] binding.c: Make sure that localport is removed from local datapath 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" When localport is removed from NB, and it is the last port remaining on the host, it is not part of local datapath anymore. Which can cause troubles when there is recompute happening in between the removal from NB and the removal of interface from host. The localport would stay in lport_ids set, so any new localport that happens to have the same unique lport key wouldn't be initiliazed properly thorugh I-P. Remove the localport port binding from local datapath if it was part of the that said datapath before. Reported-at: https://bugzilla.redhat.com/2076604 Signed-off-by: Ales Musil --- v2: Add a test case for the scenario and rebase on newer main --- controller/binding.c | 9 +++++++ tests/ovn-controller.at | 54 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/controller/binding.c b/controller/binding.c index 92baebd29..a900c9a50 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -2131,6 +2131,15 @@ handle_deleted_lport(const struct sbrec_port_binding *pb, return; } + /* + * Remove localport that was part of local datapath that is not + * considered to be local anymore. + */ + if (!ld && !strcmp(pb->type, "localport") && + sset_find(&b_ctx_out->related_lports->lport_names, pb->logical_port)) { + remove_related_lport(pb, b_ctx_out); + } + /* If the binding is not local, if 'pb' is a L3 gateway port, we should * remove its peer, if that one is local. */ diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 3ca59f7e0..a34740d85 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -2186,3 +2186,57 @@ AT_CHECK([grep "Parsing of ovn-chassis-mac-mappings failed" hv1/ovn-controller.l OVN_CLEANUP([hv1]) AT_CLEANUP + +AT_SETUP([ovn-controller - localport can be recreated]) + +ovn_start + +net_add n1 +sim_add hv1 +as hv1 +ovs-vsctl add-br br-phys +ovn_attach n1 br-phys 192.168.0.1 + +create_localport() { + AT_CHECK([ovn-nbctl lsp-add ls0 metadata]) + AT_CHECK([ovn-nbctl lsp-set-type metadata localport]) + AT_CHECK([ovn-nbctl lsp-set-addresses metadata "00:00:00:00:10:25 192.168.10.25"]) +} + +bind_ports() { + AT_CHECK([ovs-vsctl add-port br-int vm0 -- set interface vm0 type=internal external_ids:iface-id=vm0]) + AT_CHECK([ovs-vsctl add-port br-int metadata -- set interface metadata type=internal external_ids:iface-id=metadata]) +} + +# Create one VIF and localport and bind it to chassis +AT_CHECK([ovn-nbctl ls-add ls0]) +AT_CHECK([ovn-nbctl lsp-add ls0 vm0]) +AT_CHECK([ovn-nbctl lsp-set-addresses vm0 "00:00:00:00:10:10 192.168.10.10"]) +create_localport +bind_ports + +pb=$(ovn-sbctl --bare --columns _uuid find port_binding logical_port=metadata | cut -d '-' -f 1 | tr -d '\n') + + +# Check that localport has all physical flows defined +OVS_WAIT_UNTIL([test 6 = $(as hv1 ovs-ofctl dump-flows br-int | grep -c $pb)]) + +# Remove ls0 from local datapaths +AT_CHECK([ovs-vsctl del-port br-int vm0]) +AT_CHECK([ovn-appctl inc-engine/recompute]) + +# Check that localports physical flows are removed +OVS_WAIT_UNTIL([test 0 = $(as hv1 ovs-ofctl dump-flows br-int | grep -c $pb)]) + +# The order is impotant, if the port is removed first, the bug wouldn't be triggered +AT_CHECK([ovn-nbctl lsp-del metadata]) +AT_CHECK([ovs-vsctl del-port br-int metadata]) +create_localport +bind_ports + +pb=$(ovn-sbctl --bare --columns _uuid find port_binding logical_port=metadata | cut -d '-' -f 1 | tr -d '\n') +# Check that localport has all physical flows re-defined +OVS_WAIT_UNTIL([test 6 = $(as hv1 ovs-ofctl dump-flows br-int | grep -c $pb)]) + +OVN_CLEANUP([hv1]) +AT_CLEANUP