From patchwork Fri Jul 22 19:11:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Wilson X-Patchwork-Id: 1659731 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=M1OKIIeQ; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LqJvf2Cq4z9sGH for ; Sat, 23 Jul 2022 05:11:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 26F7B41628; Fri, 22 Jul 2022 19:11:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 26F7B41628 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=M1OKIIeQ X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AHuSFxyjo88d; Fri, 22 Jul 2022 19:11:39 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id EF8AE40104; Fri, 22 Jul 2022 19:11:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org EF8AE40104 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AE1E5C0035; Fri, 22 Jul 2022 19:11:37 +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 B5FB9C002D for ; Fri, 22 Jul 2022 19:11:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 89E64849A0 for ; Fri, 22 Jul 2022 19:11:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 89E64849A0 Authentication-Results: smtp1.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=M1OKIIeQ 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 eNSFZogpzs-K for ; Fri, 22 Jul 2022 19:11:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C6F2B8499E 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 C6F2B8499E for ; Fri, 22 Jul 2022 19:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658517094; 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=PxYdcp5SvgCCALrab0oeaxR6uzio3QDFDkZbSP0Ok6o=; b=M1OKIIeQoudIZrIYJheMazM1/uRDro7D/L5pn3PNI4k/gwbFd4XUiJ6rSduuK47z/5E7aY yn5slVr5QD5dE/sdnhYV37bre8dCzo92YGrhGHi/Q0UICBIyYZwz4H9sMv7sv84vyfMECo RA1Z+tuZ2oYujPLwCYxbalp0+9TvZJ0= 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-148-dk2-tuaXNr2pLfr84OVyqA-1; Fri, 22 Jul 2022 15:11:33 -0400 X-MC-Unique: dk2-tuaXNr2pLfr84OVyqA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C0639811E76 for ; Fri, 22 Jul 2022 19:11:32 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.34.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93988C28100; Fri, 22 Jul 2022 19:11:32 +0000 (UTC) From: Terry Wilson To: dev@openvswitch.org Date: Fri, 22 Jul 2022 14:11:26 -0500 Message-Id: <20220722191126.2112869-1-twilson@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=twilson@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovsdb v1] Add CLI remote confiuration parity with DB 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" Several remote config options are configurable via the DB, e.g. inactivity_probe and max_backoff. This patch adds the ability to configure these options via the CLI as well, e.g.: --remote="pssl:6640;inactivity_probe=10000,max_backoff=4000" Signed-off-by: Terry Wilson --- ovsdb/ovsdb-server.1.in | 4 ++++ ovsdb/ovsdb-server.c | 42 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/ovsdb/ovsdb-server.1.in b/ovsdb/ovsdb-server.1.in index da7a6fd5d..aaa3059a9 100644 --- a/ovsdb/ovsdb-server.1.in +++ b/ovsdb/ovsdb-server.1.in @@ -103,6 +103,10 @@ It is an error for \fIcolumn\fR to have another type. .RE . .IP +When specifying a remote via the CLI, the options configurable via the +above columns may be added as a comma-separated list following a +semi-colon, e.g. \fB"pssl:6640;inactivity_probe=10000,max_backoff=4000"\fR. + To connect or listen on multiple connection methods, use multiple \fB\-\-remote\fR options. . diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index 5549b4e3a..0e0d45fa1 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -998,6 +998,46 @@ add_manager_options(struct shash *remotes, const struct ovsdb_row *row) } } +static void +add_cli_remote(struct shash *remotes, const char *target_str) +{ + struct ovsdb_jsonrpc_options *options; + char *save_ptr = NULL; + char *target; + char *opt; + + target = xstrdup(target_str); + strtok_r(target, ";", &save_ptr); + options = add_remote(remotes, target); + for (opt = strtok_r(NULL, ",", &save_ptr); opt != NULL; + opt = strtok_r(NULL, ",", &save_ptr)) { + char *save_ptr2 = NULL; + char *key, *value; + + key = strtok_r(opt, "=", &save_ptr2); + value = strtok_r(NULL, ",", &save_ptr2); + if (value == NULL) { + continue; + } + if (!strcmp(key, "max_backoff")) { + options->max_backoff = atoi(value); + } else if (!strcmp(key, "inactivity_probe")) { + options->probe_interval = atoi(value); + } else if (!strcmp(key, "read_only")) { + options->read_only = !strcmp(value, "true"); + } else if (!strcmp(key, "role")) { + free(options->role); + options->role = xstrdup(value); + } else if (!strcmp(key, "dscp")) { + int dscp = atoi(value); + if (dscp >= 0 && dscp <= 63) { + options->dscp = dscp; + } + } + } + free(target); +} + static void query_db_remotes(const char *name, const struct shash *all_dbs, struct shash *remotes, struct ds *errors) @@ -1308,7 +1348,7 @@ reconfigure_remotes(struct ovsdb_jsonrpc_server *jsonrpc, if (!strncmp(name, "db:", 3)) { query_db_remotes(name, all_dbs, &resolved_remotes, &errors); } else { - add_remote(&resolved_remotes, name); + add_cli_remote(&resolved_remotes, name); } } ovsdb_jsonrpc_server_set_remotes(jsonrpc, &resolved_remotes);