However, there is a problem deleting both IPv4 and IPv6 subnet routes.
Also, there is a problem opening a BPF fd in non blocking mode directly and
posix_spawn(3) fails to work so we block that in configure.
Occured in NetBSD-5.0, fixed in NetBSD-6.99.29
Occured in OpenBSD-4.2, fixed in OpenBSD-5.0
+On FreeBSD-10 dhcpcd cannot delete IPv4 subnet routes
+On OpenBSD-5.4 dhcpcd cannot delete IPv4 subnet routes and the kernel allows
+the addition of duplicate routes.
+
We try and detect how dhcpcd should interact with system services at runtime.
If we cannot auto-detect how do to this, or it is wrong then
you can change this by passing shell commands to --serviceexists,
}
if (ioctl(fd, BIOCSETF, &pf) == -1)
goto eexit;
+
+#ifdef __OpenBSD__
+ /* For some reason OpenBSD fails to open the fd as non blocking */
+ if ((flags = fcntl(fd, F_GETFL, 0)) == -1 ||
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)
+ goto eexit;
+#endif
+
return fd;
eexit:
CFLAGS+= -g -Wall -Wextra -Wshadow -Wformat=2
CFLAGS+= -Wmissing-prototypes -Wmissing-declarations
CFLAGS+= -Wmissing-noreturn -Wmissing-format-attribute
-CFLAGS+= -Wredundant-decls -Wnested-externs
+CFLAGS+= -Wnested-externs
CFLAGS+= -Winline -Wwrite-strings -Wcast-align -Wcast-qual
CFLAGS+= -Wpointer-arith -Wstrict-overflow
CFLAGS+= -Wdeclaration-after-statement
EOF
+ case "$OS" in
+ openbsd) ;; # OpenBSD has many redundant decs in system headers
+ *) echo "CFLAGS+= -Wredundant-decls" >>$CONFIG_MK;;
+ esac
fi
if [ -z "$EMBEDDED" -o "$EMBEDDED" = yes ]; then
EOF
fi
+if [ -z "$TAILQ_CONCAT" ]; then
+ printf "Testing for TAILQ_CONCAT ..."
+ cat <<EOF >_queue.c
+#include <sys/queue.h>
+int main(void) {
+#ifndef TAILQ_CONCAT
+#error TAILQ_CONCAT
+#endif
+ return 0;
+}
+EOF
+ if $XCC _queue.c -o _queue 2>/dev/null; then
+ TAILQ_CONCAT=yes
+ else
+ TAILQ_CONCAT=no
+ fi
+ echo "$TAILQ_CONCAT"
+ rm -f _queue.c _queue
+fi
+if [ "$TAILQ_CONCAT" = no ]; then
+ cat <<EOF >>$CONFIG_H
+#define TAILQ_CONCAT(head1, head2, field) do { \\
+ if (!TAILQ_EMPTY(head2)) { \\
+ *(head1)->tqh_last = (head2)->tqh_first; \\
+ (head2)->tqh_first->field.tqe_prev = (head1)->tqh_last; \\
+ (head1)->tqh_last = (head2)->tqh_last; \\
+ TAILQ_INIT((head2)); \\
+ } \\
+} while (/*CONSTCOND*/0)
+EOF
+fi
+
if [ -z "$POSIX_SPAWN" ]; then
printf "Testing for posix_spawn ... "
cat <<EOF >_posix_spawn.c
}
EOF
if $XCC _posix_spawn.c -o _posix_spawn 2>/dev/null; then
- POSIX_SPAWN=yes
+ case "$OS" in
+ openbsd) printf "broken OpenBSD ... "; POSIX_SPAWN=no;;
+ *) POSIX_SPAWN=yes;;
+ esac
else
POSIX_SPAWN=no
fi
}
#endif
+#ifdef __FreeBSD__
+ syslog(LOG_WARNING, "FreeBSD errors that are worked around:");
+ syslog(LOG_WARNING, "IPv4 subnet routes cannot be deleted");
+#endif
+#ifdef __OpenBSD__
+ syslog(LOG_WARNING, "OpenBSD errors that need to be fixed:");
+ syslog(LOG_WARNING,
+ "IPv4 subnet routes and IPv6 prefixes cannot be deleted");
+ syslog(LOG_WARNING, "duplicate IPv4 subnet routes will be created");
+#endif
+
ctx.ifc = argc - optind;
ctx.ifv = argv + optind;
#elif __APPLE__
/* FIXME: Add apple includes so we can work out SSID */
#else
+# include <net80211/ieee80211.h>
# include <net80211/ieee80211_ioctl.h>
#endif
# define IN6_IFF_TENTATIVE (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)
# define IN6_IFF_DUPLICATED IFA_F_DADFAILED
#else
-#ifdef __FreeBSD__ /* Needed so that including netinet6/in6_var.h works */
# include <net/if.h>
+#ifdef __FreeBSD__ /* Needed so that including netinet6/in6_var.h works */
# include <net/if_var.h>
#endif
# include <netinet6/in6_var.h>
#define IPV6_H
#include <sys/queue.h>
+#include <sys/uio.h>
#include <netinet/in.h>
#define IP6BUFLEN (CMSG_SPACE(sizeof(struct in6_pktinfo)) + \
CMSG_SPACE(sizeof(int)))
+#ifdef INET6
struct ipv6_ctx {
struct sockaddr_in6 from;
struct msghdr sndhdr;
int dhcp_fd;
};
+#endif
#ifdef INET6
struct ipv6_ctx *ipv6_init(struct dhcpcd_ctx *);
# define SYS_NMLN 256
#endif
+#ifndef HW_MACHINE_ARCH
+# ifdef HW_MODEL /* OpenBSD */
+# define HW_MACHINE_ARCH HW_MODEL
+# endif
+#endif
+
int
hardware_platform(char *str, size_t len)
{