-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14637 from FRRouting/mergify/bp/dev/9.1/pr-14628
bgpd: Do not suppress conditional advertisement updates if triggered (backport #14628)
- Loading branch information
Showing
6 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
10 changes: 10 additions & 0 deletions
10
tests/topotests/bgp_conditional_advertisement_static_route/r1/frr.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
! | ||
int r1-eth0 | ||
ip address 192.168.1.1/24 | ||
! | ||
router bgp 65000 | ||
no bgp ebgp-requires-policy | ||
neighbor 192.168.1.2 remote-as internal | ||
neighbor 192.168.1.2 timers 1 3 | ||
neighbor 192.168.1.2 timers connect 1 | ||
! |
39 changes: 39 additions & 0 deletions
39
tests/topotests/bgp_conditional_advertisement_static_route/r2/frr.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
! | ||
!debug bgp conditional-advertisement | ||
!debug bgp updates | ||
! | ||
int r2-eth0 | ||
ip address 192.168.1.2/24 | ||
! | ||
int r2-eth1 | ||
ip address 192.168.2.2/24 | ||
! | ||
router bgp 65000 | ||
no bgp ebgp-requires-policy | ||
bgp conditional-advertisement timer 5 | ||
neighbor 192.168.1.1 remote-as internal | ||
neighbor 192.168.1.1 timers 1 3 | ||
neighbor 192.168.1.1 timers connect 1 | ||
neighbor 192.168.2.1 remote-as internal | ||
neighbor 192.168.2.1 timers 1 3 | ||
neighbor 192.168.2.1 timers connect 1 | ||
address-family ipv4 unicast | ||
redistribute static | ||
neighbor 192.168.1.1 advertise-map advertise-map exist-map exist-map | ||
neighbor 192.168.1.1 route-map deny-all out | ||
exit-address-family | ||
! | ||
ip route 10.10.10.1/32 r2-eth0 | ||
ip route 10.10.10.2/32 r2-eth0 | ||
! | ||
ip prefix-list default seq 5 permit 0.0.0.0/0 | ||
ip prefix-list advertise seq 5 permit 10.10.10.1/32 | ||
! | ||
route-map deny-all deny 10 | ||
! | ||
route-map exist-map permit 10 | ||
match ip address prefix-list default | ||
! | ||
route-map advertise-map permit 10 | ||
match ip address prefix-list advertise | ||
! |
19 changes: 19 additions & 0 deletions
19
tests/topotests/bgp_conditional_advertisement_static_route/r3/frr.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
! | ||
int lo | ||
ip address 10.10.10.1/32 | ||
ip address 10.10.10.2/32 | ||
! | ||
int r3-eth0 | ||
ip address 192.168.2.1/24 | ||
! | ||
router bgp 65000 | ||
no bgp ebgp-requires-policy | ||
no bgp network import-check | ||
neighbor 192.168.2.2 remote-as internal | ||
neighbor 192.168.2.2 timers 1 3 | ||
neighbor 192.168.2.2 timers connect 1 | ||
! | ||
address-family ipv4 unicast | ||
neighbor 192.168.2.2 default-originate | ||
exit-address-family | ||
! |
118 changes: 118 additions & 0 deletions
118
...conditional_advertisement_static_route/test_bgp_conditional_advertisement_static_route.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#!/usr/bin/env python | ||
# SPDX-License-Identifier: ISC | ||
|
||
# Copyright (c) 2023 by | ||
# Donatas Abraitis <[email protected]> | ||
# | ||
|
||
""" | ||
Test if static route with BGP conditional advertisement works correctly | ||
if we modify the prefix-lists. | ||
""" | ||
|
||
import os | ||
import re | ||
import sys | ||
import json | ||
import pytest | ||
import functools | ||
|
||
pytestmark = pytest.mark.bgpd | ||
|
||
CWD = os.path.dirname(os.path.realpath(__file__)) | ||
sys.path.append(os.path.join(CWD, "../")) | ||
|
||
# pylint: disable=C0413 | ||
from lib import topotest | ||
from lib.topogen import Topogen, TopoRouter, get_topogen | ||
from lib.common_config import step | ||
|
||
pytestmark = [pytest.mark.bgpd] | ||
|
||
|
||
def setup_module(mod): | ||
topodef = {"s1": ("r1", "r2"), "s2": ("r2", "r3")} | ||
tgen = Topogen(topodef, mod.__name__) | ||
tgen.start_topology() | ||
|
||
router_list = tgen.routers() | ||
|
||
for _, (rname, router) in enumerate(router_list.items(), 1): | ||
router.load_frr_config(os.path.join(CWD, "{}/frr.conf".format(rname))) | ||
|
||
tgen.start_router() | ||
|
||
|
||
def teardown_module(mod): | ||
tgen = get_topogen() | ||
tgen.stop_topology() | ||
|
||
|
||
def test_bgp_conditional_advertisements_static_route(): | ||
tgen = get_topogen() | ||
|
||
if tgen.routers_have_failure(): | ||
pytest.skip(tgen.errors) | ||
|
||
r2 = tgen.gears["r2"] | ||
|
||
def _bgp_converge(): | ||
output = json.loads( | ||
r2.vtysh_cmd( | ||
"show bgp ipv4 unicast neighbor 192.168.1.1 advertised-routes json" | ||
) | ||
) | ||
expected = { | ||
"advertisedRoutes": { | ||
"10.10.10.1/32": { | ||
"valid": True, | ||
} | ||
}, | ||
"totalPrefixCounter": 1, | ||
} | ||
return topotest.json_cmp(output, expected) | ||
|
||
test_func = functools.partial( | ||
_bgp_converge, | ||
) | ||
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1) | ||
assert result is None, "Can't converge" | ||
|
||
step("Append prefix-list to advertise 10.10.10.2/32") | ||
|
||
r2.vtysh_cmd( | ||
""" | ||
configure terminal | ||
ip prefix-list advertise seq 10 permit 10.10.10.2/32 | ||
""" | ||
) | ||
|
||
def _bgp_check_advertised_after_update(): | ||
output = json.loads( | ||
r2.vtysh_cmd( | ||
"show bgp ipv4 unicast neighbor 192.168.1.1 advertised-routes json" | ||
) | ||
) | ||
expected = { | ||
"advertisedRoutes": { | ||
"10.10.10.1/32": { | ||
"valid": True, | ||
}, | ||
"10.10.10.2/32": { | ||
"valid": True, | ||
}, | ||
}, | ||
"totalPrefixCounter": 2, | ||
} | ||
return topotest.json_cmp(output, expected) | ||
|
||
test_func = functools.partial( | ||
_bgp_check_advertised_after_update, | ||
) | ||
_, result = topotest.run_and_expect(test_func, None, count=30, wait=1) | ||
assert result is None, "10.10.10.2/32 is not advertised after prefix-list update" | ||
|
||
|
||
if __name__ == "__main__": | ||
args = ["-s"] + sys.argv[1:] | ||
sys.exit(pytest.main(args)) |