Skip to content

migrate kea-netconf to libyang2 and sysrepo2

Andrei Pavel requested to merge 2311-sysrepo2 into master

Part of #2311 (closed)

This MR contains minimal changes to make Kea compile and function with libyang2 and sysrepo2. It mostly contains renames and logic adjustments. Here's a list:

  • S_Connection -> Connection

  • S_Context -> Context

  • S_Module -> Module

  • S_Session -> Session

  • S_Val -> DataNode (when it retrieves data from Sysrepo) or string (when pushing data to Sysrepo)

  • sr_error_t -> ErrorCode

  • sr_ev_notif_type_t -> NotificationType

  • sr_event_t -> Event

  • sr_subscr_options_t -> SubscribeOptions

  • sr_type_t -> LeafBaseType

  • sysrepo_exception -> Error

  • Session::apply_changes -> Session::applyChanges

  • Session::delete_item -> Session::deleteItem

  • Session::get_context-> Session::getContext

  • Session::set_item -> Session::setItem

  • Removed getValuesFromItems(). getItem() should be able to retrieve any type of YANG node now.

  • Removed YangRepr::validate() and Session::validate(). This function has been removed from the C++ API. It is marked as sensitive in a comment in C code. That's probably why it's not offered to third-parties.

  • Removed the TranslatorBasicTest::valueFrom test. We cannot build a DataNode anymore to pass to TranslatorBasic::value(). The code that was tested with that test should be sufficiently tested as part of other tests that work with a real YANG module.

There are TODOs and other unoptimized code that I'd like to deal with in another issue. The point of this one was strictly the migration.

These are the commits:

  • 3a5b18b7 migrate autoconf to libyang2 and sysrepo2

  • 0928f2de detect C++20 in autoconf

    • And enforce -std=c++20 when building --with-libyang-cpp or --with-sysrepo-cpp.
  • 04474747 fix errors caused by the C++20 'requires' keyword

  • c8fa5314 fix variable shadowing

      adaptor_config.cc:314:29: warning: declaration of ‘pools’ shadows a previous local [-Wshadow]
        314 |             ConstElementPtr pools = subnet->get("pd-pools");
            |                             ^~~~~
      adaptor_config.cc:303:25: note: shadowed declaration is here
        303 |         ConstElementPtr pools = subnet->get("pools");
            |                         ^~~~~
      translator_host.cc: In member function ‘isc::data::ElementPtr isc::yang::TranslatorHost::getHostKea(const std::string&)’:
      translator_host.cc:89:25: warning: declaration of ‘hostname’ shadows a previous local [-Wshadow]
         89 |         ConstElementPtr hostname = getItem(xpath + "/server-hostname");
            |                         ^~~~~~~~
      translator_host.cc:57:21: note: shadowed declaration is here
         57 |     ConstElementPtr hostname = getItem(xpath + "/hostname");
            |                     ^~~~~~~~
      translator_host.cc: In member function ‘void isc::yang::TranslatorHost::setHostKea(const std::string&, isc::data::ConstElementPtr)’:
      translator_host.cc:165:25: warning: declaration of ‘hostname’ shadows a previous local [-Wshadow]
        165 |         ConstElementPtr hostname = elem->get("server-hostname");
            |                         ^~~~~~~~
      translator_host.cc:124:21: note: shadowed declaration is here
        124 |     ConstElementPtr hostname = elem->get("hostname");
      
  • 284a36fe fix deprecated capture of 'this' in C++20

      In file included from readwrite_mutex_unittest.cc:9:
      ../../../../src/lib/util/readwrite_mutex.h: In lambda function:
      ../../../../src/lib/util/readwrite_mutex.h:57:25: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
         57 |         gate1_.wait(lk, [=]() { return (!writeEntered()); });
            |                         ^
      ../../../../src/lib/util/readwrite_mutex.h:57:25: note: add explicit ‘this’ or ‘*this’ capture
      ../../../../src/lib/util/readwrite_mutex.h: In lambda function:
      ../../../../src/lib/util/readwrite_mutex.h:60:25: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
         60 |         gate2_.wait(lk, [=]() { return (readers() == 0); });
            |                         ^
      ../../../../src/lib/util/readwrite_mutex.h:60:25: note: add explicit ‘this’ or ‘*this’ capture
      ../../../../src/lib/util/readwrite_mutex.h: In lambda function:
      ../../../../src/lib/util/readwrite_mutex.h:77:25: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated]
         77 |         gate1_.wait(lk, [=]() { return (state_ < MAX_READERS); });
            |                         ^
      ../../../../src/lib/util/readwrite_mutex.h:77:25: note: add explicit ‘this’ or ‘*this’ capture
      
  • 88571e4f migrate src/lib/yang to libyang2 and sysrepo2

  • ac50d4bc migrate src/bin/netconf to libyang2 and sysrepo2

  • 5d57e0e6 retouch the NETCONF developer guide

  • ab86e912 update NETCONF documentation

  • ef740257 hammer.py now installs libyang2 and sysrepo2

    • Also adds the --ignore-errors-for. I wanted to use it in Jenkins, but I ended up not using it and hardcoding the list of systems that cannot build Kea with NETCONF using default packages in the Jenkinsfile. So I only left it for the work I put into it.
  • 754d10e3 rename AX_SYSREPO to AX_NETCONF

  • 065794ce autoconf: include when checking for boost headers

      Solves this error on some systems:
    

    In file included from /usr/include/boost/asio.hpp:23, from conftest.cpp:75: /usr/include/boost/asio/awaitable.hpp: In constructor 'boost::asio::awaitable<T, Executor>::awaitable(boost::asio::awaitable<T, Executor>&&)': /usr/include/boost/asio/awaitable.hpp:68:19: error: 'exchange' is not a member of 'std'; did you mean 'std::atomic_impl::exchange'? 68 | : frame(std::exchange(other.frame, nullptr)) | ^~~~~~~~ In file included from /usr/include/c++/12/bits/shared_ptr_atomic.h:33, from /usr/include/c++/12/memory:78, from /usr/include/boost/asio/associated_allocator.hpp:19, from /usr/include/boost/asio.hpp:20: /usr/include/c++/12/bits/atomic_base.h:976:7: note: 'std::__atomic_impl::exchange' declared here 976 | exchange(_Tp* __ptr, _Val<_Tp> __desired, memory_order __m) noexcept | ^~~~~~~~

  • f58feb63 fix ERROR: unbound variable in xml_reporting_test_lib.sh

    • /tmp/workspace/kea-manual/ut-extended/src/lib/testutils/xml_reporting_test_lib.sh: line 142: ERROR: unbound variable
  • 7b85eb29 add ChangeLog entry

  • 35b73cb4 ax_find_library: add -L if pkg-config doesn't

    • Solves a problem in RHEL where -L${libdir} is missing from pkg-config --libs.

#huge-sorry

Edited by Andrei Pavel

Merge request reports