Opened 3 years ago

Last modified 3 years ago

#5065 new defect

Issues with Cassandra backend found on macOS sierra

Reported by: marcin Owned by:
Priority: medium Milestone: Outstanding Tasks
Component: Unclassified Version: git
Keywords: Cassandra Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: Low
Sub-Project: DHCP Feature Depending on Ticket:
Estimated Difficulty: 0 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

During implementation of #5029 I found the following issues with the current implementation of Cassandra lease database backend:

  • configure.ac should specify location of the libuv, otherwise it won't be found if it is installed in non-standard location
  • local variables should not be used in CQL binding tables. In the diff below I made them static, which works ok, but maybe we want to put them in the class scope? The use of static seems to be ok for me, though.
  • The readlink -f $0 in the cql_config doesn't seem to be portable. Perhaps better to use: "$(cd $(dirname $0); pwd -P)"

The following is a diff I used to build Kea with Cassandra support and run unit tests on macOS Sierra:

diff --git a/configure.ac b/configure.ac
index ead7e9f..5b36970 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1061,7 +1061,7 @@ if test "$CQL_CONFIG" != "" ; then
 
     CQL_INCLUDEDIR=`$CQL_CONFIG --includedir`
     CQL_CPPFLAGS="`$CQL_CONFIG --cppflags` -I$CQL_INCLUDEDIR"
-    CQL_LIBS="-L`$CQL_CONFIG --libdir` -lcassandra_static -luv"
+    CQL_LIBS="-L`$CQL_CONFIG --libdir` -L$LIBUV_ROOT_DIR/lib -lcassandra_static -luv"
     CQL_VERSION=`$CQL_CONFIG --version`
 
     AC_SUBST(CQL_CPPFLAGS)
@@ -1278,7 +1278,7 @@ AC_SUBST(GTEST_SOURCE)
 if test $enable_gtest != "no"; then
    AC_MSG_CHECKING([if Google Test is compatible with the compiler])
    CPPFLAGS_SAVED=$CPPFLAGS
-   CPPFLAGS="$CPPFLAGS $GTEST_INCLUDES"
+   CPPFLAGS="$CPPFLAGS $BOOST_INCLUDES $GTEST_INCLUDES"
    AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
            [#include <boost/shared_ptr.hpp>
diff --git a/src/lib/dhcpsrv/cql_lease_mgr.cc b/src/lib/dhcpsrv/cql_lease_mgr.cc
index f7486c6..e6a6606 100644
--- a/src/lib/dhcpsrv/cql_lease_mgr.cc
+++ b/src/lib/dhcpsrv/cql_lease_mgr.cc
@@ -1239,12 +1239,13 @@ CqlLeaseMgr::addLeaseCommon(StatementIndex stindex,
     CassIterator* rows = cass_iterator_from_result(resultCollection);
     CqlDataArray appliedData;
     CqlDataArray appliedSize;
-    bool applied = false;
+    static bool applied = false;
     while (cass_iterator_next(rows)) {
         const CassRow* row = cass_iterator_get_row(rows);
         // [applied]: bool
         appliedData.add(reinterpret_cast<void*>(&applied));
         appliedSize.add(NULL);
+
         CqlLeaseMgr::getData(row, exchange.parameters_.size() - 1, appliedData,
                              appliedSize, 0, exchange);
     }
@@ -1255,6 +1256,7 @@ CqlLeaseMgr::addLeaseCommon(StatementIndex stindex,
     cass_future_free(future);
     cass_statement_free(statement);
 
+
     return applied;
 }
 
@@ -1673,7 +1675,7 @@ CqlLeaseMgr::updateLeaseCommon(StatementIndex stindex,
     CassIterator* rows = cass_iterator_from_result(resultCollection);
     CqlDataArray appliedData;
     CqlDataArray appliedSize;
-    bool applied = false;
+    static bool applied = false;
     while (cass_iterator_next(rows)) {
         const CassRow* row = cass_iterator_get_row(rows);
         // [applied]: bool
@@ -1777,7 +1779,7 @@ CqlLeaseMgr::deleteLeaseCommon(StatementIndex stindex,
     CassIterator* rows = cass_iterator_from_result(resultCollection);
     CqlDataArray appliedData;
     CqlDataArray appliedSize;
-    bool applied = false;
+    static bool applied = false;
     while (cass_iterator_next(rows)) {
         const CassRow* row = cass_iterator_get_row(rows);
         // [applied]: bool
diff --git a/src/lib/dhcpsrv/dhcp4o6_ipc.cc b/src/lib/dhcpsrv/dhcp4o6_ipc.cc
index 063e808..86dfafc 100644
--- a/src/lib/dhcpsrv/dhcp4o6_ipc.cc
+++ b/src/lib/dhcpsrv/dhcp4o6_ipc.cc
@@ -71,7 +71,7 @@ int Dhcp4o6IpcBase::open(uint16_t port, EndpointType endpoint_type) {
     }
     // We'll connect to the loopback address so bind to it too.
     local6.sin6_addr.s6_addr[15] = 1;
-    if (bind(sock, (struct sockaddr *)&local6, sizeof(local6)) < 0) {
+    if (::bind(sock, (struct sockaddr *)&local6, sizeof(local6)) < 0) {
         ::close(sock);
         isc_throw(Dhcp4o6IpcError, "Failed to bind DHCP4o6 socket.");
     }
diff --git a/tools/cql_config b/tools/cql_config
index 19a426a..1c9fdb5 100755
--- a/tools/cql_config
+++ b/tools/cql_config
@@ -1,5 +1,5 @@
 #!/bin/bash
-DIR=$(readlink -f $0 | xargs dirname)
+DIR=$(cd $(dirname $0); pwd -P)
 if ! [ -f ${DIR}/cql_config_defines.sh ] || ! [ -x ${DIR}/cql_config_defines.sh ]
 then
 	echo "missing path configuration file for DataStax Cassandra (cql_config_defines.h)"
diff --git a/tools/cql_config_defines.sh b/tools/cql_config_defines.sh
index bf3810d..a90fe61 100755
--- a/tools/cql_config_defines.sh
+++ b/tools/cql_config_defines.sh
@@ -6,5 +6,5 @@
 
 # This variable should point to the directory where cpp-driver is compiled.
 # You can download cpp-driver sources from https://github.com/datastax/cpp-driver
-CPP_DRIVER_PATH="/please/specify/path/to/cpp-driver/in/cql_config_defines.sh"
+CPP_DRIVER_PATH="/Users/marcin/devel/cpp-driver/"

Subtickets

Change History (1)

comment:1 Changed 3 years ago by hschempf

  • Milestone changed from Kea-proposed to Outstanding Tasks

Per Dec 1 Kea team meeting, move outstanding

Note: See TracTickets for help on using tickets.