Browse Source

Merge branch 'master' of ssh://git.kea.isc.org/git/kea

Tomek Mrugalski 7 years ago
parent
commit
6931fb4bf1

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+1306.	[bug]*		marcin
+	Respective Kea daemons now use their own default configuration
+	files: kea-dhcp4.conf, kea-dhcp6.conf, kea-dhcp-ddns.conf and
+	kea-ctrl-agent.conf. This change is aimed at eliminating the
+	issue whereby 'config-write' command overrides configuration
+	of all servers rather than just a configuration of the deamon
+	to which this command has been sent.
+	(Trac #5338, git 252e5e8a75fa42271b0cdb6edad3c152bbf3c515)
+
 1305.	[bug]	tmark
 	Corrected logic that was causing kea-dhcp4 to remove DNS entries
 	when renewing leases with generated FQDN names.  Prior to this

+ 1 - 1
doc/guide/agent.xml

@@ -297,7 +297,7 @@ http {
       The CA is started by running its binary and specifying the configuration file
       it should use. For example:
 <screen>
-$ ./kea-ctrl-agent -c /usr/local/etc/kea/kea.conf
+$ ./kea-ctrl-agent -c /usr/local/etc/kea/kea-ctrl-agent.conf
 </screen>
     </para>
   </section>

+ 13 - 5
doc/guide/keactrl.xml

@@ -73,7 +73,11 @@ keactrl &lt;command&gt; [-c keactrl-config-file] [-s server[,server,..]]
 prefix=@prefix@
 
 # Location of Kea configuration file.
-kea_config_file=@sysconfdir@/@PACKAGE@/kea.conf
+kea_dhcp4_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp4.conf
+kea_dhcp6_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp6.conf
+kea_dhcp_ddns_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp-ddns.conf
+kea_ctrl_agent_config_file=@sysconfdir@/@PACKAGE@/kea-ctrl-agent.conf
+
 
 # Location of Kea binaries.
 exec_prefix=@exec_prefix@
@@ -168,10 +172,10 @@ kea_verbose=no
       the servers looks similar to the following:
 <screen>
 <userinput>$ keactrl start</userinput>
-INFO/keactrl: Starting kea-dhcp4 -c /usr/local/etc/kea/kea.conf -d
-INFO/keactrl: Starting kea-dhcp6 -c /usr/local/etc/kea/kea.conf -d
-INFO/keactrl: Starting kea-dhcp-ddns -c /usr/local/etc/kea/kea.conf -d
-INFO/keactrl: Starting kea-ctrl-agent -c /usr/local/etc/kea/kea.conf -d
+INFO/keactrl: Starting kea-dhcp4 -c /usr/local/etc/kea/kea-dhcp4.conf -d
+INFO/keactrl: Starting kea-dhcp6 -c /usr/local/etc/kea/kea-dhcp6.conf -d
+INFO/keactrl: Starting kea-dhcp-ddns -c /usr/local/etc/kea/kea-dhcp-ddns.conf -d
+INFO/keactrl: Starting kea-ctrl-agent -c /usr/local/etc/kea/kea-ctrl-agent.conf -d
 </screen>
       </para>
 
@@ -261,6 +265,10 @@ DHCPv6 server: inactive
 DHCP DDNS: active
 Control Agent: active
 Kea configuration file: /usr/local/etc/kea/kea.conf
+Kea DHCPv4 configuration file: /usr/local/etc/kea/kea-dhcp4.conf
+Kea DHCPv6 configuration file: /usr/local/etc/kea/kea-dhcp6.conf
+Kea DHCP DDNS configuration file: /usr/local/etc/kea/kea-dhcp-ddns.conf
+Kea Control Agent configuration file: /usr/local/etc/kea/kea-ctrl-agent.conf
 keactrl configuration file: /usr/local/etc/kea/keactrl.conf
 </screen>
       </para>

+ 12 - 8
doc/guide/quickstart.xml

@@ -62,11 +62,13 @@ $ <userinput>./configure [your extra parameters]</userinput></screen>
         </listitem>
 
         <listitem>
-          <para>Edit the configuration file which by default is installed in
-          <filename>[kea-install-dir]/etc/kea/kea.conf</filename> and contains
-          configuration for all Kea services. Configuration choices for DHCPv4
-          and DHCPv6 services are described in <xref linkend="dhcp4-configuration"/> and <xref linkend="dhcp6-configuration"/>:w
- respectively.</para>
+          <para>Edit the Kea configuration files which by default are installed in
+          the <filename>[kea-install-dir]/etc/kea/</filename> directory. These are:
+          <filename>kea-dhcp4.conf</filename>, <filename>kea-dhcp6.conf</filename>,
+          <filename>kea-dhcp-ddns.conf</filename> and
+          <filename>kea-ctrl-agent.conf</filename>, for DHCPv4 server, DHCPv6 server,
+          D2 and Control Agent respectively.
+          </para>
         </listitem>
 
         <listitem>
@@ -75,7 +77,7 @@ $ <userinput>./configure [your extra parameters]</userinput></screen>
           <screen># <userinput>keactrl start -s dhcp4</userinput></screen>
           Or run the following command to start DHCPv6 server instead:
           <screen># <userinput>keactrl start -s dhcp6</userinput></screen>
-          Note that it is also possible to start both servers simultaneously:
+          Note that it is also possible to start all servers simultaneously:
           <screen>$ <userinput>keactrl start</userinput></screen>
           </para>
         </listitem>
@@ -85,8 +87,10 @@ $ <userinput>./configure [your extra parameters]</userinput></screen>
           <screen># <userinput>keactrl status</userinput></screen>
           A server status of "inactive" may indicate a configuration
           error. Please check the log file (by default named
-          <filename>[kea-install-dir]/var/kea/kea-dhcp4.log</filename> or
-          <filename>[kea-install-dir]/var/kea/kea-dhcp6.log</filename>) 
+          <filename>[kea-install-dir]/var/kea/kea-dhcp4.log</filename>,
+          <filename>[kea-install-dir]/var/kea/kea-dhcp6.log</filename>,
+          <filename>[kea-install-dir]/var/kea/kea-ddns.log</filename> or
+          <filename>[kea-install-dir]/var/kea/kea-ctrl-agent.log</filename>) 
           for the details of the error.
           </para>
         </listitem>

+ 4 - 1
src/bin/keactrl/.gitignore

@@ -1,4 +1,7 @@
 /keactrl
-/kea.conf
+/kea-dhcp4.conf
+/kea-dhcp6.conf
+/kea-dhcp-ddns.conf
+/kea-ctrl-agent.conf
 /keactrl.conf
 /keactrl.8

+ 27 - 9
src/bin/keactrl/Makefile.am

@@ -5,21 +5,26 @@ SUBDIRS = . tests
 # If the default location needs to be changed it may be achieved by
 # setting KEACTRL_CONF environment variable.
 sbin_SCRIPTS  = keactrl
-CONFIGFILES = keactrl.conf kea.conf
+KEA_CONFIGFILES = kea-dhcp4.conf kea-dhcp6.conf kea-dhcp-ddns.conf \
+                  kea-ctrl-agent.conf
+CONFIGFILES = keactrl.conf $(KEA_CONFIGFILES)
 
 man_MANS = keactrl.8
 DISTCLEANFILES = keactrl keactrl.conf $(man_MANS)
-CLEANFILES = kea.conf
-EXTRA_DIST = keactrl.in keactrl.conf.in kea.conf.pre $(man_MANS) keactrl.xml
+CLEANFILES = $(KEA_CONFIGFILES)
+EXTRA_DIST = keactrl.in keactrl.conf.in kea-dhcp4.conf.pre \
+             kea-dhcp6.conf.pre kea-dhcp-ddns.conf.pre \
+             kea-ctrl-agent.conf.pre $(man_MANS) keactrl.xml
 
-# kea.conf is not really a source used for building other targets, but we need
-# this file to be generated before make install is called.
-BUILT_SOURCES = kea.conf
+# *.conf files are not really sources used for building other targets, but we need
+# these files to be generated before make install is called.
+BUILT_SOURCES = $(KEA_CONFIGFILES)
 
 if GENERATE_DOCS
 
 keactrl.8: keactrl.xml
-	@XSLTPROC@ --novalid --xinclude --nonet -o $@ http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/keactrl.xml
+	@XSLTPROC@ --novalid --xinclude --nonet -o $@ \
+        http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $(srcdir)/keactrl.xml
 
 else
 
@@ -29,8 +34,21 @@ $(man_MANS):
 
 endif
 
-kea.conf: kea.conf.pre
-	$(top_builddir)/tools/path_replacer.sh $(top_srcdir)/src/bin/keactrl/kea.conf.pre $@
+kea-dhcp4.conf: kea-dhcp4.conf.pre
+	$(top_builddir)/tools/path_replacer.sh \
+    $(top_srcdir)/src/bin/keactrl/kea-dhcp4.conf.pre $@
+
+kea-dhcp6.conf: kea-dhcp6.conf.pre
+	$(top_builddir)/tools/path_replacer.sh \
+    $(top_srcdir)/src/bin/keactrl/kea-dhcp6.conf.pre $@
+
+kea-dhcp-ddns.conf: kea-dhcp-ddns.conf.pre
+	$(top_builddir)/tools/path_replacer.sh \
+    $(top_srcdir)/src/bin/keactrl/kea-dhcp-ddns.conf.pre $@
+
+kea-ctrl-agent.conf: kea-ctrl-agent.conf.pre
+	$(top_builddir)/tools/path_replacer.sh \
+    $(top_srcdir)/src/bin/keactrl/kea-ctrl-agent.conf.pre $@
 
 if INSTALL_CONFIGURATIONS
 

+ 94 - 0
src/bin/keactrl/kea-ctrl-agent.conf.pre

@@ -0,0 +1,94 @@
+// This is a basic configuration for the Kea Control Agent.
+//
+// This is just a very basic configuration. Kea comes with large suite (over 30)
+// of configuration examples and extensive Kea User's Guide. Please refer to
+// those materials to get better understanding of what this software is able to
+// do. Comments in this configuration file sometimes refer to sections for more
+// details. These are section numbers in Kea User's Guide. The version matching
+// your software should come with your Kea package, but it is also available
+// on Kea web page (http://kea.isc.org, click User's Guide, direct link for
+// stable version is http://kea.isc.org/docs/kea-guide.html).
+//
+// This configuration file contains only Control Agent's configuration.
+// If configurations for other Kea services are also included in this file they
+// are ignored by the Control Agent.
+{
+
+// This is a basic configuration for the Kea Control Agent.
+// RESTful interface to be available at http://127.0.0.1:8080/
+"Control-agent": {
+    "http-host": "127.0.0.1",
+    "http-port": 8080,
+
+    // Specify location of the files to which the Control Agent
+    // should connect to forward commands to the DHCPv4 and DHCPv6
+    // server via unix domain socket.
+    "control-sockets": {
+        "dhcp4": {
+            "socket-type": "unix",
+            "socket-name": "/tmp/kea-dhcp4-ctrl.sock"
+        },
+        "dhcp6": {
+            "socket-type": "unix",
+            "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
+        }
+    },
+
+    // Specify hooks libraries that are attached to the Control Agent.
+    // Such hooks libraries should support 'control_command_receive'
+    // hook point. This is currently commented out because it has to
+    // point to the existing hooks library. Otherwise the Control
+    // Agent will fail to start.
+    "hooks-libraries": [
+//  {
+//      "library": "/opt/local/control-agent-commands.so",
+//      "parameters": {
+//          "param1": "foo"
+//      }
+//  }
+    ]
+},
+
+// Logging configuration starts here. Kea uses different loggers to log various
+// activities. For details (e.g. names of loggers), see Chapter 18.
+"Logging":
+{
+  "loggers": [
+    {
+        // This specifies the logging for Control Agent daemon.
+        "name": "kea-ctrl-agent",
+        "output_options": [
+            {
+                // Specifies the output file. There are several special values
+                // supported:
+                // - stdout (prints on standard output)
+                // - stderr (prints on standard error)
+                // - syslog (logs to syslog)
+                // - syslog:name (logs to syslog using specified name)
+                // Any other value is considered a name of a time
+                "output": "@localstatedir@/log/kea-ctrl-agent.log"
+
+                // This governs whether the log output is flushed to disk after
+                // every write.
+                // "flush": false,
+
+                // This specifies the maximum size of the file before it is
+                // rotated.
+                // "maxsize": 1048576,
+
+                // This specifies the maximum number of rotated files to keep.
+                // "maxver": 8
+            }
+        ],
+        // This specifies the severity of log messages to keep. Supported values
+        // are: FATAL, ERROR, WARN, INFO, DEBUG
+        "severity": "INFO",
+
+        // If DEBUG level is specified, this value is used. 0 is least verbose,
+        // 99 is most verbose. Be cautious, Kea can generate lots and lots
+        // of logs if told to do so.
+        "debuglevel": 0
+    }
+  ]
+}
+}

+ 71 - 0
src/bin/keactrl/kea-dhcp-ddns.conf.pre

@@ -0,0 +1,71 @@
+// This is a basic configuration for the Kea DHCP DDNS daemon.
+//
+// This is just a very basic configuration. Kea comes with large suite (over 30)
+// of configuration examples and extensive Kea User's Guide. Please refer to
+// those materials to get better understanding of what this software is able to
+// do. Comments in this configuration file sometimes refer to sections for more
+// details. These are section numbers in Kea User's Guide. The version matching
+// your software should come with your Kea package, but it is also available
+// on Kea web page (http://kea.isc.org, click User's Guide, direct link for
+// stable version is http://kea.isc.org/docs/kea-guide.html).
+//
+// This configuration file contains only DHCP DDNS daemon's configuration.
+// If configurations for other Kea services are also included in this file they
+// are ignored by the DHCP DDNS daemon.
+{
+
+// DHCP DDNS configuration starts here. This is a very simple configuration
+// that simply starts the DDNS daemon, but will not do anything useful.
+// See Section 11 for examples and details description.
+"DhcpDdns":
+{
+  "ip-address": "127.0.0.1",
+  "port": 53001,
+  "tsig-keys": [],
+  "forward-ddns" : {},
+  "reverse-ddns" : {}
+},
+
+// Logging configuration starts here. Kea uses different loggers to log various
+// activities. For details (e.g. names of loggers), see Chapter 18.
+"Logging":
+{
+  "loggers": [
+    {
+        // This specifies the logging for D2 (DHCP-DDNS) daemon.
+        "name": "kea-dhcp-ddns",
+        "output_options": [
+            {
+                // Specifies the output file. There are several special values
+                // supported:
+                // - stdout (prints on standard output)
+                // - stderr (prints on standard error)
+                // - syslog (logs to syslog)
+                // - syslog:name (logs to syslog using specified name)
+                // Any other value is considered a name of a time
+                "output": "@localstatedir@/log/kea-ddns.log"
+
+                // This governs whether the log output is flushed to disk after
+                // every write.
+                // "flush": false,
+
+                // This specifies the maximum size of the file before it is
+                // rotated.
+                // "maxsize": 1048576,
+
+                // This specifies the maximum number of rotated files to keep.
+                // "maxver": 8
+            }
+        ],
+        // This specifies the severity of log messages to keep. Supported values
+        // are: FATAL, ERROR, WARN, INFO, DEBUG
+        "severity": "INFO",
+
+        // If DEBUG level is specified, this value is used. 0 is least verbose,
+        // 99 is most verbose. Be cautious, Kea can generate lots and lots
+        // of logs if told to do so.
+        "debuglevel": 0
+    }
+  ]
+}
+}

+ 7 - 398
src/bin/keactrl/kea.conf.pre

@@ -1,6 +1,6 @@
-// This is a basic configuration for the Kea DHCP servers and Kea Control
-// Agent. Subnet declarations are mostly commented out and no interfaces are
-// listed. Therefore, the servers will not listen or respond to any queries.
+// This is a basic configuration for the Kea DHCPv4 server. Subnet declarations
+// are mostly commented out and no interfaces are listed. Therefore, the servers
+// will not listen or respond to any queries.
 // The basic configuration must be extended to specify interfaces on which
 // the servers should listen. There are a number of example options defined.
 // These probably don't make any sense in your network. Make sure you at least
@@ -17,6 +17,10 @@
 // your software should come with your Kea package, but it is also available
 // on Kea web page (http://kea.isc.org, click User's Guide, direct link for
 // stable version is http://kea.isc.org/docs/kea-guide.html).
+//
+// This configuration file contains only DHCPv4 server's configuration.
+// If configurations for other Kea services are also included in this file they
+// are ignored by the DHCPv4 server.
 {
 
 // DHCPv4 configuration starts here. This section will be read by DHCPv4 server
@@ -407,368 +411,6 @@
     // information at once.
 },
 
-// DHCPv6 configuration starts here. This section will be read by DHCPv6 server
-// and will be ignored by other components.
-"Dhcp6": {
-    // Add names of your network interfaces to listen on.
-    "interfaces-config": {
-        // You typically want to put specific interface names here, e.g. eth0
-        // but you can also specify unicast addresses (e.g. eth0/2001:db8::1) if
-        // you want your server to handle unicast traffic in addition to
-        // multicast. (DHCPv6 is a multicast based protocol).
-        "interfaces": [ ]
-    },
-
-    // Kea support control channel, which is a way to receive management commands
-    // while the server is running. This is a Unix domain socket that receives
-    // commands formatted in JSON, e.g. config-set (which sets new configuration),
-    // config-reload (which tells Kea to reload its configuration from file),
-    // statistic-get (to retrieve statistics) and many more. For detailed
-    // description, see Sections 9.12, 16 and 15.
-    "control-socket": {
-        "socket-type": "unix",
-        "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
-    },
-
-    // Use Memfile lease database backend to store leases in a CSV file.
-    // Depending on how Kea was compiled, it may also support SQL databases
-    // (MySQL and/or PostgreSQL) and even Cassandra. Those database backends
-    // require more parameters, like name, host and possibly user and password.
-    // There are dedicated examples for each backend. See Section 8.2.2 "Lease
-    // Storage" for details.
-    "lease-database": {
-        "type": "memfile"
-    },
-
-    // Kea allows storing host reservations in a database. If your network is
-    // small or you have few reservations, it's probably easier to keep them
-    // in the configuration file. If your network is large, it's usually better
-    // to use database for it. To enable it, uncomment the following:
-    // "hosts-database": {
-    //     "type": "mysql",
-    //     "name": "kea",
-    //     "user": "kea",
-    //     "password": "kea",
-    //     "host": "localhost",
-    //     "port": 3306
-    // },
-    // See Section 8.2.3 "Hosts storage" for details.
-
-    // Setup reclamation of the expired leases and leases affinity.
-    // Expired leases will be reclaimed every 10 seconds. Every 25
-    // seconds reclaimed leases, which have expired more than 3600
-    // seconds ago, will be removed. The limits for leases reclamation
-    // are 100 leases or 250 ms for a single cycle. A warning message
-    // will be logged if there are still expired leases in the
-    // database after 5 consecutive reclamation cycles.
-    "expired-leases-processing": {
-        "reclaim-timer-wait-time": 10,
-        "flush-reclaimed-timer-wait-time": 25,
-        "hold-reclaimed-time": 3600,
-        "max-reclaim-leases": 100,
-        "max-reclaim-time": 250,
-        "unwarned-reclaim-cycles": 5
-    },
-
-    // These parameters govern global timers. Addresses will be assigned with
-    // preferred and valid lifetimes being 3000 and 4000, respectively. Client
-    // is told to start renewing after 1000 seconds. If the server does not
-    // respond after 2000 seconds since the lease was granted, a client is
-    // supposed to start REBIND procedure (emergency renewal that allows
-    // switching to a different server).
-    "renew-timer": 1000,
-    "rebind-timer": 2000,
-    "preferred-lifetime": 3000,
-    "valid-lifetime": 4000,
-
-    // These are global options. They are going to be sent when a client requests
-    // them, unless overwritten with values in more specific scopes. The scope
-    // hierarchy is:
-    // - global
-    // - subnet
-    // - class
-    // - host
-    //
-    // Not all of those options make sense. Please configure only those that
-    // are actually useful in your network.
-    //
-    // For a complete list of options currently supported by Kea, see
-    // Section 8.2.9 "Standard DHCPv6 Options". Kea also supports
-    // vendor options (see Section 7.2.10) and allows users to define their
-    // own custom options (see Section 7.2.9).
-    "option-data": [
-        // When specifying options, you typically need to specify
-        // one of (name or code) and data. The full option specification
-        // covers name, code, space, csv-format and data.
-        // space defaults to "dhcp6" which is usually correct, unless you
-        // use encapsulate options. csv-format defaults to "true", so
-        // this is also correct, unless you want to specify the whole
-        // option value as long hex string. For example, to specify
-        // domain-name-servers you could do this:
-        // {
-        //     "name": "dns-servers",
-        //     "code": 23,
-        //     "csv-format": "true",
-        //     "space": "dhcp6",
-        //     "data": "2001:db8:2::45, 2001:db8:2::100"
-        // }
-        // but it's a lot of writing, so it's easier to do this instead:
-        {
-            "name": "dns-servers",
-            "data": "2001:db8:2::45, 2001:db8:2::100"
-        },
-
-        // Typically people prefer to refer to options by their names, so they
-        // don't need to remember the code names. However, some people like
-        // to use numerical values. For example, DHCPv6 can optionally use
-        // server unicast communication, if extra option is present. Option
-        // "unicast" uses option code 12, so you can reference to it either
-        // by "name": "unicast" or "code": 12. If you enable this option,
-        // you really should also tell the server to listen on that address
-        // (see interfaces-config/interfaces list above).
-        {
-            "code": 12,
-            "data": "2001:db8::1"
-        },
-
-        // String options that have a comma in their values need to have
-        // it escaped (i.e. each comma is preceded by two backslashes).
-        // That's because commas are reserved for separating fields in
-        // compound options. At the same time, we need to be conformant
-        // with JSON spec, that does not allow "\,". Therefore the
-        // slightly uncommon double backslashes notation is needed.
-
-        // Legal JSON escapes are \ followed by "\/bfnrt character
-        // or \u followed by 4 hexadecimal numbers (currently Kea
-        // supports only \u0000 to \u00ff code points).
-        // CSV processing translates '\\' into '\' and '\,' into ','
-        // only so for instance '\x' is translated into '\x'. But
-        // as it works on a JSON string value each of these '\'
-        // characters must be doubled on JSON input.
-        {
-            "name": "new-posix-timezone",
-            "data": "EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00"
-        },
-
-        // Options that take integer values can either be specified in
-        // dec or hex format. Hex format could be either plain (e.g. abcd)
-        // or prefixed with 0x (e.g. 0xabcd).
-        {
-            "name": "preference",
-            "data": "0xf0"
-        },
-
-        // A few options are encoded in (length, string) tuples
-        // which can be defined using only strings as the CSV
-        // processing computes lengths.
-        {
-            "name": "bootfile-param",
-            "data": "root=/dev/sda2, quiet, splash"
-        }
-    ],
-
-    // Below an example of a simple IPv6 subnet declaration. Uncomment to enable
-    // it. This is a list, denoted with [ ], of structures, each denoted with
-    // { }. Each structure describes a single subnet and may have several
-    // parameters. One of those parameters is "pools" that is also a list of
-    // structures.
-    "subnet6": [
-        {
-            // This defines the whole subnet. Kea will use this information to
-            // determine where the clients are connected. This is the whole
-            // subnet in your network. This is mandatory parameter for each
-            // subnet.
-            "subnet": "2001:db8:1::/64",
-
-            // Pools define the actual part of your subnet that is governed
-            // by Kea. Technically this is optional parameter, but it's
-            // almost always needed for DHCP to do its job. If you omit it,
-            // clients won't be able to get addresses, unless there are
-            // host reservations defined for them.
-            "pools": [ { "pool": "2001:db8:1::/80" } ],
-
-            // Kea supports prefix delegation (PD). This mechanism delegates
-            // whole prefixes, instead of single addresses. You need to specify
-            // a prefix and then size of the delegated prefixes that it will
-            // be split into. This example below tells Kea to use
-            // 2001:db8:1::/56 prefix as pool and split it into /64 prefixes.
-            // This will give you 256 (2^(64-56)) prefixes.
-            "pd-pools": [
-                {
-                    "prefix": "2001:db8:8::",
-                    "prefix-len": 56,
-                    "delegated-len": 64
-
-                    // Kea also supports excluded prefixes. This advanced option
-                    // is explained in Section 9.2.9. Please make sure your
-                    // excluded prefix matches the pool it is defined in.
-                    // "excluded-prefix": "2001:db8:8:0:80::",
-                    // "excluded-prefix-len": 72
-                }
-            ],
-            "option-data": [
-                // You can specify additional options here that are subnet
-                // specific. Also, you can override global options here.
-                {
-                    "name": "dns-servers",
-                    "data": "2001:db8:2::dead:beef, 2001:db8:2::cafe:babe"
-                }
-            ],
-
-            // Host reservations can be defined for each subnet.
-            //
-            // Note that reservations are subnet-specific in Kea. This is
-            // different than ISC DHCP. Keep that in mind when migrating
-            // your configurations.
-            "reservations": [
-                // This is a simple host reservation. The host with DUID matching
-                // the specified value will get an address of 2001:db8:1::100.
-                {
-                    "duid": "01:02:03:04:05:0A:0B:0C:0D:0E",
-                    "ip-addresses": [ "2001:db8:1::100" ]
-                },
-
-                // This is similar to the previous one, but this time the
-                // reservation is done based on hardware/MAC address. The server
-                // will do its best to extract the hardware/MAC address from
-                // received packets (see 'mac-sources' directive for
-                // details). This particular reservation also specifies two
-                // extra options to be available for this client. If there are
-                // options with the same code specified in a global, subnet or
-                // class scope, the values defined at host level take
-                // precedence.
-                {
-                    "hw-address": "00:01:02:03:04:05",
-                    "ip-addresses": [ "2001:db8:1::101" ],
-                    "option-data": [
-                        {
-                            "name": "dns-servers",
-                            "data": "3000:1::234"
-                        },
-                        {
-                            "name": "nis-servers",
-                            "data": "3000:1::234"
-                        }],
-
-                    // This client will be automatically added to certain
-                    // classes.
-                    "client-classes": [ "special_snowflake", "office" ]
-                },
-
-                // This is a bit more advanced reservation. The client with the
-                // specified DUID will get a reserved address, a reserved prefix
-                // and a hostname.  This reservation is for an address that it
-                // not within the dynamic pool.  Finally, this reservation
-                // features vendor specific options for CableLabs, which happen
-                // to use enterprise-id 4491. Those particular values will be
-                // returned only to the client that has a DUID matching this
-                // reservation.
-                {
-                    "duid": "01:02:03:04:05:06:07:08:09:0A",
-                    "ip-addresses": [ "2001:db8:1:cafe::1" ],
-                    "prefixes": [ "2001:db8:2:abcd::/64" ],
-                    "hostname": "foo.example.com",
-                    "option-data": [
-                        {
-                            "name": "vendor-opts",
-                            "data": "4491"
-                        },
-                        {
-                            "name": "tftp-servers",
-                            "space": "vendor-4491",
-                            "data": "3000:1::234"
-                        }
-                    ]
-                },
-
-                // This reservation is using flexible identifier. Instead of
-                // relying on specific field, sysadmin can define an expression
-                // similar to what is used for client classification,
-                // e.g. substring(relay[0].option[17],0,6). Then, based on the
-                // value of that expression for incoming packet, the reservation
-                // is matched.  Expression can be specified either as hex or
-                // plain text using single quotes.
-
-                // Note: flexible identifier requires flex_id hook library to be
-                // loaded to work.
-                {
-                    "flex-id": "'somevalue'",
-                    "ip-addresses": [ "2001:db8:1:cafe::2" ]
-                }
-            ]
-        }
-        // More subnets can be defined here.
-        //      {
-        //          "subnet": "2001:db8:2::/64",
-        //          "pools": [ { "pool": "2001:db8:2::/80" } ]
-        //      },
-        //      {
-        //          "subnet": "2001:db8:3::/64",
-        //          "pools": [ { "pool": "2001:db8:3::/80" } ]
-        //      },
-        //      {
-        //          "subnet": "2001:db8:4::/64",
-        //          "pools": [ { "pool": "2001:db8:4::/80" } ]
-        //      }
-    ]
-
-    // Client-classes can be defined here. See "client-classes" in Dhcp4 for
-    // an example.
-
-    // Hook libraries can be defined here. See "hooks-libraries" example in
-    // Dhcp4.
-
-    // DDNS information (how the DHCPv6 component can reach a DDNS daemon)
-
-},
-
-// DHCP DDNS configuration starts here. This is a very simple configuration
-// that simply starts the DDNS daemon, but will not do anything useful.
-// See Section 11 for examples and details description.
-"DhcpDdns":
-{
-  "ip-address": "127.0.0.1",
-  "port": 53001,
-  "tsig-keys": [],
-  "forward-ddns" : {},
-  "reverse-ddns" : {}
-},
-
-// This is a basic configuration for the Kea Control Agent.
-// RESTful interface to be available at http://127.0.0.1:8080/
-"Control-agent": {
-    "http-host": "127.0.0.1",
-    "http-port": 8080,
-
-    // Specify location of the files to which the Control Agent
-    // should connect to forward commands to the DHCPv4 and DHCPv6
-    // server via unix domain socket.
-    "control-sockets": {
-        "dhcp4": {
-            "socket-type": "unix",
-            "socket-name": "/tmp/kea-dhcp4-ctrl.sock"
-        },
-        "dhcp6": {
-            "socket-type": "unix",
-            "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
-        }
-    },
-
-    // Specify hooks libraries that are attached to the Control Agent.
-    // Such hooks libraries should support 'control_command_receive'
-    // hook point. This is currently commented out because it has to
-    // point to the existing hooks library. Otherwise the Control
-    // Agent will fail to start.
-    "hooks-libraries": [
-//  {
-//      "library": "/opt/local/control-agent-commands.so",
-//      "parameters": {
-//          "param1": "foo"
-//      }
-//  }
-    ]
-},
-
 // Logging configuration starts here. Kea uses different loggers to log various
 // activities. For details (e.g. names of loggers), see Chapter 18.
 "Logging":
@@ -810,39 +452,6 @@
         // 99 is most verbose. Be cautious, Kea can generate lots and lots
         // of logs if told to do so.
         "debuglevel": 0
-    },
-    {
-        // This specifies the logging for kea-dhcp6 logger, i.e. all logs
-        // generated by Kea DHCPv6 server.
-        "name": "kea-dhcp6",
-        "output_options": [
-            {
-                "output": "@localstatedir@/log/kea-dhcp6.log"
-            }
-        ],
-        "severity": "INFO",
-        "debuglevel": 0
-    },
-    {
-        // This specifies the logging for D2 (DHCP-DDNS) daemon.
-        "name": "kea-dhcp-ddns",
-        "output_options": [
-            {
-                "output": "@localstatedir@/log/kea-ddns.log"
-            }
-        ],
-        "severity": "INFO",
-        "debuglevel": 0
-    },
-    {
-        "name": "kea-ctrl-agent",
-        "output_options": [
-            {
-                "output": "@localstatedir@/log/kea-ctrl-agent.log"
-            }
-        ],
-        "severity": "INFO",
-        "debuglevel": 0
     }
   ]
 }

