From patchwork Wed Nov 6 20:10:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosemarie O'Riorden X-Patchwork-Id: 2007697 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=YtBpjSy1; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (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 4XkGY54xzmz1xxq for ; Thu, 7 Nov 2024 07:10:49 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 5498540B19; Wed, 6 Nov 2024 20:10:46 +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 sQKEek2amRs3; Wed, 6 Nov 2024 20:10:44 +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 smtp2.osuosl.org 2C7F3400D7 Authentication-Results: smtp2.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=YtBpjSy1 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id 2C7F3400D7; Wed, 6 Nov 2024 20:10:44 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 01E2FC08A6; Wed, 6 Nov 2024 20:10:44 +0000 (UTC) X-Original-To: ovs-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 BDA3BC08A3 for ; Wed, 6 Nov 2024 20:10:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9F82C40452 for ; Wed, 6 Nov 2024 20:10:42 +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 aCI6m5TRIdVb for ; Wed, 6 Nov 2024 20:10:41 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.133.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=rosemarie@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 45F2C400D7 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 45F2C400D7 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 45F2C400D7 for ; Wed, 6 Nov 2024 20:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730923839; 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=wqhcOBoVNIEY1IN1DLkjBMixlczCQKH63SkgKKooX0o=; b=YtBpjSy138jt9hvht9+4hd3Yzmw71DKikLZjDd2bu44/LR2gZko6HnvfMtRq2fw6e7/6Nx wi4xeXW2jVdnxIbLrDLXPuBQUwgDp/UpZY4HPV9pwJ3WLe7IXgriegvCoKBthVNyDwBypQ 4dCJeDMBfDzCyF20aT1E00/TAC+FT5c= Received: from mx-prod-mc-03.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-670-yyYLz5o-OqakoICYD12rtQ-1; Wed, 06 Nov 2024 15:10:38 -0500 X-MC-Unique: yyYLz5o-OqakoICYD12rtQ-1 X-Mimecast-MFC-AGG-ID: yyYLz5o-OqakoICYD12rtQ Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A9C7A195604F; Wed, 6 Nov 2024 20:10:37 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.64.245]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A290519560AA; Wed, 6 Nov 2024 20:10:35 +0000 (UTC) From: Rosemarie O'Riorden To: ovs-dev@openvswitch.org Cc: rosemarie@redhat.com, i.maximets@ovn.org, ctrautma@redhat.com Date: Wed, 6 Nov 2024 15:10:31 -0500 Message-ID: <20241106201031.151466-1-rosemarie@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 1neACyH68cGrEqw8SrKQk_pYMb-w3f5PZz2asyK80Vo_1730923837 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v2] controller: Prevent crash when db is empty. 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" ovn-controller crashed when connected to an empty local db, forcing the user to initialize a local db before starting the controller daemon. With this fix, the controller will no longer crash in this case, but instead keep running and wait until the database is initialized to do anything else. Reported-at: https://issues.redhat.com/browse/FDP-715 Signed-off-by: Rosemarie O'Riorden Acked-by: Ilya Maximets --- v2: - Add Reported-at tag. - Syntax and style fixes. - Change macro used in test to OVS_WAIT_FOR_OUTPUT instead of AT_CHECK. - Remove unwanted line deletion. --- controller/chassis.c | 3 +++ controller/ovn-controller.c | 8 ++++---- tests/ovn-controller.at | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/controller/chassis.c b/controller/chassis.c index 2991a0af3..b2eefd58a 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -1016,6 +1016,9 @@ store_chassis_index_if_needed( { const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_table_first(ovs_table); + if (!cfg) { + return; + } const char *chassis_id = get_ovs_chassis_id(ovs_table); char *idx_key = xasprintf(CHASSIS_IDX_PREFIX "%s", chassis_id); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index c48667887..1e987e630 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -5434,6 +5434,8 @@ main(int argc, char *argv[]) ovsrec_open_vswitch_table_get(ovs_idl_loop.idl); const struct ovsrec_bridge *br_int = NULL; const struct ovsrec_datapath *br_int_dp = NULL; + const struct ovsrec_open_vswitch *cfg = + ovsrec_open_vswitch_table_first(ovs_table); process_br_int(ovs_idl_txn, bridge_table, ovs_table, &br_int, ovsrec_server_has_datapath_table(ovs_idl_loop.idl) ? &br_int_dp @@ -5445,9 +5447,7 @@ main(int argc, char *argv[]) br_int_remote.probe_interval); /* Enable ACL matching for double tagged traffic. */ - if (ovs_idl_txn) { - const struct ovsrec_open_vswitch *cfg = - ovsrec_open_vswitch_table_first(ovs_table); + if (ovs_idl_txn && cfg) { int vlan_limit = smap_get_int( &cfg->other_config, "vlan-limit", -1); if (vlan_limit != 0) { @@ -5463,7 +5463,7 @@ main(int argc, char *argv[]) } if (ovsdb_idl_has_ever_connected(ovnsb_idl_loop.idl) && - northd_version_match) { + northd_version_match && cfg) { /* Unconditionally remove all deleted lflows from the lflow * cache. diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index a2e451880..82ed5d0f1 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -3419,3 +3419,28 @@ AT_CHECK([test $(grep -c "HANDLER_MESSAGE" hv1/ovn-controller.log) -ge 1]) OVN_CLEANUP([hv1]) AT_CLEANUP + +AT_SETUP([ovn-controller - qwerty Start controller with empty db]) +AT_KEYWORDS([ovn]) + +check ovsdb-tool create conf.db $ovs_srcdir/vswitchd/vswitch.ovsschema +start_daemon ovsdb-server --remote=punix:db.sock +start_daemon ovn-controller unix:db.sock + +AT_CHECK([ovsdb-client --bare dump unix:db.sock Open_vSwitch Open_vSwitch], [], [dnl +Open_vSwitch table +]) +check ovs-vsctl --no-wait init +OVS_WAIT_FOR_OUTPUT([ovs-vsctl show | tail -n +2], [], [dnl + Bridge br-int + fail_mode: secure + datapath_type: system + Port br-int + Interface br-int + type: internal +]) + +# Gracefully terminate daemons. +OVS_APP_EXIT_AND_WAIT([ovn-controller]) +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) +AT_CLEANUP