]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#488,!259] Added support for authoritative flag in MySQL CB.
authorMarcin Siodelski <marcin@isc.org>
Mon, 4 Mar 2019 19:06:04 +0000 (20:06 +0100)
committerMarcin Siodelski <marcin@isc.org>
Thu, 7 Mar 2019 13:00:35 +0000 (08:00 -0500)
src/bin/admin/tests/mysql_tests.sh.in
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc
src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in

index 10947812de26b0cc36e23ec069206d2ee735bce3..61fd5b14468e6fcb5eb3e51ed966d24a244c1ff2 100644 (file)
@@ -507,7 +507,7 @@ EOF
     run_statement "dhcp4_option_def_server" "$qry"
 
     # table: dhcp4_shared_network
-    qry="select id, name, client_class, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp4_shared_network"
+    qry="select id, name, client_class, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, user_context, valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent from dhcp4_shared_network"
     run_statement "dhcp4_shared_network" "$qry"
 
     # table: dhcp4_shared_network_server
@@ -515,7 +515,7 @@ EOF
     run_statement "dhcp4_shared_network_server" "$qry"
 
     # table: dhcp4_subnet
-    qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_class, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp4_subnet"
+    qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_class, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent from dhcp4_subnet"
     run_statement "dhcp4_subnet" "$qry"
 
     # table: dhcp4_pool
index 372ab9f30c3a5963e40a07bb30a041c61d7ab009..2847022dd00fba63899222b718b91b12dfd6d23d 100644 (file)
@@ -278,7 +278,8 @@ public:
             MySqlBinding::createTimestamp(), //option: modification_ts
             MySqlBinding::createInteger<uint8_t>(), // calculate_tee_times
             MySqlBinding::createInteger<float>(), // t1_percent
-            MySqlBinding::createInteger<float>() // t2_percent
+            MySqlBinding::createInteger<float>(), // t2_percent
+            MySqlBinding::createInteger<uint8_t>() // authoritative
         };
 
         uint64_t last_pool_id = 0;
@@ -440,6 +441,11 @@ public:
                     last_subnet->setT2Percent(out_bindings[51]->getFloat());
                 }
 
+                // authoritative
+                if (!out_bindings[52]->amNull()) {
+                    last_subnet->setAuthoritative(out_bindings[52]->getBool());
+                }
+
                 // Subnet ready. Add it to the list.
                 subnets.push_back(last_subnet);
             }
@@ -798,7 +804,8 @@ public:
             createBinding(subnet->getValid()),
             MySqlBinding::condCreateBool(subnet->getCalculateTeeTimes()),
             MySqlBinding::condCreateFloat(subnet->getT1Percent()),
-            MySqlBinding::condCreateFloat(subnet->getT2Percent())
+            MySqlBinding::condCreateFloat(subnet->getT2Percent()),
+            MySqlBinding::condCreateBool(subnet->getAuthoritative())
         };
 
         MySqlTransaction transaction(conn_);
@@ -1004,7 +1011,8 @@ public:
             MySqlBinding::createTimestamp(), //option: modification_ts
             MySqlBinding::createInteger<uint8_t>(), // calculate_tee_times
             MySqlBinding::createInteger<float>(), // t1_percent
-            MySqlBinding::createInteger<float>() // t2_percent
+            MySqlBinding::createInteger<float>(), // t2_percent
+            MySqlBinding::createInteger<uint8_t>() // authoritative
         };
 
         uint64_t last_network_id = 0;
@@ -1118,6 +1126,11 @@ public:
                     last_network->setT2Percent(out_bindings[27]->getFloat());
                 }
 
+                // authoritative
+                if (!out_bindings[28]->amNull()) {
+                    last_network->setAuthoritative(out_bindings[28]->getBool());
+                }
+
                 shared_networks.push_back(last_network);
             }
 
@@ -1241,7 +1254,8 @@ public:
             createBinding(shared_network->getValid()),
             MySqlBinding::condCreateBool(shared_network->getCalculateTeeTimes()),
             MySqlBinding::condCreateFloat(shared_network->getT1Percent()),
-            MySqlBinding::condCreateFloat(shared_network->getT2Percent())
+            MySqlBinding::condCreateFloat(shared_network->getT2Percent()),
+            MySqlBinding::condCreateBool(shared_network->getAuthoritative())
         };
 
         MySqlTransaction transaction(conn_);