+ 384 - 0
src/bin/keactrl/kea-dhcp6.conf.pre

@@ -0,0 +1,384 @@
+// This is a basic configuration for the Kea DHCPv6 server. Subnet declarations
+// are mostly commented out and no interfaces are listed. Therefore, the servers
+// will not listen or respond to any queries.
+// The basic configuration must be extended to specify interfaces on which
+// the servers should listen. There are a number of example options defined.
+// These probably don't make any sense in your network. Make sure you at least
+// update the following, before running this example in your network:
+// - change the network interface names
+// - change the subnets to match your actual network
+// - change the option values to match your network
+//
+// This is just a very basic configuration. Kea comes with large suite (over 30)
+// of configuration examples and extensive Kea User's Guide. Please refer to
+// those materials to get better understanding of what this software is able to
+// do. Comments in this configuration file sometimes refer to sections for more
+// details. These are section numbers in Kea User's Guide. The version matching
+// your software should come with your Kea package, but it is also available
+// on Kea web page (http://kea.isc.org, click User's Guide, direct link for
+// stable version is http://kea.isc.org/docs/kea-guide.html).
+//
+// This configuration file contains only DHCPv6 server's configuration.
+// If configurations for other Kea services are also included in this file they
+// are ignored by the DHCPv6 server.
+{
+
+// DHCPv6 configuration starts here. This section will be read by DHCPv6 server
+// and will be ignored by other components.
+"Dhcp6": {
+    // Add names of your network interfaces to listen on.
+    "interfaces-config": {
+        // You typically want to put specific interface names here, e.g. eth0
+        // but you can also specify unicast addresses (e.g. eth0/2001:db8::1) if
+        // you want your server to handle unicast traffic in addition to
+        // multicast. (DHCPv6 is a multicast based protocol).
+        "interfaces": [ ]
+    },
+
+    // Kea support control channel, which is a way to receive management commands
+    // while the server is running. This is a Unix domain socket that receives
+    // commands formatted in JSON, e.g. config-set (which sets new configuration),
+    // config-reload (which tells Kea to reload its configuration from file),
+    // statistic-get (to retrieve statistics) and many more. For detailed
+    // description, see Sections 9.12, 16 and 15.
+    "control-socket": {
+        "socket-type": "unix",
+        "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
+    },
+
+    // Use Memfile lease database backend to store leases in a CSV file.
+    // Depending on how Kea was compiled, it may also support SQL databases
+    // (MySQL and/or PostgreSQL) and even Cassandra. Those database backends
+    // require more parameters, like name, host and possibly user and password.
+    // There are dedicated examples for each backend. See Section 8.2.2 "Lease
+    // Storage" for details.
+    "lease-database": {
+        "type": "memfile"
+    },
+
+    // Kea allows storing host reservations in a database. If your network is
+    // small or you have few reservations, it's probably easier to keep them
+    // in the configuration file. If your network is large, it's usually better
+    // to use database for it. To enable it, uncomment the following:
+    // "hosts-database": {
+    //     "type": "mysql",
+    //     "name": "kea",
+    //     "user": "kea",
+    //     "password": "kea",
+    //     "host": "localhost",
+    //     "port": 3306
+    // },
+    // See Section 8.2.3 "Hosts storage" for details.
+
+    // Setup reclamation of the expired leases and leases affinity.
+    // Expired leases will be reclaimed every 10 seconds. Every 25
+    // seconds reclaimed leases, which have expired more than 3600
+    // seconds ago, will be removed. The limits for leases reclamation
+    // are 100 leases or 250 ms for a single cycle. A warning message
+    // will be logged if there are still expired leases in the
+    // database after 5 consecutive reclamation cycles.
+    "expired-leases-processing": {
+        "reclaim-timer-wait-time": 10,
+        "flush-reclaimed-timer-wait-time": 25,
+        "hold-reclaimed-time": 3600,
+        "max-reclaim-leases": 100,
+        "max-reclaim-time": 250,
+        "unwarned-reclaim-cycles": 5
+    },
+
+    // These parameters govern global timers. Addresses will be assigned with
+    // preferred and valid lifetimes being 3000 and 4000, respectively. Client
+    // is told to start renewing after 1000 seconds. If the server does not
+    // respond after 2000 seconds since the lease was granted, a client is
+    // supposed to start REBIND procedure (emergency renewal that allows
+    // switching to a different server).
+    "renew-timer": 1000,
+    "rebind-timer": 2000,
+    "preferred-lifetime": 3000,
+    "valid-lifetime": 4000,
+
+    // These are global options. They are going to be sent when a client requests
+    // them, unless overwritten with values in more specific scopes. The scope
+    // hierarchy is:
+    // - global
+    // - subnet
+    // - class
+    // - host
+    //
+    // Not all of those options make sense. Please configure only those that
+    // are actually useful in your network.
+    //
+    // For a complete list of options currently supported by Kea, see
+    // Section 8.2.9 "Standard DHCPv6 Options". Kea also supports
+    // vendor options (see Section 7.2.10) and allows users to define their
+    // own custom options (see Section 7.2.9).
+    "option-data": [
+        // When specifying options, you typically need to specify
+        // one of (name or code) and data. The full option specification
+        // covers name, code, space, csv-format and data.
+        // space defaults to "dhcp6" which is usually correct, unless you
+        // use encapsulate options. csv-format defaults to "true", so
+        // this is also correct, unless you want to specify the whole
+        // option value as long hex string. For example, to specify
+        // domain-name-servers you could do this:
+        // {
+        //     "name": "dns-servers",
+        //     "code": 23,
+        //     "csv-format": "true",
+        //     "space": "dhcp6",
+        //     "data": "2001:db8:2::45, 2001:db8:2::100"
+        // }
+        // but it's a lot of writing, so it's easier to do this instead:
+        {
+            "name": "dns-servers",
+            "data": "2001:db8:2::45, 2001:db8:2::100"
+        },
+
+        // Typically people prefer to refer to options by their names, so they
+        // don't need to remember the code names. However, some people like
+        // to use numerical values. For example, DHCPv6 can optionally use
+        // server unicast communication, if extra option is present. Option
+        // "unicast" uses option code 12, so you can reference to it either
+        // by "name": "unicast" or "code": 12. If you enable this option,
+        // you really should also tell the server to listen on that address
+        // (see interfaces-config/interfaces list above).
+        {
+            "code": 12,
+            "data": "2001:db8::1"
+        },
+
+        // String options that have a comma in their values need to have
+        // it escaped (i.e. each comma is preceded by two backslashes).
+        // That's because commas are reserved for separating fields in
+        // compound options. At the same time, we need to be conformant
+        // with JSON spec, that does not allow "\,". Therefore the
+        // slightly uncommon double backslashes notation is needed.
+
+        // Legal JSON escapes are \ followed by "\/bfnrt character
+        // or \u followed by 4 hexadecimal numbers (currently Kea
+        // supports only \u0000 to \u00ff code points).
+        // CSV processing translates '\\' into '\' and '\,' into ','
+        // only so for instance '\x' is translated into '\x'. But
+        // as it works on a JSON string value each of these '\'
+        // characters must be doubled on JSON input.
+        {
+            "name": "new-posix-timezone",
+            "data": "EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00"
+        },
+
+        // Options that take integer values can either be specified in
+        // dec or hex format. Hex format could be either plain (e.g. abcd)
+        // or prefixed with 0x (e.g. 0xabcd).
+        {
+            "name": "preference",
+            "data": "0xf0"
+        },
+
+        // A few options are encoded in (length, string) tuples
+        // which can be defined using only strings as the CSV
+        // processing computes lengths.
+        {
+            "name": "bootfile-param",
+            "data": "root=/dev/sda2, quiet, splash"
+        }
+    ],
+
+    // Below an example of a simple IPv6 subnet declaration. Uncomment to enable
+    // it. This is a list, denoted with [ ], of structures, each denoted with
+    // { }. Each structure describes a single subnet and may have several
+    // parameters. One of those parameters is "pools" that is also a list of
+    // structures.
+    "subnet6": [
+        {
+            // This defines the whole subnet. Kea will use this information to
+            // determine where the clients are connected. This is the whole
+            // subnet in your network. This is mandatory parameter for each
+            // subnet.
+            "subnet": "2001:db8:1::/64",
+
+            // Pools define the actual part of your subnet that is governed
+            // by Kea. Technically this is optional parameter, but it's
+            // almost always needed for DHCP to do its job. If you omit it,
+            // clients won't be able to get addresses, unless there are
+            // host reservations defined for them.
+            "pools": [ { "pool": "2001:db8:1::/80" } ],
+
+            // Kea supports prefix delegation (PD). This mechanism delegates
+            // whole prefixes, instead of single addresses. You need to specify
+            // a prefix and then size of the delegated prefixes that it will
+            // be split into. This example below tells Kea to use
+            // 2001:db8:1::/56 prefix as pool and split it into /64 prefixes.
+            // This will give you 256 (2^(64-56)) prefixes.
+            "pd-pools": [
+                {
+                    "prefix": "2001:db8:8::",
+                    "prefix-len": 56,
+                    "delegated-len": 64
+
+                    // Kea also supports excluded prefixes. This advanced option
+                    // is explained in Section 9.2.9. Please make sure your
+                    // excluded prefix matches the pool it is defined in.
+                    // "excluded-prefix": "2001:db8:8:0:80::",
+                    // "excluded-prefix-len": 72
+                }
+            ],
+            "option-data": [
+                // You can specify additional options here that are subnet
+                // specific. Also, you can override global options here.
+                {
+                    "name": "dns-servers",
+                    "data": "2001:db8:2::dead:beef, 2001:db8:2::cafe:babe"
+                }
+            ],
+
+            // Host reservations can be defined for each subnet.
+            //
+            // Note that reservations are subnet-specific in Kea. This is
+            // different than ISC DHCP. Keep that in mind when migrating
+            // your configurations.
+            "reservations": [
+                // This is a simple host reservation. The host with DUID matching
+                // the specified value will get an address of 2001:db8:1::100.
+                {
+                    "duid": "01:02:03:04:05:0A:0B:0C:0D:0E",
+                    "ip-addresses": [ "2001:db8:1::100" ]
+                },
+
+                // This is similar to the previous one, but this time the
+                // reservation is done based on hardware/MAC address. The server
+                // will do its best to extract the hardware/MAC address from
+                // received packets (see 'mac-sources' directive for
+                // details). This particular reservation also specifies two
+                // extra options to be available for this client. If there are
+                // options with the same code specified in a global, subnet or
+                // class scope, the values defined at host level take
+                // precedence.
+                {
+                    "hw-address": "00:01:02:03:04:05",
+                    "ip-addresses": [ "2001:db8:1::101" ],
+                    "option-data": [
+                        {
+                            "name": "dns-servers",
+                            "data": "3000:1::234"
+                        },
+                        {
+                            "name": "nis-servers",
+                            "data": "3000:1::234"
+                        }],
+
+                    // This client will be automatically added to certain
+                    // classes.
+                    "client-classes": [ "special_snowflake", "office" ]
+                },
+
+                // This is a bit more advanced reservation. The client with the
+                // specified DUID will get a reserved address, a reserved prefix
+                // and a hostname.  This reservation is for an address that it
+                // not within the dynamic pool.  Finally, this reservation
+                // features vendor specific options for CableLabs, which happen
+                // to use enterprise-id 4491. Those particular values will be
+                // returned only to the client that has a DUID matching this
+                // reservation.
+                {
+                    "duid": "01:02:03:04:05:06:07:08:09:0A",
+                    "ip-addresses": [ "2001:db8:1:cafe::1" ],
+                    "prefixes": [ "2001:db8:2:abcd::/64" ],
+                    "hostname": "foo.example.com",
+                    "option-data": [
+                        {
+                            "name": "vendor-opts",
+                            "data": "4491"
+                        },
+                        {
+                            "name": "tftp-servers",
+                            "space": "vendor-4491",
+                            "data": "3000:1::234"
+                        }
+                    ]
+                },
+
+                // This reservation is using flexible identifier. Instead of
+                // relying on specific field, sysadmin can define an expression
+                // similar to what is used for client classification,
+                // e.g. substring(relay[0].option[17],0,6). Then, based on the
+                // value of that expression for incoming packet, the reservation
+                // is matched.  Expression can be specified either as hex or
+                // plain text using single quotes.
+
+                // Note: flexible identifier requires flex_id hook library to be
+                // loaded to work.
+                {
+                    "flex-id": "'somevalue'",
+                    "ip-addresses": [ "2001:db8:1:cafe::2" ]
+                }
+            ]
+        }
+        // More subnets can be defined here.
+        //      {
+        //          "subnet": "2001:db8:2::/64",
+        //          "pools": [ { "pool": "2001:db8:2::/80" } ]
+        //      },
+        //      {
+        //          "subnet": "2001:db8:3::/64",
+        //          "pools": [ { "pool": "2001:db8:3::/80" } ]
+        //      },
+        //      {
+        //          "subnet": "2001:db8:4::/64",
+        //          "pools": [ { "pool": "2001:db8:4::/80" } ]
+        //      }
+    ]
+
+    // Client-classes can be defined here. See "client-classes" in Dhcp4 for
+    // an example.
+
+    // Hook libraries can be defined here. See "hooks-libraries" example in
+    // Dhcp4.
+
+    // DDNS information (how the DHCPv6 component can reach a DDNS daemon)
+
+},
+
+// Logging configuration starts here. Kea uses different loggers to log various
+// activities. For details (e.g. names of loggers), see Chapter 18.
+"Logging":
+{
+  "loggers": [
+    {
+        // This specifies the logging for kea-dhcp6 logger, i.e. all logs
+        // generated by Kea DHCPv6 server.
+        "name": "kea-dhcp6",
+        "output_options": [
+            {
+                // Specifies the output file. There are several special values
+                // supported:
+                // - stdout (prints on standard output)
+                // - stderr (prints on standard error)
+                // - syslog (logs to syslog)
+                // - syslog:name (logs to syslog using specified name)
+                // Any other value is considered a name of a time
+                "output": "@localstatedir@/log/kea-dhcp6.log"
+
+                // This governs whether the log output is flushed to disk after
+                // every write.
+                // "flush": false,
+
+                // This specifies the maximum size of the file before it is
+                // rotated.
+                // "maxsize": 1048576,
+
+                // This specifies the maximum number of rotated files to keep.
+                // "maxver": 8
+            }
+        ],
+        // This specifies the severity of log messages to keep. Supported values
+        // are: FATAL, ERROR, WARN, INFO, DEBUG
+        "severity": "INFO",
+
+        // If DEBUG level is specified, this value is used. 0 is least verbose,
+        // 99 is most verbose. Be cautious, Kea can generate lots and lots
+        // of logs if told to do so.
+        "debuglevel": 0
+    }
+  ]
+}
+}

