Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ipv4 addr plus port #63

Open
wants to merge 56 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
233950b
added address plus port
Feb 1, 2018
43f201b
fixed merge
Feb 1, 2018
a238b7c
add static casts
Feb 1, 2018
67483dc
minor changes
Feb 1, 2018
0868823
minor changes
Feb 1, 2018
6012b29
fixed unit tests
Feb 2, 2018
62ce579
updated unit tests
Feb 2, 2018
26e8bf4
removed unsupported options
Feb 3, 2018
a875ea1
updated cql schema and added minor changes (including spelling mistak…
Feb 7, 2018
f804d7e
minor chnages
Feb 9, 2018
7ecf8fb
Merge remote-tracking branch 'isc-kea/master' into cql_clean_code
Feb 15, 2018
01d56b8
Merge remote-tracking branch 'isc-kea/master' into cql_clean_code
Feb 15, 2018
098865d
Merge remote-tracking branch 'isc-kea/master' into HEAD
Feb 15, 2018
10e19f3
Merge branch 'cql_clean_code' of https://github.com/razvan-becheriu/k…
Feb 15, 2018
e2317a1
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
Feb 19, 2018
448cf73
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
Feb 28, 2018
ae60f3f
Merge remote-tracking branch 'isc-kea/master' into cql_clean_code
Feb 28, 2018
14c3a55
minor changes - fixed eventual memory leak
Mar 1, 2018
45464c5
minor changes
Mar 1, 2018
16c80de
minor changes
Mar 1, 2018
5637d01
minor changes
Mar 1, 2018
4637a23
refactored cql recount leases plus minor changes
Mar 1, 2018
d3f8281
minor changes
Mar 1, 2018
b2d80eb
minor changes
Mar 1, 2018
ffc8c78
Merge remote-tracking branch 'isc-kea/master' into cassandra_improvem…
Mar 2, 2018
afddd8a
Merge remote-tracking branch 'isc-kea/master' into cql_clean_code
Mar 7, 2018
d32a318
Merge remote-tracking branch 'isc-kea/master' into cassandra_improvem…
Mar 7, 2018
c3e4fe2
enabled tests for cql
Mar 7, 2018
e728823
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
Mar 7, 2018
8b1f21a
src/lib/dhcpsrv/tests/generic_host_data_source_unittest.cc
Mar 7, 2018
55a57d4
enabled tests for cql
Mar 7, 2018
38b5430
fixed unit tests
Mar 7, 2018
400abf1
fixed merge
Mar 13, 2018
33e4b4f
Merge remote-tracking branch 'isc-kea/master' into cassandra_improvem…
Mar 13, 2018
42d8ad3
minor changes
Mar 13, 2018
1b6df23
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
Mar 13, 2018
39bc0b7
fixed merge
Mar 13, 2018
61f9562
Merge branch 'cql_clean_code' into ipv4_addr_plus_port
Mar 13, 2018
b65cd1f
fixed merge
Mar 13, 2018
a1ab751
fixed comments
Mar 13, 2018
387ffa4
minor changes
Mar 13, 2018
746acc8
minor changes
Mar 13, 2018
78f3ad6
Merge branch 'cassandra_improvements' into cql_clean_code
Mar 13, 2018
38a837f
minor changes
Mar 14, 2018
9ed1f3d
minor changes
Mar 14, 2018
d61a05b
minor changes
Mar 14, 2018
cc59e9a
minor changes
Mar 14, 2018
365e64f
minor changes
Mar 14, 2018
85e88a2
Merge remote-tracking branch 'isc-kea/master' into cql_clean_code
Mar 15, 2018
594bd9e
Merge branch 'cql_clean_code' into ipv4_addr_plus_port
Mar 15, 2018
053d2f3
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
Mar 19, 2018
aac7d46
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
May 24, 2018
8670f46
minor changes
May 24, 2018
552f467
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
Jun 5, 2018
3d23cef
minor changes
Jun 14, 2018
0872bf5
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
Jun 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'isc-kea/master' into ipv4_addr_plus_port
  • Loading branch information
Razvan Becheriu committed Mar 13, 2018
commit 1b6df23627ddf08c6ddfa23618beea8ba43c711b
7 changes: 5 additions & 2 deletions src/bin/dhcp4/dhcp4_parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ using namespace std;
CONTACT_POINTS "contact-points"
KEYSPACE "keyspace"
MAX_RECONNECT_TRIES "max-reconnect-tries"
RECONNECT_WAIT_TIME "reconnect-wait-time"

VALID_LIFETIME "valid-lifetime"
RENEW_TIMER "renew-timer"
Expand Down Expand Up @@ -596,7 +595,6 @@ database_map_param: database_type
| tcp_keepalive
| contact_points
| max_reconnect_tries
| reconnect_wait_time
| keyspace
| unknown_map_entry
;
Expand Down Expand Up @@ -707,6 +705,11 @@ keyspace: KEYSPACE {
ctx.leave();
};

max_reconnect_tries: MAX_RECONNECT_TRIES COLON INTEGER {
ElementPtr n(new IntElement($3, ctx.loc2pos(@3)));
ctx.stack_.back()->set("max-reconnect-tries", n);
};

host_reservation_identifiers: HOST_RESERVATION_IDENTIFIERS {
ElementPtr l(new ListElement(ctx.loc2pos(@1)));
ctx.stack_.back()->set("host-reservation-identifiers", l);
Expand Down
1 change: 0 additions & 1 deletion src/bin/dhcp6/dhcp6_parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ database_map_param: database_type
| tcp_keepalive
| contact_points
| max_reconnect_tries
| reconnect_wait_time
| keyspace
| unknown_map_entry
;
Expand Down
111 changes: 50 additions & 61 deletions src/lib/dhcpsrv/mysql_lease_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -663,36 +663,29 @@ class MySqlLease4Exchange : public MySqlLeaseExchange {
// Note: All array lengths are equal to the corresponding variable in the
// schema.
// Note: Arrays are declared fixed length for speed of creation
uint64_t addr4_; ///< IPv4 address plus port
MYSQL_BIND bind_[LEASE_COLUMNS]; ///< Bind array
std::string columns_[LEASE_COLUMNS]; ///< Column names
my_bool error_[LEASE_COLUMNS]; ///< Error array
std::vector<uint8_t> hwaddr_; ///< Hardware address
uint8_t hwaddr_buffer_[HWAddr::MAX_HWADDR_LEN];
///< Hardware address buffer
unsigned long hwaddr_length_; ///< Hardware address length
std::vector<uint8_t> client_id_; ///< Client identification
uint8_t client_id_buffer_[ClientId::MAX_CLIENT_ID_LEN];
///< Client ID buffer
unsigned long client_id_length_; ///< Client ID address length
my_bool client_id_null_; ///< Is Client ID null?

MYSQL_TIME expire_; ///< Lease expiry time
Lease4Ptr lease_; ///< Pointer to lease object
uint32_t subnet_id_; ///< Subnet identification
uint32_t valid_lifetime_; ///< Lease time

my_bool fqdn_fwd_; ///< Has forward DNS update been
///< performed
my_bool fqdn_rev_; ///< Has reverse DNS update been
///< performed
char hostname_buffer_[HOSTNAME_MAX_LEN];
///< Client hostname
unsigned long hostname_length_; ///< Client hostname length
uint32_t state_; ///< Lease state
uint64_t addr4_; ///< IPv4 address plus port
MYSQL_BIND bind_[LEASE_COLUMNS]; ///< Bind array
std::string columns_[LEASE_COLUMNS]; ///< Column names
my_bool error_[LEASE_COLUMNS]; ///< Error array
std::vector<uint8_t> hwaddr_; ///< Hardware address
uint8_t hwaddr_buffer_[HWAddr::MAX_HWADDR_LEN]; ///< Hardware address buffer
unsigned long hwaddr_length_; ///< Hardware address length
my_bool hwaddr_null_; ///< Used when HWAddr is null
std::vector<uint8_t> client_id_; ///< Client identification
uint8_t client_id_buffer_[ClientId::MAX_CLIENT_ID_LEN]; ///< Client ID buffer
unsigned long client_id_length_; ///< Client ID address length
my_bool client_id_null_; ///< Is Client ID null?
MYSQL_TIME expire_; ///< Lease expiry time
Lease4Ptr lease_; ///< Pointer to lease object
uint32_t subnet_id_; ///< Subnet identification
uint32_t valid_lifetime_; ///< Lease time
my_bool fqdn_fwd_; ///< Has forward DNS update been performed
my_bool fqdn_rev_; ///< Has reverse DNS update been performed
char hostname_buffer_[HOSTNAME_MAX_LEN]; ///< Client hostname
unsigned long hostname_length_; ///< Client hostname length
uint32_t state_; ///< Lease state
};


/// @brief Exchange MySQL and Lease6 Data
///
/// On any MySQL operation, arrays of MYSQL_BIND structures must be built to
Expand Down Expand Up @@ -1212,39 +1205,35 @@ class MySqlLease6Exchange : public MySqlLeaseExchange {
// Note: All array lengths are equal to the corresponding variable in the
// schema.
// Note: arrays are declared fixed length for speed of creation
std::string addr6_; ///< String form of address
char addr6_buffer_[ADDRESS6_TEXT_MAX_LEN + 1]; ///< Character
///< array form of V6 address
unsigned long addr6_length_; ///< Length of the address
MYSQL_BIND bind_[LEASE_COLUMNS]; ///< Bind array
std::string columns_[LEASE_COLUMNS]; ///< Column names
std::vector<uint8_t> duid_; ///< Client identification
uint8_t duid_buffer_[DUID::MAX_DUID_LEN]; ///< Buffer form of DUID
unsigned long duid_length_; ///< Length of the DUID
my_bool error_[LEASE_COLUMNS]; ///< Error indicators
MYSQL_TIME expire_; ///< Lease expiry time
uint32_t iaid_; ///< Identity association ID
Lease6Ptr lease_; ///< Pointer to lease object
uint8_t lease_type_; ///< Lease type
uint8_t prefixlen_; ///< Prefix length
uint32_t pref_lifetime_; ///< Preferred lifetime
uint32_t subnet_id_; ///< Subnet identification
uint32_t valid_lifetime_; ///< Lease time
my_bool fqdn_fwd_; ///< Has forward DNS update been
///< performed
my_bool fqdn_rev_; ///< Has reverse DNS update been
///< performed
char hostname_buffer_[HOSTNAME_MAX_LEN];
///< Client hostname
unsigned long hostname_length_; ///< Client hostname length
uint8_t hwaddr_buffer_[HWAddr::MAX_HWADDR_LEN];
///< Buffer for Hardware address
std::vector<uint8_t> hwaddr_; ///< Hardware address (optional)
unsigned long hwaddr_length_; ///< Aux. variable denoting hwaddr_ size()
my_bool hwaddr_null_; ///< Used when HWAddr is null
uint16_t hwtype_; ///< Hardware type
uint32_t hwaddr_source_; ///< Source of the hardware address
uint32_t state_; ///< Lease state.
std::string addr6_; ///< String form of address
char addr6_buffer_[ADDRESS6_TEXT_MAX_LEN + 1]; ///< Character
///< array form of V6 address
unsigned long addr6_length_; ///< Length of the address
MYSQL_BIND bind_[LEASE_COLUMNS]; ///< Bind array
std::string columns_[LEASE_COLUMNS]; ///< Column names
std::vector<uint8_t> duid_; ///< Client identification
uint8_t duid_buffer_[DUID::MAX_DUID_LEN]; ///< Buffer form of DUID
unsigned long duid_length_; ///< Length of the DUID
my_bool error_[LEASE_COLUMNS]; ///< Error indicators
MYSQL_TIME expire_; ///< Lease expiry time
uint32_t iaid_; ///< Identity association ID
Lease6Ptr lease_; ///< Pointer to lease object
uint8_t lease_type_; ///< Lease type
uint8_t prefixlen_; ///< Prefix length
uint32_t pref_lifetime_; ///< Preferred lifetime
uint32_t subnet_id_; ///< Subnet identification
uint32_t valid_lifetime_; ///< Lease time
my_bool fqdn_fwd_; ///< Has forward DNS update been performed
my_bool fqdn_rev_; ///< Has reverse DNS update been performed
char hostname_buffer_[HOSTNAME_MAX_LEN]; ///< Client hostname
unsigned long hostname_length_; ///< Client hostname length
uint8_t hwaddr_buffer_[HWAddr::MAX_HWADDR_LEN]; ///< Buffer form of Hardware address
std::vector<uint8_t> hwaddr_; ///< Hardware address (optional)
unsigned long hwaddr_length_; ///< Aux. variable denoting hwaddr_ size()
my_bool hwaddr_null_; ///< Used when HWAddr is null
uint16_t hwtype_; ///< Hardware type
uint32_t hwaddr_source_; ///< Source of the hardware address
uint32_t state_; ///< Lease state.
};

/// @brief MySql derivation of the statistical lease data query
Expand Down
18 changes: 10 additions & 8 deletions src/lib/dhcpsrv/pgsql_lease_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ PgSqlTaggedStatement tagged_statements[] = {
"extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len, "
"fqdn_fwd, fqdn_rev, hostname, "
"hwaddr, hwtype, hwaddr_source, "
"state "
"FROM lease6 "
"WHERE state != $1 AND expire < $2 "
Expand Down Expand Up @@ -202,8 +203,9 @@ PgSqlTaggedStatement tagged_statements[] = {
"INSERT INTO lease6(address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
"hwaddr, hwtype, hwaddr_source, "
"state) "
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)"},
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)"},

// UPDATE_LEASE4
{ 11, { OID_INT8, OID_BYTEA, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
Expand Down Expand Up @@ -462,13 +464,13 @@ class PgSqlLease4Exchange : public PgSqlLeaseExchange {
/// that refer to its contents are in use.
Lease4Ptr lease_;

/// @Brief Lease4 specific members used for binding and conversion.
uint64_t addr4_;
size_t hwaddr_length_;
std::vector<uint8_t> hwaddr_;
uint8_t hwaddr_buffer_[HWAddr::MAX_HWADDR_LEN];
size_t client_id_length_;
uint8_t client_id_buffer_[ClientId::MAX_CLIENT_ID_LEN];
/// @brief Lease4 specific members for binding and conversion.
uint64_t addr4_;
size_t hwaddr_length_;
std::vector<uint8_t> hwaddr_;
uint8_t hwaddr_buffer_[HWAddr::MAX_HWADDR_LEN];
size_t client_id_length_;
uint8_t client_id_buffer_[ClientId::MAX_CLIENT_ID_LEN];
};

/// @brief Supports exchanging IPv6 leases with PostgreSQL.
Expand Down
2 changes: 1 addition & 1 deletion src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MySqlHostDataSourceTest : public GenericHostDataSourceTest {

/// @brief Destructor
///
/// Rolls back all pending transactions. The deletion of myhdsptr_ will close
/// Rolls back all pending transactions. The deletion of hdsptr_ will close
/// the database. Then reopen it and delete everything created by the test.
virtual ~MySqlHostDataSourceTest() {
destroyTest();
Expand Down
5 changes: 2 additions & 3 deletions src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ class PgSqlHostDataSourceTest : public GenericHostDataSourceTest {

/// @brief Destructor
///
/// Rolls back all pending transactions. The deletion of myhdsptr_ will
/// close the database. Then reopen it and delete everything created by
/// the test.
/// Rolls back all pending transactions. The deletion of hdsptr_ will close
/// the database. Then reopen it and delete everything created by the test.
virtual ~PgSqlHostDataSourceTest() {
destroyTest();
}
Expand Down
11 changes: 5 additions & 6 deletions src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ TEST(PgSqlOpenTest, OpenDatabase) {

// Check for invalid timeouts
EXPECT_THROW(LeaseMgrFactory::create(connectionString(
PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER,
VALID_PASSWORD, INVALID_TIMEOUT_1)),
DbInvalidTimeout);
PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER, VALID_PASSWORD, INVALID_TIMEOUT_1)),
DbInvalidTimeout);

EXPECT_THROW(LeaseMgrFactory::create(connectionString(
PGSQL_VALID_TYPE, VALID_NAME, VALID_HOST, VALID_USER,
VALID_PASSWORD, INVALID_TIMEOUT_2)),
Expand Down Expand Up @@ -355,8 +355,7 @@ TEST_F(PgSqlLeaseMgrTest, getLeases4) {

/// @brief Basic Lease4 Checks
///
/// Checks that the addLease, getLease4(by address),
/// getLease4(hwaddr,subnet_id),
/// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
/// updateLease4() and deleteLease can handle NULL client-id.
/// (client-id is optional and may not be present)
TEST_F(PgSqlLeaseMgrTest, lease4NullClientId) {
Expand Down Expand Up @@ -510,7 +509,7 @@ TEST_F(PgSqlLeaseMgrTest, deleteExpiredReclaimedLeases6) {
testDeleteExpiredReclaimedLeases6();
}

// Verifies that IPv4 lease statistics can be recalculated.
/// @brief Verifies that IPv4 lease statistics can be recalculated.
TEST_F(PgSqlLeaseMgrTest, recountLeaseStats4) {
testRecountLeaseStats4();
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.