summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2020-08-19 05:55:09 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2020-08-19 05:55:09 +0000
commit8821fcd74d26c36c0ec3493419ad4acb68ab85b3 (patch)
tree6af07cb32c5a0d07386a9051cf177e6ca78b2f56
parentaf5d7b6b36abeeddc857571ceedf89702d59712d (diff)
When sending a router solicitation use the link-layer (mac) address of
the outgoing interface in the source link-layer address ICMPv6 option instead of the address of the last configured autoconf interface. It is not the most efficient way to first transform an if_index into and interface name and then iterate over all addresses but this is also not in the hot path. Under normal operations slaacd will send one solicitation when an interface is set to autoconf and then never again because it will see unsolicitated router advertisements before addresses expire. OK kn
-rw-r--r--sbin/slaacd/frontend.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sbin/slaacd/frontend.c b/sbin/slaacd/frontend.c
index 2adbdb0f97a..3594085ae06 100644
--- a/sbin/slaacd/frontend.c
+++ b/sbin/slaacd/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.33 2020/07/03 17:42:50 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.34 2020/08/19 05:55:08 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -520,9 +520,6 @@ update_iface(uint32_t if_index, char* if_name)
imsg_ifinfo.soii = !(xflags & IFXF_INET6_NOSOII);
get_lladdr(if_name, &imsg_ifinfo.hw_address, &imsg_ifinfo.ll_address);
- memcpy(&nd_opt_source_link_addr, &imsg_ifinfo.hw_address,
- sizeof(nd_opt_source_link_addr));
-
frontend_imsg_compose_main(IMSG_UPDATE_IF, 0, &imsg_ifinfo,
sizeof(imsg_ifinfo));
}
@@ -1023,9 +1020,20 @@ send_solicitation(uint32_t if_index)
{
struct in6_pktinfo *pi;
struct cmsghdr *cm;
+ struct ether_addr hw_address;
+ struct sockaddr_in6 ll_address;
+ char if_name[IF_NAMESIZE];
log_debug("%s(%u)", __func__, if_index);
+ if (if_indextoname(if_index, if_name) == NULL)
+ return;
+
+ get_lladdr(if_name, &hw_address, &ll_address);
+
+ memcpy(&nd_opt_source_link_addr, &hw_address,
+ sizeof(nd_opt_source_link_addr));
+
dst.sin6_scope_id = if_index;
cm = CMSG_FIRSTHDR(&sndmhdr);