From: Marcin Siodelski Date: Mon, 4 Mar 2019 19:06:04 +0000 (+0100) Subject: [#488,!259] Added support for authoritative flag in MySQL CB. X-Git-Tag: 494-dhcp4configparser-sharednetworkssanitychecks-is-buggy_base~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=434b93940cf37a1fb8cba7c9b9ffef5e0f17ed34;p=thirdparty%2Fkea.git [#488,!259] Added support for authoritative flag in MySQL CB. --- diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index 10947812de..61fd5b1446 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -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 diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc index 372ab9f30c..2847022dd0 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc @@ -278,7 +278,8 @@ public: MySqlBinding::createTimestamp(), //option: modification_ts MySqlBinding::createInteger(), // calculate_tee_times MySqlBinding::createInteger(), // t1_percent - MySqlBinding::createInteger() // t2_percent + MySqlBinding::createInteger(), // t2_percent + MySqlBinding::createInteger() // 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(), // calculate_tee_times MySqlBinding::createInteger(), // t1_percent - MySqlBinding::createInteger() // t2_percent + MySqlBinding::createInteger(), // t2_percent + MySqlBinding::createInteger() // 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. diff --git a/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h b/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h index e7a0c4dd33..57bfa67201 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h +++ b/src/hooks/dhcp/mysql_cb/mysql_query_macros_dhcp.h @@ -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 " \ diff --git a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc index 7cb3ea59a7..cd70ef4ff9 100644 --- a/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc +++ b/src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc @@ -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); diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index 475bdb6d15..7e4fc83096 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -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; diff --git a/src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in b/src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in index e7038380a4..a90a3612b3 100644 --- a/src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in +++ b/src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in @@ -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;