From patchwork Wed Sep 30 14:58:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaygue Lee X-Patchwork-Id: 2314380 X-Patchwork-Delegate: dceara@redhat.com 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" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=p41OcQJp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 4hwD7V21XDz1xxW for ; Thu, 01 Oct 2026 10:58:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 30DFC60B6F; Thu, 1 Oct 2026 00:58:42 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id O3He_UgHxhxd; Thu, 1 Oct 2026 00:58:41 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp3.osuosl.org DCC43605E3 Authentication-Results: smtp3.osuosl.org; arc=fail smtp.remote-ip=140.211.9.56 ARC-Seal: i=2; d=osuosl.org; s=arc; a=rsa-sha256; cv=fail; t=1790816321; b=kPvhLwmodY1yk11xnyrocL4nPW3OgWi35LZoYFUc6BVm6/MwVa7Inz2Zpyf38Q7lrbfh sdaxBVRhGocogOQpvkOYKlPM43/a6Jo+K3YrPNlxweCqLHv66YYpD9xuoaRTADkRH/Yed BAh2n8gxYkOhFIK7zhAc4D/GI0UF6+CMLq7zQBwYz2iwHtGY9E0S5hnX9jlrN9nH85Dol 7RzzKiq5Lx2SfRNe5ejdwtF6Aqs0sAdyR1SFyOn1l8NDfFOW1e458i/vtKRQmQ8UHhrWC xaxWK+iiDz51eqSTINWglEFXZh/2qTp9JaiwyFNfTO8eHI/h2PBUiFIGtkOuRw14crg== ARC-Message-Signature: i=2; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790816321; h=X-Comment:Received:X-Original-To:Delivered-To:Received:Received: X-Virus-Scanned:X-Spam-Flag:X-Spam-Score:X-Spam-Level:X-Spam-Status: Received:ARC-Filter:Received-SPF:Received:Received:DKIM-Signature: X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received: Received:To:Cc:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Subject:X-BeenThere:X-Mailman-Version:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:From: Reply-To:Content-Type:Content-Transfer-Encoding:Errors-To:Sender; bh=kYQS++aEsp8bOkbTguZQDbDe3KtiicaalNMhIfB+mSU=; b=Qhg1t5oIL/wnyC0H/qNdpFb5R7IQ4SK0dQbwIw1GV8reUfw0ua+gQahlscuTQVZDz/14 qjXCxZ3FsFfsqcVOnNqC75z9BQHNb1VZE3N0w/ZjLBuLcfZMwiS33FQ7HV6IgpjBdjt0L mxII8rP3hzTsPlIIuVqTVZVuWvb4vHJ/3/nfgUm4NtItPp6ag0prNFNZh+4JIZxFEZj+9 w8xiiFtzpvJq85Soefla4VPJyZZzy0J7vaqRqFny960eQwQHjQizuh5TVhllpRwKVuIPT yC4pQelbEHXMlL3rbKS8E9KmDDc21gu/rWkqfKVZ8OJfQlxr2rRqr7X/kgKANqS2zfg== ARC-Authentication-Results: i=2; smtp3.osuosl.org; dkim=fail reason="signature verification failed" header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=p41OcQJp; arc=fail smtp.remote-ip=140.211.9.56 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= Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=p41OcQJp Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id DCC43605E3; Thu, 1 Oct 2026 00:58:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A49C9C0561; Thu, 1 Oct 2026 00:58:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0C23CC0560 for ; Thu, 1 Oct 2026 00:58:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id E6C85408DE for ; Thu, 1 Oct 2026 00:58:39 +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 gSjdPEIf0RTS for ; Thu, 1 Oct 2026 00:58:39 +0000 (UTC) ARC-Filter: OpenARC Filter v1.3.0 smtp4.osuosl.org 1899B407FD Authentication-Results: smtp4.osuosl.org; arc=none smtp.remote-ip="2607:f8b0:4864:39::f" ARC-Seal: i=1; d=osuosl.org; s=arc; a=rsa-sha256; cv=none; t=1790816319; b=kdN8hGEDsv8oULapZrApPgVfPUf1k37GbZrfOHKUAfgafGsWPtMN2mSXsUfLuKcWrzIT GIJJuYl1XMDgtJ/I0PBVa5S2r/J6q2cUrWodBkbCpENk1pLpsRJDg1StxcuoLVixpBbNa 54TpM7f/DxNB7UsobkH01Cm4g+dmOUfpyaywFskYeZZP9eYyJgOxVxxeFb0kQPJwTWPKC 3PjvyhL8y28Qg/W62lNoYjxmURRvxh4d94Capxf/xYKdA5Fm22HDjJgHBzABsXRBoM49f +H8kiT3q5ozvkJshy29FZOiGE7ImFjYtUU80IrUy4DQeE8skYDDL2Km9h40bUvzsrlQ== ARC-Message-Signature: i=1; d=osuosl.org; s=arc; a=rsa-sha256; c=relaxed/relaxed; t=1790816319; h=Received-SPF:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=2eoKBamZX2+/KoDR+JZPMKBK87aarIUsxLGNUBehTeA=; b=ZPOp+AmVanq+kdZmk/ewwcAqWDdmdOPCSyyWqxDuhehtusDZ3juiv1YYLutRsHbBB/An +eCTbVoxcmaMZZ8fFDYIHX+U1F7GY/Jz1HgnRmUJbucjI21xkee0j41bwJKZCzTFzxvQU iGdLWBYOGPAiXl8aI9HPE09/wbCRqFSi5ytoVnUzp2JHG6LT3f8or7PJfh4OjuS+el4qR kFdBwf1GYyZ2ZkFCymrve4aRKclFz9La9BE0euc9drhpT0zztc3TBeXwYctIS2Jb6SOY4 Qtn9teSYPyn844fPI/1lloQNhB/GfZ5X3t8HbCgIJLQiat7lpWzE8zK1afHTL5VLecg== ARC-Authentication-Results: i=1; smtp4.osuosl.org; dmarc=pass header.from=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=p41OcQJp; arc=none smtp.remote-ip="2607:f8b0:4864:39::f" Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:39::f; helo=mail-pj2-x0f.google.com; envelope-from=enginrect@gmail.com; receiver= Authentication-Results: smtp4.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp4.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=p41OcQJp Received: from mail-pj2-x0f.google.com (mail-pj2-x0f.google.com [IPv6:2607:f8b0:4864:39::f]) by smtp4.osuosl.org (Postfix) with ESMTPS id 1899B407FD for ; Thu, 1 Oct 2026 00:58:38 +0000 (UTC) Received: by mail-pj2-x0f.google.com with SMTP id 98e67ed59e1d1-39666bed444so649670a91.1 for ; Wed, 30 Sep 2026 17:58:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790816318; x=1791421118; darn=openvswitch.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2eoKBamZX2+/KoDR+JZPMKBK87aarIUsxLGNUBehTeA=; b=p41OcQJprjAWlYGl5wCH6rG0REhhl8rxYerKW5C1dhd6pl4vg2Toz1kbgwKjZ+o7a2 QzEVBqtkLXe4wCAQRjmsTzt9DwJC2Lz17LQPOOuTw+Eu/IIqV8c1svmeSvZr0qc5urhq /rw1ojs8g63Xud/4EcUlnhye7Ni/6/zy7JvSGsHpiUy/9MQbUjgmg1MqeLp94zxfOXNr aeQTKiVFD4PI/oW8dm4QWclXu8zuyhH0JQqhrBbo7jVinLLORfFs5CWru99LQS4hAFf0 0JEj4yRi078qG8Cnaxox8TWzy9u/uM931h3Cn/MUoSb0mQsI/awQ+MNlwkPsJ/syrnI9 M5KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790816318; x=1791421118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=2eoK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by 2002:a17:90b:518e:b0:3a0:238b:db4d with SMTP id 98e67ed59e1d1-3a4d1b18399mr4115990a91.5.1790816317760; Wed, 30 Sep 2026 17:58:37 -0700 (PDT) Received: from localhost.localdomain ([1.234.165.150]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3a4f4452b4fsm2080535a91.10.2026.09.30.17.58.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 30 Sep 2026 17:58:37 -0700 (PDT) To: dev@openvswitch.org Cc: moloings@redhat.com, Jaygue Lee , Dumitru Ceara Date: Thu, 1 Oct 2026 09:58:34 +0900 Message-ID: <20261001005834.74233-1-enginrect@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20260930063639.70494-1-enginrect@gmail.com> References: <20260930063639.70494-1-enginrect@gmail.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH ovn v3] controller: Set untracked ports down on release. 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: , X-Patchwork-Original-From: Jaygue Lee via dev From: Jaygue Lee Reply-To: Jaygue Lee Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" if_status_mgr_release_iface() only moves an interface to OIF_MARK_DOWN, and therefore only clears Port_Binding "up", for interfaces this ovn-controller instance claimed itself. Ports that were already bound to this chassis when ovn-controller started are adopted without being tracked, so when the recompute path releases one of them, for example after a hypervisor crash where the VM's tap is gone but the Port_Binding still points at this chassis, the chassis is cleared but "up" stays true. That leaves the port unbound but up, a state that cannot happen otherwise. Since commit e180d57ee6 ("northd: Mark unbound ports' service monitors offline.") northd no longer trusts "up" alone for service monitors, but the Southbound record stays wrong until the port is claimed again, and anything else reading Port_Binding.up is misled. When if_status_mgr_release_iface() is asked to release an interface it does not track and the Port_Binding is left unbound but up, add it in OIF_UPDATE_PORT, the state the tracked path uses for a released port with no local binding, so that if_status_mgr_update() sets it down. Ports bound to another chassis are left alone. The function now takes the Port_Binding instead of its name. Such an interface has no OVS interface name, so also make if_status_mgr_delete_iface() cope with a NULL name. CC: Dumitru Ceara Fixes: 5c3371922994 ("if-status: Add OVS interface status management module.") Assisted-by: Claude Opus 5, Claude Code Signed-off-by: Jaygue Lee --- v3: - Only take over ports left unbound; v2 also set down ports bound to another chassis, which broke "Deleting vif while controller fight for port claim". - Handle the NULL interface name in if_status_mgr_delete_iface() (sanitizer report from CI). v2: - Fix it in if_status_mgr_release_iface() instead of release_lport() (Dumitru). - Use wait_for_ports_up in the test (Dumitru). - Such ports no longer log "Trying to release unknown interface", so the test no longer ignores that warning. - Dropped Mairtin's Acked-by since the fix changed. controller/binding.c | 6 +++--- controller/if-status.c | 21 ++++++++++++++++----- controller/if-status.h | 3 ++- tests/ovn-controller.at | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/controller/binding.c b/controller/binding.c index c2bce665e7..5812641a44 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -1593,7 +1593,7 @@ release_lport(const struct sbrec_port_binding *pb, VLOG_INFO("Releasing lport %s", pb->logical_port); } update_lport_tracking(pb, tracked_datapaths, false); - if_status_mgr_release_iface(if_mgr, pb->logical_port); + if_status_mgr_release_iface(if_mgr, pb); return true; } @@ -2925,7 +2925,7 @@ handle_deleted_lport(const struct sbrec_port_binding *pb, * it is seen as never claimed. */ if (if_status_is_port_claimed(b_ctx_out->if_mgr, pb->logical_port)) { - if_status_mgr_release_iface(b_ctx_out->if_mgr, pb->logical_port); + if_status_mgr_release_iface(b_ctx_out->if_mgr, pb); } return; } @@ -2948,7 +2948,7 @@ handle_deleted_lport(const struct sbrec_port_binding *pb, ld); } if (if_status_is_port_claimed(b_ctx_out->if_mgr, pb->logical_port)) { - if_status_mgr_release_iface(b_ctx_out->if_mgr, pb->logical_port); + if_status_mgr_release_iface(b_ctx_out->if_mgr, pb); } } } diff --git a/controller/if-status.c b/controller/if-status.c index 6c6e9b27b1..5d773f9b7d 100644 --- a/controller/if-status.c +++ b/controller/if-status.c @@ -390,13 +390,23 @@ get_claimed_cr(struct if_status_mgr *mgr) } void -if_status_mgr_release_iface(struct if_status_mgr *mgr, const char *iface_id) +if_status_mgr_release_iface(struct if_status_mgr *mgr, + const struct sbrec_port_binding *pb) { - struct ovs_iface *iface = shash_find_data(&mgr->ifaces, iface_id); + struct ovs_iface *iface = shash_find_data(&mgr->ifaces, pb->logical_port); if (!iface) { + if (!pb->chassis && pb->n_up && pb->up[0]) { + /* Unbound but still up, e.g. bound by a previous ovn-controller + * instance and never claimed by this one: set it down. */ + iface = ovs_iface_create(mgr, pb->logical_port, NULL, + OIF_UPDATE_PORT); + iface->pb_uuid = pb->header_.uuid; + return; + } static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1); - VLOG_WARN_RL(&rl, "Trying to release unknown interface %s", iface_id); + VLOG_WARN_RL(&rl, "Trying to release unknown interface %s", + pb->logical_port); return; } @@ -436,9 +446,10 @@ if_status_mgr_delete_iface(struct if_status_mgr *mgr, const char *iface_id, return; } - if (iface_rec && strcmp(iface->name, iface_rec->name)) { + if (iface_rec && (!iface->name || strcmp(iface->name, iface_rec->name))) { VLOG_DBG("Interface %s not deleted as port %s bound to %s", - iface_rec->name, iface_id, iface->name); + iface_rec->name, iface_id, + iface->name ? iface->name : "no interface"); return; } diff --git a/controller/if-status.h b/controller/if-status.h index 75c7bf71c7..eaf7127aa0 100644 --- a/controller/if-status.h +++ b/controller/if-status.h @@ -36,7 +36,8 @@ void if_status_mgr_claim_iface(struct if_status_mgr *, bool sb_readonly, enum can_bind bind_type, bool notify_up, const struct sbrec_port_binding *parent_pb); -void if_status_mgr_release_iface(struct if_status_mgr *, const char *iface_id); +void if_status_mgr_release_iface(struct if_status_mgr *, + const struct sbrec_port_binding *); void if_status_mgr_delete_iface(struct if_status_mgr *, const char *iface_id, const struct ovsrec_interface *iface_rec); diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index a7b79fc670..c4a0837566 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -3070,6 +3070,44 @@ OVN_CLEANUP([hv1]) AT_CLEANUP ]) +OVN_FOR_EACH_NORTHD([ +AT_SETUP([ovn-controller - released untracked port is set down]) +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 + +check ovn-nbctl ls-add sw0 +check ovn-nbctl lsp-add sw0 sw0-p1 -- lsp-set-addresses sw0-p1 \ +"00:00:00:00:00:01 10.0.0.1" +check ovs-vsctl -- add-port br-int hv1-vif1 -- \ + set interface hv1-vif1 external-ids:iface-id=sw0-p1 +wait_for_ports_up sw0-p1 + +# Stop ovn-controller without releasing anything (as after a crash), remove +# the VIF while it is stopped (the VM did not come back) and start it again. +# The port is still bound to hv1 in the SB but this ovn-controller instance +# never claimed it, so if-status does not track it. +check ovn-appctl -t ovn-controller exit --restart +check ovs-vsctl del-port br-int hv1-vif1 +start_daemon ovn-controller + +# The port must be released and set down. +wait_row_count Port_Binding 1 logical_port=sw0-p1 'chassis=[[]]' 'up=false' +wait_row_count nb:Logical_Switch_Port 1 name=sw0-p1 'up=false' + +# Adding the VIF back claims the port again as usual. +check ovs-vsctl -- add-port br-int hv1-vif1 -- \ + set interface hv1-vif1 external-ids:iface-id=sw0-p1 +wait_for_ports_up sw0-p1 + +OVN_CLEANUP([hv1]) +AT_CLEANUP +]) + OVN_FOR_EACH_NORTHD([ AT_SETUP([Encap enforce local_ip]) ovn_start