Skip to content

Commit

Permalink
T6629: call check_kmod within a standard config function
Browse files Browse the repository at this point in the history
Move the remaining calls to check_kmod within a standard function,
with placement determined by the needs of the config script.

(cherry picked from commit 95eef73)
  • Loading branch information
jestabro authored and mergify[bot] committed Aug 2, 2024
1 parent 1982aa3 commit 7c93698
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/conf_mode/interfaces_l2tpv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def generate(l2tpv3):
return None

def apply(l2tpv3):
check_kmod(k_mod)

# Check if L2TPv3 interface already exists
if interface_exists(l2tpv3['ifname']):
# L2TPv3 is picky when changing tunnels/sessions, thus we can simply
Expand All @@ -102,7 +104,6 @@ def apply(l2tpv3):

if __name__ == '__main__':
try:
check_kmod(k_mod)
c = get_config()
verify(c)
generate(c)
Expand Down
3 changes: 2 additions & 1 deletion src/conf_mode/interfaces_wireguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def verify(wireguard):
public_keys.append(peer['public_key'])

def apply(wireguard):
check_kmod('wireguard')

if 'rebuild_required' in wireguard or 'deleted' in wireguard:
wg = WireGuardIf(**wireguard)
# WireGuard only supports peer removal based on the configured public-key,
Expand All @@ -123,7 +125,6 @@ def apply(wireguard):

if __name__ == '__main__':
try:
check_kmod('wireguard')
c = get_config()
verify(c)
apply(c)
Expand Down
3 changes: 2 additions & 1 deletion src/conf_mode/interfaces_wireless.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ def verify(wifi):
return None

def generate(wifi):
check_kmod('mac80211')

interface = wifi['ifname']

# Delete config files if interface is removed
Expand Down Expand Up @@ -319,7 +321,6 @@ def apply(wifi):

if __name__ == '__main__':
try:
check_kmod('mac80211')
c = get_config()
verify(c)
generate(c)
Expand Down
3 changes: 2 additions & 1 deletion src/conf_mode/nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ def generate(nat):
return None

def apply(nat):
check_kmod(k_mod)

cmd(f'nft --file {nftables_nat_config}')
cmd(f'nft --file {nftables_static_nat_conf}')

Expand All @@ -253,7 +255,6 @@ def apply(nat):

if __name__ == '__main__':
try:
check_kmod(k_mod)
c = get_config()
verify(c)
generate(c)
Expand Down
3 changes: 2 additions & 1 deletion src/conf_mode/nat66.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,15 @@ def apply(nat):
if not nat:
return None

check_kmod(k_mod)

cmd(f'nft --file {nftables_nat66_config}')
call_dependents()

return None

if __name__ == '__main__':
try:
check_kmod(k_mod)
c = get_config()
verify(c)
generate(c)
Expand Down

0 comments on commit 7c93698

Please sign in to comment.