+ 5 - 2
src/bin/keactrl/keactrl.conf.in

@@ -5,8 +5,11 @@
 # prefix holds the location where the Kea is installed.
 prefix=@prefix@
 
-# Location of Kea configuration file.
-kea_config_file=@sysconfdir@/@PACKAGE@/kea.conf
+# Location of Kea configuration files.
+kea_dhcp4_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp4.conf
+kea_dhcp6_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp6.conf
+kea_dhcp_ddns_config_file=@sysconfdir@/@PACKAGE@/kea-dhcp-ddns.conf
+kea_ctrl_agent_config_file=@sysconfdir@/@PACKAGE@/kea-ctrl-agent.conf
 
 # Location of Kea binaries.
 exec_prefix=@exec_prefix@

+ 53 - 33
src/bin/keactrl/keactrl.in

@@ -65,6 +65,22 @@ usage() {
 get_pid_from_file() {
     local proc_name=${1} # Process name.
 
+    local kea_config_file=
+    case ${proc_name} in
+    kea-dhcp4)
+        kea_config_file=${kea_dhcp4_config_file}
+        ;;
+    kea-dhcp6)
+        kea_config_file=${kea_dhcp6_config_file}
+        ;;
+    kea-dhcp-ddns)
+        kea_config_file=${kea_dhcp_ddns_config_file}
+        ;;
+    kea-ctrl-agent)
+        kea_config_file=${kea_ctrl_agent_config_file}
+        ;;
+    esac
+
     # Extract the name portion of the config file
     local conf_name=$(basename ${kea_config_file} | cut -f1 -d'.')
 
