Skip to content

Commit

Permalink
Fix interop issue for EVPN w/ MPLS in GRE encapsulation
Browse files Browse the repository at this point in the history
Current version of EVPN overlay draft says to use MPLSoGRE codepoint,
whereas Contrail uses GRE. This results in interop issues with other
implementations.

The justification for definining a new code point for MPLSoGRE is not
clear. In the intrest of improving interoperability, advertise both GRE
and MPLSoGRE for EVPN routes and map both GRE and MPLSoGRE to the same
string value when advertising routes via xmpp.

Change-Id: I6d01053de225c8058756f9d76682164b6499352e
Closes-Bug: 1588554
  • Loading branch information
Nischal Sheth committed Jun 3, 2016
1 parent 49f6637 commit 06b8bb0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/bgp/bgp_xmpp_channel.cc
Expand Up @@ -1614,9 +1614,19 @@ bool BgpXmppChannel::ProcessEnetItem(string vrf_name,
if (first_nh) {
ext.communities.push_back(
tun_encap.GetExtCommunityValue());
if (tun_encap.tunnel_encap() == TunnelEncapType::GRE) {
TunnelEncap alt_tun_encap(TunnelEncapType::MPLS_O_GRE);
ext.communities.push_back(
alt_tun_encap.GetExtCommunityValue());
}
}
nexthop.tunnel_encapsulations_.push_back(
tun_encap.GetExtCommunity());
if (tun_encap.tunnel_encap() == TunnelEncapType::GRE) {
TunnelEncap alt_tun_encap(TunnelEncapType::MPLS_O_GRE);
nexthop.tunnel_encapsulations_.push_back(
alt_tun_encap.GetExtCommunity());
}
}

