From patchwork Tue Aug 27 13:46:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1977327 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=Fc+OyFBG; dkim-atps=neutral Authentication-Results: legolas.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=patchwork.ozlabs.org) 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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WtTPY4Lzcz1yZd for ; Tue, 27 Aug 2024 23:47:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4B7E38119A; Tue, 27 Aug 2024 13:47:27 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id LckePbnJiUyS; Tue, 27 Aug 2024 13:47:25 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 80BB181168 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=Fc+OyFBG Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 80BB181168; Tue, 27 Aug 2024 13:47:24 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4F852C07E6; Tue, 27 Aug 2024 13:47:24 +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 4131BC07E6 for ; Tue, 27 Aug 2024 13:47:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 3DDA94017B for ; Tue, 27 Aug 2024 13:47:21 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id YBtRxVsIsScR for ; Tue, 27 Aug 2024 13:47:20 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=xsimonar@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org D4F7B4000B Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org D4F7B4000B Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Fc+OyFBG Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id D4F7B4000B for ; Tue, 27 Aug 2024 13:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724766438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NYt1+/5/qL41EnLUyHh4UQToGAQKgvcY6syfWDVZpCo=; b=Fc+OyFBG6zprlD3dvH+r6F3zv+3oPI7T09u98HptfNpfa563okK+RMM3WDwilY2nb13Iis Btd/z/28KF4cmYWiJSflegsuH3kyIT5+vIe+0LRf6tRQzkBvNU7b9r4l0qxffgKdwRN6IC NEzQWq+a3aFiZOk4NwZWDjzkqrdBT6M= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-402-7zDcH_djNOOs3MlitOXVLw-1; Tue, 27 Aug 2024 09:47:17 -0400 X-MC-Unique: 7zDcH_djNOOs3MlitOXVLw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 42086191815B for ; Tue, 27 Aug 2024 13:47:15 +0000 (UTC) Received: from wsfd-netdev90.ntdv.lab.eng.bos.redhat.com (wsfd-netdev90.anl.eng.rdu2.dc.redhat.com [10.6.38.135]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DD3801953979; Tue, 27 Aug 2024 13:46:42 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Tue, 27 Aug 2024 15:46:40 +0200 Message-Id: <20240827134641.3140022-2-xsimonar@redhat.com> In-Reply-To: <20240827134641.3140022-1-xsimonar@redhat.com> References: <20240827134641.3140022-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 1/2] ct_zones: Fix ct_zone removal on port type change. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In ct_zones I+P, when ports changed to patch ports (e.g. from l3gateway, for which ct_zone has been allocated), delete the ct_zone. Signed-off-by: Xavier Simonart Acked-by: Mark Michelson Acked-by: Ales Musil --- controller/binding.c | 10 +++ controller/ovn-controller.c | 9 ++- tests/ovn.at | 142 ++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 1 deletion(-) diff --git a/controller/binding.c b/controller/binding.c index bfdeb99b9..d3fe127f7 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -2934,6 +2934,16 @@ consider_patch_port_for_local_datapaths(const struct sbrec_port_binding *pb, b_ctx_out->tracked_dp_bindings); } } + + if (sbrec_port_binding_is_updated(pb, SBREC_PORT_BINDING_COL_TYPE) && + (pb->chassis == b_ctx_in->chassis_rec || + is_additional_chassis(pb, b_ctx_in->chassis_rec))) { + remove_local_lports(pb->logical_port, b_ctx_out); + release_lport(pb, b_ctx_in->chassis_rec, + !b_ctx_in->ovnsb_idl_txn, + b_ctx_out->tracked_dp_bindings, + b_ctx_out->if_mgr); + } } static bool diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 854d80bdf..a10f1af8a 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -2312,9 +2312,16 @@ ct_zones_runtime_data_handler(struct engine_node *node, void *data) && strcmp(t_lport->pb->type, "localnet")) { /* We allocate zone-id's only to VIF, localport, l3gateway, * and localnet lports. */ + if (sbrec_port_binding_is_updated(t_lport->pb, + SBREC_PORT_BINDING_COL_TYPE)) { + updated |= ct_zone_handle_port_update(&ct_zones_data->ctx, + t_lport->pb, + false, &scan_start, + min_ct_zone, max_ct_zone); + } + continue; } - bool port_updated = t_lport->tracked_type == TRACKED_RESOURCE_NEW || t_lport->tracked_type == TRACKED_RESOURCE_UPDATED; diff --git a/tests/ovn.at b/tests/ovn.at index 50c9f04da..4d9beea1b 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -38924,3 +38924,145 @@ OVN_CHECK_PACKETS([hv/vif1-tx.pcap], [expected-vif1]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([ct_zones]) +AT_KEYWORDS([ct_zones]) + +ovn_start + +net_add n1 +for i in 1 2; do + check ovn-nbctl ls-add ls${i} + ovn-nbctl lsp-add ls${i} lsp${i} + sim_add hv$i + as hv$i + ovs-vsctl add-br br-phys + ovn_attach n1 br-phys 192.168.0.$i + ovs-vsctl -- add-port br-int vif${i} -- set Interface vif${i} external-ids:iface-id=lsp${i} +done + +check ovn-nbctl lr-add r1 +check ovn-nbctl lrp-add r1 r1-ls1 f0:00:00:00:00:01 192.168.2.1/24 \ + -- lsp-add ls1 ls1-r1 \ + -- set Logical_Switch_Port ls1-r1 type=router options:router-port=r1-ls1 addresses=router + +check ovn-nbctl lrp-add r1 r1-ls2 f0:00:00:00:00:02 192.168.3.1/24 \ + -- lsp-add ls2 ls2-r1 \ + -- set Logical_Switch_Port ls2-r1 type=router options:router-port=r1-ls2 addresses=router + +check ovn-nbctl --wait=hv sync + +AS_BOX([With patch ports]) +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp1 ?? +r1_dnat ?? +r1_snat ?? +]) + +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp2 ?? +r1_dnat ?? +r1_snat ?? +]) + +AS_BOX([With patch ports after recompute]) +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([test "X$zone_list_hv1" = "X$zone_list_hv1_after_recompute"]) +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) + +AS_BOX([With l3gw in hv2]) +check ovn-nbctl --wait=hv set Logical_Router r1 options:chassis=hv2 +# ls2 should now only be a local datapath in hv2. +# However, ovn-controller does not remove datapath from list of ldp when needed, so ls2 is still seen as local in hv1. +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp1 ?? +r1_dnat ?? +r1_snat ?? +]) + +# l3gw ports should have ct_zones allocated +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1-r1 ?? +ls1_dnat ?? +ls1_snat ?? +ls2-r1 ?? +ls2_dnat ?? +ls2_snat ?? +lsp2 ?? +r1-ls1 ?? +r1-ls2 ?? +r1_dnat ?? +r1_snat ?? +]) + +AS_BOX([With l3gw ports after recompute]) +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute + +# ls2 not in hv1 after recompute, as expected +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv1_after_recompute" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +lsp1 ?? +]) + +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) + +AS_BOX([With patch ports again]) +check ovn-nbctl --wait=hv remove Logical_Router r1 options chassis=hv2 +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp1 ?? +r1_dnat ?? +r1_snat ?? +]) + +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp2 ?? +r1_dnat ?? +r1_snat ?? +]) + +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute +AS_BOX([With patch ports after recompute]) +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([test "X$zone_list_hv1" = "X$zone_list_hv1_after_recompute"]) +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) + +OVN_CLEANUP([hv1],[hv2]) + +AT_CLEANUP +]) From patchwork Tue Aug 27 13:46:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Simonart X-Patchwork-Id: 1977326 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=Wb9OSpFs; 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 4WtTPX0y75z1yZd for ; Tue, 27 Aug 2024 23:47:26 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E6C004010B; Tue, 27 Aug 2024 13:47:23 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 0TUjAg-jlm7n; Tue, 27 Aug 2024 13:47:22 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7DBF1401BB Authentication-Results: smtp4.osuosl.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=Wb9OSpFs Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 7DBF1401BB; Tue, 27 Aug 2024 13:47:22 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4D480C07E7; Tue, 27 Aug 2024 13:47:22 +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 EB765C07E6 for ; Tue, 27 Aug 2024 13:47:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CDC8080F06 for ; Tue, 27 Aug 2024 13:47:20 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id NqITpeGFSGvI for ; Tue, 27 Aug 2024 13:47:20 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=xsimonar@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp1.osuosl.org D405A80CCC Authentication-Results: smtp1.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D405A80CCC Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Wb9OSpFs Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id D405A80CCC for ; Tue, 27 Aug 2024 13:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724766438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fQsAv5vd6CIczULhFn3gCqOUFcprehYaBhD7CnrzZLg=; b=Wb9OSpFsEGlMtXHPPbV1dyybjleLFZz04LW1SLeeVoUArv2XNGCrNiMYHB07owWRORxnR4 jEhU5IyaBJu8gmTdDHLQtJULfy9ZAyh0p/2O/TDI7lykWTMPB0IpIcUvhq+CKbTb3mnI0N XR1B2s+IWfRuh+bV9OeaxyHiELoGImY= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-5UfLHlPiM-mmQ7-sexvA7g-1; Tue, 27 Aug 2024 09:47:17 -0400 X-MC-Unique: 5UfLHlPiM-mmQ7-sexvA7g-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C50018BC4DB for ; Tue, 27 Aug 2024 13:47:15 +0000 (UTC) Received: from wsfd-netdev90.ntdv.lab.eng.bos.redhat.com (wsfd-netdev90.anl.eng.rdu2.dc.redhat.com [10.6.38.135]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9CE361977404; Tue, 27 Aug 2024 13:46:43 +0000 (UTC) From: Xavier Simonart To: xsimonar@redhat.com, dev@openvswitch.org Date: Tue, 27 Aug 2024 15:46:41 +0200 Message-Id: <20240827134641.3140022-3-xsimonar@redhat.com> In-Reply-To: <20240827134641.3140022-1-xsimonar@redhat.com> References: <20240827134641.3140022-1-xsimonar@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 2/2] ct_zones: Fix virtual ports. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Do not allocate ct_zones for virtual ports. Signed-off-by: Xavier Simonart Acked-by: Mark Michelson --- controller/ct-zone.c | 11 +++++++++-- controller/ct-zone.h | 3 ++- controller/ovn-controller.c | 5 ++++- tests/ovn.at | 26 +++++++++++++++++++++++++- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/controller/ct-zone.c b/controller/ct-zone.c index 77eb16ac9..2385b700d 100644 --- a/controller/ct-zone.c +++ b/controller/ct-zone.c @@ -19,6 +19,7 @@ #include "binding.h" #include "chassis.h" #include "ct-zone.h" +#include "lport.h" #include "local_data.h" #include "openvswitch/vlog.h" @@ -169,7 +170,8 @@ out: void ct_zones_update(const struct sset *local_lports, const struct ovsrec_open_vswitch_table *ovs_table, - const struct hmap *local_datapaths, struct ct_zone_ctx *ctx) + const struct hmap *local_datapaths, struct ct_zone_ctx *ctx, + struct ovsdb_idl_index *sbrec_port_binding_by_name) { int min_ct_zone, max_ct_zone; const char *user; @@ -179,8 +181,13 @@ ct_zones_update(const struct sset *local_lports, struct simap unreq_snat_zones = SIMAP_INITIALIZER(&unreq_snat_zones); const char *local_lport; + const struct sbrec_port_binding *pb; SSET_FOR_EACH (local_lport, local_lports) { - sset_add(&all_users, local_lport); + pb = lport_lookup_by_name(sbrec_port_binding_by_name, + local_lport); + if (!pb || strcmp(pb->type, "virtual")) { + sset_add(&all_users, local_lport); + } } /* Local patched datapath (gateway routers) need zones assigned. */ diff --git a/controller/ct-zone.h b/controller/ct-zone.h index 6df03975c..fcb100619 100644 --- a/controller/ct-zone.h +++ b/controller/ct-zone.h @@ -73,7 +73,8 @@ void ct_zones_restore(struct ct_zone_ctx *ctx, void ct_zones_update(const struct sset *local_lports, const struct ovsrec_open_vswitch_table *ovs_table, const struct hmap *local_datapaths, - struct ct_zone_ctx *ctx); + struct ct_zone_ctx *ctx, + struct ovsdb_idl_index *sbrec_port_binding_by_name); void ct_zones_commit(const struct ovsrec_bridge *br_int, const struct ovsrec_datapath *ovs_dp, struct ovsdb_idl_txn *ovs_idl_txn, diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index a10f1af8a..911c7f162 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1174,6 +1174,7 @@ struct ed_type_runtime_data { struct shash local_active_ports_ras; struct sset *postponed_ports; + struct ovsdb_idl_index *sbrec_port_binding_by_name; }; /* struct ed_type_runtime_data has the below members for tracking the @@ -1438,6 +1439,7 @@ en_runtime_data_run(struct engine_node *node, void *data) binding_run(&b_ctx_in, &b_ctx_out); rt_data->localnet_learn_fdb = b_ctx_out.localnet_learn_fdb; + rt_data->sbrec_port_binding_by_name = b_ctx_in.sbrec_port_binding_by_name; engine_set_node_state(node, EN_UPDATED); } @@ -2230,7 +2232,8 @@ en_ct_zones_run(struct engine_node *node, void *data) ct_zones_restore(&ct_zones_data->ctx, ovs_table, dp_table, br_int); ct_zones_update(&rt_data->local_lports, ovs_table, - &rt_data->local_datapaths, &ct_zones_data->ctx); + &rt_data->local_datapaths, &ct_zones_data->ctx, + rt_data->sbrec_port_binding_by_name); ct_zones_limits_sync(&ct_zones_data->ctx, &rt_data->local_datapaths, &rt_data->lbinding_data.lports); diff --git a/tests/ovn.at b/tests/ovn.at index 4d9beea1b..ff7281e59 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -38951,8 +38951,29 @@ check ovn-nbctl lrp-add r1 r1-ls2 f0:00:00:00:00:02 192.168.3.1/24 \ -- lsp-add ls2 ls2-r1 \ -- set Logical_Switch_Port ls2-r1 type=router options:router-port=r1-ls2 addresses=router +check ovn-nbctl lsp-add ls1 ls1-vir \ + -- lsp-set-addresses ls1-vir "50:54:00:00:00:10 192.168.2.2" \ + -- lsp-set-type ls1-vir virtual \ + -- set logical_switch_port ls1-vir options:virtual-ip=192.168.2.2 \ + -- set logical_switch_port ls1-vir options:virtual-parents=lsp1 + check ovn-nbctl --wait=hv sync +send_garp() { + hv=$1 + dev=$2 + eth_src=$3 + ip=$4 + + packet=$(fmt_pkt "Ether(dst='ff:ff:ff:ff:ff:ff', src='${eth_src}')/ \ + ARP(op=2, hwsrc='${eth_src}', hwdst='${eth_src}', \ + psrc='${ip}', pdst='${ip}')") + as $hv ovs-appctl netdev-dummy/receive $dev $packet +} + +# Sending garp to claim virtual port. +send_garp hv1 vif1 "50:54:00:00:00:03" 192.168.2.2 + AS_BOX([With patch ports]) zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl @@ -39062,7 +39083,10 @@ zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list AT_CHECK([test "X$zone_list_hv1" = "X$zone_list_hv1_after_recompute"]) AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) -OVN_CLEANUP([hv1],[hv2]) + +OVN_CLEANUP([hv1 +/parse MAC binding/d +],[hv2]) AT_CLEANUP ])