@@ -133,7 +149,7 @@ process is not running\n"
 # already running.
 start_server() {
     binary_path=${1}   # Full path to the binary.
-    binary_args="${2}" # Arguments.
+    full_command=$@    # Binary and arguments.
     # Extract the name of the binary from the path.
     local binary_name=$(basename ${binary_path})
     # Use the binary name to check if the process is already running.
@@ -143,9 +159,9 @@ start_server() {
         log_info "${binary_name} appears to be running, see: \
 PID ${_pid}, PID file: ${_pid_file}."
     else
-        log_info "Starting ${binary_name} ${args}"
+        log_info "Starting ${full_command}"
         # Start the process.
-        ${binary_path} ${args} &
+        ${full_command} &
     fi
 }
 
@@ -193,6 +209,21 @@ to process ${proc_name}, PID ${_pid}.\n"
     fi
 }
 
+### Functions testing the existence of the Kea config file
+
+# Check if the Kea configuration file location has been specified in the
+# keactrl configuration file. If not, it is a warning or a fatal error.
+check_kea_conf() {
+    local conf_file=${1} # Kea config file name.
+    if [ -z ${conf_file} ]; then
+        log_error "Configuration file for Kea not specified."
+        exit 1
+    elif [ ! -f ${conf_file} ]; then
+        log_error "Configuration file for Kea does not exist: ${conf_file}."
+        exit 1
+    fi
+}
+
 # Run the specified command if the server has been enabled.
 # In order for the command to run, the following conditions have to be met:
 # - server must be on the list of servers (e.g. specified from command line)
