When building dhcp-server on IRIX 6.5 using the native system compilers, I see that the interface enumeration fails because the function begin_iface_scan() doesn't know how to handle the case when SIOCGLIFNUM isn't defined. This ioctl allows you to figure out the number of interfaces in a system ahead of time without tediously calling realloc() with sizes that are multiples of "struct ifreq" until the system says it has the right size. IRIX 6.5 does not provide this ioctl, so begin_iface_scan() just arbitrarily says there are 64 interfaces, which is a pretty safe bet that no interface will be left behind.<div>
<br></div><div>The problem is that once the number of interfaces is /known/, this value is never reduced to the correct number, so next_iface() keeps getting called and eventually fails because there aren't really 64 interfaces in the system.</div>
<div><br></div><div>The fix is relatively simple. The ioctl returns the size in bytes of the structures, so dividing by the size of the structure returns the correct number of interfaces. Specifically, after the ioctl(..., SIOCGLIFCONF, ) (~ line 289) call, add:</div>
<div><br></div><div>#ifndef SIOCGLIFNUM</div><div>/* Compute returned number of interfaces */</div><div>ifaces->num = ifaces->conf.lifc_len / sizeof(struct ifreq);</div><div>#endif</div><div><br></div><div>This fixes the error on dhcpd startup that reads:</div>
<div><br></div><div>Error getting interface flags for '': No such device or address</div><div><br></div><div>-- Patrick Baggett</div>