diff mbox series

[ovs-dev] util: Replace and remove ovn_smap_get_uint

Message ID 20240118080652.64968-1-amusil@redhat.com
State Accepted
Headers show
Series [ovs-dev] util: Replace and remove ovn_smap_get_uint | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Ales Musil Jan. 18, 2024, 8:06 a.m. UTC
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 <amusil@redhat.com>
---
 lib/ovn-util.c  | 20 --------------------
 lib/ovn-util.h  |  4 ----
 northd/northd.c |  6 +++---
 3 files changed, 3 insertions(+), 27 deletions(-)

Comments

Dumitru Ceara Jan. 30, 2024, 11:35 a.m. UTC | #1
On 1/18/24 09:06, Ales Musil wrote:
> 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 <amusil@redhat.com>
> ---

Applied to main, thanks!

Regards,
Dumitru
diff mbox series

Patch

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);
         }