1
0
mirror of https://git.yoctoproject.org/poky synced 2026-05-09 05:29:32 +00:00

kea: make kea environment available to lfc process

If the location of the log lock file is changed using the environment
variable KEA_LOCKFILE_DIR, the kea-dhcp process will work properly, but
the lfc (lease file cleanup) process spawned by it will not inherit this
value and use the default path[1], which will cause the kea server to
print the following message when running:

kea-dhcp4[6767]: Unable to use interprocess sync lockfile (No such file or directory): /var/run/kea/logger_lockfile

Backport a patch to fix this issue[2].

[1] https://gitlab.isc.org/isc-projects/kea/-/issues/3450
[2] https://gitlab.isc.org/isc-projects/kea/-/commit/f477e8ebcc8b8e1f1adaad4d55031084c0ff6f40

(From OE-Core rev: 34f1392aef4d5fa402600b21f6d7a47cd735cfd4)

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Yi Zhao
2025-02-21 16:12:06 +08:00
committed by Richard Purdie
parent f1ea319021
commit 131163d59d
2 changed files with 97 additions and 0 deletions
@@ -0,0 +1,96 @@
From 72d7e6c0b6b5af4fea2e4db9ed33757984ccdc5b Mon Sep 17 00:00:00 2001
From: Razvan Becheriu <razvan@isc.org>
Date: Fri, 14 Jun 2024 17:09:50 +0300
Subject: [PATCH] make kea environment available to lfc
Upstream-Status: Backport
[https://gitlab.isc.org/isc-projects/kea/-/commit/f477e8ebcc8b8e1f1adaad4d55031084c0ff6f40]
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
configure.ac | 2 ++
src/lib/dhcpsrv/memfile_lease_mgr.cc | 3 ++-
.../tests/memfile_lease_mgr_unittest.cc | 26 +++++++++++++++++++
src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in | 6 +++++
4 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in
diff --git a/configure.ac b/configure.ac
index c00edb5..7b572b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1629,6 +1629,8 @@ AC_CONFIG_FILES([src/lib/dhcp_ddns/tests/Makefile])
AC_CONFIG_FILES([src/lib/dhcpsrv/Makefile])
AC_CONFIG_FILES([src/lib/dhcpsrv/tests/Makefile])
AC_CONFIG_FILES([src/lib/dhcpsrv/tests/test_libraries.h])
+AC_CONFIG_FILES([src/lib/dhcpsrv/tests/test_kea_lfc_env.sh],
+ [chmod +x src/lib/dhcpsrv/tests/test_kea_lfc_env.sh])
AC_CONFIG_FILES([src/lib/dhcpsrv/testutils/Makefile])
AC_CONFIG_FILES([src/lib/dns/Makefile])
AC_CONFIG_FILES([src/lib/dns/tests/Makefile])
diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
index db4f5d5..0ecf3e7 100644
--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
@@ -209,7 +209,8 @@ LFCSetup::setup(const uint32_t lfc_interval,
args.push_back("ignored-path");
// Create the process (do not start it yet).
- process_.reset(new ProcessSpawn(ProcessSpawn::ASYNC, executable, args));
+ process_.reset(new ProcessSpawn(ProcessSpawn::ASYNC, executable, args,
+ ProcessEnvVars(), true));
// If we've been told to run it once now, invoke the callback directly.
if (run_once_now) {
diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
index 034f1f5..9edf637 100644
--- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
@@ -534,6 +534,32 @@ TEST_F(MemfileLeaseMgrTest, lfcTimer) {
EXPECT_EQ(2, lease_mgr->getLFCCount());
}
+/// @brief Check that the kea environment is accesible to the Lease
+/// File Cleanup process.
+TEST_F(MemfileLeaseMgrTest, lfcEnv) {
+ DatabaseConnection::ParameterMap pmap;
+ pmap["type"] = "memfile";
+ pmap["universe"] = "4";
+ pmap["name"] = getLeaseFilePath("leasefile4_0.csv");
+ pmap["lfc-interval"] = "1";
+
+ std::ostringstream s;
+ s << DHCP_DATA_DIR << "/test_kea_lfc_env.sh";
+ setenv("KEA_LFC_EXECUTABLE", s.str().c_str(), 1);
+
+ boost::scoped_ptr<NakedMemfileLeaseMgr> lease_mgr(new NakedMemfileLeaseMgr(pmap));
+
+ // Try to run the lease file cleanup.
+ ASSERT_NO_THROW(lease_mgr->lfcCallback());
+
+ // Wait for the LFC process to complete.
+ ASSERT_TRUE(waitForProcess(*lease_mgr, 1));
+
+ // And make sure it has returned an exit status of 0.
+ EXPECT_EQ(0, lease_mgr->getLFCExitStatus())
+ << "environment not available to LFC";
+}
+
/// @brief This test checks if the LFC timer is disabled (doesn't trigger)
/// cleanups when the lfc-interval is set to 0.
TEST_F(MemfileLeaseMgrTest, lfcTimerDisabled) {
diff --git a/src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in b/src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in
new file mode 100644
index 0000000..3eb71d5
--- /dev/null
+++ b/src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+if [ $(env | grep -c KEA_LFC_EXECUTABLE) != 0 ]; then
+ exit 0
+fi
+exit 1
--
2.25.1
@@ -20,6 +20,7 @@ SRC_URI = "http://ftp.isc.org/isc/kea/${PV}/${BP}.tar.gz \
file://0001-Replace-Name-NameString-with-vector-of-uint8_t.patch \
file://0002-Fix-unittests-Typo-in-Name-Name-append-to-ndata_-not.patch \
file://0001-Update-asiolink-for-boost-1.87.patch \
file://0001-make-kea-environment-available-to-lfc.patch \
"
SRC_URI[sha256sum] = "d2ce14a91c2e248ad2876e29152d647bcc5e433bc68dafad0ee96ec166fcfad1"