summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/kea/files/0001-make-kea-environment-available-to-lfc.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-connectivity/kea/files/0001-make-kea-environment-available-to-lfc.patch')
-rw-r--r--meta/recipes-connectivity/kea/files/0001-make-kea-environment-available-to-lfc.patch96
1 files changed, 96 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/kea/files/0001-make-kea-environment-available-to-lfc.patch b/meta/recipes-connectivity/kea/files/0001-make-kea-environment-available-to-lfc.patch
new file mode 100644
index 0000000000..15c09d4c41
--- /dev/null
+++ b/meta/recipes-connectivity/kea/files/0001-make-kea-environment-available-to-lfc.patch
@@ -0,0 +1,96 @@
1From 72d7e6c0b6b5af4fea2e4db9ed33757984ccdc5b Mon Sep 17 00:00:00 2001
2From: Razvan Becheriu <razvan@isc.org>
3Date: Fri, 14 Jun 2024 17:09:50 +0300
4Subject: [PATCH] make kea environment available to lfc
5
6Upstream-Status: Backport
7[https://gitlab.isc.org/isc-projects/kea/-/commit/f477e8ebcc8b8e1f1adaad4d55031084c0ff6f40]
8
9Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
10---
11 configure.ac | 2 ++
12 src/lib/dhcpsrv/memfile_lease_mgr.cc | 3 ++-
13 .../tests/memfile_lease_mgr_unittest.cc | 26 +++++++++++++++++++
14 src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in | 6 +++++
15 4 files changed, 36 insertions(+), 1 deletion(-)
16 create mode 100644 src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in
17
18diff --git a/configure.ac b/configure.ac
19index c00edb5..7b572b0 100644
20--- a/configure.ac
21+++ b/configure.ac
22@@ -1629,6 +1629,8 @@ AC_CONFIG_FILES([src/lib/dhcp_ddns/tests/Makefile])
23 AC_CONFIG_FILES([src/lib/dhcpsrv/Makefile])
24 AC_CONFIG_FILES([src/lib/dhcpsrv/tests/Makefile])
25 AC_CONFIG_FILES([src/lib/dhcpsrv/tests/test_libraries.h])
26+AC_CONFIG_FILES([src/lib/dhcpsrv/tests/test_kea_lfc_env.sh],
27+ [chmod +x src/lib/dhcpsrv/tests/test_kea_lfc_env.sh])
28 AC_CONFIG_FILES([src/lib/dhcpsrv/testutils/Makefile])
29 AC_CONFIG_FILES([src/lib/dns/Makefile])
30 AC_CONFIG_FILES([src/lib/dns/tests/Makefile])
31diff --git a/src/lib/dhcpsrv/memfile_lease_mgr.cc b/src/lib/dhcpsrv/memfile_lease_mgr.cc
32index db4f5d5..0ecf3e7 100644
33--- a/src/lib/dhcpsrv/memfile_lease_mgr.cc
34+++ b/src/lib/dhcpsrv/memfile_lease_mgr.cc
35@@ -209,7 +209,8 @@ LFCSetup::setup(const uint32_t lfc_interval,
36 args.push_back("ignored-path");
37
38 // Create the process (do not start it yet).
39- process_.reset(new ProcessSpawn(ProcessSpawn::ASYNC, executable, args));
40+ process_.reset(new ProcessSpawn(ProcessSpawn::ASYNC, executable, args,
41+ ProcessEnvVars(), true));
42
43 // If we've been told to run it once now, invoke the callback directly.
44 if (run_once_now) {
45diff --git a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
46index 034f1f5..9edf637 100644
47--- a/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
48+++ b/src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
49@@ -534,6 +534,32 @@ TEST_F(MemfileLeaseMgrTest, lfcTimer) {
50 EXPECT_EQ(2, lease_mgr->getLFCCount());
51 }
52
53+/// @brief Check that the kea environment is accesible to the Lease
54+/// File Cleanup process.
55+TEST_F(MemfileLeaseMgrTest, lfcEnv) {
56+ DatabaseConnection::ParameterMap pmap;
57+ pmap["type"] = "memfile";
58+ pmap["universe"] = "4";
59+ pmap["name"] = getLeaseFilePath("leasefile4_0.csv");
60+ pmap["lfc-interval"] = "1";
61+
62+ std::ostringstream s;
63+ s << DHCP_DATA_DIR << "/test_kea_lfc_env.sh";
64+ setenv("KEA_LFC_EXECUTABLE", s.str().c_str(), 1);
65+
66+ boost::scoped_ptr<NakedMemfileLeaseMgr> lease_mgr(new NakedMemfileLeaseMgr(pmap));
67+
68+ // Try to run the lease file cleanup.
69+ ASSERT_NO_THROW(lease_mgr->lfcCallback());
70+
71+ // Wait for the LFC process to complete.
72+ ASSERT_TRUE(waitForProcess(*lease_mgr, 1));
73+
74+ // And make sure it has returned an exit status of 0.
75+ EXPECT_EQ(0, lease_mgr->getLFCExitStatus())
76+ << "environment not available to LFC";
77+}
78+
79 /// @brief This test checks if the LFC timer is disabled (doesn't trigger)
80 /// cleanups when the lfc-interval is set to 0.
81 TEST_F(MemfileLeaseMgrTest, lfcTimerDisabled) {
82diff --git a/src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in b/src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in
83new file mode 100644
84index 0000000..3eb71d5
85--- /dev/null
86+++ b/src/lib/dhcpsrv/tests/test_kea_lfc_env.sh.in
87@@ -0,0 +1,6 @@
88+#!/bin/sh
89+
90+if [ $(env | grep -c KEA_LFC_EXECUTABLE) != 0 ]; then
91+ exit 0
92+fi
93+exit 1
94--
952.25.1
96