Skip to contentSkip to conversation

icmp6: Save SLAAC prefixes from RAs

PATCH In review Andrew Zaborowski 2 participants 9 messages Sep 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/7 icmp6: Save SLAAC prefixes from RAs

In struct l_icmp6_router save the lists of prefixes for autoconfiguration separately from routes. The two sets of prefixes may overlap completely, partially or not at all. Drop the preferred_lifetime information from route_info since this is strictly to be used as the preferred lifetime for addresses generated through SLAAC and has nothing to do with routes.

---
 ell/icmp6-private.h |  7 ++++
 ell/icmp6.c         | 98 +++++++++++++++++++++++++++++++--------------
 ell/netconfig.c     |  7 +---
 3 files changed, 77 insertions(+), 35 deletions(-)
ell/icmp6-private.h +7 -0
index 77df0b8..a26639d 100644
@@ -25,6 +25,11 @@ struct route_info {
 	bool onlink : 1;
 	uint8_t prefix_len;
 	uint8_t preference;
+	uint32_t valid_lifetime;
+};
+
+struct autoconf_prefix_info {
+	uint8_t prefix[8];
 	uint32_t preferred_lifetime;
 	uint32_t valid_lifetime;
 };
@@ -40,6 +45,8 @@ struct l_icmp6_router {
 	uint32_t max_rtr_adv_interval_ms;
 	uint32_t n_routes;
 	struct route_info *routes;
+	uint32_t n_ac_prefixes;
+	struct autoconf_prefix_info *ac_prefixes;
 };
 
 struct l_icmp6_router *_icmp6_router_new();
ell/icmp6.c +68 -30

142 lines not on this page · raw message

ell/netconfig.c +2 -5
index 29e95b7..bbe1dec 100644
@@ -799,7 +799,6 @@ static bool netconfig_check_route_need_update(
 static void netconfig_set_icmp6_route_data(struct l_netconfig *nc,
 						struct netconfig_route_data *rd,
 						const struct l_icmp6_router *ra,
-						uint32_t preferred_lifetime,
 						uint32_t valid_lifetime,
 						uint32_t mtu, bool updated)
 {
@@ -916,10 +915,10 @@ static void netconfig_icmp6_event_handler(struct l_icmp6_client *client,
 		 * netconfig_set_icmp6_route_data.
 		 */
 		netconfig_set_icmp6_route_data(nc, default_rd, r, r->lifetime,
-						r->lifetime, r->mtu, false);
+						r->mtu, false);
 	} else if (default_rd && r->lifetime)
 		netconfig_set_icmp6_route_data(nc, default_rd, r, r->lifetime,
-						r->lifetime, r->mtu, true);
+						r->mtu, true);
 	else if (default_rd && !r->lifetime)
 		netconfig_remove_icmp6_route(nc, default_rd);
 
@@ -941,12 +940,10 @@ static void netconfig_icmp6_event_handler(struct l_icmp6_client *client,
 				continue;
 
 			netconfig_set_icmp6_route_data(nc, rd, r,
-						info->preferred_lifetime,
 						info->valid_lifetime,
 						gateway ? r->mtu : 0, false);
 		} else if (rd && info->valid_lifetime)
 			netconfig_set_icmp6_route_data(nc, rd, r,
-						info->preferred_lifetime,
 						info->valid_lifetime,
 						gateway ? r->mtu : 0, true);
 		else if (rd && !info->valid_lifetime)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/7 icmp6: Parse RDNSS and DNSSL options

Save the list of DNS server addresses and the local domain search list from Router Advertisements in the l_icmp6_router structure.

---
 ell/icmp6-private.h | 14 +++++++
 ell/icmp6.c         | 94 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 106 insertions(+), 2 deletions(-)
ell/icmp6-private.h +14 -0
index a26639d..f207164 100644
@@ -34,6 +34,16 @@ struct autoconf_prefix_info {
 	uint32_t valid_lifetime;
 };
 
