mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-27 03:21:32 +03:00
network: tc: use hashmap to store traffic control settings in .network files
As now each qdisc or tclass is configured when it is ready.
This commit is contained in:
parent
7ec1846242
commit
e4bbd9c61e
@ -754,7 +754,7 @@ static Network *network_free(Network *network) {
|
||||
hashmap_free_with_destructor(network->rules_by_section, routing_policy_rule_free);
|
||||
hashmap_free_with_destructor(network->dhcp_static_leases_by_section, dhcp_static_lease_free);
|
||||
ordered_hashmap_free_with_destructor(network->sr_iov_by_section, sr_iov_free);
|
||||
ordered_hashmap_free_with_destructor(network->tc_by_section, traffic_control_free);
|
||||
hashmap_free_with_destructor(network->tc_by_section, traffic_control_free);
|
||||
|
||||
free(network->name);
|
||||
|
||||
|
@ -340,7 +340,7 @@ struct Network {
|
||||
Hashmap *route_prefixes_by_section;
|
||||
Hashmap *rules_by_section;
|
||||
Hashmap *dhcp_static_leases_by_section;
|
||||
OrderedHashmap *tc_by_section;
|
||||
Hashmap *tc_by_section;
|
||||
OrderedHashmap *sr_iov_by_section;
|
||||
|
||||
/* All kinds of DNS configuration */
|
||||
|
@ -92,7 +92,7 @@ int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, uns
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
existing = ordered_hashmap_get(network->tc_by_section, n);
|
||||
existing = hashmap_get(network->tc_by_section, n);
|
||||
if (existing) {
|
||||
if (existing->kind != TC_KIND_QDISC)
|
||||
return -EINVAL;
|
||||
@ -126,7 +126,7 @@ int qdisc_new_static(QDiscKind kind, Network *network, const char *filename, uns
|
||||
qdisc->section = TAKE_PTR(n);
|
||||
qdisc->source = NETWORK_CONFIG_SOURCE_STATIC;
|
||||
|
||||
r = ordered_hashmap_ensure_put(&network->tc_by_section, &config_section_hash_ops, qdisc->section, TC(qdisc));
|
||||
r = hashmap_ensure_put(&network->tc_by_section, &config_section_hash_ops, qdisc->section, TC(qdisc));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -139,7 +139,7 @@ QDisc* qdisc_free(QDisc *qdisc) {
|
||||
return NULL;
|
||||
|
||||
if (qdisc->network && qdisc->section)
|
||||
ordered_hashmap_remove(qdisc->network->tc_by_section, qdisc->section);
|
||||
hashmap_remove(qdisc->network->tc_by_section, qdisc->section);
|
||||
|
||||
config_section_free(qdisc->section);
|
||||
|
||||
|
@ -136,7 +136,7 @@ int link_request_traffic_control(Link *link) {
|
||||
|
||||
link->tc_configured = false;
|
||||
|
||||
ORDERED_HASHMAP_FOREACH(tc, link->network->tc_by_section) {
|
||||
HASHMAP_FOREACH(tc, link->network->tc_by_section) {
|
||||
r = link_request_traffic_control_one(link, tc);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -213,7 +213,7 @@ void network_drop_invalid_traffic_control(Network *network) {
|
||||
|
||||
assert(network);
|
||||
|
||||
ORDERED_HASHMAP_FOREACH(tc, network->tc_by_section)
|
||||
HASHMAP_FOREACH(tc, network->tc_by_section)
|
||||
if (traffic_control_section_verify(tc, &has_root, &has_clsact) < 0)
|
||||
traffic_control_free(tc);
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ int tclass_new_static(TClassKind kind, Network *network, const char *filename, u
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
existing = ordered_hashmap_get(network->tc_by_section, n);
|
||||
existing = hashmap_get(network->tc_by_section, n);
|
||||
if (existing) {
|
||||
TClass *t;
|
||||
|
||||
@ -97,7 +97,7 @@ int tclass_new_static(TClassKind kind, Network *network, const char *filename, u
|
||||
tclass->section = TAKE_PTR(n);
|
||||
tclass->source = NETWORK_CONFIG_SOURCE_STATIC;
|
||||
|
||||
r = ordered_hashmap_ensure_put(&network->tc_by_section, &config_section_hash_ops, tclass->section, tclass);
|
||||
r = hashmap_ensure_put(&network->tc_by_section, &config_section_hash_ops, tclass->section, tclass);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -110,7 +110,7 @@ TClass* tclass_free(TClass *tclass) {
|
||||
return NULL;
|
||||
|
||||
if (tclass->network && tclass->section)
|
||||
ordered_hashmap_remove(tclass->network->tc_by_section, tclass->section);
|
||||
hashmap_remove(tclass->network->tc_by_section, tclass->section);
|
||||
|
||||
config_section_free(tclass->section);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user