]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
-4 and -6 are now mutually exclusive and when running on a single interface
authorRoy Marples <roy@marples.name>
Thu, 29 May 2014 12:52:27 +0000 (12:52 +0000)
committerRoy Marples <roy@marples.name>
Thu, 29 May 2014 12:52:27 +0000 (12:52 +0000)
per protocol pidfiles are created.
This means that other control options suchs as -x and -n will require the
-4 or -6 option as well.

defs.h
dhcpcd.8.in
dhcpcd.c

diff --git a/defs.h b/defs.h
index b97c0425f295ead97845378d1666879139aab263..e9de7fa9fe1831d34199ad70d307e7a1e6dd96bb 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -49,7 +49,7 @@
 # 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"
index 6033ea9e4622d725bf597ab85e2b0e7618ac4827..fcd475ad4bb93d8b8bfe9141196a825672c45d8a 100644 (file)
@@ -22,7 +22,7 @@
 .\" 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
@@ -613,6 +613,16 @@ unicasts INFORM to the destination, otherwise it defaults to STATIC.
 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
index 5ec6b8f0ee20e99ea0a0ec0d7f76efa30fb6ad9e..482764d41bec049023c9717d4713c3d0deb51336 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1116,7 +1116,7 @@ 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;
@@ -1174,9 +1174,19 @@ main(int argc, char **argv)
        {
                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':
@@ -1278,16 +1288,29 @@ main(int argc, char **argv)
                /* 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;
                }
        }