]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/address: introduce address_get_harder() and use it where appropriate
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 11 Jul 2023 03:11:18 +0000 (12:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 30 Jul 2023 17:31:00 +0000 (02:31 +0900)
With the previous change, now Address objects under requesting are not
owned by Link object, hence we need to also search corresponding Address
object in the request queue.

src/network/networkd-address.c
src/network/networkd-address.h
src/network/networkd-dhcp-prefix-delegation.c
src/network/networkd-dhcp-server.c
src/network/networkd-dhcp6.c

index f2a88da4113b3c3b177a51da563969d8f1777c88..2dd02f5efbe9ad0c983466185ebd1a6e656fe446 100644 (file)
@@ -685,6 +685,26 @@ int address_get(Link *link, const Address *in, Address **ret) {
         return -ENOENT;
 }
 
+int address_get_harder(Link *link, const Address *in, Address **ret) {
+        Request *req;
+        int r;
+
+        assert(link);
+        assert(in);
+
+        if (address_get(link, in, ret) >= 0)
+                return 0;
+
+        r = address_get_request(link, in, &req);
+        if (r < 0)
+                return r;
+
+        if (ret)
+                *ret = ASSERT_PTR(req->userdata);
+
+        return 0;
+}
+
 int link_get_address(Link *link, int family, const union in_addr_union *address, unsigned char prefixlen, Address **ret) {
         Address *a;
         int r;
index 9b418af4142a3a4a520f8df169e23f7a9be0ab26..bdb5b5b5e508873d3c98596bfd5295c049bb06fb 100644 (file)
@@ -73,6 +73,7 @@ int address_flags_to_string_alloc(uint32_t flags, int family, char **ret);
 int address_new(Address **ret);
 Address* address_free(Address *address);
 int address_get(Link *link, const Address *in, Address **ret);
+int address_get_harder(Link *link, const Address *in, Address **ret);
 int address_configure_handler_internal(sd_netlink *rtnl, sd_netlink_message *m, Link *link, const char *error_msg);
 int address_remove(Address *address);
 int address_remove_and_drop(Address *address);
index 8d50da042c83bd908f37052f7e9b26feac5a972b..169f1b3b5ebe1ad1e1ca759bcf4d723432175435 100644 (file)
@@ -359,7 +359,7 @@ static void log_dhcp_pd_address(Link *link, const Address *address) {
         assert(address);
         assert(address->family == AF_INET6);
 
-        int log_level = address_get(link, address, NULL) >= 0 ? LOG_DEBUG : LOG_INFO;
+        int log_level = address_get_harder(link, address, NULL) >= 0 ? LOG_DEBUG : LOG_INFO;
 
         if (log_level < log_get_max_level())
                 return;
index 50d84893c63de275b3f51eaf70adf180efe011fb..8221fd92dbdb5ebc9996016712621655e18f2c49 100644 (file)
@@ -108,8 +108,8 @@ int link_request_dhcp_server_address(Link *link) {
         address->prefixlen = link->network->dhcp_server_address_prefixlen;
         address_set_broadcast(address, link);
 
-        if (address_get(link, address, &existing) >= 0 &&
-            address_exists(existing) &&
+        if (address_get_harder(link, address, &existing) >= 0 &&
+            (address_exists(existing) || address_is_requesting(existing)) &&
             existing->source == NETWORK_CONFIG_SOURCE_STATIC)
                 /* The same address seems explicitly configured in [Address] or [Network] section.
                  * Configure the DHCP server address only when it is not. */
index 755957f5b19d7b70c4df6e4727de92fc03ae6d56..00c767e1fb8f8411a5bafbb62da16d6990d5d04a 100644 (file)
@@ -161,7 +161,7 @@ static int verify_dhcp6_address(Link *link, const Address *address) {
 
         const char *pretty = IN6_ADDR_TO_STRING(&address->in_addr.in6);
 
-        if (address_get(link, address, &existing) < 0) {
+        if (address_get_harder(link, address, &existing) < 0) {
                 /* New address. */
                 log_level = LOG_INFO;
                 goto simple_log;