From: Yu Watanabe Date: Mon, 1 Aug 2022 18:01:49 +0000 (+0900) Subject: network: split link_ipv4ll_enabled() into two X-Git-Tag: v252-rc1~546^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29104ded1cc8fcb423406ff2c8f577a1df5daeaf;p=thirdparty%2Fsystemd.git network: split link_ipv4ll_enabled() into two And move it from networkd-link.[ch] to relevant files. --- diff --git a/src/network/networkd-ipv4acd.c b/src/network/networkd-ipv4acd.c index 009cde27de1..76aa2f83c86 100644 --- a/src/network/networkd-ipv4acd.c +++ b/src/network/networkd-ipv4acd.c @@ -1,14 +1,44 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include + #include "sd-dhcp-client.h" #include "sd-ipv4acd.h" +#include "ipvlan.h" #include "networkd-address.h" #include "networkd-dhcp4.h" #include "networkd-ipv4acd.h" #include "networkd-link.h" #include "networkd-manager.h" +bool link_ipv4acd_supported(Link *link) { + assert(link); + + if (link->flags & IFF_LOOPBACK) + return false; + + /* ARPHRD_INFINIBAND seems to potentially support IPv4ACD. + * But currently sd-ipv4acd only supports ARPHRD_ETHER. */ + if (link->iftype != ARPHRD_ETHER) + return false; + + if (link->hw_addr.length != ETH_ALEN) + return false; + + if (ether_addr_is_null(&link->hw_addr.ether)) + return false; + + if (streq_ptr(link->kind, "vrf")) + return false; + + /* L3 or L3S mode do not support ARP. */ + if (IN_SET(link_get_ipvlan_mode(link), NETDEV_IPVLAN_MODE_L3, NETDEV_IPVLAN_MODE_L3S)) + return false; + + return true; +} + static int static_ipv4acd_address_remove(Link *link, Address *address, bool on_conflict) { int r; diff --git a/src/network/networkd-ipv4acd.h b/src/network/networkd-ipv4acd.h index 6ebfa362896..7bd6a26b40a 100644 --- a/src/network/networkd-ipv4acd.h +++ b/src/network/networkd-ipv4acd.h @@ -4,6 +4,7 @@ typedef struct Address Address; typedef struct Link Link; +bool link_ipv4acd_supported(Link *link); int ipv4acd_configure(Address *address); int ipv4acd_update_mac(Link *link); int ipv4acd_start(Link *link); diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c index ac5bb217c30..8b0849d2d2e 100644 --- a/src/network/networkd-ipv4ll.c +++ b/src/network/networkd-ipv4ll.c @@ -5,12 +5,28 @@ #include "netif-util.h" #include "networkd-address.h" +#include "networkd-ipv4acd.h" #include "networkd-ipv4ll.h" #include "networkd-link.h" #include "networkd-manager.h" #include "networkd-queue.h" #include "parse-util.h" +bool link_ipv4ll_enabled(Link *link) { + assert(link); + + if (!link_ipv4acd_supported(link)) + return false; + + if (!link->network) + return false; + + if (link->network->bond) + return false; + + return link->network->link_local & ADDRESS_FAMILY_IPV4; +} + static int address_new_from_ipv4ll(Link *link, Address **ret) { _cleanup_(address_freep) Address *address = NULL; struct in_addr addr; diff --git a/src/network/networkd-ipv4ll.h b/src/network/networkd-ipv4ll.h index f5c69285350..fa53bd2b39a 100644 --- a/src/network/networkd-ipv4ll.h +++ b/src/network/networkd-ipv4ll.h @@ -7,6 +7,8 @@ typedef struct Link Link; +bool link_ipv4ll_enabled(Link *link); + int ipv4ll_configure(Link *link); int ipv4ll_update_mac(Link *link); diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 35d1e2f206e..269f69ec21c 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -27,7 +27,6 @@ #include "format-util.h" #include "fs-util.h" #include "glyph-util.h" -#include "ipvlan.h" #include "missing_network.h" #include "netlink-util.h" #include "network-internal.h" @@ -69,42 +68,6 @@ #include "util.h" #include "vrf.h" -bool link_ipv4ll_enabled(Link *link) { - assert(link); - - if (link->flags & IFF_LOOPBACK) - return false; - - if (!link->network) - return false; - - if (link->iftype == ARPHRD_CAN) - return false; - - if (link->hw_addr.length != ETH_ALEN) - return false; - - if (ether_addr_is_null(&link->hw_addr.ether)) - return false; - - /* ARPHRD_INFINIBAND seems to potentially support IPv4LL. - * But currently sd-ipv4ll and sd-ipv4acd only support ARPHRD_ETHER. */ - if (link->iftype != ARPHRD_ETHER) - return false; - - if (streq_ptr(link->kind, "vrf")) - return false; - - /* L3 or L3S mode do not support ARP. */ - if (IN_SET(link_get_ipvlan_mode(link), NETDEV_IPVLAN_MODE_L3, NETDEV_IPVLAN_MODE_L3S)) - return false; - - if (link->network->bond) - return false; - - return link->network->link_local & ADDRESS_FAMILY_IPV4; -} - bool link_ipv6_enabled(Link *link) { assert(link); diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index dfe43bb3a01..807fb44709f 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -225,8 +225,6 @@ static inline bool link_has_carrier(Link *link) { bool link_ipv6_enabled(Link *link); int link_ipv6ll_gained(Link *link); -bool link_ipv4ll_enabled(Link *link); - int link_stop_engines(Link *link, bool may_keep_dhcp); const char* link_state_to_string(LinkState s) _const_;