mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
network/address: introduce address_get_harder() and use it where appropriate
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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user