@@ -220,6 +251,9 @@ run_conditional() {
     # the server should be enabled or not. Variables that hold these values
     # are: ${dhcp4}, ${dhcp6}, ${dhcp_ddns}.
     local file_config=$( eval printf "%s" \${$server} )
+    # Get the location of the current Kea configuration file. This will be used
+    # to check that the file exists before it is used.
+    local kea_config_location=$( eval printf "%s" "\$kea_${server}_config_file" )
     # Run the command if we ignore the configuration setting or if the
     # setting is "yes".
     if [ ${check_file_cfg} -eq 0 ] || [ "${file_config}" = "yes" ]; then
@@ -227,21 +261,6 @@ run_conditional() {
     fi
 }
 
-### Functions testing the existence of the Kea config file
-
-# Check if the Kea configuration file location has been specified in the
-# keactrl configuration file. If not, it is a warning or a fatal error.
-check_kea_conf() {
-    local conf_file=${1} # Kea config file name.
-    if [ -z ${conf_file} ]; then
-        log_error "Configuration file for Kea not specified."
-        exit 1
-    elif [ ! -f ${conf_file} ]; then
-        log_error "Configuration file for Kea does not exist: ${conf_file}."
-        exit 1
-    fi
-}
-
 ### Script starts here ###
 
 # Configure logger to log messages into the file.
@@ -360,27 +379,24 @@ ctrl_agent=$( printf "%s" ${ctrl_agent} | tr [:upper:] [:lower:] )
 case ${command} in
     # Start the servers.
     start)
