]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: rename link_drop_managed_xyz() -> link_drop_static_xyz()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2024 05:33:07 +0000 (14:33 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Feb 2024 15:43:12 +0000 (00:43 +0900)
As networkd does not configure nexthops, neighbors, or routing policy rules
dynamically, this only changes link_drop_managed_addresses(). Previously
it also removed dynamic addresses, but with this commit, now it only
removes static addresses. Note, link_drop_managed_routes() has removed
only static routes, so this commit only changes its name.

Note. as commented in the code, the dynamic addresses will be removed
on lease expiration or stopping client, and link_drop_managed_xyz() are
called on reconfiguration or so, and at that time, all dynamic
addressing clients are stopped or restarted, so this should not
effective behavior change.

src/network/networkd-address.c
src/network/networkd-address.h
src/network/networkd-link.c
src/network/networkd-neighbor.c
src/network/networkd-neighbor.h
src/network/networkd-nexthop.c
src/network/networkd-nexthop.h
src/network/networkd-route.h
src/network/networkd-routing-policy-rule.c
src/network/networkd-routing-policy-rule.h

index 2aa8c88bb2d763e5bccbc8d2095229c465baaa83..e301cf153d6ad474386b8ff54eda42d12ce6e11c 100644 (file)
@@ -1383,15 +1383,16 @@ int link_drop_foreign_addresses(Link *link) {
         return r;
 }
 
-int link_drop_managed_addresses(Link *link) {
+int link_drop_static_addresses(Link *link) {
         Address *address;
         int r = 0;
 
         assert(link);
 
         SET_FOREACH(address, link->addresses) {
-                /* Do not touch addresses managed by kernel or other tools. */
-                if (address->source == NETWORK_CONFIG_SOURCE_FOREIGN)
+                /* Remove only static addresses here. Dynamic addresses will be removed e.g. on lease
+                 * expiration or stopping the DHCP client. */
+                if (address->source != NETWORK_CONFIG_SOURCE_STATIC)
                         continue;
 
                 /* Ignore addresses not assigned yet or already removing. */
index 350d2f6b381184fa61b733d71717b0776cbe9c06..3efbe6f48e6d56e13661127287af8ba37f47fd92 100644 (file)
@@ -103,7 +103,7 @@ bool link_check_addresses_ready(Link *link, NetworkConfigSource source);
 
 DEFINE_SECTION_CLEANUP_FUNCTIONS(Address, address_unref);
 
-int link_drop_managed_addresses(Link *link);
+int link_drop_static_addresses(Link *link);
 int link_drop_foreign_addresses(Link *link);
 int link_drop_ipv6ll_addresses(Link *link);
 void link_foreignize_addresses(Link *link);
index ee442e3a4bb5408f7721d9d601342ed98c116c34..566d251b15339307ff986ff4a393114fed9744ec 100644 (file)
@@ -1115,12 +1115,11 @@ static int link_drop_managed_config(Link *link) {
         assert(link);
         assert(link->manager);
 
-        r = link_drop_managed_routes(link);
-
-        RET_GATHER(r, link_drop_managed_nexthops(link));
-        RET_GATHER(r, link_drop_managed_addresses(link));
-        RET_GATHER(r, link_drop_managed_neighbors(link));
-        RET_GATHER(r, link_drop_managed_routing_policy_rules(link));
+        r = link_drop_static_routes(link);
+        RET_GATHER(r, link_drop_static_nexthops(link));
+        RET_GATHER(r, link_drop_static_addresses(link));
+        RET_GATHER(r, link_drop_static_neighbors(link));
+        RET_GATHER(r, link_drop_static_routing_policy_rules(link));
 
         return r;
 }
index 4347a1d282d891f37cb74b7f1d04a5845240b762..6b81950f96c6323fadf0663461daf394b166f851 100644 (file)
@@ -502,7 +502,7 @@ int link_drop_foreign_neighbors(Link *link) {
         return r;
 }
 
-int link_drop_managed_neighbors(Link *link) {
+int link_drop_static_neighbors(Link *link) {
         Neighbor *neighbor;
         int r = 0;
 
@@ -510,7 +510,7 @@ int link_drop_managed_neighbors(Link *link) {
 
         SET_FOREACH(neighbor, link->neighbors) {
                 /* Do not touch nexthops managed by kernel or other tools. */
-                if (neighbor->source == NETWORK_CONFIG_SOURCE_FOREIGN)
+                if (neighbor->source != NETWORK_CONFIG_SOURCE_STATIC)
                         continue;
 
                 /* Ignore neighbors not assigned yet or already removing. */
index 93b3927f02ca0c3df119dafd9ed4a4ff6591928f..7917930bcdb844cc458a5f8ee28d157c83476ef2 100644 (file)
@@ -36,7 +36,7 @@ int neighbor_remove(Neighbor *neighbor, Link *link);
 
 int network_drop_invalid_neighbors(Network *network);
 
-int link_drop_managed_neighbors(Link *link);
+int link_drop_static_neighbors(Link *link);
 int link_drop_foreign_neighbors(Link *link);
 void link_foreignize_neighbors(Link *link);
 
index 56abd3908a423f427cb7b7a0d597b2c2f65789d1..b07feede2ba5140ee684487284c7a7f037e6793a 100644 (file)
@@ -869,7 +869,7 @@ static void link_mark_nexthops(Link *link, bool foreign) {
                         continue;
 
                 /* When 'foreign' is true, mark only foreign nexthops, and vice versa. */
-                if (foreign != (nexthop->source == NETWORK_CONFIG_SOURCE_FOREIGN))
+                if (nexthop->source != (foreign ? NETWORK_CONFIG_SOURCE_FOREIGN : NETWORK_CONFIG_SOURCE_STATIC))
                         continue;
 
                 /* Ignore nexthops not assigned yet or already removed. */
index 9ce36c6cd9b18d3f19bc8b73da1e555d8264cb79..fbe330ad71bd1731b6571f95a4b11e41419075d1 100644 (file)
@@ -57,7 +57,7 @@ int link_drop_nexthops(Link *link, bool foreign);
 static inline int link_drop_foreign_nexthops(Link *link) {
         return link_drop_nexthops(link, /* foreign = */ true);
 }
-static inline int link_drop_managed_nexthops(Link *link) {
+static inline int link_drop_static_nexthops(Link *link) {
         return link_drop_nexthops(link, /* foreign = */ false);
 }
 void link_foreignize_nexthops(Link *link);
index c5c2693ac4ff425c8066042ab521ce5b5cda5879..a5019db65cbb487c6bab1a40861675b5447dc6d8 100644 (file)
@@ -98,7 +98,7 @@ int route_remove_and_cancel(Route *route, Manager *manager);
 int route_get(Manager *manager, const Route *route, Route **ret);
 
 int link_drop_routes(Link *link, bool foreign);
-static inline int link_drop_managed_routes(Link *link) {
+static inline int link_drop_static_routes(Link *link) {
         return link_drop_routes(link, false);
 }
 static inline int link_drop_foreign_routes(Link *link) {
index e8e154dd60671f42ad88062a82e82679fe30400a..bb757eed71fbfbc1366d84a53c105384613509e8 100644 (file)
@@ -654,7 +654,7 @@ static void manager_mark_routing_policy_rules(Manager *m, bool foreign, const Li
                         continue;
 
                 /* When 'foreign' is true, mark only foreign rules, and vice versa. */
-                if (foreign != (rule->source == NETWORK_CONFIG_SOURCE_FOREIGN))
+                if (rule->source != (foreign ? NETWORK_CONFIG_SOURCE_FOREIGN : NETWORK_CONFIG_SOURCE_STATIC))
                         continue;
 
                 /* Ignore rules not assigned yet or already removing. */
index 85016bbc8a3cc8e70a8f03f079e40050e7aa2408..42a575c493db2800a74087b9a016e134e0ce11b1 100644 (file)
@@ -66,7 +66,7 @@ int manager_drop_routing_policy_rules_internal(Manager *m, bool foreign, const L
 static inline int manager_drop_foreign_routing_policy_rules(Manager *m) {
         return manager_drop_routing_policy_rules_internal(m, true, NULL);
 }
-static inline int link_drop_managed_routing_policy_rules(Link *link) {
+static inline int link_drop_static_routing_policy_rules(Link *link) {
         assert(link);
         return manager_drop_routing_policy_rules_internal(link->manager, false, link);
 }