1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
4 #include <net/if_arp.h>
6 #include "alloc-util.h"
7 #include "firewall-util.h"
9 #include "memory-util.h"
10 #include "netlink-util.h"
11 #include "networkd-address-pool.h"
12 #include "networkd-address.h"
13 #include "networkd-dhcp-prefix-delegation.h"
14 #include "networkd-dhcp-server.h"
15 #include "networkd-ipv4acd.h"
16 #include "networkd-manager.h"
17 #include "networkd-ndisc.h"
18 #include "networkd-netlabel.h"
19 #include "networkd-network.h"
20 #include "networkd-queue.h"
21 #include "networkd-route-util.h"
22 #include "networkd-route.h"
23 #include "parse-util.h"
24 #include "string-util.h"
28 #define ADDRESSES_PER_LINK_MAX 2048U
29 #define STATIC_ADDRESSES_PER_NETWORK_MAX 1024U
40 IFA_F_MANAGETEMPADDR | \
41 IFA_F_NOPREFIXROUTE | \
45 /* From net/ipv4/devinet.c */
46 #define IPV6ONLY_FLAGS \
52 IFA_F_MANAGETEMPADDR | \
55 /* We do not control the following flags. */
56 #define UNMANAGED_FLAGS \
64 int address_flags_to_string_alloc(uint32_t flags
, int family
, char **ret
) {
65 _cleanup_free_
char *str
= NULL
;
66 static const char* map
[] = {
67 [LOG2U(IFA_F_SECONDARY
)] = "secondary", /* This is also called "temporary" for ipv6. */
68 [LOG2U(IFA_F_NODAD
)] = "nodad",
69 [LOG2U(IFA_F_OPTIMISTIC
)] = "optimistic",
70 [LOG2U(IFA_F_DADFAILED
)] = "dadfailed",
71 [LOG2U(IFA_F_HOMEADDRESS
)] = "home-address",
72 [LOG2U(IFA_F_DEPRECATED
)] = "deprecated",
73 [LOG2U(IFA_F_TENTATIVE
)] = "tentative",
74 [LOG2U(IFA_F_PERMANENT
)] = "permanent",
75 [LOG2U(IFA_F_MANAGETEMPADDR
)] = "manage-temporary-address",
76 [LOG2U(IFA_F_NOPREFIXROUTE
)] = "no-prefixroute",
77 [LOG2U(IFA_F_MCAUTOJOIN
)] = "auto-join",
78 [LOG2U(IFA_F_STABLE_PRIVACY
)] = "stable-privacy",
81 assert(IN_SET(family
, AF_INET
, AF_INET6
));
84 for (size_t i
= 0; i
< ELEMENTSOF(map
); i
++)
85 if (FLAGS_SET(flags
, 1 << i
) && map
[i
])
86 if (!strextend_with_separator(
88 family
== AF_INET6
&& (1 << i
) == IFA_F_SECONDARY
? "temporary" : map
[i
]))
95 static LinkAddressState
address_state_from_scope(uint8_t scope
) {
96 if (scope
< RT_SCOPE_SITE
)
97 /* universally accessible addresses found */
98 return LINK_ADDRESS_STATE_ROUTABLE
;
100 if (scope
< RT_SCOPE_HOST
)
101 /* only link or site local addresses found */
102 return LINK_ADDRESS_STATE_DEGRADED
;
104 /* no useful addresses found */
105 return LINK_ADDRESS_STATE_OFF
;
108 void link_get_address_states(
110 LinkAddressState
*ret_ipv4
,
111 LinkAddressState
*ret_ipv6
,
112 LinkAddressState
*ret_all
) {
114 uint8_t ipv4_scope
= RT_SCOPE_NOWHERE
, ipv6_scope
= RT_SCOPE_NOWHERE
;
119 SET_FOREACH(address
, link
->addresses
) {
120 if (!address_is_ready(address
))
123 if (address
->family
== AF_INET
)
124 ipv4_scope
= MIN(ipv4_scope
, address
->scope
);
126 if (address
->family
== AF_INET6
)
127 ipv6_scope
= MIN(ipv6_scope
, address
->scope
);
131 *ret_ipv4
= address_state_from_scope(ipv4_scope
);
133 *ret_ipv6
= address_state_from_scope(ipv6_scope
);
135 *ret_all
= address_state_from_scope(MIN(ipv4_scope
, ipv6_scope
));
138 static void address_hash_func(const Address
*a
, struct siphash
*state
);
139 static int address_compare_func(const Address
*a1
, const Address
*a2
);
140 static void address_detach(Address
*address
);
142 DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR(
143 address_hash_ops_detach
,
146 address_compare_func
,
153 address_compare_func
);
155 DEFINE_HASH_OPS_WITH_VALUE_DESTRUCTOR(
156 address_section_hash_ops
,
158 config_section_hash_func
,
159 config_section_compare_func
,
163 int address_new(Address
**ret
) {
164 _cleanup_(address_unrefp
) Address
*address
= NULL
;
166 address
= new(Address
, 1);
170 *address
= (Address
) {
173 .scope
= RT_SCOPE_UNIVERSE
,
174 .lifetime_valid_usec
= USEC_INFINITY
,
175 .lifetime_preferred_usec
= USEC_INFINITY
,
179 *ret
= TAKE_PTR(address
);
184 int address_new_static(Network
*network
, const char *filename
, unsigned section_line
, Address
**ret
) {
185 _cleanup_(config_section_freep
) ConfigSection
*n
= NULL
;
186 _cleanup_(address_unrefp
) Address
*address
= NULL
;
192 assert(section_line
> 0);
194 r
= config_section_new(filename
, section_line
, &n
);
198 address
= ordered_hashmap_get(network
->addresses_by_section
, n
);
200 *ret
= TAKE_PTR(address
);
204 if (ordered_hashmap_size(network
->addresses_by_section
) >= STATIC_ADDRESSES_PER_NETWORK_MAX
)
207 r
= address_new(&address
);
211 address
->network
= network
;
212 address
->section
= TAKE_PTR(n
);
213 address
->source
= NETWORK_CONFIG_SOURCE_STATIC
;
214 /* This will be adjusted in address_section_verify(). */
215 address
->duplicate_address_detection
= _ADDRESS_FAMILY_INVALID
;
217 r
= ordered_hashmap_ensure_put(&network
->addresses_by_section
, &address_section_hash_ops
, address
->section
, address
);
221 *ret
= TAKE_PTR(address
);
225 static Address
* address_detach_impl(Address
*address
) {
227 assert(!address
->link
|| !address
->network
);
229 if (address
->network
) {
230 assert(address
->section
);
231 ordered_hashmap_remove(address
->network
->addresses_by_section
, address
->section
);
233 if (address
->network
->dhcp_server_address
== address
)
234 address
->network
->dhcp_server_address
= NULL
;
236 address
->network
= NULL
;
241 set_remove(address
->link
->addresses
, address
);
243 address
->link
= NULL
;
250 static void address_detach(Address
*address
) {
253 address_unref(address_detach_impl(address
));
256 static Address
* address_free(Address
*address
) {
260 address_detach_impl(address
);
262 config_section_free(address
->section
);
263 free(address
->label
);
264 free(address
->netlabel
);
265 ipv6_token_unref(address
->token
);
266 nft_set_context_clear(&address
->nft_set_context
);
267 return mfree(address
);
270 DEFINE_TRIVIAL_REF_UNREF_FUNC(Address
, address
, address_free
);
272 static bool address_lifetime_is_valid(const Address
*a
) {
276 a
->lifetime_valid_usec
== USEC_INFINITY
||
277 a
->lifetime_valid_usec
> now(CLOCK_BOOTTIME
);
280 bool address_is_ready(const Address
*a
) {
284 if (!ipv4acd_bound(a
->link
, a
))
287 if (FLAGS_SET(a
->flags
, IFA_F_TENTATIVE
))
290 if (FLAGS_SET(a
->state
, NETWORK_CONFIG_STATE_REMOVING
))
293 if (!FLAGS_SET(a
->state
, NETWORK_CONFIG_STATE_CONFIGURED
))
296 return address_lifetime_is_valid(a
);
299 bool link_check_addresses_ready(Link
*link
, NetworkConfigSource source
) {
305 /* Check if all addresses on the interface are ready. If there is no address, this will return false. */
307 SET_FOREACH(a
, link
->addresses
) {
308 if (source
>= 0 && a
->source
!= source
)
310 if (address_is_marked(a
))
312 if (!address_exists(a
))
314 if (!address_is_ready(a
))
322 void link_mark_addresses(Link
*link
, NetworkConfigSource source
) {
327 SET_FOREACH(a
, link
->addresses
) {
328 if (a
->source
!= source
)
335 static int address_get_broadcast(const Address
*a
, Link
*link
, struct in_addr
*ret
) {
336 struct in_addr b_addr
= {};
341 /* Returns 0 when broadcast address is null, 1 when non-null broadcast address, -EAGAIN when the main
342 * address is null. */
344 /* broadcast is only for IPv4. */
345 if (a
->family
!= AF_INET
)
348 /* broadcast address cannot be used when peer address is specified. */
349 if (in4_addr_is_set(&a
->in_addr_peer
.in
))
352 /* A /31 or /32 IPv4 address does not have a broadcast address.
353 * See https://tools.ietf.org/html/rfc3021 */
354 if (a
->prefixlen
> 30)
357 /* If explicitly configured, use the address as is. */
358 if (in4_addr_is_set(&a
->broadcast
)) {
359 b_addr
= a
->broadcast
;
363 /* If explicitly disabled, then return null address. */
364 if (a
->set_broadcast
== 0)
367 /* For wireguard interfaces, broadcast is disabled by default. */
368 if (a
->set_broadcast
< 0 && streq_ptr(link
->kind
, "wireguard"))
371 /* If the main address is null, e.g. Address=0.0.0.0/24, the broadcast address will be automatically
372 * determined after an address is acquired. */
373 if (!in4_addr_is_set(&a
->in_addr
.in
))
376 /* Otherwise, generate a broadcast address from the main address and prefix length. */
377 b_addr
.s_addr
= a
->in_addr
.in
.s_addr
| htobe32(UINT32_C(0xffffffff) >> a
->prefixlen
);
383 return in4_addr_is_set(&b_addr
);
386 static void address_set_broadcast(Address
*a
, Link
*link
) {
388 assert_se(address_get_broadcast(a
, link
, &a
->broadcast
) >= 0);
391 static void address_set_cinfo(Manager
*m
, const Address
*a
, struct ifa_cacheinfo
*cinfo
) {
398 assert_se(sd_event_now(m
->event
, CLOCK_BOOTTIME
, &now_usec
) >= 0);
400 *cinfo
= (struct ifa_cacheinfo
) {
401 .ifa_valid
= usec_to_sec(a
->lifetime_valid_usec
, now_usec
),
402 .ifa_prefered
= usec_to_sec(a
->lifetime_preferred_usec
, now_usec
),
406 static void address_set_lifetime(Manager
*m
, Address
*a
, const struct ifa_cacheinfo
*cinfo
) {
413 assert_se(sd_event_now(m
->event
, CLOCK_BOOTTIME
, &now_usec
) >= 0);
415 a
->lifetime_valid_usec
= sec_to_usec(cinfo
->ifa_valid
, now_usec
);
416 a
->lifetime_preferred_usec
= sec_to_usec(cinfo
->ifa_prefered
, now_usec
);
419 static bool address_is_static_null(const Address
*address
) {
422 if (!address
->network
)
425 if (!address
->requested_as_null
)
428 assert(!in_addr_is_set(address
->family
, &address
->in_addr
));
432 static int address_ipv4_prefix(const Address
*a
, struct in_addr
*ret
) {
437 assert(a
->family
== AF_INET
);
440 p
= in4_addr_is_set(&a
->in_addr_peer
.in
) ? a
->in_addr_peer
.in
: a
->in_addr
.in
;
441 r
= in4_addr_mask(&p
, a
->prefixlen
);
449 static void address_hash_func(const Address
*a
, struct siphash
*state
) {
452 siphash24_compress_typesafe(a
->family
, state
);
456 struct in_addr prefix
;
458 siphash24_compress_typesafe(a
->prefixlen
, state
);
460 assert_se(address_ipv4_prefix(a
, &prefix
) >= 0);
461 siphash24_compress_typesafe(prefix
, state
);
463 siphash24_compress_typesafe(a
->in_addr
.in
, state
);
467 siphash24_compress_typesafe(a
->in_addr
.in6
, state
);
469 if (in6_addr_is_null(&a
->in_addr
.in6
))
470 siphash24_compress_typesafe(a
->prefixlen
, state
);
474 /* treat any other address family as AF_UNSPEC */
479 static int address_compare_func(const Address
*a1
, const Address
*a2
) {
482 r
= CMP(a1
->family
, a2
->family
);
486 switch (a1
->family
) {
488 struct in_addr p1
, p2
;
490 /* See kernel's find_matching_ifa() in net/ipv4/devinet.c */
491 r
= CMP(a1
->prefixlen
, a2
->prefixlen
);
495 assert_se(address_ipv4_prefix(a1
, &p1
) >= 0);
496 assert_se(address_ipv4_prefix(a2
, &p2
) >= 0);
497 r
= memcmp(&p1
, &p2
, sizeof(p1
));
501 return memcmp(&a1
->in_addr
.in
, &a2
->in_addr
.in
, sizeof(a1
->in_addr
.in
));
504 /* See kernel's ipv6_get_ifaddr() in net/ipv6/addrconf.c */
505 r
= memcmp(&a1
->in_addr
.in6
, &a2
->in_addr
.in6
, sizeof(a1
->in_addr
.in6
));
509 /* To distinguish IPv6 null addresses with different prefixlen, e.g. ::48 vs ::64, let's
510 * compare the prefix length. */
511 if (in6_addr_is_null(&a1
->in_addr
.in6
))
512 r
= CMP(a1
->prefixlen
, a2
->prefixlen
);
517 /* treat any other address family as AF_UNSPEC */
522 bool address_can_update(const Address
*existing
, const Address
*requesting
) {
527 * property | IPv4 | IPv6
528 * -----------------------------------------
530 * prefixlen | ✗ | ✗
531 * address | ✗ | ✗
534 * broadcast | ✗ | -
537 * lifetime | ✓ | ✓
538 * route metric | ✓ | ✓
539 * protocol | ✓ | ✓
541 * ✗ : cannot be changed
542 * ✓ : can be changed
545 * IPv4 : See inet_rtm_newaddr() in net/ipv4/devinet.c.
546 * IPv6 : See inet6_addr_modify() in net/ipv6/addrconf.c.
549 if (existing
->family
!= requesting
->family
)
552 if (existing
->prefixlen
!= requesting
->prefixlen
)
555 /* When a null address is requested, the address to be assigned/updated will be determined later. */
556 if (!address_is_static_null(requesting
) &&
557 in_addr_equal(existing
->family
, &existing
->in_addr
, &requesting
->in_addr
) <= 0)
560 switch (existing
->family
) {
562 struct in_addr bcast
;
564 if (existing
->scope
!= requesting
->scope
)
566 if (((existing
->flags
^ requesting
->flags
) & KNOWN_FLAGS
& ~IPV6ONLY_FLAGS
& ~UNMANAGED_FLAGS
) != 0)
568 if (!streq_ptr(existing
->label
, requesting
->label
))
570 if (!in4_addr_equal(&existing
->in_addr_peer
.in
, &requesting
->in_addr_peer
.in
))
572 if (existing
->link
&& address_get_broadcast(requesting
, existing
->link
, &bcast
) >= 0) {
573 /* If the broadcast address can be determined now, check if they match. */
574 if (!in4_addr_equal(&existing
->broadcast
, &bcast
))
577 /* When a null address is requested, then the broadcast address will be
578 * automatically calculated from the acquired address, e.g.
579 * 192.168.0.10/24 -> 192.168.0.255
580 * So, here let's only check if the broadcast is the last address in the range, e.g.
581 * 0.0.0.0/24 -> 0.0.0.255 */
582 if (!FLAGS_SET(existing
->broadcast
.s_addr
, htobe32(UINT32_C(0xffffffff) >> existing
->prefixlen
)))
591 assert_not_reached();
597 int address_dup(const Address
*src
, Address
**ret
) {
598 _cleanup_(address_unrefp
) Address
*dest
= NULL
;
604 dest
= newdup(Address
, src
, 1);
608 /* clear the reference counter and all pointers */
610 dest
->network
= NULL
;
611 dest
->section
= NULL
;
614 dest
->token
= ipv6_token_ref(src
->token
);
615 dest
->netlabel
= NULL
;
616 dest
->nft_set_context
.sets
= NULL
;
617 dest
->nft_set_context
.n_sets
= 0;
619 if (src
->family
== AF_INET
) {
620 r
= strdup_to(&dest
->label
, src
->label
);
625 r
= strdup_to(&dest
->netlabel
, src
->netlabel
);
629 r
= nft_set_context_dup(&src
->nft_set_context
, &dest
->nft_set_context
);
633 *ret
= TAKE_PTR(dest
);
637 static int address_set_masquerade(Address
*address
, bool add
) {
638 union in_addr_union masked
;
642 assert(address
->link
);
644 if (!address
->link
->network
)
647 if (address
->family
== AF_INET
&&
648 !FLAGS_SET(address
->link
->network
->ip_masquerade
, ADDRESS_FAMILY_IPV4
))
651 if (address
->family
== AF_INET6
&&
652 !FLAGS_SET(address
->link
->network
->ip_masquerade
, ADDRESS_FAMILY_IPV6
))
655 if (address
->scope
>= RT_SCOPE_LINK
)
658 if (address
->ip_masquerade_done
== add
)
661 masked
= address
->in_addr
;
662 r
= in_addr_mask(address
->family
, &masked
, address
->prefixlen
);
666 r
= fw_add_masquerade(&address
->link
->manager
->fw_ctx
, add
, address
->family
, &masked
, address
->prefixlen
);
670 address
->ip_masquerade_done
= add
;
675 static void address_modify_nft_set_context(Address
*address
, bool add
, NFTSetContext
*nft_set_context
) {
679 assert(address
->link
);
680 assert(address
->link
->manager
);
681 assert(nft_set_context
);
683 if (!address
->link
->manager
->fw_ctx
) {
684 r
= fw_ctx_new_full(&address
->link
->manager
->fw_ctx
, /* init_tables= */ false);
689 FOREACH_ARRAY(nft_set
, nft_set_context
->sets
, nft_set_context
->n_sets
) {
694 switch (nft_set
->source
) {
695 case NFT_SET_SOURCE_ADDRESS
:
696 r
= nft_set_element_modify_ip(address
->link
->manager
->fw_ctx
, add
, nft_set
->nfproto
, address
->family
, nft_set
->table
, nft_set
->set
,
699 case NFT_SET_SOURCE_PREFIX
:
700 r
= nft_set_element_modify_iprange(address
->link
->manager
->fw_ctx
, add
, nft_set
->nfproto
, address
->family
, nft_set
->table
, nft_set
->set
,
701 &address
->in_addr
, address
->prefixlen
);
703 case NFT_SET_SOURCE_IFINDEX
:
704 ifindex
= address
->link
->ifindex
;
705 r
= nft_set_element_modify_any(address
->link
->manager
->fw_ctx
, add
, nft_set
->nfproto
, nft_set
->table
, nft_set
->set
,
706 &ifindex
, sizeof(ifindex
));
709 assert_not_reached();
713 log_warning_errno(r
, "Failed to %s NFT set: family %s, table %s, set %s, IP address %s, ignoring: %m",
714 add
? "add" : "delete",
715 nfproto_to_string(nft_set
->nfproto
), nft_set
->table
, nft_set
->set
,
716 IN_ADDR_PREFIX_TO_STRING(address
->family
, &address
->in_addr
, address
->prefixlen
));
718 log_debug("%s NFT set: family %s, table %s, set %s, IP address %s",
719 add
? "Added" : "Deleted",
720 nfproto_to_string(nft_set
->nfproto
), nft_set
->table
, nft_set
->set
,
721 IN_ADDR_PREFIX_TO_STRING(address
->family
, &address
->in_addr
, address
->prefixlen
));
725 static void address_modify_nft_set(Address
*address
, bool add
) {
727 assert(address
->link
);
729 if (!IN_SET(address
->family
, AF_INET
, AF_INET6
))
732 if (!address
->link
->network
)
735 switch (address
->source
) {
736 case NETWORK_CONFIG_SOURCE_DHCP4
:
737 return address_modify_nft_set_context(address
, add
, &address
->link
->network
->dhcp_nft_set_context
);
738 case NETWORK_CONFIG_SOURCE_DHCP6
:
739 return address_modify_nft_set_context(address
, add
, &address
->link
->network
->dhcp6_nft_set_context
);
740 case NETWORK_CONFIG_SOURCE_DHCP_PD
:
741 return address_modify_nft_set_context(address
, add
, &address
->link
->network
->dhcp_pd_nft_set_context
);
742 case NETWORK_CONFIG_SOURCE_NDISC
:
743 return address_modify_nft_set_context(address
, add
, &address
->link
->network
->ndisc_nft_set_context
);
744 case NETWORK_CONFIG_SOURCE_STATIC
:
745 return address_modify_nft_set_context(address
, add
, &address
->nft_set_context
);
751 static int address_attach(Link
*link
, Address
*address
) {
756 assert(!address
->link
);
758 r
= set_ensure_put(&link
->addresses
, &address_hash_ops_detach
, address
);
764 address
->link
= link
;
765 address_ref(address
);
769 static int address_update(Address
*address
) {
770 Link
*link
= ASSERT_PTR(ASSERT_PTR(address
)->link
);
773 if (address_is_ready(address
) &&
774 address
->family
== AF_INET6
&&
775 in6_addr_is_link_local(&address
->in_addr
.in6
) &&
776 in6_addr_is_null(&link
->ipv6ll_address
)) {
778 link
->ipv6ll_address
= address
->in_addr
.in6
;
780 r
= link_ipv6ll_gained(link
);
785 if (IN_SET(link
->state
, LINK_STATE_FAILED
, LINK_STATE_LINGER
))
788 r
= address_set_masquerade(address
, /* add = */ true);
790 return log_link_warning_errno(link
, r
, "Could not enable IP masquerading: %m");
792 address_add_netlabel(address
);
794 address_modify_nft_set(address
, /* add = */ true);
796 if (address_is_ready(address
) && address
->callback
) {
797 r
= address
->callback(address
);
802 link_update_operstate(link
, /* also_update_master = */ true);
803 link_check_ready(link
);
807 static int address_removed_maybe_kernel_dad(Link
*link
, Address
*address
) {
813 if (!IN_SET(link
->state
, LINK_STATE_CONFIGURING
, LINK_STATE_CONFIGURED
))
816 if (address
->family
!= AF_INET6
)
819 if (!FLAGS_SET(address
->flags
, IFA_F_TENTATIVE
))
822 log_link_info(link
, "Address %s with tentative flag is removed, maybe a duplicated address is assigned on another node or link?",
823 IN6_ADDR_TO_STRING(&address
->in_addr
.in6
));
825 /* Reset the address state, as the object may be reused in the below. */
828 switch (address
->source
) {
829 case NETWORK_CONFIG_SOURCE_STATIC
:
830 r
= link_reconfigure_radv_address(address
, link
);
832 case NETWORK_CONFIG_SOURCE_DHCP_PD
:
833 r
= dhcp_pd_reconfigure_address(address
, link
);
835 case NETWORK_CONFIG_SOURCE_NDISC
:
836 r
= ndisc_reconfigure_address(address
, link
);
842 return log_link_warning_errno(link
, r
, "Failed to configure an alternative address: %m");
847 static int address_drop(Address
*in
, bool removed_by_us
) {
848 _cleanup_(address_unrefp
) Address
*address
= address_ref(ASSERT_PTR(in
));
849 Link
*link
= ASSERT_PTR(address
->link
);
852 r
= address_set_masquerade(address
, /* add = */ false);
854 log_link_warning_errno(link
, r
, "Failed to disable IP masquerading, ignoring: %m");
856 address_modify_nft_set(address
, /* add = */ false);
858 address_del_netlabel(address
);
860 /* FIXME: if the IPv6LL address is dropped, stop DHCPv6, NDISC, RADV. */
861 if (address
->family
== AF_INET6
&&
862 in6_addr_equal(&address
->in_addr
.in6
, &link
->ipv6ll_address
))
863 link
->ipv6ll_address
= (const struct in6_addr
) {};
865 ipv4acd_detach(link
, address
);
867 address_detach(address
);
869 if (!removed_by_us
) {
870 r
= address_removed_maybe_kernel_dad(link
, address
);
872 link_enter_failed(link
);
877 link_update_operstate(link
, /* also_update_master = */ true);
878 link_check_ready(link
);
882 static bool address_match_null(const Address
*a
, const Address
*null_address
) {
884 assert(null_address
);
886 if (!a
->requested_as_null
)
889 /* Currently, null address is supported only by static addresses. Note that static
890 * address may be set as foreign during reconfiguring the interface. */
891 if (!IN_SET(a
->source
, NETWORK_CONFIG_SOURCE_FOREIGN
, NETWORK_CONFIG_SOURCE_STATIC
))
894 if (a
->family
!= null_address
->family
)
897 if (a
->prefixlen
!= null_address
->prefixlen
)
903 static int address_get_request(Link
*link
, const Address
*address
, Request
**ret
) {
907 assert(link
->manager
);
910 req
= ordered_set_get(
911 link
->manager
->request_queue
,
914 .type
= REQUEST_TYPE_ADDRESS
,
915 .userdata
= (void*) address
,
916 .hash_func
= (hash_func_t
) address_hash_func
,
917 .compare_func
= (compare_func_t
) address_compare_func
,
925 if (address_is_static_null(address
))
926 ORDERED_SET_FOREACH(req
, link
->manager
->request_queue
) {
927 if (req
->link
!= link
)
929 if (req
->type
!= REQUEST_TYPE_ADDRESS
)
932 if (!address_match_null(req
->userdata
, address
))
944 int address_get(Link
*link
, const Address
*in
, Address
**ret
) {
950 a
= set_get(link
->addresses
, in
);
957 /* Find matching address that originally requested as null address. */
958 if (address_is_static_null(in
))
959 SET_FOREACH(a
, link
->addresses
) {
960 if (!address_match_null(a
, in
))
971 int address_get_harder(Link
*link
, const Address
*in
, Address
**ret
) {
978 if (address_get(link
, in
, ret
) >= 0)
981 r
= address_get_request(link
, in
, &req
);
986 *ret
= ASSERT_PTR(req
->userdata
);
991 int link_get_address(Link
*link
, int family
, const union in_addr_union
*address
, unsigned char prefixlen
, Address
**ret
) {
996 assert(IN_SET(family
, AF_INET
, AF_INET6
));
999 /* This find an Address object on the link which matches the given address and prefix length
1000 * and does not have peer address. When the prefixlen is zero, then an Address object with an
1001 * arbitrary prefixlen will be returned. */
1003 if (family
== AF_INET6
|| prefixlen
!= 0) {
1004 _cleanup_(address_unrefp
) Address
*tmp
= NULL
;
1006 /* In this case, we can use address_get(). */
1008 r
= address_new(&tmp
);
1012 tmp
->family
= family
;
1013 tmp
->in_addr
= *address
;
1014 tmp
->prefixlen
= prefixlen
;
1016 r
= address_get(link
, tmp
, &a
);
1020 if (family
== AF_INET6
) {
1021 /* IPv6 addresses are managed without peer address and prefix length. Hence, we need
1022 * to check them explicitly. */
1023 if (in_addr_is_set(family
, &a
->in_addr_peer
))
1025 if (prefixlen
!= 0 && a
->prefixlen
!= prefixlen
)
1035 SET_FOREACH(a
, link
->addresses
) {
1036 if (a
->family
!= family
)
1039 if (!in_addr_equal(family
, &a
->in_addr
, address
))
1042 if (in_addr_is_set(family
, &a
->in_addr_peer
))
1054 int manager_get_address(Manager
*manager
, int family
, const union in_addr_union
*address
, unsigned char prefixlen
, Address
**ret
) {
1058 assert(IN_SET(family
, AF_INET
, AF_INET6
));
1061 HASHMAP_FOREACH(link
, manager
->links_by_index
) {
1062 if (!IN_SET(link
->state
, LINK_STATE_CONFIGURING
, LINK_STATE_CONFIGURED
))
1065 if (link_get_address(link
, family
, address
, prefixlen
, ret
) >= 0)
1072 bool manager_has_address(Manager
*manager
, int family
, const union in_addr_union
*address
) {
1076 assert(IN_SET(family
, AF_INET
, AF_INET6
));
1079 if (manager_get_address(manager
, family
, address
, 0, &a
) < 0)
1082 return address_is_ready(a
);
1085 const char* format_lifetime(char *buf
, size_t l
, usec_t lifetime_usec
) {
1089 if (lifetime_usec
== USEC_INFINITY
)
1092 sprintf(buf
, "for ");
1093 /* format_timespan() never fails */
1094 assert_se(format_timespan(buf
+ 4, l
- 4, usec_sub_unsigned(lifetime_usec
, now(CLOCK_BOOTTIME
)), USEC_PER_SEC
));
1098 static void log_address_debug(const Address
*address
, const char *str
, const Link
*link
) {
1099 _cleanup_free_
char *state
= NULL
, *flags_str
= NULL
, *scope_str
= NULL
;
1108 (void) network_config_state_to_string_alloc(address
->state
, &state
);
1110 const char *peer
= in_addr_is_set(address
->family
, &address
->in_addr_peer
) ?
1111 IN_ADDR_TO_STRING(address
->family
, &address
->in_addr_peer
) : NULL
;
1113 const char *broadcast
= (address
->family
== AF_INET
&& in4_addr_is_set(&address
->broadcast
)) ?
1114 IN4_ADDR_TO_STRING(&address
->broadcast
) : NULL
;
1116 (void) address_flags_to_string_alloc(address
->flags
, address
->family
, &flags_str
);
1117 (void) route_scope_to_string_alloc(address
->scope
, &scope_str
);
1119 log_link_debug(link
, "%s %s address (%s): %s%s%s/%u%s%s (valid %s, preferred %s), flags: %s, scope: %s%s%s",
1120 str
, strna(network_config_source_to_string(address
->source
)), strna(state
),
1121 IN_ADDR_TO_STRING(address
->family
, &address
->in_addr
),
1122 peer
? " peer " : "", strempty(peer
), address
->prefixlen
,
1123 broadcast
? " broadcast " : "", strempty(broadcast
),
1124 FORMAT_LIFETIME(address
->lifetime_valid_usec
),
1125 FORMAT_LIFETIME(address
->lifetime_preferred_usec
),
1126 strna(flags_str
), strna(scope_str
),
1127 address
->family
== AF_INET
? ", label: " : "",
1128 address
->family
== AF_INET
? strna(address
->label
) : "");
1131 static int address_set_netlink_message(const Address
*address
, sd_netlink_message
*m
, Link
*link
) {
1139 r
= sd_rtnl_message_addr_set_prefixlen(m
, address
->prefixlen
);
1143 /* On remove, only IFA_F_MANAGETEMPADDR flag for IPv6 addresses are used. But anyway, set all
1144 * flags except tentative flag here unconditionally. Without setting the flag, the template
1145 * addresses generated by kernel will not be removed automatically when the main address is
1147 flags
= address
->flags
& ~IFA_F_TENTATIVE
;
1148 r
= sd_rtnl_message_addr_set_flags(m
, flags
& 0xff);
1152 if ((flags
& ~0xff) != 0) {
1153 r
= sd_netlink_message_append_u32(m
, IFA_FLAGS
, flags
);
1158 r
= netlink_message_append_in_addr_union(m
, IFA_LOCAL
, address
->family
, &address
->in_addr
);
1165 static int address_remove_handler(sd_netlink
*rtnl
, sd_netlink_message
*m
, RemoveRequest
*rreq
) {
1171 Link
*link
= ASSERT_PTR(rreq
->link
);
1172 Address
*address
= ASSERT_PTR(rreq
->userdata
);
1174 if (link
->state
== LINK_STATE_LINGER
)
1177 r
= sd_netlink_message_get_errno(m
);
1179 log_link_message_full_errno(link
, m
,
1180 (r
== -EADDRNOTAVAIL
|| !address
->link
) ? LOG_DEBUG
: LOG_WARNING
,
1181 r
, "Could not drop address");
1183 if (address
->link
) {
1184 /* If the address cannot be removed, then assume the address is already removed. */
1185 log_address_debug(address
, "Forgetting", link
);
1188 if (address_get_request(link
, address
, &req
) >= 0)
1189 address_enter_removed(req
->userdata
);
1191 (void) address_drop(address
, /* removed_by_us = */ true);
1198 int address_remove(Address
*address
, Link
*link
) {
1199 _cleanup_(sd_netlink_message_unrefp
) sd_netlink_message
*m
= NULL
;
1203 assert(IN_SET(address
->family
, AF_INET
, AF_INET6
));
1205 assert(link
->ifindex
> 0);
1206 assert(link
->manager
);
1207 assert(link
->manager
->rtnl
);
1209 /* If the address is remembered, use the remembered object. */
1210 (void) address_get(link
, address
, &address
);
1212 log_address_debug(address
, "Removing", link
);
1214 r
= sd_rtnl_message_new_addr(link
->manager
->rtnl
, &m
, RTM_DELADDR
,
1215 link
->ifindex
, address
->family
);
1217 return log_link_warning_errno(link
, r
, "Could not allocate RTM_DELADDR message: %m");
1219 r
= address_set_netlink_message(address
, m
, link
);
1221 return log_link_warning_errno(link
, r
, "Could not set netlink attributes: %m");
1223 r
= link_remove_request_add(link
, address
, address
, link
->manager
->rtnl
, m
, address_remove_handler
);
1225 return log_link_warning_errno(link
, r
, "Could not queue rtnetlink message: %m");
1227 address_enter_removing(address
);
1229 /* The operational state is determined by address state and carrier state. Hence, if we remove
1230 * an address, the operational state may be changed. */
1231 link_update_operstate(link
, true);
1235 int address_remove_and_cancel(Address
*address
, Link
*link
) {
1236 _cleanup_(request_unrefp
) Request
*req
= NULL
;
1237 bool waiting
= false;
1241 assert(link
->manager
);
1243 /* If the address is remembered by the link, then use the remembered object. */
1244 (void) address_get(link
, address
, &address
);
1246 /* Cancel the request for the address. If the request is already called but we have not received the
1247 * notification about the request, then explicitly remove the address. */
1248 if (address_get_request(link
, address
, &req
) >= 0) {
1249 request_ref(req
); /* avoid the request freed by request_detach() */
1250 waiting
= req
->waiting_reply
;
1251 request_detach(req
);
1252 address_cancel_requesting(address
);
1255 /* If we know the address will come or already exists, remove it. */
1256 if (waiting
|| (address
->link
&& address_exists(address
)))
1257 return address_remove(address
, link
);
1262 bool link_address_is_dynamic(const Link
*link
, const Address
*address
) {
1266 assert(link
->manager
);
1269 if (address
->lifetime_preferred_usec
!= USEC_INFINITY
)
1272 /* Even when the address is leased from a DHCP server, networkd assign the address
1273 * without lifetime when KeepConfiguration=dhcp. So, let's check that we have
1274 * corresponding routes with RTPROT_DHCP. */
1275 SET_FOREACH(route
, link
->manager
->routes
) {
1276 if (route
->source
!= NETWORK_CONFIG_SOURCE_FOREIGN
)
1279 /* The route is not assigned yet, or already removed. Ignoring. */
1280 if (!route_exists(route
))
1283 if (route
->protocol
!= RTPROT_DHCP
)
1286 if (route
->nexthop
.ifindex
!= link
->ifindex
)
1289 if (address
->family
!= route
->family
)
1292 if (in_addr_equal(address
->family
, &address
->in_addr
, &route
->prefsrc
))
1299 int link_drop_ipv6ll_addresses(Link
*link
) {
1300 _cleanup_(sd_netlink_message_unrefp
) sd_netlink_message
*req
= NULL
, *reply
= NULL
;
1304 assert(link
->manager
);
1305 assert(link
->manager
->rtnl
);
1307 /* IPv6LL address may be in the tentative state, and in that case networkd has not received it.
1308 * So, we need to dump all IPv6 addresses. */
1310 if (link_may_have_ipv6ll(link
, /* check_multicast = */ false))
1313 r
= sd_rtnl_message_new_addr(link
->manager
->rtnl
, &req
, RTM_GETADDR
, link
->ifindex
, AF_INET6
);
1317 r
= sd_netlink_message_set_request_dump(req
, true);
1321 r
= sd_netlink_call(link
->manager
->rtnl
, req
, 0, &reply
);
1325 for (sd_netlink_message
*addr
= reply
; addr
; addr
= sd_netlink_message_next(addr
)) {
1326 _cleanup_(address_unrefp
) Address
*a
= NULL
;
1327 unsigned char flags
, prefixlen
;
1328 struct in6_addr address
;
1331 /* NETLINK_GET_STRICT_CHK socket option is supported since kernel 4.20. To support
1332 * older kernels, we need to check ifindex here. */
1333 r
= sd_rtnl_message_addr_get_ifindex(addr
, &ifindex
);
1335 log_link_debug_errno(link
, r
, "rtnl: received address message without valid ifindex, ignoring: %m");
1337 } else if (link
->ifindex
!= ifindex
)
1340 r
= sd_rtnl_message_addr_get_flags(addr
, &flags
);
1342 log_link_debug_errno(link
, r
, "rtnl: received address message without valid flags, ignoring: %m");
1346 r
= sd_rtnl_message_addr_get_prefixlen(addr
, &prefixlen
);
1348 log_link_debug_errno(link
, r
, "rtnl: received address message without prefixlen, ignoring: %m");
1352 if (sd_netlink_message_read_in6_addr(addr
, IFA_LOCAL
, NULL
) >= 0)
1353 /* address with peer, ignoring. */
1356 r
= sd_netlink_message_read_in6_addr(addr
, IFA_ADDRESS
, &address
);
1358 log_link_debug_errno(link
, r
, "rtnl: received address message without valid address, ignoring: %m");
1362 if (!in6_addr_is_link_local(&address
))
1365 r
= address_new(&a
);
1369 a
->family
= AF_INET6
;
1370 a
->in_addr
.in6
= address
;
1371 a
->prefixlen
= prefixlen
;
1374 r
= address_remove(a
, link
);
1382 int link_drop_foreign_addresses(Link
*link
) {
1387 assert(link
->network
);
1389 /* First, mark all addresses. */
1390 SET_FOREACH(address
, link
->addresses
) {
1391 /* We consider IPv6LL addresses to be managed by the kernel, or dropped in link_drop_ipv6ll_addresses() */
1392 if (address
->family
== AF_INET6
&& in6_addr_is_link_local(&address
->in_addr
.in6
))
1395 /* Do not remove localhost address (127.0.0.1 and ::1) */
1396 if (link
->flags
& IFF_LOOPBACK
&& in_addr_is_localhost_one(address
->family
, &address
->in_addr
) > 0)
1399 /* Ignore addresses we configured. */
1400 if (address
->source
!= NETWORK_CONFIG_SOURCE_FOREIGN
)
1403 /* Ignore addresses not assigned yet or already removing. */
1404 if (!address_exists(address
))
1407 /* link_address_is_dynamic() is slightly heavy. Let's call the function only when KeepConfiguration= is set. */
1408 if (IN_SET(link
->network
->keep_configuration
, KEEP_CONFIGURATION_DHCP
, KEEP_CONFIGURATION_STATIC
) &&
1409 link_address_is_dynamic(link
, address
) == (link
->network
->keep_configuration
== KEEP_CONFIGURATION_DHCP
))
1412 address_mark(address
);
1415 /* Then, unmark requested addresses. */
1416 ORDERED_HASHMAP_FOREACH(address
, link
->network
->addresses_by_section
) {
1419 if (address_get(link
, address
, &existing
) < 0)
1422 if (!address_can_update(existing
, address
))
1425 /* Found matching static configuration. Keep the existing address. */
1426 address_unmark(existing
);
1429 /* Finally, remove all marked addresses. */
1430 SET_FOREACH(address
, link
->addresses
) {
1431 if (!address_is_marked(address
))
1434 RET_GATHER(r
, address_remove(address
, link
));
1440 int link_drop_static_addresses(Link
*link
) {
1446 SET_FOREACH(address
, link
->addresses
) {
1447 /* Remove only static addresses here. Dynamic addresses will be removed e.g. on lease
1448 * expiration or stopping the DHCP client. */
1449 if (address
->source
!= NETWORK_CONFIG_SOURCE_STATIC
)
1452 /* Ignore addresses not assigned yet or already removing. */
1453 if (!address_exists(address
))
1456 RET_GATHER(r
, address_remove(address
, link
));
1462 void link_foreignize_addresses(Link
*link
) {
1467 SET_FOREACH(address
, link
->addresses
)
1468 address
->source
= NETWORK_CONFIG_SOURCE_FOREIGN
;
1471 int address_configure_handler_internal(sd_netlink
*rtnl
, sd_netlink_message
*m
, Link
*link
, const char *error_msg
) {
1479 r
= sd_netlink_message_get_errno(m
);
1480 if (r
< 0 && r
!= -EEXIST
) {
1481 log_link_message_warning_errno(link
, m
, r
, error_msg
);
1482 link_enter_failed(link
);
1489 static int address_configure(const Address
*address
, const struct ifa_cacheinfo
*c
, Link
*link
, Request
*req
) {
1490 _cleanup_(sd_netlink_message_unrefp
) sd_netlink_message
*m
= NULL
;
1494 assert(IN_SET(address
->family
, AF_INET
, AF_INET6
));
1497 assert(link
->ifindex
> 0);
1498 assert(link
->manager
);
1499 assert(link
->manager
->rtnl
);
1502 log_address_debug(address
, "Configuring", link
);
1504 r
= sd_rtnl_message_new_addr_update(link
->manager
->rtnl
, &m
, link
->ifindex
, address
->family
);
1508 r
= address_set_netlink_message(address
, m
, link
);
1512 r
= sd_rtnl_message_addr_set_scope(m
, address
->scope
);
1516 if (address
->family
== AF_INET6
|| in_addr_is_set(address
->family
, &address
->in_addr_peer
)) {
1517 r
= netlink_message_append_in_addr_union(m
, IFA_ADDRESS
, address
->family
, &address
->in_addr_peer
);
1520 } else if (in4_addr_is_set(&address
->broadcast
)) {
1521 r
= sd_netlink_message_append_in_addr(m
, IFA_BROADCAST
, &address
->broadcast
);
1526 if (address
->family
== AF_INET
&& address
->label
) {
1527 r
= sd_netlink_message_append_string(m
, IFA_LABEL
, address
->label
);
1532 r
= sd_netlink_message_append_cache_info(m
, IFA_CACHEINFO
, c
);
1536 r
= sd_netlink_message_append_u32(m
, IFA_RT_PRIORITY
, address
->route_metric
);
1540 return request_call_netlink_async(link
->manager
->rtnl
, m
, req
);
1543 static int address_acquire(Link
*link
, const Address
*address
, union in_addr_union
*ret
) {
1544 union in_addr_union a
;
1551 r
= address_acquire_from_dhcp_server_leases_file(link
, address
, ret
);
1552 if (!IN_SET(r
, -ENOENT
, -ENXIO
, -EINVAL
))
1555 r
= address_pool_acquire(link
->manager
, address
->family
, address
->prefixlen
, &a
);
1561 /* Pick first address in range for ourselves. */
1562 if (address
->family
== AF_INET
)
1563 a
.in
.s_addr
|= htobe32(1);
1564 else if (address
->family
== AF_INET6
)
1565 a
.in6
.s6_addr
[15] |= 1;
1567 assert_not_reached();
1573 static int address_requeue_request(Request
*req
, Link
*link
, const Address
*address
) {
1578 assert(link
->manager
);
1579 assert(link
->network
);
1582 /* Something useful was configured? just use it */
1583 if (in_addr_is_set(address
->family
, &address
->in_addr
))
1586 /* The address is configured to be 0.0.0.0 or [::] by the user?
1587 * Then let's acquire something more useful. */
1588 union in_addr_union a
;
1589 r
= address_acquire(link
, address
, &a
);
1593 _cleanup_(address_unrefp
) Address
*tmp
= NULL
;
1594 r
= address_dup(address
, &tmp
);
1600 r
= link_requeue_request(link
, req
, tmp
, NULL
);
1604 return -EEXIST
; /* Already queued?? Strange... */
1607 return 1; /* A new request is queued. it is not necessary to process this request anymore. */
1610 static int address_process_request(Request
*req
, Link
*link
, Address
*address
) {
1612 struct ifa_cacheinfo c
;
1619 if (!link_is_ready_to_configure(link
, false))
1622 /* Refuse adding more than the limit */
1623 if (set_size(link
->addresses
) >= ADDRESSES_PER_LINK_MAX
)
1626 r
= address_requeue_request(req
, link
, address
);
1632 address_set_broadcast(address
, link
);
1634 r
= ipv4acd_configure(link
, address
);
1638 if (!ipv4acd_bound(link
, address
))
1641 address_set_cinfo(link
->manager
, address
, &c
);
1642 if (c
.ifa_valid
== 0) {
1643 log_link_debug(link
, "Refuse to configure %s address %s, as its valid lifetime is zero.",
1644 network_config_source_to_string(address
->source
),
1645 IN_ADDR_PREFIX_TO_STRING(address
->family
, &address
->in_addr
, address
->prefixlen
));
1647 address_cancel_requesting(address
);
1648 if (address_get(link
, address
, &existing
) >= 0)
1649 address_cancel_requesting(existing
);
1653 r
= address_configure(address
, &c
, link
, req
);
1655 return log_link_warning_errno(link
, r
, "Failed to configure address: %m");
1657 address_enter_configuring(address
);
1658 if (address_get(link
, address
, &existing
) >= 0)
1659 address_enter_configuring(existing
);
1664 int link_request_address(
1666 const Address
*address
,
1667 unsigned *message_counter
,
1668 address_netlink_handler_t netlink_handler
,
1671 _cleanup_(address_unrefp
) Address
*tmp
= NULL
;
1672 Address
*existing
= NULL
;
1677 assert(address
->source
!= NETWORK_CONFIG_SOURCE_FOREIGN
);
1679 if (address
->lifetime_valid_usec
== 0)
1680 /* The requested address is outdated. Let's ignore the request. */
1683 if (address_get_request(link
, address
, NULL
) >= 0)
1684 return 0; /* already requested, skipping. */
1686 r
= address_dup(address
, &tmp
);
1690 if (address_get(link
, address
, &existing
) >= 0) {
1691 /* Copy already assigned address when it is requested as a null address. */
1692 if (address_is_static_null(address
))
1693 tmp
->in_addr
= existing
->in_addr
;
1695 /* Copy state for logging below. */
1696 tmp
->state
= existing
->state
;
1699 log_address_debug(tmp
, "Requesting", link
);
1700 r
= link_queue_request_safe(link
, REQUEST_TYPE_ADDRESS
,
1704 address_compare_func
,
1705 address_process_request
,
1706 message_counter
, netlink_handler
, ret
);
1708 return log_link_warning_errno(link
, r
, "Failed to request address: %m");
1712 address_enter_requesting(tmp
);
1714 address_enter_requesting(existing
);
1720 static int static_address_handler(sd_netlink
*rtnl
, sd_netlink_message
*m
, Request
*req
, Link
*link
, Address
*address
) {
1725 r
= address_configure_handler_internal(rtnl
, m
, link
, "Failed to set static address");
1729 if (link
->static_address_messages
== 0) {
1730 log_link_debug(link
, "Addresses set");
1731 link
->static_addresses_configured
= true;
1732 link_check_ready(link
);
1738 int link_request_static_address(Link
*link
, const Address
*address
) {
1741 assert(address
->source
== NETWORK_CONFIG_SOURCE_STATIC
);
1743 return link_request_address(link
, address
, &link
->static_address_messages
,
1744 static_address_handler
, NULL
);
1747 int link_request_static_addresses(Link
*link
) {
1752 assert(link
->network
);
1754 link
->static_addresses_configured
= false;
1756 ORDERED_HASHMAP_FOREACH(a
, link
->network
->addresses_by_section
) {
1757 r
= link_request_static_address(link
, a
);
1762 r
= link_request_radv_addresses(link
);
1766 if (link
->static_address_messages
== 0) {
1767 link
->static_addresses_configured
= true;
1768 link_check_ready(link
);
1770 log_link_debug(link
, "Setting addresses");
1771 link_set_state(link
, LINK_STATE_CONFIGURING
);
1777 int manager_rtnl_process_address(sd_netlink
*rtnl
, sd_netlink_message
*message
, Manager
*m
) {
1778 _cleanup_(address_unrefp
) Address
*tmp
= NULL
;
1779 struct ifa_cacheinfo cinfo
;
1782 Address
*address
= NULL
;
1783 Request
*req
= NULL
;
1784 bool is_new
= false, update_dhcp4
;
1791 if (sd_netlink_message_is_error(message
)) {
1792 r
= sd_netlink_message_get_errno(message
);
1794 log_message_warning_errno(message
, r
, "rtnl: failed to receive address message, ignoring");
1799 r
= sd_netlink_message_get_type(message
, &type
);
1801 log_warning_errno(r
, "rtnl: could not get message type, ignoring: %m");
1803 } else if (!IN_SET(type
, RTM_NEWADDR
, RTM_DELADDR
)) {
1804 log_warning("rtnl: received unexpected message type %u when processing address, ignoring.", type
);
1808 r
= sd_rtnl_message_addr_get_ifindex(message
, &ifindex
);
1810 log_warning_errno(r
, "rtnl: could not get ifindex from message, ignoring: %m");
1812 } else if (ifindex
<= 0) {
1813 log_warning("rtnl: received address message with invalid ifindex %d, ignoring.", ifindex
);
1817 r
= link_get_by_index(m
, ifindex
, &link
);
1819 /* when enumerating we might be out of sync, but we will get the address again, so just
1821 if (!m
->enumerating
)
1822 log_warning("rtnl: received address for link '%d' we don't know about, ignoring.", ifindex
);
1826 r
= address_new(&tmp
);
1830 /* First, read minimal information to make address_get() work below. */
1832 r
= sd_rtnl_message_addr_get_family(message
, &tmp
->family
);
1834 log_link_warning(link
, "rtnl: received address message without family, ignoring.");
1836 } else if (!IN_SET(tmp
->family
, AF_INET
, AF_INET6
)) {
1837 log_link_debug(link
, "rtnl: received address message with invalid family '%i', ignoring.", tmp
->family
);
1841 r
= sd_rtnl_message_addr_get_prefixlen(message
, &tmp
->prefixlen
);
1843 log_link_warning_errno(link
, r
, "rtnl: received address message without prefixlen, ignoring: %m");
1847 switch (tmp
->family
) {
1849 r
= sd_netlink_message_read_in_addr(message
, IFA_LOCAL
, &tmp
->in_addr
.in
);
1851 log_link_warning_errno(link
, r
, "rtnl: received address message without valid address, ignoring: %m");
1855 r
= sd_netlink_message_read_in_addr(message
, IFA_ADDRESS
, &tmp
->in_addr_peer
.in
);
1856 if (r
< 0 && r
!= -ENODATA
) {
1857 log_link_warning_errno(link
, r
, "rtnl: could not get peer address from address message, ignoring: %m");
1859 } else if (r
>= 0) {
1860 if (in4_addr_equal(&tmp
->in_addr
.in
, &tmp
->in_addr_peer
.in
))
1861 tmp
->in_addr_peer
= IN_ADDR_NULL
;
1867 r
= sd_netlink_message_read_in6_addr(message
, IFA_LOCAL
, &tmp
->in_addr
.in6
);
1869 /* Have peer address. */
1870 r
= sd_netlink_message_read_in6_addr(message
, IFA_ADDRESS
, &tmp
->in_addr_peer
.in6
);
1872 log_link_warning_errno(link
, r
, "rtnl: could not get peer address from address message, ignoring: %m");
1875 } else if (r
== -ENODATA
) {
1876 /* Does not have peer address. */
1877 r
= sd_netlink_message_read_in6_addr(message
, IFA_ADDRESS
, &tmp
->in_addr
.in6
);
1879 log_link_warning_errno(link
, r
, "rtnl: received address message without valid address, ignoring: %m");
1883 log_link_warning_errno(link
, r
, "rtnl: could not get local address from address message, ignoring: %m");
1890 assert_not_reached();
1893 update_dhcp4
= tmp
->family
== AF_INET6
;
1895 /* Then, find the managed Address and Request objects corresponding to the received address. */
1896 (void) address_get(link
, tmp
, &address
);
1897 (void) address_get_request(link
, tmp
, &req
);
1899 if (type
== RTM_DELADDR
) {
1901 bool removed_by_us
= FLAGS_SET(address
->state
, NETWORK_CONFIG_STATE_REMOVING
);
1903 address_enter_removed(address
);
1904 log_address_debug(address
, "Forgetting removed", link
);
1905 (void) address_drop(address
, removed_by_us
);
1907 log_address_debug(tmp
, "Kernel removed unknown", link
);
1910 address_enter_removed(req
->userdata
);
1916 /* If we did not know the address, then save it. */
1917 r
= address_attach(link
, tmp
);
1919 log_link_warning_errno(link
, r
, "Failed to save received address %s, ignoring: %m",
1920 IN_ADDR_PREFIX_TO_STRING(tmp
->family
, &tmp
->in_addr
, tmp
->prefixlen
));
1928 /* Otherwise, update the managed Address object with the netlink notification. */
1929 address
->prefixlen
= tmp
->prefixlen
;
1930 address
->in_addr_peer
= tmp
->in_addr_peer
;
1933 /* Also update information that cannot be obtained through netlink notification. */
1934 if (req
&& req
->waiting_reply
) {
1935 Address
*a
= ASSERT_PTR(req
->userdata
);
1937 address
->source
= a
->source
;
1938 address
->provider
= a
->provider
;
1939 (void) free_and_strdup_warn(&address
->netlabel
, a
->netlabel
);
1940 nft_set_context_clear(&address
->nft_set_context
);
1941 (void) nft_set_context_dup(&a
->nft_set_context
, &address
->nft_set_context
);
1942 address
->requested_as_null
= a
->requested_as_null
;
1943 address
->callback
= a
->callback
;
1945 ipv6_token_ref(a
->token
);
1946 ipv6_token_unref(address
->token
);
1947 address
->token
= a
->token
;
1950 /* Then, update miscellaneous info. */
1951 r
= sd_rtnl_message_addr_get_scope(message
, &address
->scope
);
1953 log_link_debug_errno(link
, r
, "rtnl: received address message without scope, ignoring: %m");
1955 if (address
->family
== AF_INET
) {
1956 _cleanup_free_
char *label
= NULL
;
1958 r
= sd_netlink_message_read_string_strdup(message
, IFA_LABEL
, &label
);
1960 if (!streq_ptr(label
, link
->ifname
))
1961 free_and_replace(address
->label
, label
);
1962 } else if (r
!= -ENODATA
)
1963 log_link_debug_errno(link
, r
, "rtnl: could not get label from address message, ignoring: %m");
1965 r
= sd_netlink_message_read_in_addr(message
, IFA_BROADCAST
, &address
->broadcast
);
1966 if (r
< 0 && r
!= -ENODATA
)
1967 log_link_debug_errno(link
, r
, "rtnl: could not get broadcast from address message, ignoring: %m");
1970 r
= sd_netlink_message_read_u32(message
, IFA_FLAGS
, &address
->flags
);
1971 if (r
== -ENODATA
) {
1972 unsigned char flags
;
1974 /* For old kernels. */
1975 r
= sd_rtnl_message_addr_get_flags(message
, &flags
);
1977 address
->flags
= flags
;
1979 log_link_debug_errno(link
, r
, "rtnl: failed to read IFA_FLAGS attribute, ignoring: %m");
1981 r
= sd_netlink_message_read_cache_info(message
, IFA_CACHEINFO
, &cinfo
);
1983 address_set_lifetime(m
, address
, &cinfo
);
1984 else if (r
!= -ENODATA
)
1985 log_link_debug_errno(link
, r
, "rtnl: failed to read IFA_CACHEINFO attribute, ignoring: %m");
1987 r
= sd_netlink_message_read_u32(message
, IFA_RT_PRIORITY
, &address
->route_metric
);
1988 if (r
< 0 && r
!= -ENODATA
)
1989 log_link_debug_errno(link
, r
, "rtnl: failed to read IFA_RT_PRIORITY attribute, ignoring: %m");
1991 address_enter_configured(address
);
1993 address_enter_configured(req
->userdata
);
1995 log_address_debug(address
, is_new
? "Received new": "Received updated", link
);
1997 /* address_update() logs internally, so we don't need to here. */
1998 r
= address_update(address
);
2000 link_enter_failed(link
);
2004 r
= dhcp4_update_ipv6_connectivity(link
);
2006 log_link_warning_errno(link
, r
, "Failed to notify IPv6 connectivity to DHCPv4 client: %m");
2007 link_enter_failed(link
);
2014 int config_parse_broadcast(
2016 const char *filename
,
2018 const char *section
,
2019 unsigned section_line
,
2026 Network
*network
= userdata
;
2027 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2028 union in_addr_union u
;
2037 r
= address_new_static(network
, filename
, section_line
, &n
);
2041 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2042 "Failed to allocate new address, ignoring assignment: %m");
2046 if (isempty(rvalue
)) {
2047 /* The broadcast address will be calculated based on Address=, and set if the link is
2048 * not a wireguard interface. Here, we do not check or set n->family. */
2049 n
->broadcast
= (struct in_addr
) {};
2050 n
->set_broadcast
= -1;
2055 r
= parse_boolean(rvalue
);
2057 /* The broadcast address will be calculated based on Address=. Here, we do not check or
2059 n
->broadcast
= (struct in_addr
) {};
2060 n
->set_broadcast
= r
;
2065 if (n
->family
== AF_INET6
) {
2066 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
2067 "Broadcast is not valid for IPv6 addresses, ignoring assignment: %s", rvalue
);
2071 r
= in_addr_from_string(AF_INET
, rvalue
, &u
);
2073 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2074 "Broadcast is invalid, ignoring assignment: %s", rvalue
);
2077 if (in4_addr_is_null(&u
.in
)) {
2078 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
2079 "Broadcast cannot be ANY address, ignoring assignment: %s", rvalue
);
2083 n
->broadcast
= u
.in
;
2084 n
->set_broadcast
= true;
2085 n
->family
= AF_INET
;
2091 int config_parse_address(
2093 const char *filename
,
2095 const char *section
,
2096 unsigned section_line
,
2103 Network
*network
= userdata
;
2104 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2105 union in_addr_union buffer
;
2106 unsigned char prefixlen
;
2115 if (streq(section
, "Network")) {
2116 if (isempty(rvalue
)) {
2117 /* If an empty string specified in [Network] section, clear previously assigned addresses. */
2118 network
->addresses_by_section
= ordered_hashmap_free(network
->addresses_by_section
);
2122 /* we are not in an Address section, so use line number instead. */
2123 r
= address_new_static(network
, filename
, line
, &n
);
2125 r
= address_new_static(network
, filename
, section_line
, &n
);
2129 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2130 "Failed to allocate new address, ignoring assignment: %m");
2134 /* Address=address/prefixlen */
2135 r
= in_addr_prefix_from_string_auto_internal(rvalue
, PREFIXLEN_REFUSE
, &f
, &buffer
, &prefixlen
);
2137 r
= in_addr_prefix_from_string_auto(rvalue
, &f
, &buffer
, &prefixlen
);
2139 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2140 "Address '%s' is specified without prefix length. Assuming the prefix length is %u. "
2141 "Please specify the prefix length explicitly.", rvalue
, prefixlen
);
2144 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
, "Invalid address '%s', ignoring assignment: %m", rvalue
);
2148 if (n
->family
!= AF_UNSPEC
&& f
!= n
->family
) {
2149 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0, "Address is incompatible, ignoring assignment: %s", rvalue
);
2153 if (in_addr_is_null(f
, &buffer
)) {
2154 /* Will use address from address pool. Note that for ipv6 case, prefix of the address
2155 * pool is 8, but 40 bit is used by the global ID and 16 bit by the subnet ID. So,
2156 * let's limit the prefix length to 64 or larger. See RFC4193. */
2157 if ((f
== AF_INET
&& prefixlen
< 8) ||
2158 (f
== AF_INET6
&& prefixlen
< 64)) {
2159 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
2160 "Null address with invalid prefixlen='%u', ignoring assignment: %s",
2167 n
->prefixlen
= prefixlen
;
2169 if (streq(lvalue
, "Address")) {
2170 n
->in_addr
= buffer
;
2171 n
->requested_as_null
= !in_addr_is_set(n
->family
, &n
->in_addr
);
2173 n
->in_addr_peer
= buffer
;
2179 int config_parse_label(
2181 const char *filename
,
2183 const char *section
,
2184 unsigned section_line
,
2191 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2192 Network
*network
= userdata
;
2201 r
= address_new_static(network
, filename
, section_line
, &n
);
2205 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2206 "Failed to allocate new address, ignoring assignment: %m");
2210 if (isempty(rvalue
)) {
2211 n
->label
= mfree(n
->label
);
2216 if (!address_label_valid(rvalue
)) {
2217 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
2218 "Interface label is too long or invalid, ignoring assignment: %s", rvalue
);
2222 r
= free_and_strdup(&n
->label
, rvalue
);
2230 int config_parse_lifetime(
2232 const char *filename
,
2234 const char *section
,
2235 unsigned section_line
,
2242 Network
*network
= userdata
;
2243 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2253 r
= address_new_static(network
, filename
, section_line
, &n
);
2257 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2258 "Failed to allocate new address, ignoring assignment: %m");
2262 /* We accept only "forever", "infinity", empty, or "0". */
2263 if (STR_IN_SET(rvalue
, "forever", "infinity", ""))
2265 else if (streq(rvalue
, "0"))
2268 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
2269 "Invalid PreferredLifetime= value, ignoring: %s", rvalue
);
2273 n
->lifetime_preferred_usec
= k
;
2279 int config_parse_address_flags(
2281 const char *filename
,
2283 const char *section
,
2284 unsigned section_line
,
2291 Network
*network
= userdata
;
2292 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2301 r
= address_new_static(network
, filename
, section_line
, &n
);
2305 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2306 "Failed to allocate new address, ignoring assignment: %m");
2310 r
= parse_boolean(rvalue
);
2312 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2313 "Failed to parse %s=, ignoring: %s", lvalue
, rvalue
);
2317 if (streq(lvalue
, "AddPrefixRoute"))
2320 SET_FLAG(n
->flags
, ltype
, r
);
2326 int config_parse_address_scope(
2328 const char *filename
,
2330 const char *section
,
2331 unsigned section_line
,
2338 Network
*network
= userdata
;
2339 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2348 r
= address_new_static(network
, filename
, section_line
, &n
);
2352 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2353 "Failed to allocate new address, ignoring assignment: %m");
2357 r
= route_scope_from_string(rvalue
);
2359 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2360 "Could not parse address scope \"%s\", ignoring assignment: %m", rvalue
);
2365 n
->scope_set
= true;
2370 int config_parse_address_route_metric(
2372 const char *filename
,
2374 const char *section
,
2375 unsigned section_line
,
2382 Network
*network
= userdata
;
2383 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2392 r
= address_new_static(network
, filename
, section_line
, &n
);
2396 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2397 "Failed to allocate new address, ignoring assignment: %m");
2401 r
= safe_atou32(rvalue
, &n
->route_metric
);
2403 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2404 "Could not parse %s=, ignoring assignment: %s", lvalue
, rvalue
);
2412 int config_parse_duplicate_address_detection(
2414 const char *filename
,
2416 const char *section
,
2417 unsigned section_line
,
2424 Network
*network
= userdata
;
2425 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2434 r
= address_new_static(network
, filename
, section_line
, &n
);
2438 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2439 "Failed to allocate new address, ignoring assignment: %m");
2443 r
= parse_boolean(rvalue
);
2445 log_syntax(unit
, LOG_WARNING
, filename
, line
, 0,
2446 "For historical reasons, %s=%s means %s=%s. "
2447 "Please use 'both', 'ipv4', 'ipv6' or 'none' instead.",
2448 lvalue
, rvalue
, lvalue
, r
? "none" : "both");
2449 n
->duplicate_address_detection
= r
? ADDRESS_FAMILY_NO
: ADDRESS_FAMILY_YES
;
2454 AddressFamily a
= duplicate_address_detection_address_family_from_string(rvalue
);
2456 log_syntax(unit
, LOG_WARNING
, filename
, line
, a
,
2457 "Failed to parse %s=, ignoring: %s", lvalue
, rvalue
);
2460 n
->duplicate_address_detection
= a
;
2466 int config_parse_address_netlabel(
2468 const char *filename
,
2470 const char *section
,
2471 unsigned section_line
,
2478 Network
*network
= userdata
;
2479 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2489 r
= address_new_static(network
, filename
, section_line
, &n
);
2493 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2494 "Failed to allocate new address, ignoring assignment: %m");
2498 r
= config_parse_string(unit
, filename
, line
, section
, section_line
,
2499 lvalue
, CONFIG_PARSE_STRING_SAFE
, rvalue
, &n
->netlabel
, network
);
2507 static void address_section_adjust_broadcast(Address
*address
) {
2509 assert(address
->section
);
2511 if (!in4_addr_is_set(&address
->broadcast
))
2514 if (address
->family
== AF_INET6
)
2515 log_warning("%s: broadcast address is set for an IPv6 address. "
2516 "Ignoring Broadcast= setting in the [Address] section from line %u.",
2517 address
->section
->filename
, address
->section
->line
);
2518 else if (address
->prefixlen
> 30)
2519 log_warning("%s: broadcast address is set for an IPv4 address with prefix length larger than 30. "
2520 "Ignoring Broadcast= setting in the [Address] section from line %u.",
2521 address
->section
->filename
, address
->section
->line
);
2522 else if (in4_addr_is_set(&address
->in_addr_peer
.in
))
2523 log_warning("%s: broadcast address is set for an IPv4 address with peer address. "
2524 "Ignoring Broadcast= setting in the [Address] section from line %u.",
2525 address
->section
->filename
, address
->section
->line
);
2526 else if (!in4_addr_is_set(&address
->in_addr
.in
))
2527 log_warning("%s: broadcast address is set for an IPv4 address with null address. "
2528 "Ignoring Broadcast= setting in the [Address] section from line %u.",
2529 address
->section
->filename
, address
->section
->line
);
2531 /* Otherwise, keep the specified broadcast address. */
2534 address
->broadcast
.s_addr
= 0;
2537 int address_section_verify(Address
*address
) {
2538 if (section_is_invalid(address
->section
))
2541 if (address
->family
== AF_UNSPEC
) {
2542 assert(address
->section
);
2544 return log_warning_errno(SYNTHETIC_ERRNO(EINVAL
),
2545 "%s: Address section without Address= field was configured. "
2546 "Ignoring [Address] section from line %u.",
2547 address
->section
->filename
, address
->section
->line
);
2550 if (address
->family
== AF_INET6
&& !socket_ipv6_is_supported())
2551 return log_warning_errno(SYNTHETIC_ERRNO(EINVAL
),
2552 "%s: an IPv6 address was configured, but the kernel does not support IPv6. "
2553 "Ignoring [Address] section from line %u.",
2554 address
->section
->filename
, address
->section
->line
);
2556 assert(IN_SET(address
->family
, AF_INET
, AF_INET6
));
2558 address_section_adjust_broadcast(address
);
2560 if (address
->family
== AF_INET6
&& address
->label
) {
2561 log_warning("%s: address label is set for IPv6 address in the [Address] section from line %u. "
2562 "Ignoring Label= setting.",
2563 address
->section
->filename
, address
->section
->line
);
2565 address
->label
= mfree(address
->label
);
2568 if (!address
->scope_set
) {
2569 if (in_addr_is_localhost(address
->family
, &address
->in_addr
) > 0)
2570 address
->scope
= RT_SCOPE_HOST
;
2571 else if (in_addr_is_link_local(address
->family
, &address
->in_addr
) > 0)
2572 address
->scope
= RT_SCOPE_LINK
;
2575 if (address
->duplicate_address_detection
< 0) {
2576 if (address
->family
== AF_INET6
)
2577 address
->duplicate_address_detection
= ADDRESS_FAMILY_IPV6
;
2578 else if (in4_addr_is_link_local(&address
->in_addr
.in
))
2579 address
->duplicate_address_detection
= ADDRESS_FAMILY_IPV4
;
2581 address
->duplicate_address_detection
= ADDRESS_FAMILY_NO
;
2582 } else if (address
->duplicate_address_detection
== ADDRESS_FAMILY_IPV6
&& address
->family
== AF_INET
)
2583 log_warning("%s: DuplicateAddressDetection=ipv6 is specified for IPv4 address, ignoring.",
2584 address
->section
->filename
);
2585 else if (address
->duplicate_address_detection
== ADDRESS_FAMILY_IPV4
&& address
->family
== AF_INET6
)
2586 log_warning("%s: DuplicateAddressDetection=ipv4 is specified for IPv6 address, ignoring.",
2587 address
->section
->filename
);
2589 if (address
->family
== AF_INET6
&&
2590 !FLAGS_SET(address
->duplicate_address_detection
, ADDRESS_FAMILY_IPV6
))
2591 address
->flags
|= IFA_F_NODAD
;
2593 uint32_t filtered_flags
= address
->family
== AF_INET
?
2594 address
->flags
& KNOWN_FLAGS
& ~UNMANAGED_FLAGS
& ~IPV6ONLY_FLAGS
:
2595 address
->flags
& KNOWN_FLAGS
& ~UNMANAGED_FLAGS
;
2596 if (address
->flags
!= filtered_flags
) {
2597 _cleanup_free_
char *str
= NULL
;
2599 (void) address_flags_to_string_alloc(address
->flags
^ filtered_flags
, address
->family
, &str
);
2600 return log_warning_errno(SYNTHETIC_ERRNO(EINVAL
),
2601 "%s: unexpected address flags \"%s\" were configured. "
2602 "Ignoring [Address] section from line %u.",
2603 address
->section
->filename
, strna(str
), address
->section
->line
);
2609 int network_drop_invalid_addresses(Network
*network
) {
2610 _cleanup_set_free_ Set
*addresses
= NULL
;
2616 ORDERED_HASHMAP_FOREACH(address
, network
->addresses_by_section
) {
2619 if (address_section_verify(address
) < 0) {
2620 /* Drop invalid [Address] sections or Address= settings in [Network].
2621 * Note that address_detach() will drop the address from addresses_by_section. */
2622 address_detach(address
);
2626 /* Always use the setting specified later. So, remove the previously assigned setting. */
2627 dup
= set_remove(addresses
, address
);
2629 log_warning("%s: Duplicated address %s is specified at line %u and %u, "
2630 "dropping the address setting specified at line %u.",
2631 dup
->section
->filename
,
2632 IN_ADDR_PREFIX_TO_STRING(address
->family
, &address
->in_addr
, address
->prefixlen
),
2633 address
->section
->line
,
2634 dup
->section
->line
, dup
->section
->line
);
2636 /* address_detach() will drop the address from addresses_by_section. */
2637 address_detach(dup
);
2640 /* Use address_hash_ops, instead of address_hash_ops_detach. Otherwise, the Address objects
2641 * will be detached. */
2642 r
= set_ensure_put(&addresses
, &address_hash_ops
, address
);
2648 r
= network_adjust_dhcp_server(network
, &addresses
);
2655 int config_parse_address_ip_nft_set(
2657 const char *filename
,
2659 const char *section
,
2660 unsigned section_line
,
2667 Network
*network
= userdata
;
2668 _cleanup_(address_unref_or_set_invalidp
) Address
*n
= NULL
;
2676 r
= address_new_static(network
, filename
, section_line
, &n
);
2680 log_syntax(unit
, LOG_WARNING
, filename
, line
, r
,
2681 "Failed to allocate a new address, ignoring assignment: %m");
2685 r
= config_parse_nft_set(unit
, filename
, line
, section
, section_line
, lvalue
, ltype
, rvalue
, &n
->nft_set_context
, network
);