-        check_kea_conf ${kea_config_file}
-
-        args="-c ${kea_config_file}"
-
+        args=""
         if [ "${kea_verbose}" = "yes" ]; then
-            args="${args} -d"
+            args="-d"
         fi
 
         # Run servers if they are on the list of servers from the command line
         # and if they are enabled in the keactrl configuration file.
-        run_conditional "dhcp4" "start_server ${dhcp4_srv} \"${args}\"" 1
-        run_conditional "dhcp6" "start_server ${dhcp6_srv} \"${args}\"" 1
-        run_conditional "dhcp_ddns" "start_server ${dhcp_ddns_srv} \"${args}\"" 1
-        run_conditional "ctrl_agent" "start_server ${ctrl_agent_srv} \"${args}\"" 1
+        run_conditional "dhcp4" "start_server ${dhcp4_srv} -c ${kea_dhcp4_config_file} ${args}" 1
+        run_conditional "dhcp6" "start_server ${dhcp6_srv} -c ${kea_dhcp6_config_file} ${args}" 1
+        run_conditional "dhcp_ddns" "start_server ${dhcp_ddns_srv} -c ${kea_dhcp_ddns_config_file} \
+${args}" 1
+        run_conditional "ctrl_agent" "start_server ${ctrl_agent_srv} -c ${kea_ctrl_agent_config_file} \
+${args}" 1
 
         exit 0 ;;
 
     # Stop running servers.
     stop)
