summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2026-03-30 21:32:15 +0200
committerGitHub <noreply@github.com>2026-03-30 21:32:15 +0200
commit83d76acd34e4d822e68e72e3b072a789b1abd845 (patch)
tree6d020cb315dc08d8a79d67b24b8078ee244e9dca
parent03b412fd9ca754f3ea61c8c7c210babf4aa4d251 (diff)
parentd0b9b7037478d2374007c87cd7cc5d424d3674e6 (diff)
downloadvyos-1x-83d76acd34e4d822e68e72e3b072a789b1abd845.tar.gz
vyos-1x-83d76acd34e4d822e68e72e3b072a789b1abd845.zip
Merge pull request #5089 from robinchrist/T7338-bgp-as-notation
bgp: T7338: Add support for "parameters as-notation <asdot|asdot+>"
-rw-r--r--data/templates/frr/bgpd.frr.j22
-rw-r--r--interface-definitions/include/bgp/protocol-common-config.xml.i19
-rwxr-xr-xsmoketest/scripts/cli/test_protocols_bgp.py51
3 files changed, 71 insertions, 1 deletions
diff --git a/data/templates/frr/bgpd.frr.j2 b/data/templates/frr/bgpd.frr.j2
index 44022f738..929e57d9c 100644
--- a/data/templates/frr/bgpd.frr.j2
+++ b/data/templates/frr/bgpd.frr.j2
@@ -259,7 +259,7 @@
{# j2lint: disable=jinja-statements-delimeter #}
{%- endmacro -%}
!
-router bgp {{ system_as }} {{ 'vrf ' ~ vrf if vrf is vyos_defined }}
+router bgp {{ system_as }} {{ 'vrf ' ~ vrf if vrf is vyos_defined }} {{ 'as-notation ' ~ parameters.as_notation | replace('as', '') if parameters.as_notation is vyos_defined }}
{% if parameters.ebgp_requires_policy is vyos_defined %}
bgp ebgp-requires-policy
{% else %}
diff --git a/interface-definitions/include/bgp/protocol-common-config.xml.i b/interface-definitions/include/bgp/protocol-common-config.xml.i
index f4bcf1509..ccf976b29 100644
--- a/interface-definitions/include/bgp/protocol-common-config.xml.i
+++ b/interface-definitions/include/bgp/protocol-common-config.xml.i
@@ -1153,6 +1153,25 @@
<help>BGP parameters</help>
</properties>
<children>
+ <leafNode name="as-notation">
+ <properties>
+ <help>BGP AS-notation output format</help>
+ <completionHelp>
+ <list>asdot asdot+</list>
+ </completionHelp>
+ <valueHelp>
+ <format>asdot</format>
+ <description>Use asdot notation only for 4 byte AS numbers</description>
+ </valueHelp>
+ <valueHelp>
+ <format>asdot+</format>
+ <description>Use asdot notation for all AS numbers</description>
+ </valueHelp>
+ <constraint>
+ <regex>(asdot\+|asdot)</regex>
+ </constraint>
+ </properties>
+ </leafNode>
<leafNode name="allow-martian-nexthop">
<properties>
<help>Allow Martian nexthops to be received in the NLRI from a peer</help>
diff --git a/smoketest/scripts/cli/test_protocols_bgp.py b/smoketest/scripts/cli/test_protocols_bgp.py
index edd797cf6..7df563239 100755
--- a/smoketest/scripts/cli/test_protocols_bgp.py
+++ b/smoketest/scripts/cli/test_protocols_bgp.py
@@ -1638,6 +1638,57 @@ class TestProtocolsBGP(VyOSUnitTestSHIM.TestCase):
self.assertIn(f' bgp router-id {router_id}', frr_vrf_config)
+ def test_bgp_31_as_notation(self):
+ # Test BGP AS-notation output format for both global and VRF BGP instances.
+ # Verify all three notation types render correctly on the router bgp line.
+ router_id = '127.0.0.4'
+ vrf = 'red'
+
+ for vrf in ['', 'red']:
+ vrf_base = ['vrf', 'name', vrf] if vrf else []
+ vrf_frr_bit = f' vrf {vrf}' if vrf else ''
+ bgp_path = vrf_base + base_path
+
+ if vrf_base:
+ self.cli_set(vrf_base + ['table', '2000'])
+
+ self.cli_set(bgp_path + ['system-as', ASN])
+ self.cli_set(bgp_path + ['parameters', 'router-id', router_id])
+
+ for notation in ['asdot', 'asdot+']:
+ self.cli_set(bgp_path + ['parameters', 'as-notation', notation])
+ self.cli_commit()
+
+ # our config options are called 'asdot' and 'asdot+' as in
+ # RFC 5396
+ # but FRR calls them 'dot' and 'dot+' in the router bgp line
+ # e.g. router bgp 12345 as-notation dot
+ # or
+ # router bgp 12345 vrf red as-notation dot
+ router_str = f'router bgp {ASN}{vrf_frr_bit} as-notation {notation.replace("as", "")}'
+ # getFRRConfig interprets the arguments as regex, so escape '+' if present
+ frrconfig = self.getFRRconfig(
+ router_str.replace('+', r'\+'), stop_section='^exit'
+ )
+ self.assertIn(router_str, frrconfig)
+
+ # Verify removing as-notation works
+ self.cli_delete(bgp_path + ['parameters', 'as-notation'])
+ self.cli_commit()
+
+ router_str = f'router bgp {ASN}{vrf_frr_bit}'
+
+ frrconfig = self.getFRRconfig(router_str, stop_section='^exit')
+ self.assertIn(router_str, frrconfig)
+ self.assertNotIn('as-notation', frrconfig.splitlines()[0])
+
+ # Cleanup
+ self.cli_delete(bgp_path)
+ if vrf_base:
+ self.cli_delete(vrf_base)
+
+ self.cli_commit()
+
def test_bgp_99_bmp(self):
target_name = 'instance-bmp'
target_address = '127.0.0.1'