Skip to content
Open
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_aspath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ bool aspath_firstas_check(struct aspath *aspath, as_t asno)

unsigned int aspath_get_first_as(struct aspath *aspath)
{
if (aspath == NULL || aspath->segments == NULL)
if (aspath == NULL || aspath->segments == NULL || aspath->segments->length == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we should release aspath->segments if the length is 0 (if we use replace as / remove as)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that point is pertinent. i will study the impact.

return 0;

return aspath->segments->as[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from lib import topotest
from lib.topogen import Topogen, TopoRouter, get_topogen
from functools import partial
from lib.topolog import logger

pytestmark = [pytest.mark.bgpd]

Expand Down Expand Up @@ -389,6 +390,44 @@ def _validate_paths(remove_type):
real_path = adj_rib_in["receivedRoutes"][pfx]["path"]
return real_path == good_path

def __no_crash():
output = json.loads(
tgen.gears["r2"].vtysh_cmd(
"show ip bgp neighbor 203.0.113.0 advertised-routes detail json"
)
)
logger.info(output)
logger.info(output["totalPrefixCounter"])
if output["totalPrefixCounter"] != 0:
return True
return False

def _crash_scenario():
"""add list of command making"""
tgen = get_topogen()
tgen.gears["r2"].vtysh_cmd(
"""
configure terminal
route-map OLDCORE-INTERNET-IN-IPv4 permit 5
set as-path replace any 65398
exit
route-map OLDCORE-INTERNET-OUT-IPv4 permit 5
set as-path replace any 65399
exit
router bgp 65002
bgp deterministic-med
address-family ipv4 unicast
neighbor 203.0.113.0 remove-private-AS all
neighbor 203.0.113.0 soft-reconfiguration inbound
neighbor 203.0.113.0 route-map OLDCORE-INTERNET-IN-IPv4 in
neighbor 203.0.113.0 route-map OLDCORE-INTERNET-OUT-IPv4 out
exit-address-family
"""
)
test_func = partial(__no_crash)
_, result = topotest.run_and_expect(test_func, True, count=60, wait=0.5)
assert result == True, "bgpd may has major failure"

#######################
# Begin Test
#######################
Expand All @@ -408,6 +447,13 @@ def _validate_paths(remove_type):
# the old flag after each iteration so we only test the flags we expect.
_change_remove_type(rmv_type, "del")

# verify that nulled as_path don't make a crash.
_change_remove_type("remove-private-AS all", "add")
_crash_scenario()


exit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftovers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up



if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
Expand Down
Loading