From patchwork Thu Jan 18 08:06:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ales Musil X-Patchwork-Id: 1887783 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=aWY3qLp6; 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 4TFwMF3bK5z1yPJ for ; Thu, 18 Jan 2024 19:07:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CF0C483F01; Thu, 18 Jan 2024 08:07:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CF0C483F01 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=aWY3qLp6 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 6cI7RGvK-Pgt; Thu, 18 Jan 2024 08:07:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id D918283DCC; Thu, 18 Jan 2024 08:06:59 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D918283DCC Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id AFF03C0077; Thu, 18 Jan 2024 08:06:59 +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 09442C0037 for ; Thu, 18 Jan 2024 08:06:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CB03F421C6 for ; Thu, 18 Jan 2024 08:06:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org CB03F421C6 Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aWY3qLp6 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q4aUyGvW1Mse for ; Thu, 18 Jan 2024 08:06:57 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id CCFD040250 for ; Thu, 18 Jan 2024 08:06:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org CCFD040250 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705565215; 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=bSbPCM0eNbZkZnJqcGjl4FwPnzHM7lhozHcz0VjuC+Y=; b=aWY3qLp606VhJur43Blg10mPbM7JOzEFuOy6RTPI0jGu3yP9VflJa+cGHCTJ8I9PAQZ+Y/ IUlsNnwwrP/DpYiC1jSx4o1jqg62GlC6livwmi6agSv8ArnUp5oUg428uT+Z1HS3yD6/1p UVxckyINVHwQob396xnL3/P/HZfQT1M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-261-6Bp1DzuHN6aGXRVkQ0RfwA-1; Thu, 18 Jan 2024 03:06:53 -0500 X-MC-Unique: 6Bp1DzuHN6aGXRVkQ0RfwA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27D7F84ACA1 for ; Thu, 18 Jan 2024 08:06:53 +0000 (UTC) Received: from amusil.brq.redhat.com (unknown [10.43.17.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB6FF2166B33; Thu, 18 Jan 2024 08:06:52 +0000 (UTC) From: Ales Musil To: dev@openvswitch.org Date: Thu, 18 Jan 2024 09:06:52 +0100 Message-ID: <20240118080652.64968-1-amusil@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn] util: Replace and remove ovn_smap_get_uint 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" Replace and remove the ovn_smap_get_uint as smap_get_uint is avaiable in OvS library since 7b2e999fd759 ("smap: Add smap_get_uint() helper function."). Signed-off-by: Ales Musil --- lib/ovn-util.c | 20 -------------------- lib/ovn-util.h | 4 ---- northd/northd.c | 6 +++--- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/lib/ovn-util.c b/lib/ovn-util.c index 6ef9cac7f..882e67f93 100644 --- a/lib/ovn-util.c +++ b/lib/ovn-util.c @@ -815,26 +815,6 @@ str_tolower(const char *orig) return copy; } -/* This is a wrapper function which get the value associated with 'key' in - * 'smap' and converts it to an unsigned int. If 'key' is not in 'smap' or a - * valid unsigned integer can't be parsed from it's value, returns 'def'. - * - * Note: Remove this function once OpenvSwitch library (lib/smap.h) has this - * helper function. - */ -unsigned int -ovn_smap_get_uint(const struct smap *smap, const char *key, unsigned int def) -{ - const char *value = smap_get(smap, key); - unsigned int u_value; - - if (!value || !str_to_uint(value, 10, &u_value)) { - return def; - } - - return u_value; -} - /* For a 'key' of the form "IP:port" or just "IP", sets 'port', * 'ip_address' and 'ip' ('struct in6_addr' IPv6 or IPv4 mapped address). * The caller must free() the memory allocated for 'ip_address'. diff --git a/lib/ovn-util.h b/lib/ovn-util.h index aa0b3b2fb..2afff0d07 100644 --- a/lib/ovn-util.h +++ b/lib/ovn-util.h @@ -206,10 +206,6 @@ char *normalize_ipv4_prefix(ovs_be32 ipv4, unsigned int plen); char *normalize_ipv6_prefix(const struct in6_addr *ipv6, unsigned int plen); char *normalize_v46_prefix(const struct in6_addr *prefix, unsigned int plen); -/* Temporary util function until ovs library has smap_get_unit. */ -unsigned int ovn_smap_get_uint(const struct smap *smap, const char *key, - unsigned int def); - /* Returns a lowercase copy of orig. * Caller must free the returned string. */ diff --git a/northd/northd.c b/northd/northd.c index 952f8200d..5f2d3d0ea 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -10915,7 +10915,7 @@ build_routing_policy_flow(struct hmap *lflows, struct ovn_datapath *od, rule->priority, nexthop); return; } - uint32_t pkt_mark = ovn_smap_get_uint(&rule->options, "pkt_mark", 0); + uint32_t pkt_mark = smap_get_uint(&rule->options, "pkt_mark", 0); if (pkt_mark) { ds_put_format(&actions, "pkt.mark = %u; ", pkt_mark); } @@ -10938,7 +10938,7 @@ build_routing_policy_flow(struct hmap *lflows, struct ovn_datapath *od, } else if (!strcmp(rule->action, "drop")) { ds_put_cstr(&actions, debug_drop_action()); } else if (!strcmp(rule->action, "allow")) { - uint32_t pkt_mark = ovn_smap_get_uint(&rule->options, "pkt_mark", 0); + uint32_t pkt_mark = smap_get_uint(&rule->options, "pkt_mark", 0); if (pkt_mark) { ds_put_format(&actions, "pkt.mark = %u; ", pkt_mark); } @@ -11002,7 +11002,7 @@ build_ecmp_routing_policy_flows(struct hmap *lflows, struct ovn_datapath *od, } ds_clear(&actions); - uint32_t pkt_mark = ovn_smap_get_uint(&rule->options, "pkt_mark", 0); + uint32_t pkt_mark = smap_get_uint(&rule->options, "pkt_mark", 0); if (pkt_mark) { ds_put_format(&actions, "pkt.mark = %u; ", pkt_mark); }