mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 06:25:34 +00:00
[#2909] Mysql v6 addresses to binary
lease6.address and ipv6_reservations.address columns changed from varbinary(39) to binary(16). lease6.binaddr column removed deleted: src/share/api/binary-address6-upgrade.json new file: src/share/database/scripts/mysql/upgrade_018_to_019.sh.in configure.ac added new mysql upgrade script doc/sphinx/arm/hooks-lease-query.rst removed doc for binary-address6-upgrade command src/bin/admin/tests/mysql_tests.sh.in modified to use inet6_aton/ntoa as now needed Updated to test upgrage src/lib/dhcpsrv/lease_mgr.h LeaseMgr::upgradeBinaryAddress6() - no longer abstract, provides a dummy implemention src/lib/dhcpsrv/mysql_host_data_source.cc Change v6 reservation address to binary src/lib/dhcpsrv/mysql_lease_mgr.* Remove lease6.binaddr and uses Change lease6.address to binary src/lib/mysql/mysql_constants.h Update schema version src/share/api/api_files.mk Remove binary-address6-upgrade.json src/share/database/scripts/mysql/Makefile.am Add upgrade script src/share/database/scripts/mysql/dhcpdb_create.mysql Modify lease6, ipv6_reservations, and impacted functions
This commit is contained in:
@@ -1700,6 +1700,8 @@ AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_016_to_017.sh],
|
|||||||
[chmod +x src/share/database/scripts/mysql/upgrade_016_to_017.sh])
|
[chmod +x src/share/database/scripts/mysql/upgrade_016_to_017.sh])
|
||||||
AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_017_to_018.sh],
|
AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_017_to_018.sh],
|
||||||
[chmod +x src/share/database/scripts/mysql/upgrade_017_to_018.sh])
|
[chmod +x src/share/database/scripts/mysql/upgrade_017_to_018.sh])
|
||||||
|
AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_018_to_019.sh],
|
||||||
|
[chmod +x src/share/database/scripts/mysql/upgrade_018_to_019.sh])
|
||||||
AC_CONFIG_FILES([src/share/database/scripts/mysql/wipe_data.sh],
|
AC_CONFIG_FILES([src/share/database/scripts/mysql/wipe_data.sh],
|
||||||
[chmod +x src/share/database/scripts/mysql/wipe_data.sh])
|
[chmod +x src/share/database/scripts/mysql/wipe_data.sh])
|
||||||
AC_CONFIG_FILES([src/share/database/scripts/pgsql/Makefile])
|
AC_CONFIG_FILES([src/share/database/scripts/pgsql/Makefile])
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
src/share/api/binary-address6-upgrade.json
|
|
||||||
src/share/api/build-report.json
|
src/share/api/build-report.json
|
||||||
src/share/api/cache-clear.json
|
src/share/api/cache-clear.json
|
||||||
src/share/api/cache-flush.json
|
src/share/api/cache-flush.json
|
||||||
|
@@ -625,17 +625,7 @@ For DHCPv4 lease data, the command is:
|
|||||||
"command": "extended-info4-upgrade"
|
"command": "extended-info4-upgrade"
|
||||||
}
|
}
|
||||||
|
|
||||||
.. isccmd:: binary-address6-upgrade
|
For DHCPv6 lease data, the command is:
|
||||||
.. _command-binary-address6-upgrade:
|
|
||||||
|
|
||||||
For DHCPv6 lease data, there are two commands, for upgrading the binary
|
|
||||||
address used for by link address query the command is:
|
|
||||||
|
|
||||||
::
|
|
||||||
|
|
||||||
{
|
|
||||||
"command": "binary-address6-upgrade"
|
|
||||||
}
|
|
||||||
|
|
||||||
.. isccmd:: extended-info6-upgrade
|
.. isccmd:: extended-info6-upgrade
|
||||||
.. _command-extended-info6-upgrade:
|
.. _command-extended-info6-upgrade:
|
||||||
|
@@ -359,7 +359,7 @@ mysql_upgrade_12_to_13_test() {
|
|||||||
|
|
||||||
# Check lease6Dump*().
|
# Check lease6Dump*().
|
||||||
run_command \
|
run_command \
|
||||||
mysql_execute "INSERT INTO lease6 VALUES('::10',20,30,(SELECT FROM_UNIXTIME(1678900000)),40,50,1,60,70,1,1,'one,example,com',80,90,16,0,'{ \"a\": 1, \"b\": 2 }',0, NULL)"
|
mysql_execute "INSERT INTO lease6 VALUES(inet6_aton('::10'),20,30,(SELECT FROM_UNIXTIME(1678900000)),40,50,1,60,70,1,1,'one,example,com',80,90,16,0,'{ \"a\": 1, \"b\": 2 }',0)"
|
||||||
assert_eq 0 "${EXIT_CODE}" 'INSERT INTO lease6 failed, expected exit code %d, actual %d'
|
assert_eq 0 "${EXIT_CODE}" 'INSERT INTO lease6 failed, expected exit code %d, actual %d'
|
||||||
assert_str_eq '' "${OUTPUT}"
|
assert_str_eq '' "${OUTPUT}"
|
||||||
|
|
||||||
@@ -767,7 +767,7 @@ mysql_upgrade_17_to_18_test() {
|
|||||||
run_statement "hosts_255_long_dhcp_identifier" "$qry"
|
run_statement "hosts_255_long_dhcp_identifier" "$qry"
|
||||||
|
|
||||||
#lease6 duid should support 130 long strings.
|
#lease6 duid should support 130 long strings.
|
||||||
qry="insert into lease6 values('::10',12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,1,60,70,1,1,'one.example.com',80,90,16,0,NULL,0,NULL)"
|
qry="insert into lease6 values(inet6_aton('::10'),12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,1,60,70,1,1,'one.example.com',80,90,16,0,NULL,0)"
|
||||||
run_statement "lease6_130_long_duid" "$qry"
|
run_statement "lease6_130_long_duid" "$qry"
|
||||||
|
|
||||||
#lease4_pool_stat new table.
|
#lease4_pool_stat new table.
|
||||||
@@ -782,17 +782,6 @@ mysql_upgrade_17_to_18_test() {
|
|||||||
'SELECT subnet_id, pool_id, lease_type, state, leases FROM lease6_pool_stat'
|
'SELECT subnet_id, pool_id, lease_type, state, leases FROM lease6_pool_stat'
|
||||||
assert_eq 0 "${EXIT_CODE}" "lease6_pool_stat table is missing or broken. (expected status code %d, returned %d)"
|
assert_eq 0 "${EXIT_CODE}" "lease6_pool_stat table is missing or broken. (expected status code %d, returned %d)"
|
||||||
|
|
||||||
#lease6 new binaddr column.
|
|
||||||
qry="select binaddr from lease6"
|
|
||||||
run_statement "lease6" "$qry"
|
|
||||||
|
|
||||||
qry="show indexes from lease6 where key_name = 'lease6_by_binaddr'"
|
|
||||||
run_command \
|
|
||||||
mysql_execute "${qry}"
|
|
||||||
assert_eq 0 "${EXIT_CODE}" "show indexes from lease6 failed. (expected status code %d, returned %d)"
|
|
||||||
count=$(echo "${OUTPUT}" | grep -Fci lease6_by_binaddr)
|
|
||||||
assert_eq 1 "${count}" "lease6_by_binaddr wrong or missing. (expected count %d, actual %d)"
|
|
||||||
|
|
||||||
#lease6_relay_id new table.
|
#lease6_relay_id new table.
|
||||||
run_command \
|
run_command \
|
||||||
mysql -u"${db_user}" -p"${db_password}" "${db_name}" -e \
|
mysql -u"${db_user}" -p"${db_password}" "${db_name}" -e \
|
||||||
@@ -806,6 +795,25 @@ mysql_upgrade_17_to_18_test() {
|
|||||||
assert_eq 0 "${EXIT_CODE}" "lease6_remote_id table is missing or broken. (expected status code %d, returned %d)"
|
assert_eq 0 "${EXIT_CODE}" "lease6_remote_id table is missing or broken. (expected status code %d, returned %d)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mysql_upgrade_18_to_19_test() {
|
||||||
|
# Verify that lease6 address is binary. This is sort of overkill as many of
|
||||||
|
# the prior upgrade tests manipulate lease6 records.
|
||||||
|
qry="insert into lease6 values(inet6_aton('3001::99'),'18219',30,(SELECT FROM_UNIXTIME(1642000000)),40,50,1,60,70,1,1,'one.example.com',80,90,16,0,NULL,0)"
|
||||||
|
run_statement "lease6_insert" "$qry"
|
||||||
|
|
||||||
|
qry="select inet6_ntoa(address) from lease6 where duid = '18219';"
|
||||||
|
run_statement "lease6_insert" "$qry" "3001::99"
|
||||||
|
|
||||||
|
# Verify that ipv6_reservations address is binary.
|
||||||
|
qry="\
|
||||||
|
insert into hosts(host_id, dhcp_identifier, dhcp_identifier_type) values (18219, '18219', 1); \
|
||||||
|
insert into ipv6_reservations (address, prefix_len, type, dhcp6_iaid, host_id) \
|
||||||
|
values (inet6_aton('3001::99'), 128, 1, 123, 18219); \
|
||||||
|
select inet6_ntoa(address) from ipv6_reservations where host_id = 18219;"
|
||||||
|
|
||||||
|
run_statement "ipv6_reservations_insert" "$qry" "3001::99"
|
||||||
|
}
|
||||||
|
|
||||||
mysql_upgrade_test() {
|
mysql_upgrade_test() {
|
||||||
|
|
||||||
test_start "mysql.upgrade"
|
test_start "mysql.upgrade"
|
||||||
@@ -827,7 +835,7 @@ mysql_upgrade_test() {
|
|||||||
|
|
||||||
# Verify that the upgraded schema reports the latest version.
|
# Verify that the upgraded schema reports the latest version.
|
||||||
version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
|
version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
|
||||||
assert_str_eq "18.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
|
assert_str_eq "19.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
|
||||||
|
|
||||||
# Let's check that the new tables are indeed there.
|
# Let's check that the new tables are indeed there.
|
||||||
|
|
||||||
@@ -1487,6 +1495,9 @@ SET @disable_audit = 0"
|
|||||||
# Check upgrade from 17.0 to 18.0.
|
# Check upgrade from 17.0 to 18.0.
|
||||||
mysql_upgrade_17_to_18_test
|
mysql_upgrade_17_to_18_test
|
||||||
|
|
||||||
|
# Check upgrade from 18.0 to 19.0.
|
||||||
|
mysql_upgrade_18_to_19_test
|
||||||
|
|
||||||
# Let's wipe the whole database
|
# Let's wipe the whole database
|
||||||
mysql_wipe
|
mysql_wipe
|
||||||
|
|
||||||
@@ -1591,9 +1602,9 @@ mysql_lease6_dump_test() {
|
|||||||
|
|
||||||
# Insert the reference record
|
# Insert the reference record
|
||||||
insert_sql="\
|
insert_sql="\
|
||||||
insert into lease6 values('::10',203,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,1,60,70,1,1,'one.example.com',80,90,16,0,NULL,0,NULL);\
|
insert into lease6 values(inet6_aton('::10'),203,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,1,60,70,1,1,'one.example.com',80,90,16,0,NULL,0);\
|
||||||
insert into lease6 values('::11',213,30,(SELECT FROM_UNIXTIME(1643210000)),40,50,1,60,70,1,1,'',80,90,1,1,'{ }',0,NULL);\
|
insert into lease6 values(inet6_aton('::11'),213,30,(SELECT FROM_UNIXTIME(1643210000)),40,50,1,60,70,1,1,'',80,90,1,1,'{ }',0);\
|
||||||
insert into lease6 values('::12',223,30,(SELECT FROM_UNIXTIME(1643212345)),40,50,1,60,70,1,1,'three,example,com',80,90,4,2,'{ \"a\": 1, \"b\": \"c\" }',0,NULL)"
|
insert into lease6 values(inet6_aton('::12'),223,30,(SELECT FROM_UNIXTIME(1643212345)),40,50,1,60,70,1,1,'three,example,com',80,90,4,2,'{ \"a\": 1, \"b\": \"c\" }',0)"
|
||||||
|
|
||||||
run_command \
|
run_command \
|
||||||
mysql_execute "$insert_sql"
|
mysql_execute "$insert_sql"
|
||||||
@@ -1873,7 +1884,7 @@ mysql_lease6_stat_per_type() {
|
|||||||
ltype=$1
|
ltype=$1
|
||||||
|
|
||||||
# insert a lease6 for addr and ltype, state assigned
|
# insert a lease6 for addr and ltype, state assigned
|
||||||
qry="insert into lease6 (address, lease_type, subnet_id, state) values ($addr,$ltype,1,0)"
|
qry="insert into lease6 (address, lease_type, subnet_id, state) values (inet6_aton('$addr'),$ltype,1,0)"
|
||||||
run_statement "#2" "$qry"
|
run_statement "#2" "$qry"
|
||||||
|
|
||||||
# assigned stat should be 1
|
# assigned stat should be 1
|
||||||
@@ -1885,7 +1896,7 @@ mysql_lease6_stat_per_type() {
|
|||||||
run_statement "#4" "$qry" 1
|
run_statement "#4" "$qry" 1
|
||||||
|
|
||||||
# update the lease, changing state to declined
|
# update the lease, changing state to declined
|
||||||
qry="update lease6 set state = 1 where address = $addr"
|
qry="update lease6 set state = 1 where address = inet6_aton('$addr')"
|
||||||
run_statement "#5" "$qry"
|
run_statement "#5" "$qry"
|
||||||
|
|
||||||
# leases stat for assigned state should be 0
|
# leases stat for assigned state should be 0
|
||||||
@@ -1905,7 +1916,7 @@ mysql_lease6_stat_per_type() {
|
|||||||
run_statement "#9" "$qry" 1
|
run_statement "#9" "$qry" 1
|
||||||
|
|
||||||
# delete the lease
|
# delete the lease
|
||||||
qry="delete from lease6 where address = $addr"
|
qry="delete from lease6 where address = inet6_aton('$addr')"
|
||||||
run_statement "#10" "$qry"
|
run_statement "#10" "$qry"
|
||||||
|
|
||||||
# leases count for declined state should be 0
|
# leases count for declined state should be 0
|
||||||
@@ -1917,7 +1928,7 @@ mysql_lease6_stat_per_type() {
|
|||||||
run_statement "#12" "$qry" 0
|
run_statement "#12" "$qry" 0
|
||||||
|
|
||||||
# insert a lease6 for addr and ltype, state assigned
|
# insert a lease6 for addr and ltype, state assigned
|
||||||
qry="insert into lease6 (address, lease_type, subnet_id, pool_id, state) values ($addr1,$ltype,1,1,0)"
|
qry="insert into lease6 (address, lease_type, subnet_id, pool_id, state) values (inet6_aton('$addr1'),$ltype,1,1,0)"
|
||||||
run_statement "#13" "$qry"
|
run_statement "#13" "$qry"
|
||||||
|
|
||||||
# assigned stat should be 1
|
# assigned stat should be 1
|
||||||
@@ -1929,7 +1940,7 @@ mysql_lease6_stat_per_type() {
|
|||||||
run_statement "#15" "$qry" 1
|
run_statement "#15" "$qry" 1
|
||||||
|
|
||||||
# insert a lease6 for addr and ltype, state assigned
|
# insert a lease6 for addr and ltype, state assigned
|
||||||
qry="insert into lease6 (address, lease_type, subnet_id, pool_id, state) values ($addr2,$ltype,1,2,0)"
|
qry="insert into lease6 (address, lease_type, subnet_id, pool_id, state) values (inet6_aton('$addr2'),$ltype,1,2,0)"
|
||||||
run_statement "#16" "$qry"
|
run_statement "#16" "$qry"
|
||||||
|
|
||||||
# assigned stat should be 2
|
# assigned stat should be 2
|
||||||
@@ -1963,11 +1974,11 @@ mysql_lease6_stat_test() {
|
|||||||
qry="select count(subnet_id) from lease6_stat"
|
qry="select count(subnet_id) from lease6_stat"
|
||||||
run_statement "#1" "$qry"
|
run_statement "#1" "$qry"
|
||||||
|
|
||||||
# Test for address 111, NA lease type
|
# Test for address ::11, NA lease type
|
||||||
mysql_lease6_stat_per_type "111" "112" "113" "0"
|
mysql_lease6_stat_per_type "::11" "::12" "::13" "0"
|
||||||
|
|
||||||
# Test for address 222, PD lease type
|
# Test for address ::22, PD lease type
|
||||||
mysql_lease6_stat_per_type "222" "223" "224" "1"
|
mysql_lease6_stat_per_type "::22" "::23" "::24" "1"
|
||||||
|
|
||||||
# Let's wipe the whole database
|
# Let's wipe the whole database
|
||||||
mysql_wipe
|
mysql_wipe
|
||||||
@@ -2004,12 +2015,12 @@ mysql_lease_stat_upgrade_test() {
|
|||||||
run_statement "insert v4 leases" "$qry"
|
run_statement "insert v4 leases" "$qry"
|
||||||
|
|
||||||
qry=\
|
qry=\
|
||||||
"insert into lease6 (address, lease_type, subnet_id, state) values (111,0,40,0);\
|
"insert into lease6 (address, lease_type, subnet_id, state) values (inet6_aton('::11'),0,40,0);\
|
||||||
insert into lease6 (address, lease_type, subnet_id, state) values (222,0,40,1);\
|
insert into lease6 (address, lease_type, subnet_id, state) values (inet6_aton('::22'),0,40,1);\
|
||||||
insert into lease6 (address, lease_type, subnet_id, state) values (333,1,40,0);\
|
insert into lease6 (address, lease_type, subnet_id, state) values (inet6_aton('::33'),1,40,0);\
|
||||||
insert into lease6 (address, lease_type, subnet_id, state) values (444,1,50,0);\
|
insert into lease6 (address, lease_type, subnet_id, state) values (inet6_aton('::44'),1,50,0);\
|
||||||
insert into lease6 (address, lease_type, subnet_id, state) values (555,1,50,0);\
|
insert into lease6 (address, lease_type, subnet_id, state) values (inet6_aton('::55'),1,50,0);\
|
||||||
insert into lease6 (address, lease_type, subnet_id, state) values (666,1,40,2)"
|
insert into lease6 (address, lease_type, subnet_id, state) values (inet6_aton('::66'),1,40,2)"
|
||||||
run_statement "insert v6 leases" "$qry"
|
run_statement "insert v6 leases" "$qry"
|
||||||
|
|
||||||
# Let's upgrade it to the latest version.
|
# Let's upgrade it to the latest version.
|
||||||
@@ -2149,7 +2160,7 @@ mysql_lease_stat_upgrade_test() {
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Insert a new lease subnet 50
|
# Insert a new lease subnet 50
|
||||||
qry="insert into lease6 (address, subnet_id, pool_id, lease_type, state) values (777,50,1,1,0)"
|
qry="insert into lease6 (address, subnet_id, pool_id, lease_type, state) values (inet6_aton('::77'),50,1,1,0)"
|
||||||
run_statement "#6.11" "$qry"
|
run_statement "#6.11" "$qry"
|
||||||
|
|
||||||
# Assigned count for subnet 50 should be 3
|
# Assigned count for subnet 50 should be 3
|
||||||
@@ -2165,7 +2176,7 @@ mysql_lease_stat_upgrade_test() {
|
|||||||
run_statement "#6.14" "$qry" 1
|
run_statement "#6.14" "$qry" 1
|
||||||
|
|
||||||
# Update the state of the new lease to expired
|
# Update the state of the new lease to expired
|
||||||
qry="update lease6 set state = 2 where address = 777"
|
qry="update lease6 set state = 2 where address = inet6_aton('::77')"
|
||||||
run_statement "#6.15" "$qry"
|
run_statement "#6.15" "$qry"
|
||||||
|
|
||||||
# Assigned count for subnet 50 should be 2 again
|
# Assigned count for subnet 50 should be 2 again
|
||||||
@@ -2177,7 +2188,7 @@ mysql_lease_stat_upgrade_test() {
|
|||||||
run_statement "#6.17" "$qry" 0
|
run_statement "#6.17" "$qry" 0
|
||||||
|
|
||||||
# Delete another PD lease.
|
# Delete another PD lease.
|
||||||
qry="delete from lease6 where address = 555"
|
qry="delete from lease6 where address = inet6_aton('::55')"
|
||||||
run_statement "#6.18" "$qry"
|
run_statement "#6.18" "$qry"
|
||||||
|
|
||||||
# Assigned leases for subnet 50 should be 1
|
# Assigned leases for subnet 50 should be 1
|
||||||
@@ -2778,8 +2789,8 @@ mysql_update_empty_duid_test() {
|
|||||||
mysql_upgrade_schema_to_version 16.0
|
mysql_upgrade_schema_to_version 16.0
|
||||||
|
|
||||||
sql=\
|
sql=\
|
||||||
"insert into lease6 values('::10',203,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,1,60,70,1,1,'one.example.com',80,90,16,0,NULL);\
|
"insert into lease6 values(inet6_aton('::10'),203,30,(SELECT FROM_UNIXTIME(1642000000)),40,50,1,60,70,1,1,'one.example.com',80,90,16,0,NULL);\
|
||||||
insert into lease6 values('::11',UNHEX('00'),30,(SELECT FROM_UNIXTIME(1643210000)),40,50,1,60,70,1,1,'',80,90,1,1,'{ }')"
|
insert into lease6 values(inet6_aton('::11'),UNHEX('00'),30,(SELECT FROM_UNIXTIME(1643210000)),40,50,1,60,70,1,1,'',80,90,1,1,'{ }')"
|
||||||
|
|
||||||
run_statement "insert v6 leases" "$sql"
|
run_statement "insert v6 leases" "$sql"
|
||||||
|
|
||||||
@@ -2788,11 +2799,11 @@ mysql_update_empty_duid_test() {
|
|||||||
"${kea_admin}" db-upgrade mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
|
"${kea_admin}" db-upgrade mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
|
||||||
|
|
||||||
# leases count for declined state should be 1 with DUID updated (0x000000)
|
# leases count for declined state should be 1 with DUID updated (0x000000)
|
||||||
qry="select count(*) from lease6 where address = '::11' and duid = 0x000000 and state = 1"
|
qry="select count(*) from lease6 where address = inet6_aton('::11') and duid = 0x000000 and state = 1"
|
||||||
run_statement "#2" "$qry" 1
|
run_statement "#2" "$qry" 1
|
||||||
|
|
||||||
# leases count for non declined state should be 1 with DUID unchanged (0x323033)
|
# leases count for non declined state should be 1 with DUID unchanged (0x323033)
|
||||||
qry="select count(*) from lease6 where address = '::10' and duid = 0x323033 and state = 0"
|
qry="select count(*) from lease6 where address = inet6_aton('::10') and duid = 0x323033 and state = 0"
|
||||||
run_statement "#3" "$qry" 1
|
run_statement "#3" "$qry" 1
|
||||||
|
|
||||||
# Let's wipe the whole database
|
# Let's wipe the whole database
|
||||||
|
@@ -1041,7 +1041,11 @@ public:
|
|||||||
///
|
///
|
||||||
/// @param page_size The page size used for retrieval.
|
/// @param page_size The page size used for retrieval.
|
||||||
/// @return The number of updates in the database.
|
/// @return The number of updates in the database.
|
||||||
virtual size_t upgradeBinaryAddress6(const LeasePageSize& page_size) = 0;
|
/// @todo This will be obsolete once #2909 is completed for all backends
|
||||||
|
/// and lease-query hook lib
|
||||||
|
virtual size_t upgradeBinaryAddress6(const LeasePageSize& /* page_size */) {
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Build extended info v6 tables.
|
/// @brief Build extended info v6 tables.
|
||||||
///
|
///
|
||||||
|
@@ -1463,9 +1463,8 @@ public:
|
|||||||
<< ". Only 0 or 2 are allowed.");
|
<< ". Only 0 or 2 are allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
ipv6_address_buffer_[ipv6_address_buffer_len_] = '\0';
|
IOAddress addr6 = IOAddress::fromBytes(AF_INET6, ipv6_address_buffer_);
|
||||||
std::string address = ipv6_address_buffer_;
|
IPv6Resrv r(type, addr6, prefix_len_);
|
||||||
IPv6Resrv r(type, IOAddress(address), prefix_len_);
|
|
||||||
return (r);
|
return (r);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1535,10 +1534,10 @@ public:
|
|||||||
bind_[reservation_id_index_].buffer = reinterpret_cast<char*>(&reservation_id_);
|
bind_[reservation_id_index_].buffer = reinterpret_cast<char*>(&reservation_id_);
|
||||||
bind_[reservation_id_index_].is_unsigned = MLM_TRUE;
|
bind_[reservation_id_index_].is_unsigned = MLM_TRUE;
|
||||||
|
|
||||||
// IPv6 address/prefix VARCHAR(39)
|
// IPv6 address/prefix BINARY(16)
|
||||||
ipv6_address_buffer_len_ = sizeof(ipv6_address_buffer_) - 1;
|
ipv6_address_buffer_len_ = 16;
|
||||||
bind_[address_index_].buffer_type = MYSQL_TYPE_STRING;
|
bind_[address_index_].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
bind_[address_index_].buffer = ipv6_address_buffer_;
|
bind_[address_index_].buffer = reinterpret_cast<char*>(ipv6_address_buffer_);
|
||||||
bind_[address_index_].buffer_length = ipv6_address_buffer_len_;
|
bind_[address_index_].buffer_length = ipv6_address_buffer_len_;
|
||||||
bind_[address_index_].length = &ipv6_address_buffer_len_;
|
bind_[address_index_].length = &ipv6_address_buffer_len_;
|
||||||
|
|
||||||
@@ -1580,7 +1579,7 @@ private:
|
|||||||
my_bool reserv_type_null_;
|
my_bool reserv_type_null_;
|
||||||
|
|
||||||
/// @brief Buffer holding IPv6 address/prefix in textual format.
|
/// @brief Buffer holding IPv6 address/prefix in textual format.
|
||||||
char ipv6_address_buffer_[ADDRESS6_TEXT_MAX_LEN + 1];
|
uint8_t ipv6_address_buffer_[16];
|
||||||
|
|
||||||
/// @brief Length of the textual address representation.
|
/// @brief Length of the textual address representation.
|
||||||
unsigned long ipv6_address_buffer_len_;
|
unsigned long ipv6_address_buffer_len_;
|
||||||
@@ -1684,14 +1683,16 @@ public:
|
|||||||
// Set up the structures for the various components of the host structure.
|
// Set up the structures for the various components of the host structure.
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// address VARCHAR(39)
|
addr6_ = resv.getPrefix().toBytes();
|
||||||
address_ = resv.getPrefix().toText();
|
if (addr6_.size() != 16) {
|
||||||
address_len_ = address_.length();
|
isc_throw(DbOperationError, "createBindForSend() - prefix is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
|
addr6_length_ = 16;
|
||||||
bind_[0].buffer_type = MYSQL_TYPE_BLOB;
|
bind_[0].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
bind_[0].buffer = reinterpret_cast<char*>
|
bind_[0].buffer = reinterpret_cast<char*>(&addr6_[0]);
|
||||||
(const_cast<char*>(address_.c_str()));
|
bind_[0].buffer_length = 16;
|
||||||
bind_[0].buffer_length = address_len_;
|
bind_[0].length = &addr6_length_;
|
||||||
bind_[0].length = &address_len_;
|
|
||||||
|
|
||||||
// prefix_len tinyint
|
// prefix_len tinyint
|
||||||
prefix_len_ = resv.getPrefixLen();
|
prefix_len_ = resv.getPrefixLen();
|
||||||
@@ -1772,6 +1773,15 @@ private:
|
|||||||
/// @brief Array of boolean values indicating if error occurred
|
/// @brief Array of boolean values indicating if error occurred
|
||||||
/// for respective columns.
|
/// for respective columns.
|
||||||
my_bool error_[RESRV_COLUMNS];
|
my_bool error_[RESRV_COLUMNS];
|
||||||
|
|
||||||
|
/// @brief Binary address data.
|
||||||
|
std::vector<uint8_t> addr6_;
|
||||||
|
|
||||||
|
/// @brief Binary address buffer.
|
||||||
|
uint8_t addr6_buffer_[16];
|
||||||
|
|
||||||
|
/// @brief Binary address length.
|
||||||
|
unsigned long addr6_length_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief This class is used for inserting options into a database.
|
/// @brief This class is used for inserting options into a database.
|
||||||
@@ -3312,13 +3322,16 @@ MySqlHostDataSource::del(const SubnetID& subnet_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// v6
|
// v6
|
||||||
std::string addr_str = addr.toText();
|
std::vector<uint8_t>addr6 = addr.toBytes();
|
||||||
unsigned long addr_len = addr_str.size();
|
if (addr6.size() != 16) {
|
||||||
|
isc_throw(DbOperationError, "del() - address is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long addr6_length = 16;
|
||||||
inbind[1].buffer_type = MYSQL_TYPE_BLOB;
|
inbind[1].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
inbind[1].buffer = reinterpret_cast<char*>
|
inbind[1].buffer = reinterpret_cast<char*>(&addr6[0]);
|
||||||
(const_cast<char*>(addr_str.c_str()));
|
inbind[1].buffer_length = 16;
|
||||||
inbind[1].length = &addr_len;
|
inbind[1].length = &addr6_length;
|
||||||
inbind[1].buffer_length = addr_len;
|
|
||||||
|
|
||||||
return (impl_->delStatement(ctx, MySqlHostDataSourceImpl::DEL_HOST_ADDR6, inbind));
|
return (impl_->delStatement(ctx, MySqlHostDataSourceImpl::DEL_HOST_ADDR6, inbind));
|
||||||
}
|
}
|
||||||
@@ -3846,14 +3859,16 @@ MySqlHostDataSource::get6(const asiolink::IOAddress& prefix,
|
|||||||
MYSQL_BIND inbind[2];
|
MYSQL_BIND inbind[2];
|
||||||
memset(inbind, 0, sizeof(inbind));
|
memset(inbind, 0, sizeof(inbind));
|
||||||
|
|
||||||
std::string addr6 = prefix.toText();
|
std::vector<uint8_t>addr6 = prefix.toBytes();
|
||||||
unsigned long addr6_length = addr6.size();
|
if (addr6.size() != 16) {
|
||||||
|
isc_throw(DbOperationError, "get6() - prefix is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long addr6_length = 16;
|
||||||
inbind[0].buffer_type = MYSQL_TYPE_BLOB;
|
inbind[0].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
inbind[0].buffer = reinterpret_cast<char*>
|
inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
|
||||||
(const_cast<char*>(addr6.c_str()));
|
inbind[0].buffer_length = 16;
|
||||||
inbind[0].length = &addr6_length;
|
inbind[0].length = &addr6_length;
|
||||||
inbind[0].buffer_length = addr6_length;
|
|
||||||
|
|
||||||
uint8_t tmp = prefix_len;
|
uint8_t tmp = prefix_len;
|
||||||
inbind[1].buffer_type = MYSQL_TYPE_TINY;
|
inbind[1].buffer_type = MYSQL_TYPE_TINY;
|
||||||
@@ -3894,14 +3909,16 @@ MySqlHostDataSource::get6(const SubnetID& subnet_id,
|
|||||||
inbind[0].buffer = reinterpret_cast<char*>(&subnet_buffer);
|
inbind[0].buffer = reinterpret_cast<char*>(&subnet_buffer);
|
||||||
inbind[0].is_unsigned = MLM_TRUE;
|
inbind[0].is_unsigned = MLM_TRUE;
|
||||||
|
|
||||||
std::string addr6 = address.toText();
|
std::vector<uint8_t>addr6 = address.toBytes();
|
||||||
unsigned long addr6_length = addr6.size();
|
if (addr6.size() != 16) {
|
||||||
|
isc_throw(DbOperationError, "get6() - address is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long addr6_length = 16;
|
||||||
inbind[1].buffer_type = MYSQL_TYPE_BLOB;
|
inbind[1].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
inbind[1].buffer = reinterpret_cast<char*>
|
inbind[1].buffer = reinterpret_cast<char*>(&addr6[0]);
|
||||||
(const_cast<char*>(addr6.c_str()));
|
inbind[1].buffer_length = 16;
|
||||||
inbind[1].length = &addr6_length;
|
inbind[1].length = &addr6_length;
|
||||||
inbind[1].buffer_length = addr6_length;
|
|
||||||
|
|
||||||
ConstHostCollection collection;
|
ConstHostCollection collection;
|
||||||
impl_->getHostCollection(ctx, MySqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR, inbind,
|
impl_->getHostCollection(ctx, MySqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR, inbind,
|
||||||
@@ -3937,14 +3954,16 @@ MySqlHostDataSource::getAll6(const SubnetID& subnet_id,
|
|||||||
inbind[0].buffer = reinterpret_cast<char*>(&subnet_buffer);
|
inbind[0].buffer = reinterpret_cast<char*>(&subnet_buffer);
|
||||||
inbind[0].is_unsigned = MLM_TRUE;
|
inbind[0].is_unsigned = MLM_TRUE;
|
||||||
|
|
||||||
std::string addr6 = address.toText();
|
std::vector<uint8_t>addr6 = address.toBytes();
|
||||||
unsigned long addr6_length = addr6.size();
|
if (addr6.size() != 16) {
|
||||||
|
isc_throw(DbOperationError, "getAll6() - address is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long addr6_length = 16;
|
||||||
inbind[1].buffer_type = MYSQL_TYPE_BLOB;
|
inbind[1].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
inbind[1].buffer = reinterpret_cast<char*>
|
inbind[1].buffer = reinterpret_cast<char*>(&addr6[0]);
|
||||||
(const_cast<char*>(addr6.c_str()));
|
inbind[1].buffer_length = 16;
|
||||||
inbind[1].length = &addr6_length;
|
inbind[1].length = &addr6_length;
|
||||||
inbind[1].buffer_length = addr6_length;
|
|
||||||
|
|
||||||
ConstHostCollection collection;
|
ConstHostCollection collection;
|
||||||
impl_->getHostCollection(ctx, MySqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR, inbind,
|
impl_->getHostCollection(ctx, MySqlHostDataSourceImpl::GET_HOST_SUBID6_ADDR, inbind,
|
||||||
|
@@ -350,17 +350,6 @@ tagged_statements = { {
|
|||||||
"WHERE address > ? AND user_context IS NOT NULL "
|
"WHERE address > ? AND user_context IS NOT NULL "
|
||||||
"ORDER BY address "
|
"ORDER BY address "
|
||||||
"LIMIT ?"},
|
"LIMIT ?"},
|
||||||
{MySqlLeaseMgr::GET_LEASE6_BINADDR_PAGE,
|
|
||||||
"SELECT address, duid, valid_lifetime, "
|
|
||||||
"expire, subnet_id, pref_lifetime, "
|
|
||||||
"lease_type, iaid, prefix_len, "
|
|
||||||
"fqdn_fwd, fqdn_rev, hostname, "
|
|
||||||
"hwaddr, hwtype, hwaddr_source, "
|
|
||||||
"state, user_context, pool_id "
|
|
||||||
"FROM lease6 "
|
|
||||||
"WHERE address > ? AND binaddr IS NULL "
|
|
||||||
"ORDER BY address "
|
|
||||||
"LIMIT ?"},
|
|
||||||
{MySqlLeaseMgr::GET_LEASE6_SUBID,
|
{MySqlLeaseMgr::GET_LEASE6_SUBID,
|
||||||
"SELECT address, duid, valid_lifetime, "
|
"SELECT address, duid, valid_lifetime, "
|
||||||
"expire, subnet_id, pref_lifetime, "
|
"expire, subnet_id, pref_lifetime, "
|
||||||
@@ -409,9 +398,8 @@ tagged_statements = { {
|
|||||||
"hwaddr, hwtype, hwaddr_source, "
|
"hwaddr, hwtype, hwaddr_source, "
|
||||||
"state, user_context, pool_id "
|
"state, user_context, pool_id "
|
||||||
"FROM lease6 "
|
"FROM lease6 "
|
||||||
"WHERE binaddr IS NOT NULL "
|
"WHERE address BETWEEN ? AND ? "
|
||||||
"AND binaddr BETWEEN ? AND ? "
|
"ORDER BY address "
|
||||||
"ORDER BY binaddr "
|
|
||||||
"LIMIT ?"},
|
"LIMIT ?"},
|
||||||
{MySqlLeaseMgr::INSERT_LEASE4,
|
{MySqlLeaseMgr::INSERT_LEASE4,
|
||||||
"INSERT INTO lease4(address, hwaddr, client_id, "
|
"INSERT INTO lease4(address, hwaddr, client_id, "
|
||||||
@@ -425,8 +413,8 @@ tagged_statements = { {
|
|||||||
"lease_type, iaid, prefix_len, "
|
"lease_type, iaid, prefix_len, "
|
||||||
"fqdn_fwd, fqdn_rev, hostname, "
|
"fqdn_fwd, fqdn_rev, hostname, "
|
||||||
"hwaddr, hwtype, hwaddr_source, "
|
"hwaddr, hwtype, hwaddr_source, "
|
||||||
"state, user_context, pool_id, binaddr) "
|
"state, user_context, pool_id) "
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"},
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"},
|
||||||
{MySqlLeaseMgr::UPDATE_LEASE4,
|
{MySqlLeaseMgr::UPDATE_LEASE4,
|
||||||
"UPDATE lease4 SET address = ?, hwaddr = ?, "
|
"UPDATE lease4 SET address = ?, hwaddr = ?, "
|
||||||
"client_id = ?, valid_lifetime = ?, expire = ?, "
|
"client_id = ?, valid_lifetime = ?, expire = ?, "
|
||||||
@@ -441,7 +429,7 @@ tagged_statements = { {
|
|||||||
"pref_lifetime = ?, lease_type = ?, iaid = ?, "
|
"pref_lifetime = ?, lease_type = ?, iaid = ?, "
|
||||||
"prefix_len = ?, fqdn_fwd = ?, fqdn_rev = ?, "
|
"prefix_len = ?, fqdn_fwd = ?, fqdn_rev = ?, "
|
||||||
"hostname = ?, hwaddr = ?, hwtype = ?, hwaddr_source = ?, "
|
"hostname = ?, hwaddr = ?, hwtype = ?, hwaddr_source = ?, "
|
||||||
"state = ?, user_context = ?, pool_id = ?, binaddr = ? "
|
"state = ?, user_context = ?, pool_id = ? "
|
||||||
"WHERE address = ? AND expire = ?"},
|
"WHERE address = ? AND expire = ?"},
|
||||||
{MySqlLeaseMgr::ALL_LEASE4_STATS,
|
{MySqlLeaseMgr::ALL_LEASE4_STATS,
|
||||||
"SELECT subnet_id, state, leases as state_count "
|
"SELECT subnet_id, state, leases as state_count "
|
||||||
@@ -1182,10 +1170,9 @@ class MySqlLease6Exchange : public MySqlLeaseExchange {
|
|||||||
static const size_t STATE_COL = 15;
|
static const size_t STATE_COL = 15;
|
||||||
static const size_t USER_CONTEXT_COL = 16;
|
static const size_t USER_CONTEXT_COL = 16;
|
||||||
static const size_t POOL_ID_COL = 17;
|
static const size_t POOL_ID_COL = 17;
|
||||||
static const size_t BINADDR_COL = 18;
|
|
||||||
//@}
|
//@}
|
||||||
/// @brief Number of columns in the table holding DHCPv6 leases.
|
/// @brief Number of columns in the table holding DHCPv6 leases.
|
||||||
static const size_t LEASE_COLUMNS = 19;
|
static const size_t LEASE_COLUMNS = 18;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -1193,14 +1180,14 @@ public:
|
|||||||
///
|
///
|
||||||
/// The initialization of the variables here is only to satisfy cppcheck -
|
/// The initialization of the variables here is only to satisfy cppcheck -
|
||||||
/// all variables are initialized/set in the methods before they are used.
|
/// all variables are initialized/set in the methods before they are used.
|
||||||
MySqlLease6Exchange() : addr6_length_(0), hwaddr_length_(0),
|
MySqlLease6Exchange() : addr6_length_(16), hwaddr_length_(0),
|
||||||
hwaddr_null_(MLM_FALSE), duid_length_(0),
|
hwaddr_null_(MLM_FALSE), duid_length_(0),
|
||||||
iaid_(0), lease_type_(0), prefix_len_(0),
|
iaid_(0), lease_type_(0), prefix_len_(0),
|
||||||
pref_lifetime_(0), subnet_id_(0), pool_id_(0),
|
pref_lifetime_(0), subnet_id_(0), pool_id_(0),
|
||||||
valid_lifetime_(0), fqdn_fwd_(false), fqdn_rev_(false),
|
valid_lifetime_(0), fqdn_fwd_(false), fqdn_rev_(false),
|
||||||
hostname_length_(0), hwtype_(0), hwaddr_source_(0),
|
hostname_length_(0), hwtype_(0), hwaddr_source_(0),
|
||||||
state_(0), user_context_length_(0),
|
state_(0), user_context_length_(0),
|
||||||
user_context_null_(MLM_FALSE), binaddr_length_(16) {
|
user_context_null_(MLM_FALSE) {
|
||||||
memset(addr6_buffer_, 0, sizeof(addr6_buffer_));
|
memset(addr6_buffer_, 0, sizeof(addr6_buffer_));
|
||||||
memset(duid_buffer_, 0, sizeof(duid_buffer_));
|
memset(duid_buffer_, 0, sizeof(duid_buffer_));
|
||||||
memset(hostname_buffer_, 0, sizeof(hostname_buffer_));
|
memset(hostname_buffer_, 0, sizeof(hostname_buffer_));
|
||||||
@@ -1227,8 +1214,7 @@ public:
|
|||||||
columns_[STATE_COL] = "state";
|
columns_[STATE_COL] = "state";
|
||||||
columns_[USER_CONTEXT_COL] = "user_context";
|
columns_[USER_CONTEXT_COL] = "user_context";
|
||||||
columns_[POOL_ID_COL] = "pool_id";
|
columns_[POOL_ID_COL] = "pool_id";
|
||||||
columns_[BINADDR_COL] = "binaddr";
|
BOOST_STATIC_ASSERT(17 < LEASE_COLUMNS);
|
||||||
BOOST_STATIC_ASSERT(18 < LEASE_COLUMNS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Create MYSQL_BIND objects for Lease6 Pointer
|
/// @brief Create MYSQL_BIND objects for Lease6 Pointer
|
||||||
@@ -1252,34 +1238,23 @@ public:
|
|||||||
memset(bind_, 0, sizeof(bind_));
|
memset(bind_, 0, sizeof(bind_));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// address: varchar(39)
|
// address: binary(16)
|
||||||
addr6_ = lease_->addr_.toText();
|
addr6_ = lease->addr_.toBytes();
|
||||||
addr6_length_ = addr6_.size();
|
if (addr6_.size() != 16) {
|
||||||
|
isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
// In the following statement, the string is being read. However, the
|
addr6_length_ = 16;
|
||||||
// MySQL C interface does not use "const", so the "buffer" element
|
bind_[0].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
// is declared as "char*" instead of "const char*". To resolve this,
|
bind_[0].buffer = reinterpret_cast<char*>(&addr6_[0]);
|
||||||
// the "const" is discarded. (Note that the address of addr6_.c_str()
|
bind_[0].buffer_length = 16;
|
||||||
// is guaranteed to be valid until the next non-const operation on
|
|
||||||
// addr6_.)
|
|
||||||
//
|
|
||||||
// The const_cast could be avoided by copying the string to a writable
|
|
||||||
// buffer and storing the address of that in the "buffer" element.
|
|
||||||
// However, this introduces a copy operation (with additional overhead)
|
|
||||||
// purely to get round the structures introduced by design of the
|
|
||||||
// MySQL interface (which uses the area pointed to by "buffer" as input
|
|
||||||
// when specifying query parameters and as output when retrieving data).
|
|
||||||
// For that reason, "const_cast" has been used.
|
|
||||||
bind_[0].buffer_type = MYSQL_TYPE_STRING;
|
|
||||||
bind_[0].buffer = const_cast<char*>(addr6_.c_str());
|
|
||||||
bind_[0].buffer_length = addr6_length_;
|
|
||||||
bind_[0].length = &addr6_length_;
|
bind_[0].length = &addr6_length_;
|
||||||
// bind_[0].is_null = &MLM_FALSE; // commented out for performance
|
// bind_[0].is_null = &MLM_FALSE; // commented out for performance
|
||||||
// reasons, see memset() above
|
// reasons, see memset() above
|
||||||
|
|
||||||
// duid: varchar(130)
|
// duid: varchar(130)
|
||||||
if (!lease_->duid_) {
|
if (!lease_->duid_) {
|
||||||
isc_throw(DbOperationError, "lease6 for address " << addr6_
|
isc_throw(DbOperationError, "lease6 for address " << lease->addr_.toText()
|
||||||
<< " is missing mandatory client-id.");
|
<< " is missing mandatory client-id.");
|
||||||
}
|
}
|
||||||
duid_ = lease_->duid_->getDuid();
|
duid_ = lease_->duid_->getDuid();
|
||||||
@@ -1479,25 +1454,11 @@ public:
|
|||||||
// bind_[17].is_null = &MLM_FALSE; // commented out for performance
|
// bind_[17].is_null = &MLM_FALSE; // commented out for performance
|
||||||
// reasons, see memset() above
|
// reasons, see memset() above
|
||||||
|
|
||||||
// binaddr: binary(16)
|
|
||||||
binaddr_ = lease->addr_.toBytes();
|
|
||||||
if (binaddr_.size() != 16) {
|
|
||||||
isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
|
|
||||||
}
|
|
||||||
|
|
||||||
binaddr_length_ = 16;
|
|
||||||
bind_[18].buffer_type = MYSQL_TYPE_BLOB;
|
|
||||||
bind_[18].buffer = reinterpret_cast<char*>(&binaddr_[0]);
|
|
||||||
bind_[18].buffer_length = 16;
|
|
||||||
bind_[18].length = &binaddr_length_;
|
|
||||||
// bind_[18].is_null = &MLM_FALSE; // commented out for performance
|
|
||||||
// reasons, see memset() above
|
|
||||||
|
|
||||||
// Add the error flags
|
// Add the error flags
|
||||||
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
|
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
|
||||||
|
|
||||||
// .. and check that we have the numbers correct at compile time.
|
// .. and check that we have the numbers correct at compile time.
|
||||||
BOOST_STATIC_ASSERT(18 < LEASE_COLUMNS);
|
BOOST_STATIC_ASSERT(17 < LEASE_COLUMNS);
|
||||||
|
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
isc_throw(DbOperationError,
|
isc_throw(DbOperationError,
|
||||||
@@ -1527,13 +1488,10 @@ public:
|
|||||||
// code that explicitly sets is_null is there, but is commented out.
|
// code that explicitly sets is_null is there, but is commented out.
|
||||||
memset(bind_, 0, sizeof(bind_));
|
memset(bind_, 0, sizeof(bind_));
|
||||||
|
|
||||||
// address: varchar(39)
|
// address: binary(16)
|
||||||
// A Lease6_ address has a maximum of 39 characters. The array is
|
addr6_length_ = 16;
|
||||||
// one byte longer than this to guarantee that we can always null
|
bind_[0].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
// terminate it whatever is returned.
|
bind_[0].buffer = reinterpret_cast<char*>(addr6_buffer_);
|
||||||
addr6_length_ = sizeof(addr6_buffer_) - 1;
|
|
||||||
bind_[0].buffer_type = MYSQL_TYPE_STRING;
|
|
||||||
bind_[0].buffer = addr6_buffer_;
|
|
||||||
bind_[0].buffer_length = addr6_length_;
|
bind_[0].buffer_length = addr6_length_;
|
||||||
bind_[0].length = &addr6_length_;
|
bind_[0].length = &addr6_length_;
|
||||||
// bind_[0].is_null = &MLM_FALSE; // commented out for performance
|
// bind_[0].is_null = &MLM_FALSE; // commented out for performance
|
||||||
@@ -1666,7 +1624,7 @@ public:
|
|||||||
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
|
setErrorIndicators(bind_, error_, LEASE_COLUMNS);
|
||||||
|
|
||||||
// .. and check that we have the numbers correct at compile time.
|
// .. and check that we have the numbers correct at compile time.
|
||||||
BOOST_STATIC_ASSERT(18 < LEASE_COLUMNS);
|
BOOST_STATIC_ASSERT(17 < LEASE_COLUMNS);
|
||||||
|
|
||||||
// Add the data to the vector. Note the end element is one after the
|
// Add the data to the vector. Note the end element is one after the
|
||||||
// end of the array.
|
// end of the array.
|
||||||
@@ -1684,12 +1642,9 @@ public:
|
|||||||
///
|
///
|
||||||
/// @throw isc::BadValue Unable to convert Lease Type value in database
|
/// @throw isc::BadValue Unable to convert Lease Type value in database
|
||||||
Lease6Ptr getLeaseData() {
|
Lease6Ptr getLeaseData() {
|
||||||
// The address buffer is declared larger than the buffer size passed
|
// Convert lease from network-order bytes to IOAddress.
|
||||||
// to the access function so that we can always append a null byte.
|
IOAddress addr = IOAddress::fromBytes(AF_INET6, addr6_buffer_);
|
||||||
// Create the IOAddress object corresponding to the received data.
|
std::string address = addr.toText();
|
||||||
addr6_buffer_[addr6_length_] = '\0';
|
|
||||||
std::string address = addr6_buffer_;
|
|
||||||
IOAddress addr(address);
|
|
||||||
|
|
||||||
// Set the lease type in a variable of the appropriate data type, which
|
// Set the lease type in a variable of the appropriate data type, which
|
||||||
// has been initialized with an arbitrary (but valid) value.
|
// has been initialized with an arbitrary (but valid) value.
|
||||||
@@ -1797,9 +1752,9 @@ private:
|
|||||||
// Note: All array lengths are equal to the corresponding variable in the
|
// Note: All array lengths are equal to the corresponding variable in the
|
||||||
// schema.
|
// schema.
|
||||||
// Note: arrays are declared fixed length for speed of creation
|
// Note: arrays are declared fixed length for speed of creation
|
||||||
std::string addr6_; ///< Address
|
std::vector<uint8_t> addr6_; ///< Binary address
|
||||||
char addr6_buffer_[ADDRESS6_TEXT_MAX_LEN + 1]; ///< Address buffer
|
uint8_t addr6_buffer_[16]; ///< Binary address buffer
|
||||||
unsigned long addr6_length_; ///< Length of address
|
unsigned long addr6_length_; ///< Binary address length
|
||||||
MYSQL_BIND bind_[LEASE_COLUMNS]; ///< Bind array
|
MYSQL_BIND bind_[LEASE_COLUMNS]; ///< Bind array
|
||||||
std::string columns_[LEASE_COLUMNS]; ///< Column names
|
std::string columns_[LEASE_COLUMNS]; ///< Column names
|
||||||
my_bool error_[LEASE_COLUMNS]; ///< Error array
|
my_bool error_[LEASE_COLUMNS]; ///< Error array
|
||||||
@@ -1829,8 +1784,6 @@ private:
|
|||||||
char user_context_[USER_CONTEXT_MAX_LEN]; ///< User context
|
char user_context_[USER_CONTEXT_MAX_LEN]; ///< User context
|
||||||
unsigned long user_context_length_; ///< Length of user context
|
unsigned long user_context_length_; ///< Length of user context
|
||||||
my_bool user_context_null_; ///< Used when user context is null
|
my_bool user_context_null_; ///< Used when user context is null
|
||||||
std::vector<uint8_t> binaddr_; ///< Binary address
|
|
||||||
unsigned long binaddr_length_; ///< Length of binary data
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief MySql derivation of the statistical lease data query
|
/// @brief MySql derivation of the statistical lease data query
|
||||||
@@ -2307,6 +2260,7 @@ MySqlLeaseMgr::createContext() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Prepare all statements likely to be used.
|
// Prepare all statements likely to be used.
|
||||||
ctx->conn_.prepareStatements(tagged_statements.begin(),
|
ctx->conn_.prepareStatements(tagged_statements.begin(),
|
||||||
tagged_statements.end());
|
tagged_statements.end());
|
||||||
@@ -2858,14 +2812,16 @@ MySqlLeaseMgr::getLease6(Lease::Type lease_type,
|
|||||||
MYSQL_BIND inbind[2];
|
MYSQL_BIND inbind[2];
|
||||||
memset(inbind, 0, sizeof(inbind));
|
memset(inbind, 0, sizeof(inbind));
|
||||||
|
|
||||||
std::string addr6 = addr.toText();
|
// address: binary(16)
|
||||||
unsigned long addr6_length = addr6.size();
|
std::vector<uint8_t>addr6 = addr.toBytes();
|
||||||
|
if (addr6.size() != 16) {
|
||||||
|
isc_throw(DbOperationError, "lease6 address is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
// See the earlier description of the use of "const_cast" when accessing
|
unsigned long addr6_length = 16;
|
||||||
// the address for an explanation of the reason.
|
inbind[0].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
inbind[0].buffer_type = MYSQL_TYPE_STRING;
|
inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
|
||||||
inbind[0].buffer = const_cast<char*>(addr6.c_str());
|
inbind[0].buffer_length = 16;
|
||||||
inbind[0].buffer_length = addr6_length;
|
|
||||||
inbind[0].length = &addr6_length;
|
inbind[0].length = &addr6_length;
|
||||||
|
|
||||||
// LEASE_TYPE
|
// LEASE_TYPE
|
||||||
@@ -3111,20 +3067,17 @@ MySqlLeaseMgr::getLeases6(const IOAddress& lower_bound_address,
|
|||||||
MYSQL_BIND inbind[2];
|
MYSQL_BIND inbind[2];
|
||||||
memset(inbind, 0, sizeof(inbind));
|
memset(inbind, 0, sizeof(inbind));
|
||||||
|
|
||||||
// In IPv6 we compare addresses represented as strings. The IPv6 zero address
|
// Bind lower bound address
|
||||||
// is ::, so it is greater than any other address. In this special case, we
|
std::vector<uint8_t>lb_addr = lower_bound_address.toBytes();
|
||||||
// just use 0 for comparison which should be lower than any real IPv6 address.
|
if (lb_addr.size() != 16) {
|
||||||
std::string lb_address_data = "0";
|
isc_throw(DbOperationError, "getLeases6() - lower bound address is not 16 bytes long");
|
||||||
if (!lower_bound_address.isV6Zero()) {
|
|
||||||
lb_address_data = lower_bound_address.toText();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind lower bound address
|
unsigned long lb_addr_length = 16;
|
||||||
unsigned long lb_address_data_size = lb_address_data.size();
|
inbind[0].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
inbind[0].buffer_type = MYSQL_TYPE_STRING;
|
inbind[0].buffer = reinterpret_cast<char*>(&lb_addr[0]);
|
||||||
inbind[0].buffer = const_cast<char*>(lb_address_data.c_str());
|
inbind[0].buffer_length = 16;
|
||||||
inbind[0].buffer_length = lb_address_data_size;
|
inbind[0].length = &lb_addr_length;
|
||||||
inbind[0].length = &lb_address_data_size;
|
|
||||||
|
|
||||||
// Bind page size value
|
// Bind page size value
|
||||||
uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
|
uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
|
||||||
@@ -3309,14 +3262,16 @@ MySqlLeaseMgr::updateLease6(const Lease6Ptr& lease) {
|
|||||||
MYSQL_BIND inbind[2];
|
MYSQL_BIND inbind[2];
|
||||||
memset(inbind, 0, sizeof(inbind));
|
memset(inbind, 0, sizeof(inbind));
|
||||||
|
|
||||||
std::string addr6 = lease->addr_.toText();
|
// Bind the where clause address parameter.
|
||||||
unsigned long addr6_length = addr6.size();
|
std::vector<uint8_t>addr6 = lease->addr_.toBytes();
|
||||||
|
if (addr6.size() != 16) {
|
||||||
|
isc_throw(DbOperationError, "updateLease6() - address is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
// See the earlier description of the use of "const_cast" when accessing
|
unsigned long addr6_length = 16;
|
||||||
// the address for an explanation of the reason.
|
inbind[0].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
inbind[0].buffer_type = MYSQL_TYPE_STRING;
|
inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
|
||||||
inbind[0].buffer = const_cast<char*>(addr6.c_str());
|
inbind[0].buffer_length = 16;
|
||||||
inbind[0].buffer_length = addr6_length;
|
|
||||||
inbind[0].length = &addr6_length;
|
inbind[0].length = &addr6_length;
|
||||||
|
|
||||||
bind.push_back(inbind[0]);
|
bind.push_back(inbind[0]);
|
||||||
@@ -3435,14 +3390,16 @@ MySqlLeaseMgr::deleteLease(const Lease6Ptr& lease) {
|
|||||||
MYSQL_BIND inbind[2];
|
MYSQL_BIND inbind[2];
|
||||||
memset(inbind, 0, sizeof(inbind));
|
memset(inbind, 0, sizeof(inbind));
|
||||||
|
|
||||||
std::string addr6 = addr.toText();
|
// Bind the where clause address parameter.
|
||||||
unsigned long addr6_length = addr6.size();
|
std::vector<uint8_t>addr6 = addr.toBytes();
|
||||||
|
if (addr6.size() != 16) {
|
||||||
|
isc_throw(DbOperationError, "deleteLease6() - address is not 16 bytes long");
|
||||||
|
}
|
||||||
|
|
||||||
// See the earlier description of the use of "const_cast" when accessing
|
unsigned long addr6_length = 16;
|
||||||
// the address for an explanation of the reason.
|
inbind[0].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
inbind[0].buffer_type = MYSQL_TYPE_STRING;
|
inbind[0].buffer = reinterpret_cast<char*>(&addr6[0]);
|
||||||
inbind[0].buffer = const_cast<char*>(addr6.c_str());
|
inbind[0].buffer_length = 16;
|
||||||
inbind[0].buffer_length = addr6_length;
|
|
||||||
inbind[0].length = &addr6_length;
|
inbind[0].length = &addr6_length;
|
||||||
|
|
||||||
// See the expire code of createBindForSend for the
|
// See the expire code of createBindForSend for the
|
||||||
@@ -4266,86 +4223,6 @@ MySqlLeaseMgr::getLeases6ByLink(const IOAddress& link_addr,
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
|
||||||
MySqlLeaseMgr::upgradeBinaryAddress6(const LeasePageSize& page_size) {
|
|
||||||
auto check = CfgMgr::instance().getCurrentCfg()->
|
|
||||||
getConsistency()->getExtendedInfoSanityCheck();
|
|
||||||
|
|
||||||
size_t pages = 0;
|
|
||||||
size_t updated = 0;
|
|
||||||
IOAddress start_addr = IOAddress::IPV6_ZERO_ADDRESS();
|
|
||||||
for (;;) {
|
|
||||||
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
|
|
||||||
DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_PAGE)
|
|
||||||
.arg(pages)
|
|
||||||
.arg(start_addr.toText())
|
|
||||||
.arg(updated);
|
|
||||||
|
|
||||||
// Prepare WHERE clause.
|
|
||||||
MYSQL_BIND inbind[2];
|
|
||||||
memset(inbind, 0, sizeof(inbind));
|
|
||||||
|
|
||||||
// Bind start address.
|
|
||||||
std::string start_addr_str = "0";
|
|
||||||
if (!start_addr.isV6Zero()) {
|
|
||||||
start_addr_str = start_addr.toText();
|
|
||||||
}
|
|
||||||
unsigned long start_addr_size = start_addr_str.size();
|
|
||||||
inbind[0].buffer_type = MYSQL_TYPE_STRING;
|
|
||||||
inbind[0].buffer = const_cast<char*>(start_addr_str.c_str());
|
|
||||||
inbind[0].buffer_length = start_addr_size;
|
|
||||||
inbind[0].length = &start_addr_size;
|
|
||||||
|
|
||||||
// Bind page size value.
|
|
||||||
uint32_t ps = static_cast<uint32_t>(page_size.page_size_);
|
|
||||||
inbind[1].buffer_type = MYSQL_TYPE_LONG;
|
|
||||||
inbind[1].buffer = reinterpret_cast<char*>(&ps);
|
|
||||||
inbind[1].is_unsigned = MLM_TRUE;
|
|
||||||
|
|
||||||
Lease6Collection leases;
|
|
||||||
|
|
||||||
// Get a context.
|
|
||||||
{
|
|
||||||
MySqlLeaseContextAlloc get_context(*this);
|
|
||||||
MySqlLeaseContextPtr ctx = get_context.ctx_;
|
|
||||||
|
|
||||||
getLeaseCollection(ctx, GET_LEASE6_BINADDR_PAGE, inbind, leases);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leases.empty()) {
|
|
||||||
// Done.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
++pages;
|
|
||||||
start_addr = leases.back()->addr_;
|
|
||||||
for (auto lease : leases) {
|
|
||||||
try {
|
|
||||||
// Update to the same lease will fill the new column i.e.
|
|
||||||
// refresh does the job...
|
|
||||||
updateLease6(lease);
|
|
||||||
++updated;
|
|
||||||
} catch (const NoSuchLease&) {
|
|
||||||
// The lease was modified in parallel:
|
|
||||||
// as its extended info was processed just ignore.
|
|
||||||
continue;
|
|
||||||
} catch (const std::exception& ex) {
|
|
||||||
// Something when wrong, for instance extract failed.
|
|
||||||
LOG_ERROR(dhcpsrv_logger,
|
|
||||||
DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6_ERROR)
|
|
||||||
.arg(lease->addr_.toText())
|
|
||||||
.arg(ex.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG_INFO(dhcpsrv_logger, DHCPSRV_MYSQL_UPGRADE_BINARY_ADDRESS6)
|
|
||||||
.arg(pages)
|
|
||||||
.arg(updated);
|
|
||||||
|
|
||||||
return (updated);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
MySqlLeaseMgr::buildExtendedInfoTables6(bool /* update */, bool /* current */) {
|
MySqlLeaseMgr::buildExtendedInfoTables6(bool /* update */, bool /* current */) {
|
||||||
isc_throw(isc::NotImplemented,
|
isc_throw(isc::NotImplemented,
|
||||||
|
@@ -746,7 +746,6 @@ public:
|
|||||||
GET_LEASE6_DUID_IAID_SUBID, // Get lease6 by DUID, IAID and subnet ID
|
GET_LEASE6_DUID_IAID_SUBID, // Get lease6 by DUID, IAID and subnet ID
|
||||||
GET_LEASE6_PAGE, // Get page of leases beginning with an address
|
GET_LEASE6_PAGE, // Get page of leases beginning with an address
|
||||||
GET_LEASE6_UCTX_PAGE, // Get page of leases with user context
|
GET_LEASE6_UCTX_PAGE, // Get page of leases with user context
|
||||||
GET_LEASE6_BINADDR_PAGE, // Get page of leases with null binary address
|
|
||||||
GET_LEASE6_SUBID, // Get IPv6 leases by subnet ID
|
GET_LEASE6_SUBID, // Get IPv6 leases by subnet ID
|
||||||
GET_LEASE6_DUID, // Get IPv6 leases by DUID
|
GET_LEASE6_DUID, // Get IPv6 leases by DUID
|
||||||
GET_LEASE6_HOSTNAME, // Get IPv6 leases by hostname
|
GET_LEASE6_HOSTNAME, // Get IPv6 leases by hostname
|
||||||
@@ -1164,17 +1163,6 @@ private:
|
|||||||
/// @return The number of updates in the database.
|
/// @return The number of updates in the database.
|
||||||
virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) override;
|
virtual size_t upgradeExtendedInfo4(const LeasePageSize& page_size) override;
|
||||||
|
|
||||||
/// @brief Upgrade binary address (v6).
|
|
||||||
///
|
|
||||||
/// On SQL backends for all leases with null binary address set this
|
|
||||||
/// new column. Memfile uses IOAddress objects so does not need it.
|
|
||||||
/// This function implements the new BLQ hook command named
|
|
||||||
/// "binary-address6-upgrade".
|
|
||||||
///
|
|
||||||
/// @param page_size The page size used for retrieval.
|
|
||||||
/// @return The number of updates in the database.
|
|
||||||
virtual size_t upgradeBinaryAddress6(const LeasePageSize& page_size) override;
|
|
||||||
|
|
||||||
/// @brief Build extended info v6 tables.
|
/// @brief Build extended info v6 tables.
|
||||||
///
|
///
|
||||||
/// @param update Update extended info in database.
|
/// @param update Update extended info in database.
|
||||||
|
@@ -331,7 +331,6 @@ MySqlConnection::getVersion(const ParameterMap& parameters) {
|
|||||||
|
|
||||||
// Discard the statement and its resources
|
// Discard the statement and its resources
|
||||||
mysql_stmt_close(stmt);
|
mysql_stmt_close(stmt);
|
||||||
|
|
||||||
return (std::make_pair(version, minor));
|
return (std::make_pair(version, minor));
|
||||||
|
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
|
@@ -52,7 +52,7 @@ const int MLM_MYSQL_FETCH_FAILURE = 0;
|
|||||||
|
|
||||||
/// @name Current database schema version values.
|
/// @name Current database schema version values.
|
||||||
//@{
|
//@{
|
||||||
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 18;
|
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 19;
|
||||||
const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0;
|
const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0;
|
||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
api_files += $(top_srcdir)/src/share/api/binary-address6-upgrade.json
|
|
||||||
api_files += $(top_srcdir)/src/share/api/build-report.json
|
api_files += $(top_srcdir)/src/share/api/build-report.json
|
||||||
api_files += $(top_srcdir)/src/share/api/cache-clear.json
|
api_files += $(top_srcdir)/src/share/api/cache-clear.json
|
||||||
api_files += $(top_srcdir)/src/share/api/cache-flush.json
|
api_files += $(top_srcdir)/src/share/api/cache-flush.json
|
||||||
|
@@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"access": "write",
|
|
||||||
"avail": "2.3.8",
|
|
||||||
"brief": [
|
|
||||||
"This command fills the binary address column for all IPv6 leases where it is NULL in the SQL lease database."
|
|
||||||
],
|
|
||||||
"cmd-syntax": [
|
|
||||||
"{",
|
|
||||||
" \"command\": \"binary-address6-upgrade\"",
|
|
||||||
" }",
|
|
||||||
"}"
|
|
||||||
],
|
|
||||||
"description": "See <xref linkend=\"command-binary-address6-upgrade\"/>",
|
|
||||||
"hook": "lease_query",
|
|
||||||
"name": "binary-address6-upgrade",
|
|
||||||
"resp-comment": [
|
|
||||||
"This command should be used when some old IPv6 leases are present in the lease database using a SQL backend."
|
|
||||||
],
|
|
||||||
"resp-syntax": [
|
|
||||||
"{",
|
|
||||||
" \"arguments\": {",
|
|
||||||
" },",
|
|
||||||
" \"result\": 0,",
|
|
||||||
" \"text\": \"to be done\"",
|
|
||||||
"}"
|
|
||||||
],
|
|
||||||
"support": [
|
|
||||||
"kea-dhcp6"
|
|
||||||
]
|
|
||||||
}
|
|
1
src/share/database/scripts/mysql/.gitignore
vendored
1
src/share/database/scripts/mysql/.gitignore
vendored
@@ -26,4 +26,5 @@
|
|||||||
/upgrade_015_to_016.sh
|
/upgrade_015_to_016.sh
|
||||||
/upgrade_016_to_017.sh
|
/upgrade_016_to_017.sh
|
||||||
/upgrade_017_to_018.sh
|
/upgrade_017_to_018.sh
|
||||||
|
/upgrade_018_to_019.sh
|
||||||
/wipe_data.sh
|
/wipe_data.sh
|
||||||
|
@@ -37,6 +37,7 @@ mysql_SCRIPTS += upgrade_014_to_015.sh
|
|||||||
mysql_SCRIPTS += upgrade_015_to_016.sh
|
mysql_SCRIPTS += upgrade_015_to_016.sh
|
||||||
mysql_SCRIPTS += upgrade_016_to_017.sh
|
mysql_SCRIPTS += upgrade_016_to_017.sh
|
||||||
mysql_SCRIPTS += upgrade_017_to_018.sh
|
mysql_SCRIPTS += upgrade_017_to_018.sh
|
||||||
|
mysql_SCRIPTS += upgrade_018_to_019.sh
|
||||||
mysql_SCRIPTS += wipe_data.sh
|
mysql_SCRIPTS += wipe_data.sh
|
||||||
|
|
||||||
DISTCLEANFILES = ${mysql_SCRIPTS}
|
DISTCLEANFILES = ${mysql_SCRIPTS}
|
||||||
|
@@ -5677,6 +5677,120 @@ UPDATE schema_version
|
|||||||
|
|
||||||
-- This line concludes the schema upgrade to version 18.0.
|
-- This line concludes the schema upgrade to version 18.0.
|
||||||
|
|
||||||
|
-- This line starts the schema upgrade to version 19.0.
|
||||||
|
-- Drop binaddr column and index.
|
||||||
|
DROP INDEX lease6_by_binaddr ON lease6;
|
||||||
|
ALTER TABLE lease6
|
||||||
|
DROP COLUMN binaddr;
|
||||||
|
|
||||||
|
-- Change data type of lease6.address column.
|
||||||
|
ALTER TABLE lease6 MODIFY COLUMN address BINARY(16);
|
||||||
|
|
||||||
|
-- Change data type of ipv6_reservations.address column.
|
||||||
|
ALTER TABLE ipv6_reservations MODIFY COLUMN address BINARY(16);
|
||||||
|
|
||||||
|
-- Convert binary lease6 address to text
|
||||||
|
DROP PROCEDURE IF EXISTS lease6DumpData;
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE PROCEDURE lease6DumpData()
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
INET6_NTOA(address),
|
||||||
|
IFNULL(colonSeparatedHex(HEX(duid)), ''),
|
||||||
|
valid_lifetime,
|
||||||
|
UNIX_TIMESTAMP(expire),
|
||||||
|
subnet_id,
|
||||||
|
pref_lifetime,
|
||||||
|
lease_type,
|
||||||
|
iaid,
|
||||||
|
prefix_len,
|
||||||
|
fqdn_fwd,
|
||||||
|
fqdn_rev,
|
||||||
|
REPLACE(hostname, ',', ','),
|
||||||
|
IFNULL(colonSeparatedHex(HEX(hwaddr)), ''),
|
||||||
|
state,
|
||||||
|
REPLACE(IFNULL(user_context, ''), ',', ','),
|
||||||
|
hwtype,
|
||||||
|
hwaddr_source,
|
||||||
|
pool_id
|
||||||
|
FROM lease6
|
||||||
|
ORDER BY address;
|
||||||
|
END $$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
-- Drop and create lease6Upload stored procedure with conversion to
|
||||||
|
-- address to binary
|
||||||
|
DROP PROCEDURE IF EXISTS lease6Upload;
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE PROCEDURE lease6Upload(
|
||||||
|
IN address VARCHAR(39),
|
||||||
|
IN duid VARCHAR(130),
|
||||||
|
IN valid_lifetime INT UNSIGNED,
|
||||||
|
IN expire BIGINT UNSIGNED,
|
||||||
|
IN subnet_id INT UNSIGNED,
|
||||||
|
IN pref_lifetime INT UNSIGNED,
|
||||||
|
IN lease_type TINYINT,
|
||||||
|
IN iaid INT UNSIGNED,
|
||||||
|
IN prefix_len TINYINT UNSIGNED,
|
||||||
|
IN fqdn_fwd TINYINT,
|
||||||
|
IN fqdn_rev TINYINT,
|
||||||
|
IN hostname VARCHAR(255),
|
||||||
|
IN hwaddr VARCHAR(64),
|
||||||
|
IN state INT UNSIGNED,
|
||||||
|
IN user_context TEXT,
|
||||||
|
IN hwtype SMALLINT,
|
||||||
|
IN hwaddr_source INT UNSIGNED,
|
||||||
|
IN pool_id INT UNSIGNED
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO lease6 (
|
||||||
|
address,
|
||||||
|
duid,
|
||||||
|
valid_lifetime,
|
||||||
|
expire,
|
||||||
|
subnet_id,
|
||||||
|
pref_lifetime,
|
||||||
|
lease_type,
|
||||||
|
iaid,
|
||||||
|
prefix_len,
|
||||||
|
fqdn_fwd,
|
||||||
|
fqdn_rev,
|
||||||
|
hostname,
|
||||||
|
hwaddr,
|
||||||
|
state,
|
||||||
|
user_context,
|
||||||
|
hwtype,
|
||||||
|
hwaddr_source,
|
||||||
|
pool_id
|
||||||
|
) VALUES (
|
||||||
|
INET6_ATON(address),
|
||||||
|
UNHEX(REPLACE(duid, ':', '')),
|
||||||
|
valid_lifetime,
|
||||||
|
FROM_UNIXTIME(expire),
|
||||||
|
subnet_id,
|
||||||
|
pref_lifetime,
|
||||||
|
lease_type,
|
||||||
|
iaid,
|
||||||
|
prefix_len,
|
||||||
|
fqdn_fwd,
|
||||||
|
fqdn_rev,
|
||||||
|
REPLACE(hostname, ',', ','),
|
||||||
|
UNHEX(REPLACE(hwaddr, ':', '')),
|
||||||
|
state,
|
||||||
|
REPLACE(user_context, ',', ','),
|
||||||
|
hwtype,
|
||||||
|
hwaddr_source,
|
||||||
|
pool_id
|
||||||
|
);
|
||||||
|
END $$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
-- Update the schema version number.
|
||||||
|
UPDATE schema_version
|
||||||
|
SET version = '19', minor = '0';
|
||||||
|
|
||||||
|
-- This line concludes the schema upgrade to version 19.0.
|
||||||
|
|
||||||
# Notes:
|
# Notes:
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
|
168
src/share/database/scripts/mysql/upgrade_018_to_019.sh.in
Normal file
168
src/share/database/scripts/mysql/upgrade_018_to_019.sh.in
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Copyright (C) 2023 Internet Systems Consortium, Inc. ("ISC")
|
||||||
|
#
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
# SC1091: Not following: ... was not specified as input (see shellcheck -x).
|
||||||
|
|
||||||
|
# Exit with error if commands exit with non-zero and if undefined variables are
|
||||||
|
# used.
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
# SC2034: ... appears unused. Verify use (or export if used externally).
|
||||||
|
prefix="@prefix@"
|
||||||
|
|
||||||
|
# Include utilities. Use installed version if available and
|
||||||
|
# use build version if it isn't.
|
||||||
|
if test -f "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh"; then
|
||||||
|
. "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh"
|
||||||
|
else
|
||||||
|
. "@abs_top_builddir@/src/bin/admin/admin-utils.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check version.
|
||||||
|
version=$(mysql_version "${@}")
|
||||||
|
if test "${version}" != "18.0"; then
|
||||||
|
printf 'This script upgrades 18.0 to 19.0. '
|
||||||
|
printf 'Reported version is %s. Skipping upgrade.\n' "${version}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get the schema name from database argument. We need this to
|
||||||
|
# query information_schema for the right database.
|
||||||
|
for arg in "${@}"
|
||||||
|
do
|
||||||
|
if ! printf '%s' "${arg}" | grep -Eq -- '^--'
|
||||||
|
then
|
||||||
|
schema="$arg"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Make sure we have the schema.
|
||||||
|
if [ -z "$schema" ]
|
||||||
|
then
|
||||||
|
printf "Could not find database schema name in cmd line args: %s\n" "${*}"
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
|
||||||
|
mysql "$@" <<EOF
|
||||||
|
-- This line starts the schema upgrade to version 19.0.
|
||||||
|
-- Drop binaddr column and index.
|
||||||
|
DROP INDEX lease6_by_binaddr ON lease6;
|
||||||
|
ALTER TABLE lease6
|
||||||
|
DROP COLUMN binaddr;
|
||||||
|
|
||||||
|
-- Change data type of lease6.address column.
|
||||||
|
ALTER TABLE lease6 MODIFY COLUMN address BINARY(16);
|
||||||
|
|
||||||
|
-- Change data type of ipv6_reservations.address column.
|
||||||
|
ALTER TABLE ipv6_reservations MODIFY COLUMN address BINARY(16);
|
||||||
|
|
||||||
|
-- Convert binary lease6 address to text
|
||||||
|
DROP PROCEDURE IF EXISTS lease6DumpData;
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE PROCEDURE lease6DumpData()
|
||||||
|
BEGIN
|
||||||
|
SELECT
|
||||||
|
INET6_NTOA(address),
|
||||||
|
IFNULL(colonSeparatedHex(HEX(duid)), ''),
|
||||||
|
valid_lifetime,
|
||||||
|
UNIX_TIMESTAMP(expire),
|
||||||
|
subnet_id,
|
||||||
|
pref_lifetime,
|
||||||
|
lease_type,
|
||||||
|
iaid,
|
||||||
|
prefix_len,
|
||||||
|
fqdn_fwd,
|
||||||
|
fqdn_rev,
|
||||||
|
REPLACE(hostname, ',', ','),
|
||||||
|
IFNULL(colonSeparatedHex(HEX(hwaddr)), ''),
|
||||||
|
state,
|
||||||
|
REPLACE(IFNULL(user_context, ''), ',', ','),
|
||||||
|
hwtype,
|
||||||
|
hwaddr_source,
|
||||||
|
pool_id
|
||||||
|
FROM lease6
|
||||||
|
ORDER BY address;
|
||||||
|
END $$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
-- Drop and create lease6Upload stored procedure with conversion to
|
||||||
|
-- address to binary
|
||||||
|
DROP PROCEDURE IF EXISTS lease6Upload;
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE PROCEDURE lease6Upload(
|
||||||
|
IN address VARCHAR(39),
|
||||||
|
IN duid VARCHAR(130),
|
||||||
|
IN valid_lifetime INT UNSIGNED,
|
||||||
|
IN expire BIGINT UNSIGNED,
|
||||||
|
IN subnet_id INT UNSIGNED,
|
||||||
|
IN pref_lifetime INT UNSIGNED,
|
||||||
|
IN lease_type TINYINT,
|
||||||
|
IN iaid INT UNSIGNED,
|
||||||
|
IN prefix_len TINYINT UNSIGNED,
|
||||||
|
IN fqdn_fwd TINYINT,
|
||||||
|
IN fqdn_rev TINYINT,
|
||||||
|
IN hostname VARCHAR(255),
|
||||||
|
IN hwaddr VARCHAR(64),
|
||||||
|
IN state INT UNSIGNED,
|
||||||
|
IN user_context TEXT,
|
||||||
|
IN hwtype SMALLINT,
|
||||||
|
IN hwaddr_source INT UNSIGNED,
|
||||||
|
IN pool_id INT UNSIGNED
|
||||||
|
)
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO lease6 (
|
||||||
|
address,
|
||||||
|
duid,
|
||||||
|
valid_lifetime,
|
||||||
|
expire,
|
||||||
|
subnet_id,
|
||||||
|
pref_lifetime,
|
||||||
|
lease_type,
|
||||||
|
iaid,
|
||||||
|
prefix_len,
|
||||||
|
fqdn_fwd,
|
||||||
|
fqdn_rev,
|
||||||
|
hostname,
|
||||||
|
hwaddr,
|
||||||
|
state,
|
||||||
|
user_context,
|
||||||
|
hwtype,
|
||||||
|
hwaddr_source,
|
||||||
|
pool_id
|
||||||
|
) VALUES (
|
||||||
|
INET6_ATON(address),
|
||||||
|
UNHEX(REPLACE(duid, ':', '')),
|
||||||
|
valid_lifetime,
|
||||||
|
FROM_UNIXTIME(expire),
|
||||||
|
subnet_id,
|
||||||
|
pref_lifetime,
|
||||||
|
lease_type,
|
||||||
|
iaid,
|
||||||
|
prefix_len,
|
||||||
|
fqdn_fwd,
|
||||||
|
fqdn_rev,
|
||||||
|
REPLACE(hostname, ',', ','),
|
||||||
|
UNHEX(REPLACE(hwaddr, ':', '')),
|
||||||
|
state,
|
||||||
|
REPLACE(user_context, ',', ','),
|
||||||
|
hwtype,
|
||||||
|
hwaddr_source,
|
||||||
|
pool_id
|
||||||
|
);
|
||||||
|
END $$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
-- Update the schema version number.
|
||||||
|
UPDATE schema_version
|
||||||
|
SET version = '19', minor = '0';
|
||||||
|
|
||||||
|
-- This line concludes the schema upgrade to version 19.0.
|
||||||
|
EOF
|
Reference in New Issue
Block a user