Commit c1eabee5 authored by Marcin Siodelski's avatar Marcin Siodelski

[#628,!341] interface-id is supported by the mysql_cb.

parent 3a07c636
......@@ -563,7 +563,7 @@ EOF
run_statement "dhcp6_option_def_server" "$qry"
# table: dhcp6_shared_network
qry="select id, name, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp6_shared_network"
qry="select id, name, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent, interface_id from dhcp6_shared_network"
run_statement "dhcp6_shared_network" "$qry"
# table: dhcp6_shared_network_server
......@@ -571,7 +571,7 @@ EOF
run_statement "dhcp6_shared_network" "$qry"
# table: dhcp6_subnet
qry="select subnet_prefix, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, shared_network_name, subnet_id, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp6_subnet"
qry="select subnet_prefix, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, shared_network_name, subnet_id, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent, interface_id from dhcp6_subnet"
run_statement "dhcp6_subnet" "$qry"
# table: dhcp6_subnet_server
......
......@@ -307,6 +307,7 @@ public:
MySqlBinding::createInteger<uint8_t>(), // calculate_tee_times
MySqlBinding::createInteger<float>(), // t1_percent
MySqlBinding::createInteger<float>(), // t2_percent
MySqlBinding::createBlob(INTERFACE_ID_BUF_LENGTH), // interface_id
MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag
};
......@@ -458,8 +459,18 @@ public:
last_subnet->setT2Percent(out_bindings[67]->getFloat());
}
// interface_id
if (!out_bindings[68]->amNull()) {
auto iface_id_data = out_bindings[68]->getBlob();
if (!iface_id_data.empty()) {
OptionPtr opt_iface_id(new Option(Option::V6, D6O_INTERFACE_ID,
iface_id_data));
last_subnet->setInterfaceId(opt_iface_id);
}
}
// server_tag
last_subnet->setServerTag(out_bindings[68]->getString());
last_subnet->setServerTag(out_bindings[69]->getString());
// Subnet ready. Add it to the list.
subnets.push_back(last_subnet);
......@@ -910,6 +921,17 @@ public:
shared_network_binding = MySqlBinding::createNull();
}
// Create the binding holding interface_id.
MySqlBindingPtr interface_id_binding = MySqlBinding::createNull();
auto opt_iface_id = subnet->getInterfaceId();
if (opt_iface_id) {
auto iface_id_data = opt_iface_id->getData();
if (!iface_id_data.empty()) {
interface_id_binding = MySqlBinding::createBlob(iface_id_data.begin(),
iface_id_data.end());
}
}
// Create input bindings.
MySqlBindingCollection in_bindings = {
MySqlBinding::createInteger<uint32_t>(subnet->getID()),
......@@ -929,7 +951,8 @@ public:
createBinding(subnet->getValid(Network::Inheritance::NONE)),
MySqlBinding::condCreateBool(subnet->getCalculateTeeTimes(Network::Inheritance::NONE)),
MySqlBinding::condCreateFloat(subnet->getT1Percent(Network::Inheritance::NONE)),
MySqlBinding::condCreateFloat(subnet->getT2Percent(Network::Inheritance::NONE))
MySqlBinding::condCreateFloat(subnet->getT2Percent(Network::Inheritance::NONE)),
interface_id_binding
};
MySqlTransaction transaction(conn_);
......@@ -1193,6 +1216,7 @@ public:
MySqlBinding::createInteger<uint8_t>(), // calculate_tee_times
MySqlBinding::createInteger<float>(), // t1_percent
MySqlBinding::createInteger<float>(), // t2_percent
MySqlBinding::createBlob(INTERFACE_ID_BUF_LENGTH), // interface_id
MySqlBinding::createString(SERVER_TAG_BUF_LENGTH) // server_tag
};
......@@ -1314,8 +1338,18 @@ public:
last_network->setT2Percent(out_bindings[29]->getFloat());
}
// interface_id
if (!out_bindings[30]->amNull()) {
auto iface_id_data = out_bindings[30]->getBlob();
if (!iface_id_data.empty()) {
OptionPtr opt_iface_id(new Option(Option::V6, D6O_INTERFACE_ID,
iface_id_data));
last_network->setInterfaceId(opt_iface_id);
}
}
// server_tag
last_network->setServerTag(out_bindings[30]->getString());
last_network->setServerTag(out_bindings[31]->getString());
shared_networks.push_back(last_network);
}
......@@ -1425,6 +1459,17 @@ public:
hr_mode_binding = MySqlBinding::createNull();
}
// Create the binding holding interface_id.
MySqlBindingPtr interface_id_binding = MySqlBinding::createNull();
auto opt_iface_id = shared_network->getInterfaceId();
if (opt_iface_id) {
auto iface_id_data = opt_iface_id->getData();
if (!iface_id_data.empty()) {
interface_id_binding = MySqlBinding::createBlob(iface_id_data.begin(),
iface_id_data.end());
}
}
MySqlBindingCollection in_bindings = {
MySqlBinding::createString(shared_network->getName()),
MySqlBinding::condCreateString(shared_network->getClientClass(Network::Inheritance::NONE)),
......@@ -1441,7 +1486,8 @@ public:
createBinding(shared_network->getValid(Network::Inheritance::NONE)),
MySqlBinding::condCreateBool(shared_network->getCalculateTeeTimes(Network::Inheritance::NONE)),
MySqlBinding::condCreateFloat(shared_network->getT1Percent(Network::Inheritance::NONE)),
MySqlBinding::condCreateFloat(shared_network->getT2Percent(Network::Inheritance::NONE))
MySqlBinding::condCreateFloat(shared_network->getT2Percent(Network::Inheritance::NONE)),
interface_id_binding
};
MySqlTransaction transaction(conn_);
......@@ -2317,8 +2363,9 @@ TaggedStatementArray tagged_statements = { {
" valid_lifetime,"
" calculate_tee_times,"
" t1_percent,"
" t2_percent "
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
" t2_percent,"
" interface_id"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
// Insert association of the subnet with a server.
{ MySqlConfigBackendDHCPv6Impl::INSERT_SUBNET6_SERVER,
......@@ -2353,8 +2400,9 @@ TaggedStatementArray tagged_statements = { {
" valid_lifetime,"
" calculate_tee_times,"
" t1_percent,"
" t2_percent "
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
" t2_percent,"
" interface_id"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" },
// Insert association of the shared network with a server.
{ MySqlConfigBackendDHCPv6Impl::INSERT_SHARED_NETWORK6_SERVER,
......@@ -2406,7 +2454,8 @@ TaggedStatementArray tagged_statements = { {
" valid_lifetime = ?,"
" calculate_tee_times = ?,"
" t1_percent = ?,"
" t2_percent = ? "
" t2_percent = ?,"
" interface_id = ? "
"WHERE subnet_id = ? OR subnet_prefix = ?" },
// Update existing shared network.
......@@ -2427,7 +2476,8 @@ TaggedStatementArray tagged_statements = { {
" valid_lifetime = ?,"
" calculate_tee_times = ?,"
" t1_percent = ?,"
" t2_percent = ? "
" t2_percent = ?,"
" interface_id = ? "
"WHERE name = ?" },
// Update existing option definition.
......
......@@ -188,6 +188,7 @@ namespace {
" s.calculate_tee_times," \
" s.t1_percent," \
" s.t2_percent," \
" s.interface_id," \
" srv.tag " \
"FROM dhcp6_subnet AS s " \
"INNER JOIN dhcp6_subnet_server AS a " \
......@@ -282,6 +283,7 @@ namespace {
" n.calculate_tee_times," \
" n.t1_percent," \
" n.t2_percent," \
" n.interface_id," \
" s.tag " \
"FROM dhcp6_shared_network AS n " \
"INNER JOIN dhcp6_shared_network_server AS a " \
......
......@@ -87,6 +87,8 @@ public:
// First subnet includes all parameters.
std::string interface_id_text = "whale";
OptionBuffer interface_id(interface_id_text.begin(), interface_id_text.end());
OptionPtr opt_interface_id(new Option(Option::V6, D6O_INTERFACE_ID,
interface_id));
ElementPtr user_context = Element::createMap();
user_context->set("foo", Element::create("bar"));
......@@ -94,6 +96,7 @@ public:
64, 30, 40, 50, 60, 1024));
subnet->allowClientClass("home");
subnet->setIface("eth1");
subnet->setInterfaceId(opt_interface_id);
subnet->setT2(323212);
subnet->addRelayAddress(IOAddress("2001:db8:1::2"));
subnet->addRelayAddress(IOAddress("2001:db8:3::4"));
......@@ -206,9 +209,16 @@ public:
ElementPtr user_context = Element::createMap();
user_context->set("foo", Element::create("bar"));
std::string interface_id_text = "fish";
OptionBuffer interface_id(interface_id_text.begin(),
interface_id_text.end());
OptionPtr opt_interface_id(new Option(Option::V6, D6O_INTERFACE_ID,
interface_id));
SharedNetwork6Ptr shared_network(new SharedNetwork6("level1"));
shared_network->allowClientClass("foo");
shared_network->setIface("eth1");
shared_network->setInterfaceId(opt_interface_id);
shared_network->setT2(323212);
shared_network->addRelayAddress(IOAddress("2001:db8:1::2"));
shared_network->addRelayAddress(IOAddress("2001:db8:3::4"));
......
......@@ -34,6 +34,8 @@ constexpr unsigned long CLIENT_CLASS_BUF_LENGTH = 128;
constexpr unsigned long INTERFACE_BUF_LENGTH = 128;
constexpr unsigned long INTERFACE_ID_BUF_LENGTH = 128;
constexpr unsigned long RELAY_BUF_LENGTH = 65536;
constexpr unsigned long REQUIRE_CLIENT_CLASSES_BUF_LENGTH = 65536;
......
......@@ -1373,7 +1373,8 @@ ALTER TABLE dhcp4_shared_network
ALTER TABLE dhcp6_subnet
ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
ADD COLUMN t1_percent FLOAT DEFAULT NULL,
ADD COLUMN t2_percent FLOAT DEFAULT NULL;
ADD COLUMN t2_percent FLOAT DEFAULT NULL,
ADD COLUMN interface_id VARBINARY(128) DEFAULT NULL;
ALTER TABLE dhcp6_subnet
MODIFY COLUMN reservation_mode TINYINT(3) DEFAULT NULL;
......@@ -1384,7 +1385,8 @@ ALTER TABLE dhcp6_subnet
ALTER TABLE dhcp6_shared_network
ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
ADD COLUMN t1_percent FLOAT DEFAULT NULL,
ADD COLUMN t2_percent FLOAT DEFAULT NULL;
ADD COLUMN t2_percent FLOAT DEFAULT NULL,
ADD COLUMN interface_id VARBINARY(128) DEFAULT NULL;
ALTER TABLE dhcp6_shared_network
MODIFY COLUMN reservation_mode TINYINT(3) DEFAULT NULL;
......
......@@ -56,7 +56,8 @@ ALTER TABLE dhcp4_shared_network
ALTER TABLE dhcp6_subnet
ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
ADD COLUMN t1_percent FLOAT DEFAULT NULL,
ADD COLUMN t2_percent FLOAT DEFAULT NULL;
ADD COLUMN t2_percent FLOAT DEFAULT NULL,
ADD COLUMN interface_id VARCHAR(128) DEFAULT NULL;
ALTER TABLE dhcp6_subnet
MODIFY COLUMN reservation_mode TINYINT(3) DEFAULT NULL;
......@@ -67,7 +68,8 @@ ALTER TABLE dhcp6_subnet
ALTER TABLE dhcp6_shared_network
ADD COLUMN calculate_tee_times TINYINT(1) DEFAULT NULL,
ADD COLUMN t1_percent FLOAT DEFAULT NULL,
ADD COLUMN t2_percent FLOAT DEFAULT NULL;
ADD COLUMN t2_percent FLOAT DEFAULT NULL,
ADD COLUMN interface_id VARCHAR(128) DEFAULT NULL;
ALTER TABLE dhcp6_shared_network
MODIFY COLUMN reservation_mode TINYINT(3) DEFAULT NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment