From 0f1a34e91568e1f7db2bad922d5a494fee5eddfb Mon Sep 17 00:00:00 2001 From: Thomas Markwalder Date: Tue, 23 Feb 2016 07:09:17 -0500 Subject: [PATCH] [master] Fixed interface device naming for DLPI under Solaris 11 Merges in rt37954. --- RELNOTES | 6 ++++++ common/dlpi.c | 14 ++++++++++++-- configure | 26 +++++++++++++++++++++++++- configure.ac | 8 +++++++- includes/config.h.in | 3 +++ 5 files changed, 53 insertions(+), 4 deletions(-) diff --git a/RELNOTES b/RELNOTES index 192a08b82..d59461eef 100644 --- a/RELNOTES +++ b/RELNOTES @@ -236,6 +236,12 @@ by Eric Young (eay@cryptsoft.com). Please look at doc/DHCPv4-over-DHCPv6 for more details. [ISC-Bugs #35711] +- Corrected interface name formation when using DLPI under Solaris 11. As of + Solaris 11, ethernet device files are located in "/dev/net". The configure + script has been modified to detect this situation and adjust the directory + used accordingly. + [ISC-Bugs #37954] + Changes since 4.3.3b1 - None diff --git a/common/dlpi.c b/common/dlpi.c index c34adc392..ff4094ba7 100644 --- a/common/dlpi.c +++ b/common/dlpi.c @@ -3,7 +3,7 @@ Data Link Provider Interface (DLPI) network interface code. */ /* - * Copyright (c) 2009-2011,2014 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2009-2011,2014,2016 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996-2003 by Internet Software Consortium * @@ -130,7 +130,13 @@ static int strioctl (int fd, int cmd, int timeout, int len, char *dp); #define DLPI_MAXDLBUF 8192 /* Buffer size */ #define DLPI_MAXDLADDR 1024 /* Max address size */ -#define DLPI_DEVDIR "/dev/" /* Device directory */ + +/* Device directory */ +#if defined(USE_DEV_NET) +#define DLPI_DEVDIR "/dev/net/" /* Solaris 11 + */ +#else +#define DLPI_DEVDIR "/dev/" /* Pre Solaris 11 */ +#endif static int dlpiopen(const char *ifname); static int dlpiunit (char *ifname); @@ -794,9 +800,13 @@ dlpiopen(const char *ifname) { ep = cp = ifname; while (*ep) ep++; + +/* Before Solaris 11 we strip off the digit to open the base dev name */ +#if !defined(USE_DEV_NET) /* And back up to the first digit (unit number) */ while ((*(ep - 1) >= '0' && *(ep - 1) <= '9') || *(ep - 1) == ':') ep--; +#endif /* Copy everything up to the unit number */ while (cp < ep) { diff --git a/configure b/configure index 5c980452b..773627890 100755 --- a/configure +++ b/configure @@ -7170,7 +7170,31 @@ CFLAGS="$CFLAGS -I\$(top_srcdir)/includes -I$BINDDIR/include" case "$host" in *-darwin*) - CFLAGS="$CFLAGS -D__APPLE_USE_RFC_3542" ;; + CFLAGS="$CFLAGS -D__APPLE_USE_RFC_3542";; +*-solaris*) + # As of Solaris 11, ethernet dev files are in /dev/net + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for /dev/net" >&5 +$as_echo_n "checking for /dev/net... " >&6; } +if ${ac_cv_file__dev_net+:} false; then : + $as_echo_n "(cached) " >&6 +else + test "$cross_compiling" = yes && + as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 +if test -r "/dev/net"; then + ac_cv_file__dev_net=yes +else + ac_cv_file__dev_net=no +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_file__dev_net" >&5 +$as_echo "$ac_cv_file__dev_net" >&6; } +if test "x$ac_cv_file__dev_net" = xyes; then : + +$as_echo "#define USE_DEV_NET 1" >>confdefs.h + +fi + + ;; esac diff --git a/configure.ac b/configure.ac index 7f05b7d6a..ba252d34f 100644 --- a/configure.ac +++ b/configure.ac @@ -792,7 +792,13 @@ CFLAGS="$CFLAGS -I\$(top_srcdir)/includes -I$BINDDIR/include" case "$host" in *-darwin*) - CFLAGS="$CFLAGS -D__APPLE_USE_RFC_3542" ;; + CFLAGS="$CFLAGS -D__APPLE_USE_RFC_3542";; +*-solaris*) + # As of Solaris 11, ethernet dev files are in /dev/net + AC_CHECK_FILE(/dev/net, + [AC_DEFINE([USE_DEV_NET], [1], + [Define to 1 if ethernet devices are in /dev/net])]) + ;; esac AC_C_FLEXIBLE_ARRAY_MEMBER diff --git a/includes/config.h.in b/includes/config.h.in index 403a28f1a..02f5dbcfe 100644 --- a/includes/config.h.in +++ b/includes/config.h.in @@ -169,6 +169,9 @@ /* Define to include server activity tracing support. */ #undef TRACING +/* Define to 1 if ethernet devices are in /dev/net */ +#undef USE_DEV_NET + /* Define to include PIDs in syslog messages. */ #undef USE_LOG_PID -- 2.39.2