-        check_kea_conf ${kea_config_file}
-
         # Stop all servers or servers specified from the command line.
         run_conditional "dhcp4" "stop_server ${dhcp4_srv}" 0
         run_conditional "dhcp6" "stop_server ${dhcp6_srv}" 0
@@ -391,8 +407,6 @@ case ${command} in
 
     # Reconfigure the servers.
     reload)
-        check_kea_conf ${kea_config_file}
-
         # Reconfigure all servers or servers specified from the command line.
         run_conditional "dhcp4" "reload_server ${dhcp4_srv}" 0
         run_conditional "dhcp6" "reload_server ${dhcp6_srv}" 0
@@ -429,10 +443,16 @@ case ${command} in
             agent_status="active"
         fi
         printf "Control Agent: %s\n" ${agent_status}
-        printf "Kea configuration file: %s\n" ${kea_config_file}
+        printf "Kea DHCPv4 configuration file: %s\n" ${kea_dhcp4_config_file}
+        printf "Kea DHCPv6 configuration file: %s\n" ${kea_dhcp6_config_file}
+        printf "Kea DHCP DDNS configuration file: %s\n" ${kea_dhcp_ddns_config_file}
+        printf "Kea Control Agent configuration file: %s\n" ${kea_ctrl_agent_config_file}
         printf "keactrl configuration file: %s\n" ${keactrl_conf}
 
