Skip to content

Commit

Permalink
util: Replace and remove ovn_smap_get_uint
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
  • Loading branch information
almusil authored and dceara committed Jan 30, 2024
1 parent 7aaf4a7 commit 3ae0d09
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 27 deletions.
20 changes: 0 additions & 20 deletions lib/ovn-util.c
Expand Up @@ -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'.
Expand Down
4 changes: 0 additions & 4 deletions lib/ovn-util.h
Expand Up @@ -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.
*/
Expand Down
6 changes: 3 additions & 3 deletions northd/northd.c
Expand Up @@ -11019,7 +11019,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);
}
Expand All @@ -11042,7 +11042,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);
}
Expand Down Expand Up @@ -11106,7 +11106,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);
}
Expand Down

0 comments on commit 3ae0d09

Please sign in to comment.