-/* $OpenBSD: dhclient.c,v 1.723 2021/07/12 15:09:18 beck Exp $ */
+/* $OpenBSD: dhclient.c,v 1.724 2021/07/27 18:35:30 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
void go_daemon(void);
int rdaemon(int);
int take_charge(struct interface_info *, int, char *);
+int autoconf(struct interface_info *);
struct client_lease *get_recorded_lease(struct interface_info *);
#define ROUNDUP(a) \
fatal("path_lease_db");
routefd = get_routefd(ifi->rdomain);
- fd = take_charge(ifi, routefd, path_lease_db);
+ fd = take_charge(ifi, routefd, path_lease_db); /* Kill other dhclients. */
+ if (autoconf(ifi)) {
+ /* dhcpleased has been notified to request a new lease. */
+ return 0;
+ }
if (fd != -1)
read_lease_db(&ifi->lease_db);
return NULL;
}
+int
+autoconf(struct interface_info *ifi)
+{
+ struct ifreq ifr;
+ int ioctlfd;
+
+ if ((ioctlfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+ fatal("socket(AF_INET, SOCK_DGRAM)");
+
+ memset(&ifr, 0, sizeof(ifr));
+ strlcpy(ifr.ifr_name, ifi->name, sizeof(ifr.ifr_name));
+
+ if (ioctl(ioctlfd, SIOCGIFXFLAGS, (caddr_t)&ifr) < 0)
+ fatal("SIOGIFXFLAGS");
+
+ close(ioctlfd);
+
+ return ifr.ifr_flags & IFXF_AUTOCONF4;
+}
+
int
take_charge(struct interface_info *ifi, int routefd, char *leasespath)
{