diff options
| author | Nataliia Solomko <natalirs1985@gmail.com> | 2026-06-15 14:18:10 +0300 |
|---|---|---|
| committer | Nataliia Solomko <natalirs1985@gmail.com> | 2026-06-25 11:28:11 +0300 |
| commit | f04dfac8772c7a1326bad4f12ec3aedea9a4d8d9 (patch) | |
| tree | 3f58e675420a3daf4a04dc07f03af35e4f4385eb /src | |
| parent | d3826867554eb9dbd30d5c8c781516a8afcfd96b (diff) | |
| download | vyos-1x-f04dfac8772c7a1326bad4f12ec3aedea9a4d8d9.tar.gz vyos-1x-f04dfac8772c7a1326bad4f12ec3aedea9a4d8d9.zip | |
bgp: T5526: Fix BGP neighbor validation not raising when interface does not exist
Validation of interface-based BGP neighbors relied on checking physical
interface existence, which silently skipped the check when interface didn't
exist yet, letting invalid config reach FRR. Fix by checking whether the
neighbor is not an IP address instead, and improve the error messages to
show the correct command.
Diffstat (limited to 'src')
| -rwxr-xr-x | src/conf_mode/protocols_bgp.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py index b2bc3a6a6..2ec631f4c 100755 --- a/src/conf_mode/protocols_bgp.py +++ b/src/conf_mode/protocols_bgp.py @@ -26,7 +26,6 @@ from vyos.configverify import verify_vrf from vyos.frrender import FRRender from vyos.frrender import get_frrender_dict from vyos.template import is_ip -from vyos.template import is_interface from vyos.utils.dict import dict_search from vyos.utils.network import get_interface_vrf from vyos.utils.network import is_addr_assigned @@ -382,11 +381,21 @@ def verify(config_dict): if is_ip(peer) and is_addr_assigned(peer, vrf): raise ConfigError(f'Cannot configure local address as neighbor "{peer}"{vrf_error_msg}') - elif is_interface(peer): + elif not is_ip(peer): + # T5526: Neighbor is not an IP address — treat as interface name + # regardless of whether the interface currently exists on the system. + # Checking physical existence would silently skip validation during + # boot or config restore, allowing invalid config to reach FRR. if 'peer_group' in peer_config: - raise ConfigError(f'peer-group must be set under the interface node of "{peer}"') + raise ConfigError( + f'To assign a peer-group to an interface-based neighbor, use: ' + f'"set protocols bgp neighbor {peer} interface peer-group <name>"' + ) if 'remote_as' in peer_config: - raise ConfigError(f'remote-as must be set under the interface node of "{peer}"') + raise ConfigError( + f'To set remote-as for an interface-based neighbor, use: ' + f'"set protocols bgp neighbor {peer} interface remote-as <asn>"' + ) if 'source_interface' in peer_config['interface']: raise ConfigError(f'"source-interface" option not allowed for neighbor "{peer}"') |
