diff --git a/src/bgp/bgp_xmpp_channel.cc b/src/bgp/bgp_xmpp_channel.cc index 8672572766e..68ebd4da775 100644 --- a/src/bgp/bgp_xmpp_channel.cc +++ b/src/bgp/bgp_xmpp_channel.cc @@ -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]); diff --git a/src/bgp/test/bgp_xmpp_parse_test.cc b/src/bgp/test/bgp_xmpp_parse_test.cc index 8ae56baa41a..7c74936d3cb 100644 --- a/src/bgp/test/bgp_xmpp_parse_test.cc +++ b/src/bgp/test/bgp_xmpp_parse_test.cc @@ -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"); diff --git a/src/bgp/testdata/bad_mcast_item_12.xml b/src/bgp/testdata/bad_mcast_item_12.xml new file mode 100644 index 00000000000..0cc742aed13 --- /dev/null +++ b/src/bgp/testdata/bad_mcast_item_12.xml @@ -0,0 +1,27 @@ + + + + 1 + 241 + 255.255.255.255 + 10.1.1.1 + + + + 1 +
192.168.1.1
+ + + gre + +
+
+ 1 + + 0 + + 7999998> + + 100 +
+
diff --git a/src/bgp/testdata/bad_mcast_item_13.xml b/src/bgp/testdata/bad_mcast_item_13.xml new file mode 100644 index 00000000000..5356fb36199 --- /dev/null +++ b/src/bgp/testdata/bad_mcast_item_13.xml @@ -0,0 +1,27 @@ + + + + 1 + 241 + 255.255.255.255 + 10.1.1.1 + + + + 1 +
192.168.1.1
+ + + gre + +
+
+ 1 + + 0 + + 7999998> + + 100 +
+
diff --git a/src/bgp/testdata/bad_mcast_item_14.xml b/src/bgp/testdata/bad_mcast_item_14.xml new file mode 100644 index 00000000000..efd972c565c --- /dev/null +++ b/src/bgp/testdata/bad_mcast_item_14.xml @@ -0,0 +1,27 @@ + + + + 1 + 241 + 255.255.255.255 + 10.1.1.1 + + + + 1 +
192.168.1.1
+ + + gre + +
+
+ 1 + + 0 + + 7999998> + + 100 +
+