[Date Prev] [Date Index] [Date Next] [Thread Prev] [Thread Index] [Thread Next]

Re: Problems with conserver after OS upgrade

Chris Ross cross+conserver@distal.com
Mon, 8 Jun 2009 13:58:13 GMT

On Monday 08 June 2009 09:30:26 Chris Ross wrote:
> On Monday 08 June 2009 02:05:47 Bryan Stansell wrote:
> > A quick search found this thread:
> >
> > http://mail-index.netbsd.org/tech-userlevel/2009/03/22/msg001912.html
> >
> > which talks about how 5.0 is much less tolerant of apps that don't use
> > SIOCGIFCONF "correctly" (which could very well be the problem - but
> > conserver works across many platforms, so I wonder what's up).  Probably
> > something simple to fix, but their suggested change is basically what
> > conserver already does. 
>   HAVE_SA_LEN is set.  In looking at the code in the thread you mention,
> and the code in conserver, they're clearly similar, but referencing
> different elements of the ifreq structure. 

  Looking at this a little more, that difference there was the important one.  
The patch in the email thread which you mention above compares sa_len to 
sizeof(ifr->ifr_irfu).  The code in conserver, however, compares against 
sizeof(ifr->ifr_addr).  ifr_addr is an element in the union (ifr_ifru), but 
not the largest one, so those sizeof's yield different results.

  The attached patch causes it to find the interfaces and addresses, and 
ProbeInterfaces() now reports them in conserver -DS output.  (And all of the 
consoles come up and work under normal use)

  Was this an error on your part, that is just showing a problem for me 
because NetBSD's ifru is so much bigger than ifr_addr (128 vs 16 bytes)?  Or 
is this bug unique to NetBSD, and there should be a local change for NetBSD?


                                                - Chris

--- conserver/cutil.c.orig	2009-06-08 09:49:09.000000000 -0400
+++ conserver/cutil.c	2009-06-08 09:49:14.000000000 -0400
@@ -2283,7 +2283,7 @@
 	if ((ifc.ifc_len - r) < sizeof(*ifr))
 #ifdef HAVE_SA_LEN
-	if (sa->sa_len > sizeof(ifr->ifr_addr))
+	if (sa->sa_len > sizeof(ifr->ifr_ifru))
 	    r += sizeof(ifr->ifr_name) + sa->sa_len;