-        check_kea_conf ${kea_config_file}
+        check_kea_conf ${kea_dhcp4_config_file}
+        check_kea_conf ${kea_dhcp6_config_file}
+        check_kea_conf ${kea_dhcp_ddns_config_file}
+        check_kea_conf ${kea_ctrl_agent_config_file}
 
         exit 0 ;;
 

+ 12 - 9
src/bin/keactrl/tests/keactrl_tests.sh.in

@@ -16,6 +16,9 @@ keactrl=@abs_top_builddir@/src/bin/keactrl/keactrl
 CFG_FILE_NAME="test_config"
 # A name of the configuration file to be used by Kea.
 CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/${CFG_FILE_NAME}.json
+# Configuration files for all deamons.
+CFG_FILES="kea_dhcp4_config_file=${CFG_FILE}\nkea_dhcp6_config_file=${CFG_FILE}\n\
+kea_dhcp_ddns_config_file=${CFG_FILE}\nkea_ctrl_agent_config_file=${CFG_FILE}"
 # A name of the keactrl config file
 KEACTRL_CFG_FILE=@abs_top_builddir@/src/bin/keactrl/tests/keactrl_test.conf
 # Path to the Kea log file.
@@ -137,7 +140,7 @@ ctrl_agent_srv=${KEACTRL_BUILD_DIR}/src/bin/agent/kea-ctrl-agent\n"
 start_all_servers_no_verbose_test() {
     # Create configuration file for keactrl. This configuration enables
     # DHCPv4, DHCPv6, D2 and CA.
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
 dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
 
     test_start "keactrl.start_all_servers_no_verbose_test"
@@ -258,7 +261,7 @@ Expected wait_for_message return %d, returned %d."
 start_all_servers_verbose_test() {
     # Create configuration file for keactrl. This configuration enables
     # all servers.
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
 dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
 
     test_start "keactrl.start_all_servers_verbose_test"
@@ -376,7 +379,7 @@ Expected wait_for_message return %d, returned %d."
 start_v4_server_test() {
     # Create configuration file for keactrl. This configuration enables
     # DHCPv4 server but disables other servers.
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=no\n\
 dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
 
     test_start "keactrl.start_v4_server_test"
@@ -464,7 +467,7 @@ Expected wait_for_message return %d, returned %d."
 start_v6_server_test() {
     # Create configuration file for keactrl. This configuration enables
     # DHCPv6 server but disables other servers..
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=no\ndhcp6=yes\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=no\ndhcp6=yes\n\
 dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
 
     test_start "keactrl.start_v6_server_test"
@@ -552,7 +555,7 @@ Expected wait_for_message return %d, returned %d."
 late_start_v4_server_test() {
     # Create configuration file for keactrl. This configuration enables
     # DHCPv6 server but disables other servers.
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=no\ndhcp6=yes\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=no\ndhcp6=yes\n\
 dhcp_ddns=no\nctrl_agent=no\nkea_verbose=no\n${keactrl_fixed_config}"
 
     test_start "keactrl.late_start_v4_server_test"
@@ -612,7 +615,7 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message to return %d, returned %d."
 
     # Update keactrl config to enable other servers.
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
 dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
     create_keactrl_config "${keactrl_config}"
 
@@ -715,7 +718,7 @@ Expected wait_for_message return %d, returned %d."
 late_start_v6_server_test() {
     # Create configuration file for keactrl. This configuration enables
     # DHCPv4 server but disables DHCPv6 server.
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=no\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=no\n\
 dhcp_ddns=no\nctrl_agent=yes\nkea_verbose=yes\n${keactrl_fixed_config}"
 
     test_start "keactrl.late_start_v6_server_test"
@@ -775,7 +778,7 @@ Expected wait_for_message return %d, returned %d."
 Expected wait_for_message to return %d, returned %d."
 
     # Update keactrl config to enable other servers.
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
 dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
     create_keactrl_config "${keactrl_config}"
 
@@ -877,7 +880,7 @@ Expected wait_for_message return %d, returned %d."
 stop_selected_server_test() {
     # Create configuration file for keactrl. This configuration enables
     # all servers.
-    keactrl_config="kea_config_file=${CFG_FILE}\ndhcp4=yes\ndhcp6=yes\n\
+    keactrl_config="${CFG_FILES}\ndhcp4=yes\ndhcp6=yes\n\
 dhcp_ddns=yes\nctrl_agent=yes\nkea_verbose=no\n${keactrl_fixed_config}"
 
     test_start "keactrl.stop_selected_server_test"