summaryrefslogtreecommitdiff
path: root/sbin/slaacd
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2021-08-24 14:56:07 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2021-08-24 14:56:07 +0000
commit1b2d0bbd8ff7171e7e19d9296df96e42efe22cee (patch)
treef61148ceb81cd2bf92dbf907498f592c3986744f /sbin/slaacd
parent86c45eb35447c3eb16d8d159744560e792aa3608 (diff)
When an interface disappears, e.g. when a usb dongle gets unplugged,
we get a RTM_IFANNOUNCE message not a RTM_IFINFO message. Handle this message to not accumulate "unknown" interfaces. While here fix a bug where we would remove an interface only in the engine process but not in the frontend when an interfaces gets unplugged while we process a RTM_IFINFO message for it. OK benno
Diffstat (limited to 'sbin/slaacd')
-rw-r--r--sbin/slaacd/frontend.c13
-rw-r--r--sbin/slaacd/slaacd.c5
2 files changed, 15 insertions, 3 deletions
diff --git a/sbin/slaacd/frontend.c b/sbin/slaacd/frontend.c
index d3cb23a2925..72d7929c5df 100644
--- a/sbin/slaacd/frontend.c
+++ b/sbin/slaacd/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.57 2021/07/12 15:09:19 beck Exp $ */
+/* $OpenBSD: frontend.c,v 1.58 2021/08/24 14:56:06 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -778,6 +778,7 @@ void
handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info)
{
struct if_msghdr *ifm;
+ struct if_announcemsghdr *ifan;
struct imsg_del_addr del_addr;
struct imsg_del_route del_route;
struct imsg_dup_addr dup_addr;
@@ -798,6 +799,7 @@ handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info)
if_index = ifm->ifm_index;
frontend_imsg_compose_engine(IMSG_REMOVE_IF, 0, 0,
&if_index, sizeof(if_index));
+ remove_iface(if_index);
} else {
xflags = get_xflags(if_name);
if (xflags == -1 || !(xflags & (IFXF_AUTOCONF6 |
@@ -817,6 +819,15 @@ handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info)
}
}
break;
+ case RTM_IFANNOUNCE:
+ ifan = (struct if_announcemsghdr *)rtm;
+ if_index = ifan->ifan_index;
+ if (ifan->ifan_what == IFAN_DEPARTURE) {
+ frontend_imsg_compose_engine(IMSG_REMOVE_IF, 0, 0,
+ &if_index, sizeof(if_index));
+ remove_iface(if_index);
+ }
+ break;
case RTM_NEWADDR:
ifm = (struct if_msghdr *)rtm;
if_name = if_indextoname(ifm->ifm_index, ifnamebuf);
diff --git a/sbin/slaacd/slaacd.c b/sbin/slaacd/slaacd.c
index 0b31934c211..e167f58411c 100644
--- a/sbin/slaacd/slaacd.c
+++ b/sbin/slaacd/slaacd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slaacd.c,v 1.63 2021/07/27 08:15:11 florian Exp $ */
+/* $OpenBSD: slaacd.c,v 1.64 2021/08/24 14:56:06 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
@@ -255,7 +255,8 @@ main(int argc, char *argv[])
rtfilter = ROUTE_FILTER(RTM_IFINFO) | ROUTE_FILTER(RTM_NEWADDR) |
ROUTE_FILTER(RTM_DELADDR) | ROUTE_FILTER(RTM_DELETE) |
- ROUTE_FILTER(RTM_CHGADDRATTR) | ROUTE_FILTER(RTM_PROPOSAL);
+ ROUTE_FILTER(RTM_CHGADDRATTR) | ROUTE_FILTER(RTM_PROPOSAL) |
+ ROUTE_FILTER(RTM_IFANNOUNCE);
if (setsockopt(frontend_routesock, AF_ROUTE, ROUTE_MSGFILTER,
&rtfilter, sizeof(rtfilter)) == -1)
fatal("setsockopt(ROUTE_MSGFILTER)");