// Mark the path as infeasible if all tunnel encaps published
Expand Down
26 changes: 21 additions & 5 deletions src/bgp/tunnel_encap/test/tunnel_encap_test.cc
Expand Up @@ -13,7 +13,7 @@ class TunnelEncapTest : public ::testing::Test {

TEST_F(TunnelEncapTest, String_1) {
TunnelEncap tunnel_encap("gre");
EXPECT_EQ(TunnelEncapType::MPLS_O_GRE, tunnel_encap.tunnel_encap());
EXPECT_EQ(TunnelEncapType::GRE, tunnel_encap.tunnel_encap());
EXPECT_EQ("encapsulation:gre", tunnel_encap.ToString());
EXPECT_EQ("gre", tunnel_encap.ToXmppString());
}
Expand Down Expand Up @@ -74,10 +74,17 @@ TEST_F(TunnelEncapTest, String_7) {
EXPECT_EQ("vxlan-gpe", tunnel_encap.ToXmppString());
}

TEST_F(TunnelEncapTest, EncapType_1) {
TEST_F(TunnelEncapTest, EncapType_1a) {
TunnelEncap tunnel_encap(TunnelEncapType::GRE);
EXPECT_EQ(TunnelEncapType::GRE, tunnel_encap.tunnel_encap());
EXPECT_EQ("encapsulation:gre", tunnel_encap.ToString());
EXPECT_EQ("gre", tunnel_encap.ToXmppString());
}

TEST_F(TunnelEncapTest, EncapType_1b) {
TunnelEncap tunnel_encap(TunnelEncapType::MPLS_O_GRE);
EXPECT_EQ(TunnelEncapType::MPLS_O_GRE, tunnel_encap.tunnel_encap());
EXPECT_EQ("encapsulation:gre", tunnel_encap.ToString());
EXPECT_EQ("encapsulation:mpls-o-gre", tunnel_encap.ToString());
EXPECT_EQ("gre", tunnel_encap.ToXmppString());
}

Expand Down Expand Up @@ -136,15 +143,24 @@ TEST_F(TunnelEncapTest, EncapType_7) {
EXPECT_EQ("vxlan-gpe", tunnel_encap.ToXmppString());
}

TEST_F(TunnelEncapTest, ByteArray_1) {
TEST_F(TunnelEncapTest, ByteArray_1a) {
TunnelEncap::bytes_type data =
{ { 0x03, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02 } };
TunnelEncap tunnel_encap(data);
EXPECT_EQ(TunnelEncapType::MPLS_O_GRE, tunnel_encap.tunnel_encap());
EXPECT_EQ(TunnelEncapType::GRE, tunnel_encap.tunnel_encap());
EXPECT_EQ("encapsulation:gre", tunnel_encap.ToString());
EXPECT_EQ("gre", tunnel_encap.ToXmppString());
}

TEST_F(TunnelEncapTest, ByteArray_1b) {
TunnelEncap::bytes_type data =
{ { 0x03, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B } };
TunnelEncap tunnel_encap(data);
EXPECT_EQ(TunnelEncapType::MPLS_O_GRE, tunnel_encap.tunnel_encap());
EXPECT_EQ("encapsulation:mpls-o-gre", tunnel_encap.ToString());
EXPECT_EQ("gre", tunnel_encap.ToXmppString());
}

TEST_F(TunnelEncapTest, ByteArray_2a) {
TunnelEncap::bytes_type data =
{ { 0x03, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d } };
Expand Down
8 changes: 5 additions & 3 deletions src/net/tunnel_encap_type.cc
Expand Up @@ -15,7 +15,7 @@ TunnelEncapType::TunnelEncapType() {
static const map<string, TunnelEncapType::Encap>
fromString = boost::assign::map_list_of
("unspecified", TunnelEncapType::UNSPEC)
("gre", TunnelEncapType::MPLS_O_GRE)
("gre", TunnelEncapType::GRE)
("vxlan", TunnelEncapType::VXLAN)
("nvgre", TunnelEncapType::NVGRE)
("mpls", TunnelEncapType::MPLS)
Expand All @@ -27,10 +27,11 @@ static const map<string, TunnelEncapType::Encap>
static const map<TunnelEncapType::Encap, string>
toString = boost::assign::map_list_of
(TunnelEncapType::UNSPEC, "unspecified")
(TunnelEncapType::MPLS_O_GRE, "gre")
(TunnelEncapType::GRE, "gre")
(TunnelEncapType::VXLAN, "vxlan")
(TunnelEncapType::NVGRE, "nvgre")
(TunnelEncapType::MPLS, "mpls")
(TunnelEncapType::MPLS_O_GRE, "mpls-o-gre")
(TunnelEncapType::VXLAN_GPE, "vxlan-gpe")
(TunnelEncapType::MPLS_O_UDP, "udp")
(TunnelEncapType::MPLS_O_UDP_CONTRAIL, "udp-contrail")
Expand All @@ -39,10 +40,11 @@ static const map<TunnelEncapType::Encap, string>
static const map<TunnelEncapType::Encap, string>
toXmppString = boost::assign::map_list_of
(TunnelEncapType::UNSPEC, "unspecified")
(TunnelEncapType::MPLS_O_GRE, "gre")
(TunnelEncapType::GRE, "gre")
(TunnelEncapType::VXLAN, "vxlan")
(TunnelEncapType::NVGRE, "nvgre")
(TunnelEncapType::MPLS, "mpls")
(TunnelEncapType::MPLS_O_GRE, "gre")
(TunnelEncapType::VXLAN_GPE, "vxlan-gpe")
(TunnelEncapType::MPLS_O_UDP, "udp")
(TunnelEncapType::MPLS_O_UDP_CONTRAIL, "udp")
Expand Down
3 changes: 2 additions & 1 deletion src/net/tunnel_encap_type.h
Expand Up @@ -12,10 +12,11 @@ class TunnelEncapType {
public:
enum Encap {
UNSPEC = 0,
MPLS_O_GRE = 2,
GRE = 2,
VXLAN = 8,
NVGRE = 9,
MPLS = 10,
MPLS_O_GRE = 11,
VXLAN_GPE = 12,
MPLS_O_UDP = 13,
MPLS_O_UDP_CONTRAIL = 37001,
Expand Down

0 comments on commit 06b8bb0

Please sign in to comment.