[erlang-patches] Tiny patch to inet_drv.c for Solaris Open Indiana and Illumos

Raimo Niskanen raimo+erlang-patches@REDACTED
Thu Nov 24 18:07:46 CET 2011


On Thu, Nov 24, 2011 at 08:44:18AM +0100, Trond Norbye wrote:
> It should no longer be needed after they reapplied my patch to use
> libdlpi to retrieve the mac address. (I just built everything on
> Solaris 11, and it detects everything correctly out of the box).
> 
> At least on my OpenIndiana box (and I would guess other clones as
> well) libdlpi needs libdladm.so.1 which is installed in /lib, and
> libdlpi.so doesn't include an rpath to automatically detect it. That
> means that you'd need to add: LDFLAGS="-L/lib -R/lib" for it to
> successfully detect the availability of the library.

I am again looking at that patch of yours, and I think you will need
to review my changes it...

I have three problems:
1. On my machine (the only I found with libdlpi (we have not installed
  an OpenIndiana box yet)) there is no /lib/libdlpi.so and
  /lib/64/libdlpi.so symlinks to the corresponding *.so.1 files
  so the linking always fails. I suspect it is an installation issue
  so I did the symlinks by hand.
    $ uname -a
    SunOS fenris 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-V245
  Does this seem reasonable?
2. You are right about gcc. It passes an -Y P,/usr/ccs/lib flag to
  /usr/ccs/bin/ld which resets the by crle configured default path.
  I must however augument your patch to give -L/lib/64 -R/lib/64 to
  LDFLAGS for a 64-bit build. Does this seem reasonable?
3. When I run it does not succeed in finding the hwaddr. Truss shows this:
  4146/6:         so_socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP, "", SOV_XPG4_2) = 7
  4146/6:         fcntl(7, F_GETFL)                               = 2
  4146/6:         fcntl(7, F_SETFL, FWRITE|FNONBLOCK)             = 0
  4146/6:         setsockopt(7, SOL_SOCKET, SO_RCVBUF, 0xFEAF9C2C, 4, SOV_DEFAULT) = 0
  4146/6:         bind(7, 0xFEAFA020, 16, SOV_XPG4_2)             = 0
  4146/6:         getsockname(7, 0xFEAFA020, 0xFEAFAC00, SOV_DEFAULT) = 0
  4146/6:         open("/dev/bge0", O_RDWR)                       Err#13 EACCES [net_rawaccess]
  4146/6:         open("/devices/pseudo/clone@REDACTED:bge0", O_RDWR)    Err#2 ENOENT
  4146/6:         open("/dev/bge", O_RDWR)                        Err#13 EACCES [net_rawaccess]
  4146/6:         open("/devices/pseudo/clone@REDACTED:bge", O_RDWR)     Err#13 EACCES [net_rawaccess]
  Is there some nasty configuration I have missed to do?
  This run was without the -R flag but that should have given worse errors. Right?
  > inet:getif("bge0", [hwaddr]).
  {ok,[]}

Right now the diff is this awkward (against your patch merged to master
with a small conflict resolved):
------------------------------ erts/configure.in ------------------------------
index 992df94..d8d15ad 100644
@@ -1482,6 +1482,34 @@ AC_CHECK_HEADERS(fcntl.h limits.h unistd.h syslog.h dlfcn.h ieeefp.h \
                  net/errno.h malloc.h arpa/nameser.h libdlpi.h \
 		 pty.h util.h utmp.h langinfo.h poll.h sdkddkver.h)
 
+AC_CHECK_MEMBERS([struct ifreq.ifr_hwaddr])
+
+dnl ----------------------------------------------------------------------
+dnl Check the availability for libdlpi
+dnl ----------------------------------------------------------------------
+AC_CHECK_LIB(dlpi, dlpi_open)
+if test $ac_cv_lib_dlpi_dlpi_open = no; then
+   dnl Try again now with -L/lib (or ditto 64) as argument to linker since
+   dnl gcc makes ld ignore the crle configured linker default paths
+   save_ldflags="$LDFLAGS"
+   if test "x$ac_cv_sizeof_void_p" = "x8"; then
+      if test -d "/lib64"; then
+         LDFLAGS="-L/lib64 -R/lib64 $LDFLAGS"
+      elif test -d "/lib/64"; then
+         LDFLAGS="-L/lib/64 -R/lib/64 $LDFLAGS"
+      else
+         LDFLAGS="-L/lib -R/lib $LDFLAGS"
+      fi
+   else
+      LDFLAGS="-L/lib -R/lib $LDFLAGS"
+   fi
+   unset -v ac_cv_lib_dlpi_dlpi_open
+   AC_CHECK_LIB(dlpi, dlpi_open)
+   if test $ac_cv_lib_dlpi_dlpi_open = no; then
+      LDFLAGS="$save_ldflags"
+   fi
+fi
+
 AC_CHECK_HEADER(sys/resource.h,
 	[AC_DEFINE(HAVE_SYS_RESOURCE_H, 1,
 		[Define to 1 if you have the <sys/resource.h> header file])
@@ -4304,11 +4332,6 @@ AH_BOTTOM([
 ])
 
 dnl ----------------------------------------------------------------------
-dnl Check the availability for libdlpi
-dnl ----------------------------------------------------------------------
-AC_CHECK_LIB(dlpi, dlpi_open)
-
-dnl ----------------------------------------------------------------------
 dnl Output the result.
 dnl ----------------------------------------------------------------------
 

------------------- erts/emulator/drivers/common/inet_drv.c -------------------
index 4550065..9dbe661 100644
@@ -4301,7 +4301,7 @@ static int inet_ctl_ifget(inet_descriptor* desc, char* buf, int len,
                     sptr += alen;
                 }
             }
-#elif defined(SIOCGIFHWADDR)
+#elif defined(SIOCGIFHWADDR) && defined(HAVE_STRUCT_IFREQ_IFR_HWADDR)
 	    if (ioctl(desc->s, SIOCGIFHWADDR, (char *)&ifreq) < 0)
 		break;
 	    buf_check(sptr, s_end, 1+2+IFHWADDRLEN);

/ Raimo


 
> 
> Trond
> 
> On Thu, Nov 24, 2011 at 12:37 AM, Scott Lystig Fritchie
> <fritchie@REDACTED> wrote:
> > Hi, all.  I got a GitHub pull request several days ago for a tiny patch
> > to inet_drv.c.
> >
> >    https://github.com/slfritchie/otp/pull/3
> >
> > I haven't seen anything on this list mentioning this small patch, so I
> > thought I'd submit it on behalf of the original author.  (He hasn't
> > replied to my comment on the GitHub pull request, either.)
> >
> > Vladimir says that the patch is necessary for Solaris Illumos.  I can
> > confirm that it's necessary for Solaris Open Indiana build 151a, also.
> > I haven't bootstrapped my development environment yet for Solaris 11 to
> > know if it's required there, also.
> >
> > The 1-line patch is here:
> >
> >    https://github.com/proger/otp/commit/f40294921d5862add77fd77851beb2785b026306`
> >    https://github.com/proger/otp/commit/f40294921d5862add77fd77851beb2785b026306.patch
> >
> > -Scott
> > _______________________________________________
> > erlang-patches mailing list
> > erlang-patches@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-patches
> >
> 
> 
> 
> -- 
> Trond Norbye
> _______________________________________________
> erlang-patches mailing list
> erlang-patches@REDACTED
> http://erlang.org/mailman/listinfo/erlang-patches

-- 

/ Raimo Niskanen, Erlang/OTP, Ericsson AB



More information about the erlang-patches mailing list