Skip to content

Commit

Permalink
Merge "Drop multicast routes associated with invalid label range"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Aug 19, 2016
2 parents 1e0b9cc + ee328e7 commit 21657ae
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/bgp/bgp_xmpp_channel.cc
Expand Up @@ -1128,6 +1128,14 @@ bool BgpXmppChannel::ProcessMcastItem(string vrf_name,
return false;
}

if (!labels[0] || !labels[1] || labels[1] < labels[0]) {
BGP_LOG_PEER_INSTANCE(Peer(), vrf_name,
SandeshLevel::SYS_WARN, BGP_LOG_FLAG_ALL,
"Bad label range " << label_range <<
" for multicast route " << mc_prefix.ToString());
return false;
}

BgpAttrSpec attrs;
LabelBlockPtr lbptr = lb_mgr_->LocateBlock(labels[0], labels[1]);

Expand Down
24 changes: 24 additions & 0 deletions src/bgp/test/bgp_xmpp_parse_test.cc
Expand Up @@ -336,6 +336,30 @@ TEST_F(BgpXmppParseTest, McastItemError11) {
EXPECT_FALSE(ProcessMcastItem(item));
}

// Error in nexthop label with min label as 0
TEST_F(BgpXmppParseTest, McastItemError12) {
string data = FileRead("controller/src/bgp/testdata/bad_mcast_item_12.xml");
impl_->LoadDoc(data);
xml_node item = pugi_->FindNode("item");
EXPECT_FALSE(ProcessMcastItem(item));
}

// Error in nexthop label with both labels as 0
TEST_F(BgpXmppParseTest, McastItemError13) {
string data = FileRead("controller/src/bgp/testdata/bad_mcast_item_13.xml");
impl_->LoadDoc(data);
xml_node item = pugi_->FindNode("item");
EXPECT_FALSE(ProcessMcastItem(item));
}

// Error in nexthop label with right label in the range less then left label
TEST_F(BgpXmppParseTest, McastItemError14) {
string data = FileRead("controller/src/bgp/testdata/bad_mcast_item_14.xml");
impl_->LoadDoc(data);
xml_node item = pugi_->FindNode("item");
EXPECT_FALSE(ProcessMcastItem(item));
}

// Error in parsing message, XML document is fine.
TEST_F(BgpXmppParseTest, EnetItemError1) {
string data = FileRead("controller/src/bgp/testdata/bad_enet_item_1.xml");
Expand Down
27 changes: 27 additions & 0 deletions src/bgp/testdata/bad_mcast_item_12.xml
@@ -0,0 +1,27 @@
<item>
<entry>
<nlri>
<af>1</af>
<safi>241</safi>
<group>255.255.255.255</group>
<source>10.1.1.1</source>
</nlri>
<next-hops>
<next-hop>
<af>1</af>
<address>192.168.1.1</address>
<label>0-20000</label> <!-- XXXXXXXXXXXXXXX -->
<tunnel-encapsulation-list>
<tunnel-encapsulation>gre</tunnel-encapsulation>
</tunnel-encapsulation-list>
</next-hop>
</next-hops>
<version>1</version>
<virtual-network></virtual-network>
<sequence-number>0</sequence-number>
<security-group-list>
<security-group>7999998</security-group>>
</security-group-list>
<local-preference>100</local-preference>
</entry>
</item>
27 changes: 27 additions & 0 deletions src/bgp/testdata/bad_mcast_item_13.xml
@@ -0,0 +1,27 @@
<item>
<entry>
<nlri>
<af>1</af>
<safi>241</safi>
<group>255.255.255.255</group>
<source>10.1.1.1</source>
</nlri>
<next-hops>
<next-hop>
<af>1</af>
<address>192.168.1.1</address>
<label>0-0</label> <!-- XXXXXXXXXXXXXXX -->
<tunnel-encapsulation-list>
<tunnel-encapsulation>gre</tunnel-encapsulation>
</tunnel-encapsulation-list>
</next-hop>
</next-hops>
<version>1</version>
<virtual-network></virtual-network>
<sequence-number>0</sequence-number>
<security-group-list>
<security-group>7999998</security-group>>
</security-group-list>
<local-preference>100</local-preference>
</entry>
</item>
27 changes: 27 additions & 0 deletions src/bgp/testdata/bad_mcast_item_14.xml
@@ -0,0 +1,27 @@
<item>
<entry>
<nlri>
<af>1</af>
<safi>241</safi>
<group>255.255.255.255</group>
<source>10.1.1.1</source>
</nlri>
<next-hops>
<next-hop>
<af>1</af>
<address>192.168.1.1</address>
<label>30000-20000</label> <!-- XXXXXXXXXXXXXXX -->
<tunnel-encapsulation-list>
<tunnel-encapsulation>gre</tunnel-encapsulation>
</tunnel-encapsulation-list>
</next-hop>
</next-hops>
<version>1</version>
<virtual-network></virtual-network>
<sequence-number>0</sequence-number>
<security-group-list>
<security-group>7999998</security-group>>
</security-group-list>
<local-preference>100</local-preference>
</entry>
</item>

0 comments on commit 21657ae

Please sign in to comment.