Skip to content

Commit d5e3460

Browse files
sudarshankumar4893Sudarshan Kumar (from Dev Box)
authored and
Sudarshan Kumar (from Dev Box)
committed
Removed check to allow BGP peer in a vnet
Signed-off-by: Sudarshan Kumar (from Dev Box) <sudakumar@microsoft.com>
1 parent eb9fa45 commit d5e3460

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/sonic-bgpcfgd/bgpcfgd/managers_bgp.py

-7
Original file line numberDiff line numberDiff line change
@@ -187,19 +187,12 @@ def add_peer(self, vrf, nbr, data):
187187
if "local_addr" not in data:
188188
log_warn("Peer %s. Missing attribute 'local_addr'" % nbr)
189189
else:
190-
# The bgp session that belongs to a vnet cannot be advertised as the default BGP session.
191-
# So we need to check whether this bgp session belongs to a vnet.
192190
data["local_addr"] = str(netaddr.IPNetwork(str(data["local_addr"])).ip)
193191
interface = self.get_local_interface(data["local_addr"])
194192
if not interface:
195193
print_data = nbr, data["local_addr"]
196194
log_debug("Peer '%s' with local address '%s' wait for the corresponding interface to be set" % print_data)
197195
return False
198-
vnet = self.get_vnet(interface)
199-
if vnet:
200-
# Ignore the bgp session that is in a vnet
201-
log_info("Ignore the BGP peer '%s' as the interface '%s' is in vnet '%s'" % (nbr, interface, vnet))
202-
return True
203196

204197
kwargs = {
205198
'CONFIG_DB__DEVICE_METADATA': self.directory.get_slot("CONFIG_DB", swsscommon.CFG_DEVICE_METADATA_TABLE_NAME),

src/sonic-bgpcfgd/tests/test_bgp.py

+12
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ def test_add_peer_ipv6():
152152
res = m.set_handler("fc00:20::1", {'asn': '65200', 'holdtime': '180', 'keepalive': '60', 'local_addr': 'fc00:20::20', 'name': 'TOR', 'nhopself': '0', 'rrclient': '0'})
153153
assert res, "Expect True return value"
154154

155+
def test_add_peer_in_vnet():
156+
for constant in load_constant_files():
157+
m = constructor(constant)
158+
res = m.set_handler("Vnet-10|30.30.30.1", {'asn': '65200', 'holdtime': '180', 'keepalive': '60', 'local_addr': '30.30.30.30', 'name': 'TOR', 'nhopself': '0', 'rrclient': '0'})
159+
assert res, "Expect True return value"
160+
161+
def test_add_peer_ipv6_in_vnet():
162+
for constant in load_constant_files():
163+
m = constructor(constant)
164+
res = m.set_handler("Vnet-10|fc00:20::1", {'asn': '65200', 'holdtime': '180', 'keepalive': '60', 'local_addr': 'fc00:20::20', 'name': 'TOR', 'nhopself': '0', 'rrclient': '0'})
165+
assert res, "Expect True return value"
166+
155167
@patch('bgpcfgd.managers_bgp.log_warn')
156168
def test_add_peer_no_local_addr(mocked_log_warn):
157169
for constant in load_constant_files():

0 commit comments

Comments
 (0)