From 5a5c0cd2e6f5d6c459a7f0e2da777834fb4362b2 Mon Sep 17 00:00:00 2001
From: Christian Poessinger <christian@poessinger.com>
Date: Mon, 28 Jun 2021 22:45:11 +0200
Subject: bgp: T3657: fix remote-as validator for IPv6 link-local peering

The "v6only" CLI tree was not taken into account during validation.

vyos@vyos:~$ show configuration commands | grep bgp
set protocols bgp local-as '200'
set protocols bgp neighbor eth0.204 address-family ipv6-unicast
set protocols bgp neighbor eth0.204 interface v6only remote-as '100'

vyos@vyos:~$ show bgp ipv6 sum
IPv6 Unicast Summary:
BGP router identifier 172.18.254.201, local AS number 200 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 1, using 21 KiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
eth0.204        4        100        99        99        0    0    0 01:35:07            0        0

Total number of neighbors 1
---
 src/conf_mode/protocols_bgp.py | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'src/conf_mode')

diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index 74253c2d7..95f277d74 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -88,6 +88,10 @@ def verify_remote_as(peer_config, bgp_config):
             tmp = dict_search(f'peer_group.{peer_group_name}.remote_as', bgp_config)
             if tmp: return tmp
 
+        if 'v6only' in peer_config['interface']:
+            if 'remote_as' in peer_config['interface']['v6only']:
+                return peer_config['interface']['v6only']['remote_as']
+
     return None
 
 def verify(bgp):
-- 
cgit v1.2.3