]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: split link_ipv4ll_enabled() into two
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 Aug 2022 18:01:49 +0000 (03:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 1 Aug 2022 18:02:48 +0000 (03:02 +0900)
And move it from networkd-link.[ch] to relevant files.

src/network/networkd-ipv4acd.c
src/network/networkd-ipv4acd.h
src/network/networkd-ipv4ll.c
src/network/networkd-ipv4ll.h
src/network/networkd-link.c
src/network/networkd-link.h

index 009cde27de19679bfc3b3fe420f4eb18dbd0290e..76aa2f83c8621aa0a0d8be5c710bc54be94abee2 100644 (file)
@@ -1,14 +1,44 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
+#include <linux/if_arp.h>
+
 #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;
 
index 6ebfa362896d18bdc2f00e010c9c1038862dc06f..7bd6a26b40a67abdd44cb47fbe315efff5926fd3 100644 (file)
@@ -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);
index ac5bb217c3088195e91d51bf50996e3f1dfb2491..8b0849d2d2e367141b58c835342664c5b228557d 100644 (file)
@@ -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;
index f5c69285350efeccdbdab9bc60b370e53bdf8f11..fa53bd2b39ab2f80e4b42afd80a5c87de6a0bef0 100644 (file)
@@ -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);
 
index 35d1e2f206e02b9834c1269995d8639e2f7f363c..269f69ec21cb531c4f9ff29d5ee3cde0fe43da04 100644 (file)
@@ -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"
 #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);
 
index dfe43bb3a017ea7d3a38120866bcafbc3a5f5243..807fb44709fa5f9d45518a83bba47aebb96c4d9a 100644 (file)
@@ -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_;