From 0d54be778ba2bf1c918c43a525d7ef878a1cb9ea Mon Sep 17 00:00:00 2001 From: aapostoliuk Date: Wed, 2 Aug 2023 15:20:20 +0300 Subject: wireguard: T5409: Added 'set interfaces wireguard wgX threaded' Added 'set interfaces wireguard wgX threaded' command. Process traffic from each peer in a dedicated thread. --- python/vyos/ifconfig/wireguard.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/vyos/ifconfig/wireguard.py b/python/vyos/ifconfig/wireguard.py index fe5e9c519..58613813f 100644 --- a/python/vyos/ifconfig/wireguard.py +++ b/python/vyos/ifconfig/wireguard.py @@ -1,4 +1,4 @@ -# Copyright 2019-2022 VyOS maintainers and contributors +# Copyright 2019-2023 VyOS maintainers and contributors # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,8 @@ from hurry.filesize import alternative from vyos.ifconfig import Interface from vyos.ifconfig import Operational from vyos.template import is_ipv6 +from vyos.base import Warning + class WireGuardOperational(Operational): def _dump(self): @@ -184,7 +186,6 @@ class WireGuardIf(Interface): base_cmd += f' private-key {tmp_file.name}' base_cmd = base_cmd.format(**config) - if 'peer' in config: for peer, peer_config in config['peer'].items(): # T4702: No need to configure this peer when it was explicitly @@ -229,5 +230,12 @@ class WireGuardIf(Interface): if psk_file != no_psk_file and os.path.exists(psk_file): os.remove(psk_file) + try: + self._write_sysfs(f'/sys/devices/virtual/net/{self.ifname}/threaded', + '1' if 'threaded' in config else '0') + except Exception: + Warning(f'Update threaded status on interface "{config["ifname"]}" FAILED.\n' + f'An unexpected error occurred.') + # call base class super().update(config) -- cgit v1.2.3