Linux IPv6 interface discovery patch dhcp4
Matthew Newton
mcn4 at leicester.ac.uk
Thu Oct 2 12:25:31 UTC 2008
Hi,
I'm new here - hope this is the correct place for patches :)
In playing with dhcpd 4.1.0a2 (and 4.0.0) there is a bug whereby
it refuses to start up if /proc/net/if_inet6 does not exist. This
is the case on machines that do not have IPv6 support.
In this case, even if "-4" is specified on the dhcpd command line,
the following error is given, and the daemon refuses to start:
Error opening '/proc/net/if_inet6' to list IPv6 interfaces; No such file or directory
The following patch fixes that by not scanning /proc/net/if_inet6
if the daemon has been started in IPv4 mode. It's also available as
original file at
http://www.le.ac.uk/its/mcn4/dhcpd/linux_ipv6_discover.patch
I thought about compiling with --disable-dhcpv6, but that produces
compile-time errors on 4.0 ;)
Cheers,
Matthew
diff -Naur dhcp-4.1.0a2/common/discover.c dhcp-4.1.0a2-mcn/common/discover.c
--- dhcp-4.1.0a2/common/discover.c 2008-08-29 18:48:57.000000000 +0100
+++ dhcp-4.1.0a2-mcn/common/discover.c 2008-10-02 13:02:06.000000000 +0100
@@ -443,15 +443,17 @@
}
#ifdef DHCPv6
- ifaces->fp6 = fopen("/proc/net/if_inet6", "r");
- if (ifaces->fp6 == NULL) {
- log_error("Error opening '/proc/net/if_inet6' to "
- "list IPv6 interfaces; %m");
- close(ifaces->sock);
- ifaces->sock = -1;
- fclose(ifaces->fp);
- ifaces->fp = NULL;
- return 0;
+ if (local_family == AF_INET6) {
+ ifaces->fp6 = fopen("/proc/net/if_inet6", "r");
+ if (ifaces->fp6 == NULL) {
+ log_error("Error opening '/proc/net/if_inet6' to "
+ "list IPv6 interfaces; %m");
+ close(ifaces->sock);
+ ifaces->sock = -1;
+ fclose(ifaces->fp);
+ ifaces->fp = NULL;
+ return 0;
+ }
}
#endif
@@ -720,7 +722,8 @@
}
#ifdef DHCPv6
if (!(*err)) {
- return next_iface6(info, err, ifaces);
+ if (local_family == AF_INET6)
+ return next_iface6(info, err, ifaces);
}
#endif
return 0;
@@ -736,7 +739,8 @@
close(ifaces->sock);
ifaces->sock = -1;
#ifdef DHCPv6
- fclose(ifaces->fp6);
+ if (local_family == AF_INET6)
+ fclose(ifaces->fp6);
ifaces->fp6 = NULL;
#endif
}
--
Matthew Newton, Ph.D. <mcn4 at le.ac.uk>
Systems Architect (UNIX and Networks), Network Services,
I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom
For IT help contact helpdesk extn. 2253, <ithelp at le.ac.uk>
More information about the dhcp-hackers
mailing list