@@ -2061,9 +2075,10 @@ TaggedStatementArray tagged_statements = { {
       "  valid_lifetime,"
       "  calculate_tee_times,"
       "  t1_percent,"
-      "  t2_percent"
+      "  t2_percent,"
+      "  authoritative"
       ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,"
-      "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
+      "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
 
     // Insert association of the subnet with a server.
     { MySqlConfigBackendDHCPv4Impl::INSERT_SUBNET4_SERVER,
@@ -2092,8 +2107,9 @@ TaggedStatementArray tagged_statements = { {
       "  valid_lifetime,"
       "  calculate_tee_times,"
       "  t1_percent,"
-      "  t2_percent"
-      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
+      "  t2_percent,"
+      "  authoritative"
+      ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
 
     // Insert association of the shared network with a server.
     { MySqlConfigBackendDHCPv4Impl::INSERT_SHARED_NETWORK4_SERVER,
@@ -2150,7 +2166,8 @@ TaggedStatementArray tagged_statements = { {
       "  valid_lifetime = ?,"
       "  calculate_tee_times = ?,"
       "  t1_percent = ?,"
-      "  t2_percent = ? "
+      "  t2_percent = ?,"
+      "  authoritative = ? "
       "WHERE subnet_id = ?" },
 
     // Update existing shared network.
@@ -2170,7 +2187,8 @@ TaggedStatementArray tagged_statements = { {
       "  valid_lifetime = ?,"
       "  calculate_tee_times = ?,"
       "  t1_percent = ?,"
-      "  t2_percent = ? "
+      "  t2_percent = ?,"
+      "  authoritative = ? "
       "WHERE name = ?" },
 
     // Update existing option definition.
index e7a0c4dd3339799176586dd1731fc885215fc68a..57bfa672015b172cab6233fe9c7e7579c1f6cd37 100644 (file)
@@ -101,7 +101,8 @@ namespace {
     "  o.modification_ts," \
     "  s.calculate_tee_times," \
     "  s.t1_percent," \
-    "  s.t2_percent " \
+    "  s.t2_percent," \
+    "  s.authoritative " \
     "FROM dhcp4_subnet AS s " \
     "INNER JOIN dhcp4_subnet_server AS a " \
     "  ON s.subnet_id = a.subnet_id " \
@@ -226,7 +227,8 @@ namespace {
     "  o.modification_ts," \
     "  n.calculate_tee_times," \
     "  n.t1_percent," \
-    "  n.t2_percent " \
+    "  n.t2_percent," \
+    "  n.authoritative " \
     "FROM dhcp4_shared_network AS n " \
     "INNER JOIN dhcp4_shared_network_server AS a " \
     "  ON n.id = a.shared_network_id " \
index 7cb3ea59a79211af470132fa4c6b69d355ab08f6..cd70ef4ff9291e9f045cb16f485b15f223494d18 100644 (file)
@@ -108,6 +108,7 @@ public:
         subnet->setSname("server-hostname");
         subnet->setContext(user_context);
         subnet->setValid(555555);
+        subnet->setAuthoritative(true);
         subnet->setCalculateTeeTimes(true);
         subnet->setT1Percent(0.345);
         subnet->setT2Percent(0.444);
index 475bdb6d1507a2710914c0f06f93ab31a76dbf17..7e4fc830962d76d5687e07c24445893220a20da3 100644 (file)
@@ -1344,6 +1344,7 @@ ALTER TABLE dhcp6_options
     DEFAULT CURRENT_TIMESTAMP;
 
 ALTER TABLE dhcp4_subnet
+    ADD COLUMN authoritative TINYINT(1) DEFAULT NULL,
     ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
     ADD COLUMN t1_percent FLOAT DEFAULT NULL,
     ADD COLUMN t2_percent FLOAT DEFAULT NULL;
@@ -1355,6 +1356,7 @@ ALTER TABLE dhcp4_subnet
     MODIFY COLUMN match_client_id TINYINT(1) DEFAULT NULL;
 
 ALTER TABLE dhcp4_shared_network
+    ADD COLUMN authoritative TINYINT(1) DEFAULT NULL,
     ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
     ADD COLUMN t1_percent FLOAT DEFAULT NULL,
     ADD COLUMN t2_percent FLOAT DEFAULT NULL;
index e7038380a43f2f41af62caf9d07385628d4ac935..a90a3612b310a403f30ffb5f52b0253cf71952e3 100644 (file)
@@ -27,6 +27,7 @@ ALTER TABLE dhcp6_options
     DEFAULT CURRENT_TIMESTAMP;
 
 ALTER TABLE dhcp4_subnet
+    ADD COLUMN authoritative TINYINT(1) DEFAULT NULL,
     ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
     ADD COLUMN t1_percent FLOAT DEFAULT NULL,
     ADD COLUMN t2_percent FLOAT DEFAULT NULL;
@@ -38,6 +39,7 @@ ALTER TABLE dhcp4_subnet
     MODIFY COLUMN match_client_id TINYINT(1) DEFAULT NULL;
 
 ALTER TABLE dhcp4_shared_network
+    ADD COLUMN authoritative TINYINT(1) DEFAULT NULL,
     ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
     ADD COLUMN t1_percent FLOAT DEFAULT NULL,
     ADD COLUMN t2_percent FLOAT DEFAULT NULL;