-/* $OpenBSD: engine.c,v 1.25 2021/08/12 12:41:08 florian Exp $ */
+/* $OpenBSD: engine.c,v 1.26 2021/09/15 06:08:01 florian Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
char file[4 * DHCP_FILE_LEN + 1];
char hostname[4 * 255 + 1];
char domainname[4 * 255 + 1];
+ struct dhcp_route prev_routes[MAX_DHCP_ROUTES];
+ int prev_routes_len;
struct dhcp_route routes[MAX_DHCP_ROUTES];
int routes_len;
struct in_addr nameservers[MAX_RDNS_COUNT];
} else
#endif /* SMALL */
{
+ iface->prev_routes_len = iface->routes_len;
+ memcpy(iface->prev_routes, iface->routes,
+ sizeof(iface->prev_routes));
iface->routes_len = routes_len;
memcpy(iface->routes, routes, sizeof(iface->routes));
}
send_configure_interface(struct dhcpleased_iface *iface)
{
struct imsg_configure_interface imsg;
+ int i, j, found;
log_lease(iface, 0);
+ memset(&imsg, 0, sizeof(imsg));
imsg.if_index = iface->if_index;
imsg.rdomain = iface->rdomain;
imsg.addr.s_addr = iface->requested_ip.s_addr;
strlcpy(imsg.file, iface->file, sizeof(imsg.file));
strlcpy(imsg.domainname, iface->domainname, sizeof(imsg.domainname));
strlcpy(imsg.hostname, iface->hostname, sizeof(imsg.hostname));
+ for (i = 0; i < iface->prev_routes_len; i++) {
+ found = 0;
+ for (j = 0; j < iface->routes_len; j++) {
+ if (memcmp(&iface->prev_routes[i], &iface->routes[j],
+ sizeof(struct dhcp_route)) == 0) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found)
+ imsg.routes[imsg.routes_len++] = iface->prev_routes[i];
+ }
+ if (imsg.routes_len > 0)
+ engine_imsg_compose_main(IMSG_WITHDRAW_ROUTES, 0, &imsg,
+ sizeof(imsg));
imsg.routes_len = iface->routes_len;
memcpy(imsg.routes, iface->routes, sizeof(imsg.routes));
engine_imsg_compose_main(IMSG_CONFIGURE_INTERFACE, 0, &imsg,