networkd-ipv4ll.h
networkd-ipv6-proxy-ndp.c
networkd-ipv6-proxy-ndp.h
+ networkd-ipv6ll.c
+ networkd-ipv6ll.h
networkd-json.c
networkd-json.h
networkd-link-bus.c
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include <linux/if.h>
+#include <linux/if_arp.h>
+
+#include "in-addr-util.h"
+#include "networkd-address.h"
+#include "networkd-ipv6ll.h"
+#include "networkd-link.h"
+#include "networkd-network.h"
+#include "networkd-util.h"
+#include "socket-util.h"
+#include "string-table.h"
+#include "strv.h"
+
+bool link_ipv6ll_enabled(Link *link) {
+ assert(link);
+
+ if (!socket_ipv6_is_supported())
+ return false;
+
+ if (link->flags & IFF_LOOPBACK)
+ return false;
+
+ if (!link->network)
+ return false;
+
+ if (link->iftype == ARPHRD_CAN)
+ return false;
+
+ if (STRPTR_IN_SET(link->kind, "vrf", "wireguard", "ipip", "gre", "sit", "vti", "nlmon"))
+ return false;
+
+ if (link->network->bond)
+ return false;
+
+ return link->network->link_local & ADDRESS_FAMILY_IPV6;
+}
+
+bool link_may_have_ipv6ll(Link *link) {
+ assert(link);
+
+ /*
+ * This is equivalent to link_ipv6ll_enabled() for non-WireGuard interfaces.
+ *
+ * For WireGuard interface, the kernel does not assign any IPv6LL addresses, but we can assign
+ * it manually. It is necessary to set an IPv6LL address manually to run NDisc or RADV on
+ * WireGuard interface. Note, also Multicast=yes must be set. See #17380.
+ *
+ * TODO: May be better to introduce GenerateIPv6LinkLocalAddress= setting, and use algorithms
+ * used in networkd-address-generation.c
+ */
+
+ if (link_ipv6ll_enabled(link))
+ return true;
+
+ /* IPv6LL address can be manually assigned on WireGuard interface. */
+ if (streq_ptr(link->kind, "wireguard")) {
+ Address *a;
+
+ if (!link->network)
+ return false;
+
+ ORDERED_HASHMAP_FOREACH(a, link->network->addresses_by_section) {
+ if (a->family != AF_INET6)
+ continue;
+ if (in6_addr_is_set(&a->in_addr_peer.in6))
+ continue;
+ if (in6_addr_is_link_local(&a->in_addr.in6))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static const char* const ipv6_link_local_address_gen_mode_table[_IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_MAX] = {
+ [IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_EUI64] = "eui64",
+ [IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_NONE] = "none",
+ [IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_STABLE_PRIVACY] = "stable-privacy",
+ [IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_RANDOM] = "random",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(ipv6_link_local_address_gen_mode, IPv6LinkLocalAddressGenMode);
+DEFINE_CONFIG_PARSE_ENUM(
+ config_parse_ipv6_link_local_address_gen_mode,
+ ipv6_link_local_address_gen_mode,
+ IPv6LinkLocalAddressGenMode,
+ "Failed to parse IPv6 link local address generation mode");
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#include <errno.h>
+#include <linux/if_link.h>
+#include <stdbool.h>
+
+#include "conf-parser.h"
+#include "macro.h"
+
+typedef struct Link Link;
+
+typedef enum IPv6LinkLocalAddressGenMode {
+ IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_EUI64 = IN6_ADDR_GEN_MODE_EUI64,
+ IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_NONE = IN6_ADDR_GEN_MODE_NONE,
+ IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_STABLE_PRIVACY = IN6_ADDR_GEN_MODE_STABLE_PRIVACY,
+ IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_RANDOM = IN6_ADDR_GEN_MODE_RANDOM,
+ _IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_MAX,
+ _IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_INVALID = -EINVAL,
+} IPv6LinkLocalAddressGenMode;
+
+bool link_ipv6ll_enabled(Link *link);
+bool link_may_have_ipv6ll(Link *link);
+
+const char* ipv6_link_local_address_gen_mode_to_string(IPv6LinkLocalAddressGenMode s) _const_;
+IPv6LinkLocalAddressGenMode ipv6_link_local_address_gen_mode_from_string(const char *s) _pure_;
+
+CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode);
return link->network->link_local & ADDRESS_FAMILY_IPV4;
}
-bool link_ipv6ll_enabled(Link *link) {
- assert(link);
-
- if (!socket_ipv6_is_supported())
- return false;
-
- if (link->flags & IFF_LOOPBACK)
- return false;
-
- if (!link->network)
- return false;
-
- if (link->iftype == ARPHRD_CAN)
- return false;
-
- if (STRPTR_IN_SET(link->kind, "vrf", "wireguard", "ipip", "gre", "sit", "vti", "nlmon"))
- return false;
-
- if (link->network->bond)
- return false;
-
- return link->network->link_local & ADDRESS_FAMILY_IPV6;
-}
-
-bool link_may_have_ipv6ll(Link *link) {
- assert(link);
-
- /*
- * This is equivalent to link_ipv6ll_enabled() for non-WireGuard interfaces.
- *
- * For WireGuard interface, the kernel does not assign any IPv6LL addresses, but we can assign
- * it manually. It is necessary to set an IPv6LL address manually to run NDisc or RADV on
- * WireGuard interface. Note, also Multicast=yes must be set. See #17380.
- *
- * TODO: May be better to introduce GenerateIPv6LinkLocalAddress= setting, and use algorithms
- * used in networkd-address-generation.c
- */
-
- if (link_ipv6ll_enabled(link))
- return true;
-
- /* IPv6LL address can be manually assigned on WireGuard interface. */
- if (streq_ptr(link->kind, "wireguard")) {
- Address *a;
-
- if (!link->network)
- return false;
-
- ORDERED_HASHMAP_FOREACH(a, link->network->addresses_by_section) {
- if (a->family != AF_INET6)
- continue;
- if (in6_addr_is_set(&a->in_addr_peer.in6))
- continue;
- if (in6_addr_is_link_local(&a->in_addr.in6))
- return true;
- }
- }
-
- return false;
-}
-
bool link_ipv6_enabled(Link *link) {
assert(link);
#include "log-link.h"
#include "netif-util.h"
#include "network-util.h"
+#include "networkd-ipv6ll.h"
#include "networkd-util.h"
#include "ordered-set.h"
#include "resolve-util.h"
}
bool link_ipv6_enabled(Link *link);
-bool link_ipv6ll_enabled(Link *link);
-bool link_may_have_ipv6ll(Link *link);
int link_ipv6ll_gained(Link *link);
bool link_ipv4ll_enabled(Link *link);
#include "networkd-dhcp6.h"
#include "networkd-ipv4ll.h"
#include "networkd-ipv6-proxy-ndp.h"
+#include "networkd-ipv6ll.h"
#include "networkd-lldp-tx.h"
#include "networkd-ndisc.h"
#include "networkd-network.h"
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(keep_configuration, KeepConfiguration, KEEP_CONFIGURATION_YES);
-static const char* const ipv6_link_local_address_gen_mode_table[_IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_MAX] = {
- [IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_EUI64] = "eui64",
- [IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_NONE] = "none",
- [IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_STABLE_PRIVACY] = "stable-privacy",
- [IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_RANDOM] = "random",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(ipv6_link_local_address_gen_mode, IPv6LinkLocalAddressGenMode);
-DEFINE_CONFIG_PARSE_ENUM(config_parse_ipv6_link_local_address_gen_mode, ipv6_link_local_address_gen_mode, IPv6LinkLocalAddressGenMode, "Failed to parse IPv6 link local address generation mode");
-
static const char* const activation_policy_table[_ACTIVATION_POLICY_MAX] = {
[ACTIVATION_POLICY_UP] = "up",
[ACTIVATION_POLICY_ALWAYS_UP] = "always-up",
#include "networkd-dhcp-common.h"
#include "networkd-dhcp4.h"
#include "networkd-dhcp6.h"
+#include "networkd-ipv6ll.h"
#include "networkd-lldp-rx.h"
#include "networkd-ndisc.h"
#include "networkd-radv.h"
_KEEP_CONFIGURATION_INVALID = -EINVAL,
} KeepConfiguration;
-typedef enum IPv6LinkLocalAddressGenMode {
- IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_EUI64 = IN6_ADDR_GEN_MODE_EUI64,
- IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_NONE = IN6_ADDR_GEN_MODE_NONE,
- IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_STABLE_PRIVACY = IN6_ADDR_GEN_MODE_STABLE_PRIVACY,
- IPV6_LINK_LOCAL_ADDRESSS_GEN_MODE_RANDOM = IN6_ADDR_GEN_MODE_RANDOM,
- _IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_MAX,
- _IPV6_LINK_LOCAL_ADDRESS_GEN_MODE_INVALID = -EINVAL,
-} IPv6LinkLocalAddressGenMode;
-
typedef enum ActivationPolicy {
ACTIVATION_POLICY_UP,
ACTIVATION_POLICY_ALWAYS_UP,
CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
CONFIG_PARSER_PROTOTYPE(config_parse_required_family_for_online);
CONFIG_PARSER_PROTOTYPE(config_parse_keep_configuration);
-CONFIG_PARSER_PROTOTYPE(config_parse_ipv6_link_local_address_gen_mode);
CONFIG_PARSER_PROTOTYPE(config_parse_activation_policy);
CONFIG_PARSER_PROTOTYPE(config_parse_link_group);
CONFIG_PARSER_PROTOTYPE(config_parse_ignore_carrier_loss);
const char* keep_configuration_to_string(KeepConfiguration i) _const_;
KeepConfiguration keep_configuration_from_string(const char *s) _pure_;
-const char* ipv6_link_local_address_gen_mode_to_string(IPv6LinkLocalAddressGenMode s) _const_;
-IPv6LinkLocalAddressGenMode ipv6_link_local_address_gen_mode_from_string(const char *s) _pure_;
-
const char* activation_policy_to_string(ActivationPolicy i) _const_;
ActivationPolicy activation_policy_from_string(const char *s) _pure_;