-/* $OpenBSD: engine.c,v 1.28 2018/07/23 06:14:14 florian Exp $ */
+/* $OpenBSD: engine.c,v 1.29 2018/07/23 17:25:52 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
struct ether_addr hw_address;
struct sockaddr_in6 ll_address;
uint8_t soiikey[SLAACD_SOIIKEY_LEN];
+ int link_state;
LIST_HEAD(, radv) radvs;
LIST_HEAD(, address_proposal) addr_proposals;
LIST_HEAD(, dfr_proposal) dfr_proposals;
void engine_showinfo_ctl(struct imsg *, uint32_t);
void debug_log_ra(struct imsg_ra *);
int in6_mask2prefixlen(struct in6_addr *);
+void deprecate_all_proposals(struct slaacd_iface *);
#endif /* SMALL */
struct slaacd_iface *get_slaacd_iface_by_id(uint32_t);
void remove_slaacd_iface(uint32_t);
int shut = 0;
#ifndef SMALL
struct imsg_addrinfo imsg_addrinfo;
+ struct imsg_link_state imsg_link_state;
struct address_proposal *addr_proposal = NULL;
size_t i;
#endif /* SMALL */
LIST_INSERT_HEAD(&iface->addr_proposals,
addr_proposal, entries);
+ break;
+ case IMSG_UPDATE_LINK_STATE:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE +
+ sizeof(imsg_link_state))
+ fatal("%s: IMSG_UPDATE_LINK_STATE wrong "
+ "length: %d", __func__, imsg.hdr.len);
+
+ memcpy(&imsg_link_state, imsg.data,
+ sizeof(imsg_link_state));
+
+ iface = get_slaacd_iface_by_id(
+ imsg_link_state.if_index);
+ if (iface == NULL)
+ break;
+ if (iface->link_state != imsg_link_state.link_state) {
+ iface->link_state = imsg_link_state.link_state;
+ if (iface->link_state == LINK_STATE_DOWN)
+ deprecate_all_proposals(iface);
+ else
+ start_probe(iface);
+ }
break;
#endif /* SMALL */
default:
break;
}
}
+void
+deprecate_all_proposals(struct slaacd_iface *iface)
+{
+ struct address_proposal *addr_proposal;
+
+ log_debug("%s: iface: %d", __func__, iface->if_index);
+
+ LIST_FOREACH (addr_proposal, &iface->addr_proposals, entries) {
+ addr_proposal->pltime = 0;
+ configure_address(addr_proposal);
+ addr_proposal->state = PROPOSAL_NEARLY_EXPIRED;
+ }
+}
#endif /* SMALL */
struct slaacd_iface*
-/* $OpenBSD: frontend.c,v 1.21 2018/07/23 06:14:14 florian Exp $ */
+/* $OpenBSD: frontend.c,v 1.22 2018/07/23 17:25:52 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
struct ifaddrs *ifap, *ifa;
struct in6_addrlifetime *lifetime;
struct sockaddr_in6 *sin6;
+ struct imsg_link_state imsg_link_state;
time_t t;
int xflags;
get_lladdr(if_name, &imsg_addrinfo.hw_address,
&imsg_addrinfo.ll_address);
+ memset(&imsg_link_state, 0, sizeof(imsg_link_state));
+ imsg_link_state.if_index = if_index;
+
if (getifaddrs(&ifap) != 0)
fatal("getifaddrs");
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
if (strcmp(if_name, ifa->ifa_name) != 0)
continue;
+
+ if (ifa->ifa_addr->sa_family == AF_LINK)
+ imsg_link_state.link_state =
+ ((struct if_data *)ifa->ifa_data)->ifi_link_state;
+
if (ifa->ifa_addr->sa_family != AF_INET6)
continue;
sin6 = (struct sockaddr_in6 *)ifa->ifa_addr;
}
freeifaddrs(ifap);
+
+ log_debug("%s: %s link state down? %s", __func__, if_name,
+ imsg_link_state.link_state == LINK_STATE_DOWN ? "yes" : "no");
+
+ frontend_imsg_compose_main(IMSG_UPDATE_LINK_STATE, 0,
+ &imsg_link_state, sizeof(imsg_link_state));
}
const char*
-/* $OpenBSD: slaacd.c,v 1.26 2018/07/23 06:14:14 florian Exp $ */
+/* $OpenBSD: slaacd.c,v 1.27 2018/07/23 17:25:52 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
int shut = 0;
#ifndef SMALL
struct imsg_addrinfo imsg_addrinfo;
+ struct imsg_link_state imsg_link_state;
int verbose;
#endif /* SMALL */
main_imsg_compose_engine(IMSG_UPDATE_ADDRESS, 0,
&imsg_addrinfo, sizeof(imsg_addrinfo));
break;
+ case IMSG_UPDATE_LINK_STATE:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE +
+ sizeof(imsg_link_state))
+ fatal("%s: IMSG_UPDATE_LINK_STATE wrong "
+ "length: %d", __func__, imsg.hdr.len);
+ memcpy(&imsg_link_state, imsg.data,
+ sizeof(imsg_link_state));
+ main_imsg_compose_engine(IMSG_UPDATE_LINK_STATE, 0,
+ &imsg_link_state, sizeof(imsg_link_state));
+ break;
#endif /* SMALL */
case IMSG_UPDATE_IF:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
-/* $OpenBSD: slaacd.h,v 1.18 2018/07/23 06:14:14 florian Exp $ */
+/* $OpenBSD: slaacd.h,v 1.19 2018/07/23 17:25:52 florian Exp $ */
/*
* Copyright (c) 2017 Florian Obser <florian@openbsd.org>
IMSG_CTL_SHOW_INTERFACE_INFO_DFR_PROPOSAL,
IMSG_CTL_END,
IMSG_UPDATE_ADDRESS,
+ IMSG_UPDATE_LINK_STATE,
#endif /* SMALL */
IMSG_CTL_SEND_SOLICITATION,
IMSG_SOCKET_IPC,
uint32_t vltime;
uint32_t pltime;
};
+
+struct imsg_link_state {
+ uint32_t if_index;
+ int link_state;
+};
#endif /* SMALL */
struct imsg_ifinfo {