diff options
-rw-r--r-- | src/libsystemd-network/dhcp-option.c | 6 | ||||
-rw-r--r-- | src/libsystemd-network/dhcp-server-internal.h | 6 | ||||
-rw-r--r-- | src/libsystemd-network/sd-dhcp-client.c | 6 | ||||
-rw-r--r-- | src/libsystemd-network/sd-dhcp-server.c | 23 | ||||
-rw-r--r-- | src/network/netdev/l2tp-tunnel.c | 6 | ||||
-rw-r--r-- | src/network/networkd-sriov.c | 6 | ||||
-rw-r--r-- | src/network/tc/qdisc.c | 6 | ||||
-rw-r--r-- | src/network/tc/tclass.c | 6 |
8 files changed, 19 insertions, 46 deletions
diff --git a/src/libsystemd-network/dhcp-option.c b/src/libsystemd-network/dhcp-option.c index 7e3fe4348b..faa075cbd7 100644 --- a/src/libsystemd-network/dhcp-option.c +++ b/src/libsystemd-network/dhcp-option.c @@ -80,11 +80,11 @@ static int option_append(uint8_t options[], size_t size, size_t *offset, break; case SD_DHCP_OPTION_VENDOR_SPECIFIC: { - OrderedHashmap *s = (OrderedHashmap *) optval; + OrderedSet *s = (OrderedSet *) optval; struct sd_dhcp_option *p; size_t l = 0; - ORDERED_HASHMAP_FOREACH(p, s) + ORDERED_SET_FOREACH(p, s) l += p->length + 2; if (*offset + l + 2 > size) @@ -95,7 +95,7 @@ static int option_append(uint8_t options[], size_t size, size_t *offset, *offset += 2; - ORDERED_HASHMAP_FOREACH(p, s) { + ORDERED_SET_FOREACH(p, s) { options[*offset] = p->option; options[*offset + 1] = p->length; memcpy(&options[*offset + 2], p->data, p->length); diff --git a/src/libsystemd-network/dhcp-server-internal.h b/src/libsystemd-network/dhcp-server-internal.h index b57737ee25..b5293c3ed6 100644 --- a/src/libsystemd-network/dhcp-server-internal.h +++ b/src/libsystemd-network/dhcp-server-internal.h @@ -9,7 +9,7 @@ #include "sd-event.h" #include "dhcp-internal.h" -#include "hashmap.h" +#include "ordered-set.h" #include "log.h" #include "time-util.h" @@ -58,8 +58,8 @@ struct sd_dhcp_server { DHCPServerData servers[_SD_DHCP_LEASE_SERVER_TYPE_MAX]; - OrderedHashmap *extra_options; - OrderedHashmap *vendor_options; + OrderedSet *extra_options; + OrderedSet *vendor_options; bool emit_router; diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index ad0eeda5a2..dd9cbf6ea5 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -629,11 +629,7 @@ int sd_dhcp_client_add_option(sd_dhcp_client *client, sd_dhcp_option *v) { assert_return(client, -EINVAL); assert_return(v, -EINVAL); - r = ordered_hashmap_ensure_allocated(&client->extra_options, &dhcp_option_hash_ops); - if (r < 0) - return r; - - r = ordered_hashmap_put(client->extra_options, UINT_TO_PTR(v->option), v); + r = ordered_hashmap_ensure_put(&client->extra_options, &dhcp_option_hash_ops, UINT_TO_PTR(v->option), v); if (r < 0) return r; diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index dfced720c2..faea0dd5ca 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -15,6 +15,7 @@ #include "fd-util.h" #include "in-addr-util.h" #include "io-util.h" +#include "ordered-set.h" #include "siphash24.h" #include "string-util.h" #include "unaligned.h" @@ -153,8 +154,8 @@ static sd_dhcp_server *dhcp_server_free(sd_dhcp_server *server) { hashmap_free(server->leases_by_client_id); - ordered_hashmap_free(server->extra_options); - ordered_hashmap_free(server->vendor_options); + ordered_set_free(server->extra_options); + ordered_set_free(server->vendor_options); free(server->bound_leases); return mfree(server); @@ -531,18 +532,18 @@ static int server_send_ack( return r; } - ORDERED_HASHMAP_FOREACH(j, server->extra_options) { + ORDERED_SET_FOREACH(j, server->extra_options) { r = dhcp_option_append(&packet->dhcp, req->max_optlen, &offset, 0, j->option, j->length, j->data); if (r < 0) return r; } - if (!ordered_hashmap_isempty(server->vendor_options)) { + if (!ordered_set_isempty(server->vendor_options)) { r = dhcp_option_append( &packet->dhcp, req->max_optlen, &offset, 0, SD_DHCP_OPTION_VENDOR_SPECIFIC, - ordered_hashmap_size(server->vendor_options), server->vendor_options); + ordered_set_size(server->vendor_options), server->vendor_options); if (r < 0) return r; } @@ -1181,11 +1182,7 @@ int sd_dhcp_server_add_option(sd_dhcp_server *server, sd_dhcp_option *v) { assert_return(server, -EINVAL); assert_return(v, -EINVAL); - r = ordered_hashmap_ensure_allocated(&server->extra_options, &dhcp_option_hash_ops); - if (r < 0) - return r; - - r = ordered_hashmap_put(server->extra_options, UINT_TO_PTR(v->option), v); + r = ordered_set_ensure_put(&server->extra_options, &dhcp_option_hash_ops, v); if (r < 0) return r; @@ -1199,11 +1196,7 @@ int sd_dhcp_server_add_vendor_option(sd_dhcp_server *server, sd_dhcp_option *v) assert_return(server, -EINVAL); assert_return(v, -EINVAL); - r = ordered_hashmap_ensure_allocated(&server->vendor_options, &dhcp_option_hash_ops); - if (r < 0) - return -ENOMEM; - - r = ordered_hashmap_put(server->vendor_options, v, v); + r = ordered_set_ensure_put(&server->vendor_options, &dhcp_option_hash_ops, v); if (r < 0) return r; diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c index eeea19764e..da23db947f 100644 --- a/src/network/netdev/l2tp-tunnel.c +++ b/src/network/netdev/l2tp-tunnel.c @@ -85,11 +85,7 @@ static int l2tp_session_new_static(L2tpTunnel *t, const char *filename, unsigned .section = TAKE_PTR(n), }; - r = ordered_hashmap_ensure_allocated(&t->sessions_by_section, &network_config_hash_ops); - if (r < 0) - return r; - - r = ordered_hashmap_put(t->sessions_by_section, s->section, s); + r = ordered_hashmap_ensure_put(&t->sessions_by_section, &network_config_hash_ops, s->section, s); if (r < 0) return r; diff --git a/src/network/networkd-sriov.c b/src/network/networkd-sriov.c index 92c00d79e0..d86de6799e 100644 --- a/src/network/networkd-sriov.c +++ b/src/network/networkd-sriov.c @@ -58,11 +58,7 @@ static int sr_iov_new_static(Network *network, const char *filename, unsigned se sr_iov->network = network; sr_iov->section = TAKE_PTR(n); - r = ordered_hashmap_ensure_allocated(&network->sr_iov_by_section, &network_config_hash_ops); - if (r < 0) - return r; - - r = ordered_hashmap_put(network->sr_iov_by_section, sr_iov->section, sr_iov); + r = ordered_hashmap_ensure_put(&network->sr_iov_by_section, &network_config_hash_ops, sr_iov->section, sr_iov); if (r < 0) return r; diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c index 1a84e8b0f5..7016dc1877 100644 --- a/src/network/tc/qdisc.c +++ b/src/network/tc/qdisc.c @@ -126,11 +126,7 @@ int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, uns qdisc->network = network; qdisc->section = TAKE_PTR(n); - r = ordered_hashmap_ensure_allocated(&network->tc_by_section, &network_config_hash_ops); - if (r < 0) - return r; - - r = ordered_hashmap_put(network->tc_by_section, qdisc->section, TC(qdisc)); + r = ordered_hashmap_ensure_put(&network->tc_by_section, &network_config_hash_ops, qdisc->section, TC(qdisc)); if (r < 0) return r; diff --git a/src/network/tc/tclass.c b/src/network/tc/tclass.c index 21b26b01a0..4c03587211 100644 --- a/src/network/tc/tclass.c +++ b/src/network/tc/tclass.c @@ -82,11 +82,7 @@ int tclass_new_static(TClassKind kind, Network *network, const char *filename, u tclass->network = network; tclass->section = TAKE_PTR(n); - r = ordered_hashmap_ensure_allocated(&network->tc_by_section, &network_config_hash_ops); - if (r < 0) - return r; - - r = ordered_hashmap_put(network->tc_by_section, tclass->section, tclass); + r = ordered_hashmap_ensure_put(&network->tc_by_section, &network_config_hash_ops, tclass->section, tclass); if (r < 0) return r; |