network: split link_ipv4ll_enabled() into two

And move it from networkd-link.[ch] to relevant files.
This commit is contained in:
Yu Watanabe
2022-08-02 03:01:49 +09:00
parent 2d3d0e8f7d
commit 29104ded1c
6 changed files with 49 additions and 39 deletions

View 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;

View 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);

View 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;

View 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);

View 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"
@@ -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);

View 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_;