mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-11 05:17:44 +03:00
network: drop many unnecessary link_dirty() calls
Now link state saves mostly link state, DNS and NTP settings, .network file name. So, it is not necessary to call link_dirty() e.g. when an address is updated. This drops such unnecessary link_dirty() calls.
This commit is contained in:
parent
92395e0e83
commit
9092113d93
@ -36,8 +36,6 @@ static int dhcp4_release_old_lease(Link *link) {
|
||||
|
||||
log_link_debug(link, "Removing old DHCPv4 address and routes.");
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
SET_FOREACH(route, link->dhcp_routes_old) {
|
||||
k = route_remove(route, NULL, link, NULL);
|
||||
if (k < 0)
|
||||
|
@ -160,8 +160,6 @@ static int dhcp6_pd_remove_old(Link *link, bool force) {
|
||||
|
||||
log_link_debug(link, "Removing old DHCPv6 Prefix Delegation addresses and routes.");
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
SET_FOREACH(route, link->dhcp6_pd_routes_old) {
|
||||
k = route_remove(route, NULL, link, NULL);
|
||||
if (k < 0)
|
||||
@ -204,8 +202,6 @@ int dhcp6_pd_remove(Link *link) {
|
||||
|
||||
log_link_debug(link, "Removing DHCPv6 Prefix Delegation addresses and routes.");
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
SET_FOREACH(route, link->dhcp6_pd_routes) {
|
||||
k = route_remove(route, NULL, link, NULL);
|
||||
if (k < 0)
|
||||
@ -579,8 +575,6 @@ static int dhcp6_pd_prepare(Link *link) {
|
||||
if (!link_dhcp6_pd_is_enabled(link))
|
||||
return 0;
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
link->dhcp6_pd_address_configured = false;
|
||||
link->dhcp6_pd_route_configured = false;
|
||||
link->dhcp6_pd_prefixes_assigned = true;
|
||||
@ -696,8 +690,6 @@ static int dhcp6_remove_old(Link *link, bool force) {
|
||||
|
||||
log_link_debug(link, "Removing old DHCPv6 addresses and routes.");
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
SET_FOREACH(route, link->dhcp6_routes_old) {
|
||||
k = route_remove(route, NULL, link, NULL);
|
||||
if (k < 0)
|
||||
@ -732,8 +724,6 @@ static int dhcp6_remove(Link *link) {
|
||||
|
||||
log_link_debug(link, "Removing DHCPv6 addresses and routes.");
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
SET_FOREACH(route, link->dhcp6_routes) {
|
||||
k = route_remove(route, NULL, link, NULL);
|
||||
if (k < 0)
|
||||
@ -1096,8 +1086,6 @@ static int dhcp6_lease_ip_acquired(sd_dhcp6_client *client, Link *link) {
|
||||
link->dhcp6_address_configured = false;
|
||||
link->dhcp6_route_configured = false;
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
while ((a = set_steal_first(link->dhcp6_addresses))) {
|
||||
r = set_ensure_put(&link->dhcp6_addresses_old, &address_hash_ops, a);
|
||||
if (r < 0)
|
||||
|
@ -596,14 +596,13 @@ void link_set_state(Link *link, LinkState state) {
|
||||
link->state = state;
|
||||
|
||||
link_send_changed(link, "AdministrativeState", NULL);
|
||||
link_dirty(link);
|
||||
}
|
||||
|
||||
static void link_enter_unmanaged(Link *link) {
|
||||
assert(link);
|
||||
|
||||
link_set_state(link, LINK_STATE_UNMANAGED);
|
||||
|
||||
link_dirty(link);
|
||||
}
|
||||
|
||||
int link_stop_engines(Link *link, bool may_keep_dhcp) {
|
||||
@ -675,8 +674,6 @@ void link_enter_failed(Link *link) {
|
||||
link_set_state(link, LINK_STATE_FAILED);
|
||||
|
||||
(void) link_stop_engines(link, false);
|
||||
|
||||
link_dirty(link);
|
||||
}
|
||||
|
||||
static int link_join_netdevs_after_configured(Link *link) {
|
||||
@ -717,8 +714,6 @@ static void link_enter_configured(Link *link) {
|
||||
link_set_state(link, LINK_STATE_CONFIGURED);
|
||||
|
||||
(void) link_join_netdevs_after_configured(link);
|
||||
|
||||
link_dirty(link);
|
||||
}
|
||||
|
||||
void link_check_ready(Link *link) {
|
||||
@ -1605,6 +1600,8 @@ static int link_put_carrier(Link *link, Link *carrier, Hashmap **h) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1612,7 +1609,6 @@ static int link_new_bound_by_list(Link *link) {
|
||||
Manager *m;
|
||||
Link *carrier;
|
||||
int r;
|
||||
bool list_updated = false;
|
||||
|
||||
assert(link);
|
||||
assert(link->manager);
|
||||
@ -1630,20 +1626,13 @@ static int link_new_bound_by_list(Link *link) {
|
||||
r = link_put_carrier(link, carrier, &link->bound_by_links);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
list_updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (list_updated)
|
||||
link_dirty(link);
|
||||
|
||||
HASHMAP_FOREACH(carrier, link->bound_by_links) {
|
||||
r = link_put_carrier(carrier, link, &carrier->bound_to_links);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
link_dirty(carrier);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1653,7 +1642,6 @@ static int link_new_bound_to_list(Link *link) {
|
||||
Manager *m;
|
||||
Link *carrier;
|
||||
int r;
|
||||
bool list_updated = false;
|
||||
|
||||
assert(link);
|
||||
assert(link->manager);
|
||||
@ -1671,20 +1659,13 @@ static int link_new_bound_to_list(Link *link) {
|
||||
r = link_put_carrier(link, carrier, &link->bound_to_links);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
list_updated = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (list_updated)
|
||||
link_dirty(link);
|
||||
|
||||
HASHMAP_FOREACH (carrier, link->bound_to_links) {
|
||||
r = link_put_carrier(carrier, link, &carrier->bound_by_links);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
link_dirty(carrier);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1713,23 +1694,32 @@ static int link_new_carrier_maps(Link *link) {
|
||||
}
|
||||
|
||||
static void link_free_bound_to_list(Link *link) {
|
||||
bool updated = false;
|
||||
Link *bound_to;
|
||||
|
||||
HASHMAP_FOREACH (bound_to, link->bound_to_links) {
|
||||
hashmap_remove(link->bound_to_links, INT_TO_PTR(bound_to->ifindex));
|
||||
assert(link);
|
||||
|
||||
while ((bound_to = hashmap_steal_first(link->bound_to_links))) {
|
||||
updated = true;
|
||||
|
||||
if (hashmap_remove(bound_to->bound_by_links, INT_TO_PTR(link->ifindex)))
|
||||
link_dirty(bound_to);
|
||||
}
|
||||
|
||||
if (updated)
|
||||
link_dirty(link);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void link_free_bound_by_list(Link *link) {
|
||||
bool updated = false;
|
||||
Link *bound_by;
|
||||
|
||||
HASHMAP_FOREACH (bound_by, link->bound_by_links) {
|
||||
hashmap_remove(link->bound_by_links, INT_TO_PTR(bound_by->ifindex));
|
||||
assert(link);
|
||||
|
||||
while ((bound_by = hashmap_steal_first(link->bound_by_links))) {
|
||||
updated = true;
|
||||
|
||||
if (hashmap_remove(bound_by->bound_to_links, INT_TO_PTR(link->ifindex))) {
|
||||
link_dirty(bound_by);
|
||||
@ -1737,26 +1727,17 @@ static void link_free_bound_by_list(Link *link) {
|
||||
}
|
||||
}
|
||||
|
||||
if (updated)
|
||||
link_dirty(link);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void link_free_carrier_maps(Link *link) {
|
||||
bool list_updated = false;
|
||||
|
||||
assert(link);
|
||||
|
||||
if (!hashmap_isempty(link->bound_to_links)) {
|
||||
link_free_bound_to_list(link);
|
||||
list_updated = true;
|
||||
}
|
||||
|
||||
if (!hashmap_isempty(link->bound_by_links)) {
|
||||
link_free_bound_by_list(link);
|
||||
list_updated = true;
|
||||
}
|
||||
|
||||
if (list_updated)
|
||||
link_dirty(link);
|
||||
link_free_bound_to_list(link);
|
||||
link_free_bound_by_list(link);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1943,7 +1924,6 @@ static int link_enter_join_netdev(Link *link) {
|
||||
|
||||
link_set_state(link, LINK_STATE_CONFIGURING);
|
||||
|
||||
link_dirty(link);
|
||||
link->enslaving = 0;
|
||||
|
||||
if (link->network->bond) {
|
||||
@ -2266,9 +2246,8 @@ static int link_reconfigure_internal(Link *link, sd_netlink_message *m, bool for
|
||||
link_unref(set_remove(link->manager->links_requesting_uuid, link));
|
||||
|
||||
/* Then, apply new .network file */
|
||||
r = network_apply(network, link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
link->network = network_ref(network);
|
||||
link_dirty(link);
|
||||
|
||||
r = link_new_carrier_maps(link);
|
||||
if (r < 0)
|
||||
@ -2276,7 +2255,6 @@ static int link_reconfigure_internal(Link *link, sd_netlink_message *m, bool for
|
||||
|
||||
link_set_state(link, LINK_STATE_INITIALIZED);
|
||||
link->activated = false;
|
||||
link_dirty(link);
|
||||
|
||||
/* link_configure_duid() returns 0 if it requests product UUID. In that case,
|
||||
* link_configure() is called later asynchronously. */
|
||||
@ -2390,9 +2368,8 @@ static int link_initialized_and_synced(Link *link) {
|
||||
log_link_debug(link, "Ignoring DHCP server for loopback link");
|
||||
}
|
||||
|
||||
r = network_apply(network, link);
|
||||
if (r < 0)
|
||||
return r;
|
||||
link->network = network_ref(network);
|
||||
link_dirty(link);
|
||||
}
|
||||
|
||||
r = link_new_bound_to_list(link);
|
||||
|
@ -118,6 +118,7 @@ static int ndisc_remove_old_one(Link *link, const struct in6_addr *router, bool
|
||||
NDiscDNSSL *dnssl;
|
||||
NDiscRDNSS *rdnss;
|
||||
int k, r = 0;
|
||||
bool updated = false;
|
||||
|
||||
assert(link);
|
||||
assert(router);
|
||||
@ -182,12 +183,19 @@ static int ndisc_remove_old_one(Link *link, const struct in6_addr *router, bool
|
||||
}
|
||||
|
||||
SET_FOREACH(rdnss, link->ndisc_rdnss)
|
||||
if (rdnss->marked && IN6_ARE_ADDR_EQUAL(&rdnss->router, router))
|
||||
if (rdnss->marked && IN6_ARE_ADDR_EQUAL(&rdnss->router, router)) {
|
||||
free(set_remove(link->ndisc_rdnss, rdnss));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
SET_FOREACH(dnssl, link->ndisc_dnssl)
|
||||
if (dnssl->marked && IN6_ARE_ADDR_EQUAL(&dnssl->router, router))
|
||||
if (dnssl->marked && IN6_ARE_ADDR_EQUAL(&dnssl->router, router)) {
|
||||
free(set_remove(link->ndisc_dnssl, dnssl));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (updated)
|
||||
link_dirty(link);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -926,6 +934,7 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
|
||||
struct in6_addr router;
|
||||
NDiscRDNSS *rdnss;
|
||||
usec_t time_now;
|
||||
bool updated = false;
|
||||
int n, r;
|
||||
|
||||
assert(link);
|
||||
@ -987,8 +996,13 @@ static int ndisc_router_process_rdnss(Link *link, sd_ndisc_router *rt) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
assert(r > 0);
|
||||
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (updated)
|
||||
link_dirty(link);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1013,6 +1027,7 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
|
||||
uint32_t lifetime;
|
||||
usec_t time_now;
|
||||
NDiscDNSSL *dnssl;
|
||||
bool updated = false;
|
||||
char **j;
|
||||
int r;
|
||||
|
||||
@ -1072,8 +1087,13 @@ static int ndisc_router_process_dnssl(Link *link, sd_ndisc_router *rt) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
assert(r > 0);
|
||||
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (updated)
|
||||
link_dirty(link);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1198,8 +1218,6 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
|
||||
link->ndisc_addresses_configured = false;
|
||||
link->ndisc_routes_configured = false;
|
||||
|
||||
link_dirty(link);
|
||||
|
||||
SET_FOREACH(na, link->ndisc_addresses)
|
||||
if (IN6_ARE_ADDR_EQUAL(&na->router, &router.in6))
|
||||
na->marked = true;
|
||||
@ -1327,7 +1345,6 @@ void ndisc_vacuum(Link *link) {
|
||||
NDiscRDNSS *r;
|
||||
NDiscDNSSL *d;
|
||||
usec_t time_now;
|
||||
bool updated = false;
|
||||
|
||||
assert(link);
|
||||
|
||||
@ -1336,19 +1353,12 @@ void ndisc_vacuum(Link *link) {
|
||||
time_now = now(clock_boottime_or_monotonic());
|
||||
|
||||
SET_FOREACH(r, link->ndisc_rdnss)
|
||||
if (r->valid_until < time_now) {
|
||||
if (r->valid_until < time_now)
|
||||
free(set_remove(link->ndisc_rdnss, r));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
SET_FOREACH(d, link->ndisc_dnssl)
|
||||
if (d->valid_until < time_now) {
|
||||
if (d->valid_until < time_now)
|
||||
free(set_remove(link->ndisc_dnssl, d));
|
||||
updated = true;
|
||||
}
|
||||
|
||||
if (updated)
|
||||
link_dirty(link);
|
||||
}
|
||||
|
||||
void ndisc_flush(Link *link) {
|
||||
|
@ -736,21 +736,6 @@ int network_get(Manager *manager, unsigned short iftype, sd_device *device,
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
int network_apply(Network *network, Link *link) {
|
||||
assert(network);
|
||||
assert(link);
|
||||
|
||||
link->network = network_ref(network);
|
||||
|
||||
if (network->n_dns > 0 ||
|
||||
!strv_isempty(network->ntp) ||
|
||||
!ordered_set_isempty(network->search_domains) ||
|
||||
!ordered_set_isempty(network->route_domains))
|
||||
link_dirty(link);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool network_has_static_ipv6_configurations(Network *network) {
|
||||
Address *address;
|
||||
Route *route;
|
||||
|
@ -329,7 +329,6 @@ int network_get(Manager *manager, unsigned short iftype, sd_device *device,
|
||||
const struct ether_addr *mac, const struct ether_addr *permanent_mac,
|
||||
enum nl80211_iftype wlan_iftype, const char *ssid, const struct ether_addr *bssid,
|
||||
Network **ret);
|
||||
int network_apply(Network *network, Link *link);
|
||||
void network_apply_anonymize_if_set(Network *network);
|
||||
|
||||
bool network_has_static_ipv6_configurations(Network *network);
|
||||
|
Loading…
Reference in New Issue
Block a user