Skip to content

Commit

Permalink
Handle NULL AsPaths during remove-private processing
Browse files Browse the repository at this point in the history
Change-Id: Ief5a66f266bd6accb7d99e0d06633bf98445e4f7
Closes-Bug: 1697530
  • Loading branch information
Nischal Sheth committed Jun 13, 2017
1 parent 12f282c commit cc5e1b9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/bgp/bgp_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ void BgpTable::ProcessRemovePrivate(const RibOut *ribout, BgpAttr *attr) const {
return;
if (!ribout->remove_private_enabled())
return;
if (!attr->as_path())
return;

bool all = ribout->remove_private_all();
bool replace = ribout->remove_private_replace();
Expand Down
46 changes: 42 additions & 4 deletions src/bgp/test/bgp_table_export_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,48 @@ TEST_P(BgpTableExportParamTest2, EBgpStripNonTransitive) {
VerifyAttrNoClusterList();
}

//
// Table : inet.0, bgp.l3vpn.0
// Source: iBGP (effectively XMPP since AsPath is NULL)
// RibOut: eBGP
// Intent: Remove private all is handled gracefully when AsPath is empty.
//
TEST_P(BgpTableExportParamTest2, RemovePrivateAll1) {
RibExportPolicy policy(
BgpProto::EBGP, RibExportPolicy::BGP, 300, false, false, -1, 0);
bool all = true; bool replace = false; bool peer_loop_check = true;
policy.SetRemovePrivatePolicy(all, replace, peer_loop_check);
CreateRibOut(policy);
ResetAttrAsPath();
AddPath();
RunExport();
VerifyExportAccept();
VerifyAttrAsPrepend();
VerifyAttrAsPathCount(1);
VerifyAttrAsPathAsCount(LocalAsNumber(), 1);
}

//
// Table : inet.0, bgp.l3vpn.0
// Source: iBGP
// RibOut: eBGP
// Intent: Remove private all is handled gracefully when AsPath has no
// segments.
//
TEST_P(BgpTableExportParamTest2, RemovePrivateAll2) {
RibExportPolicy policy(
BgpProto::EBGP, RibExportPolicy::BGP, 300, false, false, -1, 0);
bool all = true; bool replace = false; bool peer_loop_check = true;
policy.SetRemovePrivatePolicy(all, replace, peer_loop_check);
CreateRibOut(policy);
AddPath();
RunExport();
VerifyExportAccept();
VerifyAttrAsPrepend();
VerifyAttrAsPathCount(1);
VerifyAttrAsPathAsCount(LocalAsNumber(), 1);
}

INSTANTIATE_TEST_CASE_P(Instance, BgpTableExportParamTest2,
::testing::Values("inet.0", "bgp.l3vpn.0"));

Expand Down Expand Up @@ -1110,8 +1152,6 @@ TEST_P(BgpTableExportParamTest3, RemovePrivateAllReplace1) {
// Table : inet.0, bgp.l3vpn.0
// Source: eBGP
// RibOut: iBGP
// Intent: Remove private all (w/ replace) replaces all private ASes.
// first public AS.
// Intent: Remove private all (w/ replace) replaces all private ASes. All
// private ASes up to the first public AS are replaced with the
// leftmost public as. Remaining private ASes are replaced with the
Expand Down Expand Up @@ -1140,8 +1180,6 @@ TEST_P(BgpTableExportParamTest3, RemovePrivateAllReplace2) {
// Table : inet.0, bgp.l3vpn.0
// Source: eBGP
// RibOut: iBGP
// Intent: Remove private all (w/ replace) replaces all private ASes.
// first public AS.
// Intent: Remove private all (w/ replace) replaces all private ASes. All
// private ASes up to the first public AS are replaced with the
// leftmost public as. Remaining private ASes are replaced with the
Expand Down

0 comments on commit cc5e1b9

Please sign in to comment.