From patchwork Fri Apr 26 17:54:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ihar Hrachyshka X-Patchwork-Id: 1928286 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=W1QtsVDg; 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 4VR0l567Jbz1yP2 for ; Sat, 27 Apr 2024 03:56:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 4A25D41FAD; Fri, 26 Apr 2024 17:56:00 +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 QNlHvjyXNX62; Fri, 26 Apr 2024 17:55:59 +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 smtp4.osuosl.org 0832241F9A 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=W1QtsVDg Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id 0832241F9A; Fri, 26 Apr 2024 17:55:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D3D2EC0077; Fri, 26 Apr 2024 17:55:58 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 924E1C0037 for ; Fri, 26 Apr 2024 17:55:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5B4A86146C for ; Fri, 26 Apr 2024 17:55:57 +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 7OrtwJrv3fxb for ; Fri, 26 Apr 2024 17:55:56 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=ihrachys@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 5539A61465 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5539A61465 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=W1QtsVDg Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 5539A61465 for ; Fri, 26 Apr 2024 17:55:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714154155; 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=c73diVRuJl4hMDJqcOR63EalQsrLzt0ckTBs4Gyo8t8=; b=W1QtsVDgoJjVc6HTiFs2/e72Dewvpv/Uk8cptL5rRKIjbMXRfZ4BQHCCPJ7tj48tcFcccQ Y46ugDThwB5FUWbf07yVpjCbzuvbxaSjajsJz+Lv/3/Q+qegZXgi5z+/vuLePAPVCGTVTH l6bP2KZYVdaH6h/ydtmV1Xi49xSwXPQ= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-3I5gjswqMfecoQklgIunmw-1; Fri, 26 Apr 2024 13:55:54 -0400 X-MC-Unique: 3I5gjswqMfecoQklgIunmw-1 Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-6eb891cf5e0so2969942a34.3 for ; Fri, 26 Apr 2024 10:55:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714154152; x=1714758952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c73diVRuJl4hMDJqcOR63EalQsrLzt0ckTBs4Gyo8t8=; b=QK0SfxTBvWHGrW+U7r8HktEPRd7Sb7CZyWfWR0yh2qDv8r3FZK/cvFA6ZGHrPEr+XE D/piJpgyV2qmNP6KZIwGygwO2KHtX6/yMMfzJqXLYQXXJxSFeup0r6BhJbdL0r7zKPhc RmfJx3HW922CGVd/gRC4KdTzE/sSw08wf26SK5EiHpnp6/lDwFjCqNEr4BRI4HklJukM iwPFi5rQdR54tlD0drY6vkiFBsFPIo3UXCWfAEeShXV8LmNtv5+kVJxb/VLC0JmhRqcI 6wBITrIqkSIrIVo0WFDs/eW/p8V3oobHu189CDomubhfD6OUBI4dD3eeSoVTB8i5uK7H vJGQ== X-Gm-Message-State: AOJu0YxNSHE2sCcLLD9waN28IfR/eCnfPSqK9Bjofarn2NS3Q7w8zkWE IyNZJgu1F2OV765+Kt9As3sBijRCDv7TYnAyKwDKJPcOuabrZhLV2jFPB8w7/jV9dEycKqT5ZO8 799PXrkTGCuvqnsq68utAfA4GOt/iRjiNNqygeSq7RzKoaiPplWSISWap7yN2vWUzyW5hWqeIzI /3DIW3kKJpQDAZD+rvGwNIUZEDzNT1h5wDwg== X-Received: by 2002:a05:6808:1302:b0:3c8:5493:d8d1 with SMTP id y2-20020a056808130200b003c85493d8d1mr4539339oiv.50.1714154152294; Fri, 26 Apr 2024 10:55:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLy2c+nSV7czicyCgHYgSFLhaNDgq4yXKUfizjhqN2knCdLJtUstW/IqwQ8MfMPQock+MZDQ== X-Received: by 2002:a05:6808:1302:b0:3c8:5493:d8d1 with SMTP id y2-20020a056808130200b003c85493d8d1mr4539308oiv.50.1714154151847; Fri, 26 Apr 2024 10:55:51 -0700 (PDT) Received: from fedora38.localdomain.com ([172.73.180.250]) by smtp.gmail.com with ESMTPSA id w17-20020a056214013100b0069b57111a98sm7179855qvs.79.2024.04.26.10.55.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 10:55:50 -0700 (PDT) From: Ihar Hrachyshka To: dev@openvswitch.org Date: Fri, 26 Apr 2024 17:54:56 +0000 Message-ID: <20240426175501.858655-3-ihrachys@redhat.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240426175501.858655-1-ihrachys@redhat.com> References: <20240426175501.858655-1-ihrachys@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v7 2/6] northd: Don't detach op->list when it wasn't used. 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" In some scenarios, op->list is not attached anywhere, which makes attempts to detach it trigger ubsan failure. ovn/ovs/include/openvswitch/list.h:252:17: runtime error: member access within null pointer of type 'struct ovs_list' #0 0x?? in ovs_list_remove ovn/ovs/include/openvswitch/list.h:252:17 #1 0x?? in ovn_port_allocate_key ovn/northd/northd.c:4021:13 #2 0x?? in ls_port_init ovn/northd/northd.c:4321:10 #3 0x?? in ls_port_create ovn/northd/northd.c:4342:10 #4 0x?? in ls_handle_lsp_changes ovn/northd/northd.c:4511:18 #5 0x?? in northd_handle_ls_changes ovn/northd/northd.c:4655:14 #6 0x?? in northd_nb_logical_switch_handler ovn/northd/en-northd.c:150: This patch makes northd use op->list only as a temporary means for build_ports logic to track ports that are persisted in both, nb, or sb only. Now build_ports will always detach ops once done. Now that op->list is never left attached to a list, we can remove ovs_list_remove calls for it elsewhere, including where op was never attached in the first place. Signed-off-by: Ihar Hrachyshka --- northd/northd.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index 3bdd0648c..4800a44bd 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -4117,6 +4117,7 @@ build_ports(struct ovsdb_idl_txn *ovnsb_txn, sbrec_mirror_table, op, queue_id_bitmap, &active_ha_chassis_grps); + ovs_list_remove(&op->list); } /* Add southbound record for each unmatched northbound record. */ @@ -4129,6 +4130,7 @@ build_ports(struct ovsdb_idl_txn *ovnsb_txn, op, queue_id_bitmap, &active_ha_chassis_grps); sbrec_port_binding_set_logical_port(op->sb, op->key); + ovs_list_remove(&op->list); } /* Delete southbound records without northbound matches. */ @@ -4298,7 +4300,7 @@ ovn_port_find_in_datapath(struct ovn_datapath *od, static bool ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, - struct hmap *ls_ports, struct ovn_datapath *od, + struct ovn_datapath *od, const struct sbrec_port_binding *sb, const struct sbrec_mirror_table *sbrec_mirror_table, const struct sbrec_chassis_table *sbrec_chassis_table, @@ -4326,11 +4328,6 @@ ls_port_init(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, } /* Assign new tunnel ids where needed. */ if (!ovn_port_allocate_key(sbrec_chassis_table, op)) { - if (op->sb) { - sbrec_port_binding_delete(op->sb); - } - ovs_list_remove(&op->list); - ovn_port_destroy(ls_ports, op); return false; } ovn_port_update_sbrec(ovnsb_txn, sbrec_chassis_by_name, @@ -4351,9 +4348,12 @@ ls_port_create(struct ovsdb_idl_txn *ovnsb_txn, struct hmap *ls_ports, struct ovn_port *op = ovn_port_create(ls_ports, key, nbsp, NULL, NULL); hmap_insert(&od->ports, &op->dp_node, hmap_node_hash(&op->key_node)); - if (!ls_port_init(op, ovnsb_txn, ls_ports, od, sb, + if (!ls_port_init(op, ovnsb_txn, od, sb, sbrec_mirror_table, sbrec_chassis_table, sbrec_chassis_by_name, sbrec_chassis_by_hostname)) { + if (op->sb) { + sbrec_port_binding_delete(op->sb); + } ovn_port_destroy(ls_ports, op); return NULL; } @@ -4363,7 +4363,6 @@ ls_port_create(struct ovsdb_idl_txn *ovnsb_txn, struct hmap *ls_ports, static bool ls_port_reinit(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, - struct hmap *ls_ports, const struct nbrec_logical_switch_port *nbsp, const struct nbrec_logical_router_port *nbrp, struct ovn_datapath *od, @@ -4377,7 +4376,7 @@ ls_port_reinit(struct ovn_port *op, struct ovsdb_idl_txn *ovnsb_txn, op->sb = sb; ovn_port_set_nb(op, nbsp, nbrp); op->l3dgw_port = op->cr_port = NULL; - return ls_port_init(op, ovnsb_txn, ls_ports, od, sb, + return ls_port_init(op, ovnsb_txn, od, sb, sbrec_mirror_table, sbrec_chassis_table, sbrec_chassis_by_name, sbrec_chassis_by_hostname); } @@ -4552,12 +4551,16 @@ ls_handle_lsp_changes(struct ovsdb_idl_txn *ovnsb_idl_txn, op->visited = true; continue; } - if (!ls_port_reinit(op, ovnsb_idl_txn, &nd->ls_ports, + if (!ls_port_reinit(op, ovnsb_idl_txn, new_nbsp, NULL, od, sb, ni->sbrec_mirror_table, ni->sbrec_chassis_table, ni->sbrec_chassis_by_name, ni->sbrec_chassis_by_hostname)) { + if (op->sb) { + sbrec_port_binding_delete(op->sb); + } + ovn_port_destroy(&nd->ls_ports, op); goto fail; } add_op_to_northd_tracked_ports(&trk_lsps->updated, op);