diff options
| author | Kyrylo Yatsenko <hedrok@gmail.com> | 2025-10-17 13:58:01 +0300 |
|---|---|---|
| committer | Kyrylo Yatsenko <hedrok@gmail.com> | 2025-10-21 19:57:40 +0300 |
| commit | c4632bb6ad6c055fb7fe5a5c055354c6895ba8e5 (patch) | |
| tree | 168bce87c31c814290ec95393c3da4e1ab893a42 /python | |
| parent | 70b7818f75f55de14214b85a12b8ec13d98ff89b (diff) | |
| download | vyos-1x-c4632bb6ad6c055fb7fe5a5c055354c6895ba8e5.tar.gz vyos-1x-c4632bb6ad6c055fb7fe5a5c055354c6895ba8e5.zip | |
T5811: Make static dhcp-interface routes robust
Solves the problem that vyos-configs in FRRender caches configuation and
DHCP changes are ignored.
* Add src/helpers/vyos-request-configd-update.py that requests vyos-configd
to update FRR configuration.
* Make dhclient hooks use it instead of calling protocols_static.py
* Make FRRender cache not only configuration but also DHCP gateways so
that is any of them changes, FRR configuration is updated
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/defaults.py | 2 | ||||
| -rw-r--r-- | python/vyos/frrender.py | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/python/vyos/defaults.py b/python/vyos/defaults.py index 43cde38e9..25d7fd50c 100644 --- a/python/vyos/defaults.py +++ b/python/vyos/defaults.py @@ -61,6 +61,8 @@ config_files = { config_status = '/tmp/vyos-config-status' api_config_state = '/run/http-api-state' frr_debug_enable = '/tmp/vyos.frr.debug' +static_route_dhcp_interfaces_path = '/tmp/static_dhcp_interfaces' +vyos_configd_socket_path = 'ipc:///run/vyos-configd.sock' cfg_group = 'vyattacfg' diff --git a/python/vyos/frrender.py b/python/vyos/frrender.py index decec8aa2..91fd3667d 100644 --- a/python/vyos/frrender.py +++ b/python/vyos/frrender.py @@ -31,11 +31,14 @@ from vyos.config import config_dict_merge from vyos.configdict import get_dhcp_interfaces from vyos.configdict import get_pppoe_interfaces from vyos.defaults import frr_debug_enable +from vyos.defaults import static_route_dhcp_interfaces_path from vyos.utils.dict import dict_search from vyos.utils.dict import dict_set_nested +from vyos.utils.file import read_file from vyos.utils.file import write_file from vyos.utils.process import cmd from vyos.utils.process import rc_cmd +from vyos.template import get_dhcp_router from vyos.template import render_to_string from vyos import ConfigError @@ -634,6 +637,7 @@ def get_frrender_dict(conf: Config, argv=None) -> dict: class FRRender: cached_config_dict = {} + cached_dhcp_gateways = {} def __init__(self): self._frr_conf = '/run/frr/config/vyos.frr.conf' @@ -646,11 +650,20 @@ class FRRender: tmp = type(config_dict) raise ValueError(f'Config must be of type "dict" and not "{tmp}"!') + dhcp_gateways = { + interface: get_dhcp_router(interface) + for interface in read_file(static_route_dhcp_interfaces_path, '').split() + } - if self.cached_config_dict == config_dict: + if ( + self.cached_config_dict == config_dict + and self.cached_dhcp_gateways == dhcp_gateways + ): debug('FRR: NO CHANGES DETECTED') return False + self.cached_config_dict = config_dict + self.cached_dhcp_gateways = dhcp_gateways def inline_helper(config_dict) -> str: output = '!\n' |
