Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: fix as-path exclude modify crash #16779

Merged
merged 4 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bgpd/bgp_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,7 @@ static void route_aspath_exclude_free(void *rule)
if (ase->exclude_aspath_acl) {
acl = ase->exclude_aspath_acl;
as_list_list_del(&acl->exclude_rule, ase);
} else {
} else if (ase->exclude_aspath_acl_name) {
/* no ref to acl, this aspath exclude is orphan */
as_exclude_remove_orphan(ase);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_bgp_set_aspath_exclude():
pytest.skip(tgen.errors)

test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_1)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)

assert result is None, "Failed overriding incoming AS-PATH with route-map"

Expand All @@ -128,7 +128,6 @@ def test_bgp_set_aspath_exclude_access_list():
conf
bgp as-path access-list FIRST permit ^65
route-map r2 permit 6
no set as-path exclude as-path-access-list SECOND
set as-path exclude as-path-access-list FIRST
"""
)
Expand All @@ -140,21 +139,20 @@ def test_bgp_set_aspath_exclude_access_list():
)

test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_2)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)

assert result is None, "Failed change of exclude rule in route map"
r1.vtysh_cmd(
"""
conf
route-map r2 permit 6
no set as-path exclude as-path-access-list FIRST
set as-path exclude as-path-access-list SECOND
"""
)

# tgen.mininet_cli()
test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_1)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)

assert result is None, "Failed reverting exclude rule in route map"

Expand Down Expand Up @@ -182,7 +180,7 @@ def test_no_bgp_set_aspath_exclude_access_list():
)

test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_3)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)

assert result is None, "Failed to removing current accesslist"

Expand All @@ -200,15 +198,15 @@ def test_no_bgp_set_aspath_exclude_access_list():
)

test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_4)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)

assert result is None, "Failed to renegotiate with peers 2"

r1.vtysh_cmd(
"""
conf
route-map r2 permit 6
no set as-path exclude as-path-access-list SECOND
set as-path exclude 65555
"""
)

Expand All @@ -219,7 +217,26 @@ def test_no_bgp_set_aspath_exclude_access_list():
)

test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_3)
_, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)

assert result is None, "Failed to renegotiate with peers 2"

r1.vtysh_cmd(
"""
conf
route-map r2 permit 6
set as-path exclude as-path-access-list NON-EXISTING
"""
)

r1.vtysh_cmd(
"""
clear bgp *
"""
)

test_func = functools.partial(bgp_converge, tgen.gears["r1"], expected_3)
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)

assert result is None, "Failed to renegotiate with peers 2"

Expand Down
Loading