]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkd: dhcp-server - allow configuration of the pool 1097/head
authorTom Gundersen <teg@jklm.no>
Fri, 28 Aug 2015 22:18:20 +0000 (00:18 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 31 Aug 2015 19:42:33 +0000 (21:42 +0200)
The constraints we place on the pool is that it is a contiguous
sequence of addresses in the same subnet as the server address, not
including the subnet nor broadcast addresses, but possibly including
the server address itself. If the server address is included in the
pool it is (obviously) reserved and not handed out to clients.

man/systemd.network.xml
src/network/networkd-link.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.h
src/shared/conf-parser.c
src/shared/conf-parser.h

index ded2c0ceff46f9038f6248818fd9c413529ca9a6..2fb4733494384d60a1809e07110e6bc03c288266 100644 (file)
 
     <variablelist class='network-directives'>
 
+      <varlistentry>
+        <term><varname>PoolOffset=</varname></term>
+        <term><varname>PoolSize=</varname></term>
+
+        <listitem><para>Configures the pool of addresses to hand out. The pool
+        is a contiguous sequence of IP addresses in the subnet configured for
+        the server address, which does not include the subnet nor the broadcast
+        address. <varname>PoolOffset=</varname> takes the offset of the pool
+        from the start of subnet, or zero to use the default value.
+        <varname>PoolSize=</varname> takes the number of IP addresses in the
+        pool or zero to use the default value. By default the pool starts at
+        the first address after the subnet address and takes up the rest of
+        the subnet, excluding the broadcast address. If the pool includes
+        the server address (the default), this is reserved and not handed
+        out to clients.</para></listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><varname>DefaultLeaseTimeSec=</varname></term>
         <term><varname>MaxLeaseTimeSec=</varname></term>
index c5434147edd08382002fa8d6cfcd2601719bc2f8..979f3115f6d25073600accc1c173b55d3d0aeedc 100644 (file)
@@ -742,7 +742,8 @@ static int link_enter_set_addresses(Link *link) {
                 }
 
                 /* use the server address' subnet as the pool */
-                r = sd_dhcp_server_configure_pool(link->dhcp_server, &address->in_addr.in, address->prefixlen, 0, 0);
+                r = sd_dhcp_server_configure_pool(link->dhcp_server, &address->in_addr.in, address->prefixlen,
+                                                  link->network->dhcp_server_pool_offset, link->network->dhcp_server_pool_size);
                 if (r < 0)
                         return r;
 
index 108e892fb8623b7804e167914dbfce8327acfff8..10ca9dae35794ab270d36ce5faae8860445f2997 100644 (file)
@@ -82,6 +82,8 @@ DHCPServer.EmitNTP,            config_parse_bool,                              0
 DHCPServer.NTP,                config_parse_dhcp_server_ntp,                   0,                             0
 DHCPServer.EmitTimezone,       config_parse_bool,                              0,                             offsetof(Network, dhcp_server_emit_timezone)
 DHCPServer.Timezone,           config_parse_timezone,                          0,                             offsetof(Network, dhcp_server_timezone)
+DHCPServer.PoolOffset,         config_parse_uint32,                            0,                             offsetof(Network, dhcp_server_pool_offset)
+DHCPServer.PoolSize,           config_parse_uint32,                            0,                             offsetof(Network, dhcp_server_pool_size)
 Bridge.Cost,                   config_parse_unsigned,                          0,                             offsetof(Network, cost)
 Bridge.UseBPDU,                config_parse_bool,                              0,                             offsetof(Network, use_bpdu)
 Bridge.HairPin,                config_parse_bool,                              0,                             offsetof(Network, hairpin)
index d691cc3a45a99f7a9ad78075ce201ad77d6a3c38..c3439a70ba2b4e78b8c5ccc767337e39e5150c41 100644 (file)
@@ -102,6 +102,8 @@ struct Network {
         bool dhcp_server_emit_timezone;
         char *dhcp_server_timezone;
         usec_t dhcp_server_default_lease_time_usec, dhcp_server_max_lease_time_usec;
+        uint32_t dhcp_server_pool_offset;
+        uint32_t dhcp_server_pool_size;
 
         /* IPV4LL Support */
         AddressFamilyBoolean link_local;
index d99aa1d6e952ebac30a17ef8da9aab7ca0aad848..1f4aea6d6be38ada80a990d3845fb6bc1a639f3b 100644 (file)
@@ -450,6 +450,7 @@ int config_parse_many(const char *conf_file,
 
 DEFINE_PARSER(int, int, safe_atoi)
 DEFINE_PARSER(long, long, safe_atoli)
+DEFINE_PARSER(uint32, uint32_t, safe_atou32)
 DEFINE_PARSER(uint64, uint64_t, safe_atou64)
 DEFINE_PARSER(unsigned, unsigned, safe_atou)
 DEFINE_PARSER(double, double, safe_atod)
index 6152ee33b93af8bb28113c84bef6850c8e32e24b..66c80890d3ea99e1b437425d18e459a70074c6c0 100644 (file)
@@ -104,6 +104,7 @@ int config_parse_many(const char *conf_file,      /* possibly NULL */
 int config_parse_int(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_unsigned(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_long(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
+int config_parse_uint32(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_uint64(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_double(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line,  const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_iec_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);