On Wed, 6 Jan 2016, Roger Shimizu wrote: > Control: forwarded -1 http://sourceforge.net/p/wide-dhcpv6/bugs/36/ > Control: tag -1 +patch > > Dear Robert, > > I find your report is similar to upstream's bug: > http://sourceforge.net/p/wide-dhcpv6/bugs/36/ > And there's also patch on that page. So if you have compiling > environment, you can try that solution. > > Cheers, > Roger
Hello Roger, you are right, the upstream bug report reports the same error, but the analysis and solution is IMHO incorrect. I will send my opinion to the upstream bug report too. IMHO the code: if (fgets(line, sizeof(line), fp) == NULL && ferror(fp)) { dprintf(LOG_ERR, FNAME, "failed to read key file: %s", strerror(errno)); goto fail; } is correct: first, fgets() tries to read something. If the fgets() returns NULL, it means either there are no data or there was an error. Then, if the fgets()==NULL (TRUE) the code does "&&" (AND) and checks, if there is ERROR on fp - ferror() checks the error state of stream. And if both, fgets()==NULL AND ferror(), are TRUE, it means there was an error. If the ferror() returns FALSE, then fgets()==NULL means only, there are no data but it is no error. It means, there is no problem with -k /dev/null - it means only there is no "shared secret to authenticate the communication with dhcp6ctl" (man page). On my system there are running two dhcp6s with -k /dev/null and I have no error: PID TTY STAT TIME COMMAND 2637 ? Ss 0:00 /usr/sbin/dhcp6s -k /dev/null -P /var/run/dhcp6s.vlan95.pid -p 2095 vlan95 2641 ? Ss 0:00 /usr/sbin/dhcp6s -k /dev/null -P /var/run/dhcp6s.vlan96.pid -p 2096 vlan96 But I have to use different control ports -p 2095 and -p 2096. But this has nothing to do with the error reported by me in Debian bug #799080: dhcp6s[1471]: dhcp6_ctl_init: bind(control sock): Address already in use This error comes because dhcp6s uses one port for communication with dhcp6ctl and the default port is set to 5546. It means, if you start first dhcp6s, it starts listening on port 5546. Then you try to start second dhcp6s and it want to listen on port 5546 too - but this port is already used and therefore the error "Address already in use" reported. The main problem is that dhcp6s must be started as one process for every interface, so if you have multiple interfaces then you have to start multiple dhcp6s processes. You can solve this using /etc/rc.local and start all these dhcp6s processes yourself with "-p" option, but the debian init.d script contains code to process multiple interfaces and start dhcp6s process for every interface: for INT in $INTERFACES; do log_daemon_msg "Starting $DESC on $INT" "$NAME" start-stop-daemon --start --quiet --pidfile ${DHCP6SPIDBASE}.${INT}.pid \ --exec $DHCP6SBIN --oknodo -- -k /dev/null -P ${DHCP6SPIDBASE}.${INT}.pid $INT sleep 2 if check_status -q; then log_end_msg 0 else log_end_msg 1 exit 1 fi done As you can see, init.d script starts dhcp6s only with different (generated) PID file, but the port is not defined, i.e. for every dhcp6s it tries to start with default port 5546. It would be great if someone can solve this and allow to start dhcp6s for every interface with different (generated or somehow defined) control port. Thank you. Regards, Robert Wolf.