Re: Late start for IPv6
Roy Marples
Thu May 29 10:32:44 2014
On 29/05/2014 8:13, Roy Marples wrote:
Attached is a patch that enables this.
This time ;)
Index: defs.h
==================================================================
--- defs.h
+++ defs.h
@@ -47,11 +47,11 @@
#endif
#ifndef LEASEFILE6
# define LEASEFILE6 DBDIR "/" PACKAGE "-%s.lease6"
#endif
#ifndef PIDFILE
-# define PIDFILE RUNDIR "/" PACKAGE "%s%s.pid"
+# define PIDFILE RUNDIR "/" PACKAGE "%s%s%s.pid"
#endif
#ifndef CONTROLSOCKET
# define CONTROLSOCKET RUNDIR "/" PACKAGE "%s%s.sock"
#endif
#ifndef RDM_MONOFILE
Index: dhcpcd.8.in
==================================================================
--- dhcpcd.8.in
+++ dhcpcd.8.in
@@ -20,11 +20,11 @@
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 7, 2014
+.Dd May 29, 2014
.Dt DHCPCD 8
.Os
.Sh NAME
.Nm dhcpcd
.Nd a DHCP client
@@ -611,10 +611,20 @@
.Sh NOTES
.Nm
requires a Berkley Packet Filter, or BPF device on BSD based systems and a
Linux Socket Filter, or LPF device on Linux based systems for all IPv4
configuration.
+.Pp
+If restricting
+.Nm
+to a single interface and optionally address family via the command-line
+then all futher calls to
+.Nm
+to rebind, reconfigure or exit need to include the same restrictive flags
+so that
+.Nm
+knows which process to signal.
.Sh FILES
.Bl -ohang
.It Pa @SYSCONFDIR@/dhcpcd.conf
Configuration file for dhcpcd.
If you always use the same options, put them here.
Index: dhcpcd.c
==================================================================
--- dhcpcd.c
+++ dhcpcd.c
@@ -1114,11 +1114,11 @@
int
main(int argc, char **argv)
{
struct dhcpcd_ctx ctx;
- char pidfile[sizeof(PIDFILE) + IF_NAMESIZE];
+ char pidfile[sizeof(PIDFILE) + IF_NAMESIZE + 1];
struct if_options *ifo;
struct interface *ifp;
uint16_t family = 0;
int opt, oi = 0, i;
time_t t;
@@ -1172,13 +1172,23 @@
i = 0;
while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
{
switch (opt) {
case '4':
+ if (family) {
+ syslog(LOG_ERR, "cannot specify more than one"
+ " address family");
+ goto exit_failure;
+ }
family = AF_INET;
break;
case '6':
+ if (family) {
+ syslog(LOG_ERR, "cannot specify more than one"
+ " address family");
+ goto exit_failure;
+ }
family = AF_INET6;
break;
case 'f':
ctx.cffile = optarg;
break;
@@ -1276,20 +1286,33 @@
if (!(ctx.options & (DHCPCD_TEST | DHCPCD_DUMPLEASE))) {
/* If we have any other args, we should run as a single dhcpcd
* instance for that interface. */
if (optind == argc - 1 && !(ctx.options & DHCPCD_MASTER)) {
+ const char *per;
+
if (strlen(argv[optind]) > IF_NAMESIZE) {
syslog(LOG_ERR, "%s: interface name too long",
argv[optind]);
goto exit_failure;
+ }
+ /* Allow a dhcpcd interface per address family */
+ switch(family) {
+ case AF_INET:
+ per = "-4";
+ break;
+ case AF_INET6:
+ per = "-6";
+ break;
+ default:
+ per = "";
}
snprintf(pidfile, sizeof(pidfile),
- PIDFILE, "-", argv[optind]);
+ PIDFILE, "-", argv[optind], per);
}
else {
- snprintf(pidfile, sizeof(pidfile), PIDFILE, "", "");
+ snprintf(pidfile, sizeof(pidfile), PIDFILE, "", "", "");
ctx.options |= DHCPCD_MASTER;
}
}
if (chdir("/") == -1)
Archive administrator: postmaster@marples.name