summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authormergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-08-03 18:13:53 +0300
committerGitHub <noreply@github.com>2024-08-03 18:13:53 +0300
commita22cad7674216b984301107b5afcc91c547016b1 (patch)
treefa00bde35c810a0b28af11e52a8e92952401d4b1 /src/conf_mode
parent4ae9d14d0989366a27f81a061ad4fdd267b2325b (diff)
downloadvyos-1x-a22cad7674216b984301107b5afcc91c547016b1.tar.gz
vyos-1x-a22cad7674216b984301107b5afcc91c547016b1.zip
nat64: T6627: call check_kmod within standard config function (#3931)
Functions called from config scripts outside of the standard functions get_config/verify/generate/apply will not be called when run under configd. Move as appropriate for the general config script structure and the specific script requirements. (cherry picked from commit aeb51976ea23d68d35685bdaa535042a05016185) Co-authored-by: John Estabrook <jestabro@vyos.io>
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/nat64.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/conf_mode/nat64.py b/src/conf_mode/nat64.py
index 32a1c47d1..df501ce7f 100755
--- a/src/conf_mode/nat64.py
+++ b/src/conf_mode/nat64.py
@@ -46,7 +46,12 @@ def get_config(config: Config | None = None) -> None:
base = ["nat64"]
nat64 = config.get_config_dict(base, key_mangling=("-", "_"), get_first_key=True)
- base_src = base + ["source", "rule"]
+ return nat64
+
+
+def verify(nat64) -> None:
+ check_kmod(["jool"])
+ base_src = ["nat64", "source", "rule"]
# Load in existing instances so we can destroy any unknown
lines = cmd("jool instance display --csv").splitlines()
@@ -76,12 +81,8 @@ def get_config(config: Config | None = None) -> None:
):
rules[num]["recreate"] = True
- return nat64
-
-
-def verify(nat64) -> None:
if not nat64:
- # no need to verify the CLI as nat64 is going to be deactivated
+ # nothing left to do
return
if dict_search("source.rule", nat64):
@@ -128,6 +129,9 @@ def verify(nat64) -> None:
def generate(nat64) -> None:
+ if not nat64:
+ return
+
os.makedirs(JOOL_CONFIG_DIR, exist_ok=True)
if dict_search("source.rule", nat64):
@@ -184,6 +188,7 @@ def generate(nat64) -> None:
def apply(nat64) -> None:
if not nat64:
+ unload_kmod(['jool'])
return
if dict_search("source.rule", nat64):
@@ -211,7 +216,6 @@ def apply(nat64) -> None:
if __name__ == "__main__":
try:
- check_kmod(["jool"])
c = get_config()
verify(c)
generate(c)