+struct dns_info {
+	uint8_t address[16];
+	uint32_t lifetime;
+};
+
+struct domain_info {
+	char *domain;
+	uint32_t lifetime;
+};
+
 struct l_icmp6_router {
 	uint8_t address[16];
 	bool managed : 1;
@@ -47,6 +57,10 @@ struct l_icmp6_router {
 	struct route_info *routes;
 	uint32_t n_ac_prefixes;
 	struct autoconf_prefix_info *ac_prefixes;
+	uint32_t n_dns;
+	struct dns_info *dns_list;
+	uint32_t n_domains;
+	struct domain_info *domains;
 };
 
 struct l_icmp6_router *_icmp6_router_new();
ell/icmp6.c +92 -2

145 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH 3/7 icmp6: Switch socket from AF_INET6 to AF_PACKET

In reply to Andrew Zaborowski

In order to be able to send our Router Solicitations before the interface has a confirmed link-local address we have to be able to supply our own IPv6 header and skip source address selection and routing in the kernel. It is at least tricky to do with an AF_INET6 raw socket as some socket features, like SO_DONTROUTE/MSG_DONTROUTE, are not supported and others don't suppress the source address selection/checks. Additionally since we need to use the IPv6 unspecified address, which is represented as all 0 bytes, some syscalls interpret it as no value supplied.

Build/parse the IPv6 header on our own and send/receive using an AF_PACKET socket.

Once we have the link-local address, we switch to sending from that address. Add l_icmp6_client_set_link_local_address for the user to give it to us as they're likely to need it for DHCPv6.

---
 ell/dhcp6.c     |   3 +
 ell/ell.sym     |   1 +
 ell/icmp6.c     | 324 ++++++++++++++++++++++++++++++------------------
 ell/icmp6.h     |   2 +
 ell/netconfig.c |   1 +
 5 files changed, 213 insertions(+), 118 deletions(-)
ell/dhcp6.c +3 -0
index 01d7eb3..15b451d 100644
@@ -1619,6 +1619,9 @@ LIB_EXPORT bool l_dhcp6_client_set_link_local_address(
 	if (inet_pton(AF_INET6, ll, &client->ll_address) != 1)
 		return false;
 
+	if (!client->nora)
+		l_icmp6_client_set_link_local_address(client->icmp6, ll);
+
 	return true;
 }
 
ell/ell.sym +1 -0
index ed66352..a28eb55 100644
@@ -703,6 +703,7 @@ global:
 	l_icmp6_client_set_nodelay;
 	l_icmp6_client_set_rtnl;
 	l_icmp6_client_set_route_priority;
+	l_icmp6_client_set_link_local_address;
 	l_icmp6_router_get_address;
 	l_icmp6_router_get_managed;
 	l_icmp6_router_get_other;
ell/icmp6.c +206 -118

441 lines not on this page · raw message

ell/icmp6.h +2 -0
index 615dba4..ffbb8a8 100644
@@ -65,6 +65,8 @@ bool l_icmp6_client_set_rtnl(struct l_icmp6_client *client,
 						struct l_netlink *rtnl);
 bool l_icmp6_client_set_route_priority(struct l_icmp6_client *client,
 						uint32_t priority);
+bool l_icmp6_client_set_link_local_address(struct l_icmp6_client *client,
+						const char *ll);
 
 char *l_icmp6_router_get_address(const struct l_icmp6_router *r);
 bool l_icmp6_router_get_managed(const struct l_icmp6_router *r);
ell/netconfig.c +1 -0
index bbe1dec..72c67a9 100644
@@ -1532,6 +1532,7 @@ static void netconfig_ifaddr_ipv6_added(struct l_netconfig *nc,
 	netconfig_addr_wait_unregister(nc, true);
 
 	l_dhcp6_client_set_link_local_address(nc->dhcp6_client, ip);
+	l_icmp6_client_set_link_local_address(nc->icmp6_client, ip);
 
 	/*
 	 * Only now that we have a link-local address start actual DHCPv6
Signature · 1 line
2.34.1
#3 lore raw

PATCH 4/7 rtnl: Add l_rtnl_address_get_in_addr

In reply to Andrew Zaborowski

Similar to l_rtnl_route_get_dst_in_addr add a getter for the raw address value, avoiding extra string conversions.

---
 ell/ell.sym | 1 +
 ell/rtnl.c  | 9 +++++++++
 ell/rtnl.h  | 1 +
 3 files changed, 11 insertions(+)
ell/ell.sym +1 -0
index a28eb55..d76b2ea 100644
@@ -626,6 +626,7 @@ global:
 	l_rtnl_address_clone;
 	l_rtnl_address_free;
 	l_rtnl_address_get_address;
+	l_rtnl_address_get_in_addr;
 	l_rtnl_address_get_family;
 	l_rtnl_address_get_prefix_length;
 	l_rtnl_address_get_broadcast;
ell/rtnl.c +9 -0
index 2483e82..5909c4b 100644
@@ -180,6 +180,15 @@ LIB_EXPORT bool l_rtnl_address_get_address(const struct l_rtnl_address *addr,
 						out_buf);
 }
 
+LIB_EXPORT const void *l_rtnl_address_get_in_addr(
+					const struct l_rtnl_address *addr)
+{
+	if (unlikely(!addr))
+		return NULL;
+
+	return addr->family == AF_INET ? (void *) &addr->in_addr : &addr->in6_addr;
+}
+
 LIB_EXPORT uint8_t l_rtnl_address_get_family(const struct l_rtnl_address *addr)
 {
 	if (unlikely(!addr))
ell/rtnl.h +1 -0
index ffd1d73..1e6b1fa 100644
@@ -44,6 +44,7 @@ void l_rtnl_address_free(struct l_rtnl_address *addr);
 DEFINE_CLEANUP_FUNC(l_rtnl_address_free);
 bool l_rtnl_address_get_address(const struct l_rtnl_address *addr,
 				char *out_buf);
+const void *l_rtnl_address_get_in_addr(const struct l_rtnl_address *addr);
 uint8_t l_rtnl_address_get_family(const struct l_rtnl_address *addr);
 uint8_t l_rtnl_address_get_prefix_length(const struct l_rtnl_address *addr);
 bool l_rtnl_address_get_broadcast(const struct l_rtnl_address *addr,
Signature · 1 line
2.34.1
#4 lore raw

PATCH 5/7 netconfig: Decouple icmp6 start from dhcp6 start

In reply to Andrew Zaborowski

In preparation for supporting generating SLAAC addresses, start the l_icmp6_client directly from the netconfig state machine. l_dhcp6_client still takes care of creating and destroying l_icmp6_client because it needs it for its own public API, but netconfig starts/stops/handles events locally. This also allows a slight optimization described in RFC4862 where if we're lucky, we will send the Router Solicitation simultaneously with the Neighbor Solicitation for the link-local addresses so as to avoid waiting the sum of the RA response time + DAD timeout and instead wait the longer of the two periods.

---
 ell/dhcp6.c     |   3 ++
 ell/netconfig.c | 102 ++++++++++++++++++++++++++++++++++++++++++------
 2 files changed, 93 insertions(+), 12 deletions(-)
ell/dhcp6.c +3 -0
index 15b451d..e234eb0 100644
@@ -1473,6 +1473,9 @@ static void dhcp6_client_icmp6_event(struct l_icmp6_client *icmp6,
 {
 	struct l_dhcp6_client *client = user_data;
 
+	if (client->nora)
+		return;
+
 	switch (event) {
 	case L_ICMP6_CLIENT_EVENT_ROUTER_FOUND:
 	{
ell/netconfig.c +90 -12

189 lines not on this page · raw message

Signature · 1 line
2.34.1
#5 lore raw

PATCH 6/7 netconfig: Create SLAAC address

In reply to Andrew Zaborowski

If the Router Advertisement doesn't indicate DHCPv6 is available and includes prefixes for address auto-configuration, fall back to using those to generate a single IPv6 address. Other settings such as DNS are not supported in this mode yet and there's no renewal timer for when the address lifetime is finite.

---
 ell/netconfig.c | 184 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 174 insertions(+), 10 deletions(-)
ell/netconfig.c +174 -10
index 3ac0319..3336b30 100644
@@ -91,6 +91,11 @@ struct l_netconfig {
 	unsigned int orig_disable_ipv6;
 	uint8_t mac[ETH_ALEN];
 	struct l_timeout *ra_timeout;
+	enum {
+		NETCONFIG_V6_METHOD_UNSET,
+		NETCONFIG_V6_METHOD_DHCP,
+		NETCONFIG_V6_METHOD_SLAAC,
+	} v6_auto_method;
 
 	/* These objects, if not NULL, are owned by @addresses and @routes */
 	struct l_rtnl_address *v4_address;
@@ -677,7 +682,7 @@ static bool netconfig_match(const void *a, const void *b)
 static bool netconfig_check_start_dhcp6(struct l_netconfig *nc)
 {
 	/* Don't start DHCPv6 until we get an RA with the managed bit set */
-	if (nc->ra_timeout)
+	if (nc->ra_timeout || nc->v6_auto_method != NETCONFIG_V6_METHOD_DHCP)
 		return true;
 
 	/* Don't start DHCPv6 while waiting for the link-local address */
@@ -698,6 +703,109 @@ static void netconfig_ra_timeout_cb(struct l_timeout *timeout, void *user_data)
 	netconfig_emit_event(nc, AF_INET6, L_NETCONFIG_EVENT_FAILED);
 }
 
+static void netconfig_add_slaac_address(struct l_netconfig *nc,
+					const struct l_icmp6_router *r)
+{
+	unsigned int i;
+	const struct autoconf_prefix_info *longest = &r->ac_prefixes[0];
+	uint8_t addr[16];
+	char addr_str[INET6_ADDRSTRLEN];
+	uint32_t p, v;
+
+	/* Find the autoconfiguration prefix that offers the longest lifetime */
+	for (i = 1; i < r->n_ac_prefixes; i++)
+		if (r->ac_prefixes[i].preferred_lifetime >
+				longest->preferred_lifetime)
+			longest = &r->ac_prefixes[i];
+
+	memcpy(addr, longest->prefix, 8);
+	/* EUI-64-based Interface Identifier (RFC2464 Section 4) */
+	addr[ 8] = nc->mac[0] ^ 0x02;
+	addr[ 9] = nc->mac[1];
+	addr[10] = nc->mac[2];
+	addr[11] = 0xff;
+	addr[12] = 0xfe;
+	addr[13] = nc->mac[3];
+	addr[14] = nc->mac[4];
+	addr[15] = nc->mac[5];
+	inet_ntop(AF_INET6, addr, addr_str, sizeof(addr_str));
+	p = longest->preferred_lifetime;
+	v = longest->valid_lifetime;
+
+	nc->v6_address = l_rtnl_address_new(addr_str, 128);
+	l_rtnl_address_set_noprefixroute(nc->v6_address, true);
+
+	if (p != 0xffffffff || v != 0xffffffff) {
+		l_rtnl_address_set_lifetimes(nc->v6_address,
+					p != 0xffffffff ? p : 0,
+					v != 0xffffffff ? v : 0);
+		l_rtnl_address_set_expiry(nc->v6_address,
+					p != 0xffffffff ?
+					r->start_time + p * L_USEC_PER_SEC : 0,
+					v != 0xffffffff ?
+					r->start_time + v * L_USEC_PER_SEC : 0);
+	}
+
+	l_queue_push_tail(nc->addresses.current, nc->v6_address);
+	l_queue_push_tail(nc->addresses.added, nc->v6_address);
+	netconfig_emit_event(nc, AF_INET6, L_NETCONFIG_EVENT_CONFIGURE);
+
+	/* TODO: set a renew timeout */
+}
+
+static void netconfig_set_slaac_address_lifetimes(struct l_netconfig *nc,
+						const struct l_icmp6_router *r)
+{
+	const uint8_t *addr = l_rtnl_address_get_in_addr(nc->v6_address);
+	bool updated = false;
+	uint64_t p_expiry;
+	uint64_t v_expiry;
+	uint32_t remaining = 0xffffffff;
+	unsigned int i;
+
+	if (L_WARN_ON(!addr))
+		return;
+
+	l_rtnl_address_get_expiry(nc->v6_address, &p_expiry, &v_expiry);
+
+	if (v_expiry)
+		remaining = (v_expiry - r->start_time) / L_USEC_PER_SEC;
+
+	for (i = 0; i < r->n_ac_prefixes; i++) {
+		const struct autoconf_prefix_info *prefix = &r->ac_prefixes[i];
+		uint32_t p = prefix->preferred_lifetime;
+		uint32_t v = prefix->valid_lifetime;
+
+		if (memcmp(prefix->prefix, addr, 8))
+			continue;
+
+		/* RFC4862 Section 5.5.3 e) */
+		if (v < 120 * 60 && v < remaining)
+			v = 120 * 60; /* 2 hours */
+
+		l_rtnl_address_set_lifetimes(nc->v6_address,
+						p != 0xffffffff ? p : 0,
+						v != 0xffffffff ? v : 0);
+		p_expiry = p != 0xffffffff ? r->start_time + p * L_USEC_PER_SEC : 0;
+		v_expiry = v != 0xffffffff ? r->start_time + v * L_USEC_PER_SEC : 0;
+		l_rtnl_address_set_expiry(nc->v6_address, p_expiry, v_expiry);
+		updated = true;
+
+		/*
+		 * TODO: modify the renew timeout.
+		 *
+		 * Also we probably want to apply a mechanism similar to that
+		 * in netconfig_check_route_need_update() to avoid generating
+		 * and UPDATED event for every RA that covers this prefix
+		 * with constant lifetime values.
+		 */
+	}
+
+	if (updated && !l_queue_find(nc->addresses.added, netconfig_match,
+					nc->v6_address))
+		l_queue_push_tail(nc->addresses.updated, nc->v6_address);
+}
+
 static uint64_t now;
 
 static bool netconfig_check_route_expired(void *data, void *user_data)
@@ -916,17 +1024,14 @@ static void netconfig_icmp6_event_handler(struct l_icmp6_client *client,
 	const struct l_icmp6_router *r;
 	struct netconfig_route_data *default_rd;
 	unsigned int i;
-	bool first_ra = false;
 
 	if (event != L_ICMP6_CLIENT_EVENT_ROUTER_FOUND)
 		return;
 
 	r = event_data;
 
-	if (nc->ra_timeout) {
-		first_ra = true;
+	if (nc->ra_timeout)
 		l_timeout_remove(l_steal_ptr(nc->ra_timeout));
-	}
 
 	netconfig_expire_routes(nc);
 
@@ -984,16 +1089,72 @@ process_nondefault_routes:
 			netconfig_remove_icmp6_route(nc, rd);
 	}
 
-	/* See if we should start DHCPv6 now */
-	if (first_ra) {
-		if (!l_icmp6_router_get_managed(r) ||
-				!netconfig_check_start_dhcp6(nc)) {
+	/*
+	 * For lack of a better policy, select between DHCPv6 and SLAAC based
+	 * on the first RA received.  Prefer DHCPv6.
+	 *
+	 * Just like we currently only request one address in l_dhcp6_client,
+	 * we only set up one address using SLAAC regardless of how many
+	 * prefixes are available.  Generate the address in the prefix that
+	 * offers the longest preferred_lifetime.
+	 */
+	if (nc->v6_auto_method == NETCONFIG_V6_METHOD_UNSET &&
+			l_icmp6_router_get_managed(r)) {
+		nc->v6_auto_method = NETCONFIG_V6_METHOD_DHCP;
+
+		if (!netconfig_check_start_dhcp6(nc)) {
 			netconfig_emit_event(nc, AF_INET6,
 						L_NETCONFIG_EVENT_FAILED);
 			return;
 		}
+
+		goto emit_event;
+	}
+
+	/*
+	 * DHCP not available according to this router, check if any of the
+	 * prefixes allow SLAAC.
+	 */
+	if (nc->v6_auto_method == NETCONFIG_V6_METHOD_UNSET &&
+			r->n_ac_prefixes) {
+		nc->v6_auto_method = NETCONFIG_V6_METHOD_SLAAC;
+
+		/*
+		 * The DAD for the link-local address may be still running
+		 * but again we can generate the global address already and
+		 * commit it to start in-kernel DAD for it.
+		 *
+		 * The global address alone should work for most uses.  On
+		 * the other hand since both the link-local address and the
+		 * global address are based on the same MAC, there's some
+		 * correlation between one failing DAD and the other
+		 * failing DAD due to another host using the same address.
+		 * As RFC4862 Section 5.4 notes we can't rely on that to
+		 * skip DAD for one of the addresses.
+		 */
+
+		netconfig_add_slaac_address(nc, r);
+		return;
 	}
 
+	/* Neither method seems available, fail */
+	if (nc->v6_auto_method == NETCONFIG_V6_METHOD_UNSET) {
+		netconfig_emit_event(nc, AF_INET6, L_NETCONFIG_EVENT_FAILED);
+		return;
+	}
+
+	/* DHCP already started or waiting for the LL address, nothing to do */
+	if (nc->v6_auto_method == NETCONFIG_V6_METHOD_DHCP)
+		goto emit_event;
+
+	/*
+	 * Otherwise we already have a SLAAC address, just check if any of the
+	 * auto-configuration prefixes in this RA covers our existing address
+	 * and allows us to extend its lifetime.
+	 */
+	netconfig_set_slaac_address_lifetimes(nc, r);
+
+emit_event:
 	/*
 	 * Note: we may be emitting this before L_NETCONFIG_EVENT_CONFIGURE.
 	 * We should probably instead save the affected routes in separate
@@ -1003,7 +1164,8 @@ process_nondefault_routes:
 	if (!l_queue_isempty(nc->routes.added) ||
 			!l_queue_isempty(nc->routes.updated) ||
 			!l_queue_isempty(nc->routes.removed) ||
-			!l_queue_isempty(nc->routes.expired))
+			!l_queue_isempty(nc->routes.expired) ||
+			!l_queue_isempty(nc->addresses.updated))
 		netconfig_emit_event(nc, AF_INET6, L_NETCONFIG_EVENT_UPDATE);
 }
 
@@ -1706,6 +1868,8 @@ configure_ipv6:
 		goto done;
 	}
 
+	netconfig->v6_auto_method = NETCONFIG_V6_METHOD_UNSET;
+
 	/*
 	 * We only care about being on addr_wait_list if we're waiting for
 	 * the link-local address for DHCP6.  Add ourself to the list here
Signature · 1 line
2.34.1
#6 lore raw

PATCH 7/7 netconfig: Control optimistic DAD

In reply to Andrew Zaborowski

Enable or disable optimistic DAD for the interface using /proc. Add l_netconfig_set_optimistic_dad_enabled() for the user to request that RFC 4429 optimistic DAD be enabled. As recommended in the RFC, we'll only actually enable optimistic DAD for the automatic address generation methods and disable it if a static IPv6 address is configured. The default if l_netconfig_set_optimistic_dad_enabled() isn't used is to disable optimistic DAD always.

Optimistic DAD can shorten practical IPv6 setup time by an amount on the order of a second by allowing the link-local address and the global address to be used immediately after being generated. For the link-local address this means that DHCPv6 may start sooner and for the global address, which is added to the kernel by the L_NETCONFIG_EVENT_CONFIGURE event handler, the user can start establishing connections sooner. With DHCPv6 and some luck the two savings may compound, with SLAAC only the global address's DAD time should matter.

---
 ell/ell.sym     |  1 +
 ell/netconfig.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 ell/netconfig.h |  2 ++
 3 files changed, 51 insertions(+), 1 deletion(-)
ell/ell.sym +1 -0
index d76b2ea..6df9024 100644
@@ -751,6 +751,7 @@ global:
 	l_netconfig_set_dns_override;
 	l_netconfig_set_domain_names_override;
 	l_netconfig_set_acd_enabled;
+	l_netconfig_set_optimistic_dad_enabled;
 	l_netconfig_check_config;
 	l_netconfig_reset_config;
 	l_netconfig_start;
ell/netconfig.c +48 -1

97 lines not on this page · raw message

ell/netconfig.h +2 -0
index fb3c536..3c024fe 100644
@@ -69,6 +69,8 @@ bool l_netconfig_set_dns_override(struct l_netconfig *netconfig, uint8_t family,
 bool l_netconfig_set_domain_names_override(struct l_netconfig *netconfig,
 						uint8_t family, char **names);
 bool l_netconfig_set_acd_enabled(struct l_netconfig *netconfig, bool enabled);
+bool l_netconfig_set_optimistic_dad_enabled(struct l_netconfig *netconfig,
+						bool enabled);
 bool l_netconfig_check_config(struct l_netconfig *netconfig);
 bool l_netconfig_reset_config(struct l_netconfig *netconfig);
 
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH 7/7] netconfig: Control optimistic DAD

Hi Andrew,

Quoted 17 lines · Andrew Zaborowski

Enable or disable optimistic DAD for the interface using /proc. Add l_netconfig_set_optimistic_dad_enabled() for the user to request that RFC 4429 optimistic DAD be enabled. As recommended in the RFC, we'll only actually enable optimistic DAD for the automatic address generation methods and disable it if a static IPv6 address is configured. The default if l_netconfig_set_optimistic_dad_enabled() isn't used is to disable optimistic DAD always.

Optimistic DAD can shorten practical IPv6 setup time by an amount on the order of a second by allowing the link-local address and the global address to be used immediately after being generated. For the link-local address this means that DHCPv6 may start sooner and for the global address, which is added to the kernel by the L_NETCONFIG_EVENT_CONFIGURE event handler, the user can start establishing connections sooner. With DHCPv6 and some luck the two savings may compound, with SLAAC only the global address's DAD time should matter.

Quoted 6 lines
---
  ell/ell.sym     |  1 +
  ell/netconfig.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
  ell/netconfig.h |  2 ++
  3 files changed, 51 insertions(+), 1 deletion(-)

I went ahead and applied all patches in this series. Question:

ell/netconfig.c static void netconfig_ifaddr_ipv6_added(struct l_netconfig *nc, · line 1742

Quoted 8 lines
ell/netconfig.c +2 -1
@@ -1724,7 +1737,8 @@ static void netconfig_ifaddr_ipv6_added(struct l_netconfig *nc,
  	struct in6_addr in6;
  	_auto_(l_free) char *ip = NULL;
 
-	if (ifa->ifa_flags & IFA_F_TENTATIVE)
+	if ((ifa->ifa_flags & IFA_F_TENTATIVE) &&
+			!(ifa->ifa_flags & IFA_F_OPTIMISTIC))
  		return;

This implies that we set the link local address even if it is still OPTIMISTIC.
Do we now need to update icmp6_send_router_solicitation() logic to make sure
we do not include SLLAO from optimistic addresses?

ell/netconfig.c static void netconfig_ifaddr_ipv6_added(struct l_netconfig *nc, · line 1744

Quoted 2 lines
ell/netconfig.c +0 -0
  	if (!nc->started)

Regards,
-Denis

#8 lore raw

Re: [PATCH 7/7] netconfig: Control optimistic DAD

Hi Denis,

Quoted 4 lines · Denis Kenzior
Quoted 4 lines
ell/netconfig.c +0 -0
@@ -1724,7 +1737,8 @@ static void netconfig_ifaddr_ipv6_added(struct l_netconfig *nc,
      struct in6_addr in6;
      _auto_(l_free) char *ip = NULL;
 
Quoted 8 lines

ell/netconfig.c static void netconfig_ifaddr_ipv6_added(struct l_netconfig *nc, · line 1742

Quoted 4 lines
ell/netconfig.c +2 -1
-     if (ifa->ifa_flags & IFA_F_TENTATIVE)
+     if ((ifa->ifa_flags & IFA_F_TENTATIVE) &&
+                     !(ifa->ifa_flags & IFA_F_OPTIMISTIC))
              return;

This implies that we set the link local address even if it is still OPTIMISTIC.
Do we now need to update icmp6_send_router_solicitation() logic to make sure
we do not include SLLAO from optimistic addresses?

Good point. I'll add an extra l_icmp6_client_set_link_local_address() parameter to indicate whether the address is optimistic and make sure we call it again after DAD finishes.

Best regards