Skip to content

Commit

Permalink
Merge "Source IP in tunnel NH of mcast route is zero in Tor-agent" in…
Browse files Browse the repository at this point in the history
…to R2.20
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jun 23, 2015
2 parents ef36bf4 + a42d742 commit 7b67fe3
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/vnsw/agent/oper/agent_path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,15 @@ bool AgentPath::UpdateTunnelType(Agent *agent, const AgentRoute *sync_route) {
}
if (nh_.get() && nh_->GetType() == NextHop::TUNNEL) {
DBRequest nh_req(DBRequest::DB_ENTRY_ADD_CHANGE);
const TunnelNH *tunnel_nh = static_cast<const TunnelNH*>(nh_.get());
TunnelNHKey *tnh_key =
new TunnelNHKey(agent->fabric_vrf_name(), agent->router_id(),
new TunnelNHKey(agent->fabric_vrf_name(), *(tunnel_nh->GetSip()),
tunnel_dest_, false, tunnel_type_);
nh_req.key.reset(tnh_key);
nh_req.data.reset(new TunnelNHData());
agent->nexthop_table()->Process(nh_req);

TunnelNHKey nh_key(agent->fabric_vrf_name(), agent->router_id(),
TunnelNHKey nh_key(agent->fabric_vrf_name(), *(tunnel_nh->GetSip()),
tunnel_dest_, false, tunnel_type_);
NextHop *nh = static_cast<NextHop *>
(agent->nexthop_table()->FindActiveEntry(&nh_key));
Expand Down
54 changes: 45 additions & 9 deletions src/vnsw/agent/oper/bridge_route.cc
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ void BridgeAgentRouteTable::AddBridgeRoute(const AgentRoute *rt) {
BridgeTableProcess(agent(), vrf_name(), req);
}

void BridgeAgentRouteTable::AddOvsPeerMulticastRoute(const Peer *peer,
uint32_t vxlan_id,
const std::string &vn_name,
Ip4Address tsn,
Ip4Address tor_ip) {
void BridgeAgentRouteTable::AddOvsPeerMulticastRouteInternal(const Peer *peer,
uint32_t vxlan_id,
const std::string &vn_name,
Ip4Address tsn,
Ip4Address tor_ip,
bool enqueue) {
const VrfEntry *vrf = vrf_entry();
DBRequest nh_req(DBRequest::DB_ENTRY_ADD_CHANGE);
nh_req.key.reset(new TunnelNHKey(vrf->GetName(), tsn, tor_ip,
Expand All @@ -148,9 +149,29 @@ void BridgeAgentRouteTable::AddOvsPeerMulticastRoute(const Peer *peer,
req.data.reset(new MulticastRoute(vn_name, 0, vxlan_id,
TunnelType::VxlanType(),
nh_req, Composite::L2COMP));
BridgeTableProcess(agent(), vrf_name(), req);
if (enqueue) {
BridgeTableEnqueue(agent(), &req);
} else {
BridgeTableProcess(agent(), vrf_name(), req);
}
}

void BridgeAgentRouteTable::AddOvsPeerMulticastRoute(const Peer *peer,
uint32_t vxlan_id,
const std::string &vn_name,
Ip4Address tsn,
Ip4Address tor_ip) {
AddOvsPeerMulticastRouteInternal(peer, vxlan_id, vn_name, tsn, tor_ip, false);
}

void BridgeAgentRouteTable::AddOvsPeerMulticastRouteReq(const Peer *peer,
uint32_t vxlan_id,
const std::string &vn_name,
Ip4Address tsn,
Ip4Address tor_ip) {
AddOvsPeerMulticastRouteInternal(peer, vxlan_id, vn_name, tsn, tor_ip, true);
}

void BridgeAgentRouteTable::AddMacVmBindingRoute(const Peer *peer,
const std::string &vrf_name,
const MacAddress &mac,
Expand Down Expand Up @@ -200,16 +221,31 @@ void BridgeAgentRouteTable::Delete(const Peer *peer, const string &vrf_name,
BridgeTableProcess(Agent::GetInstance(), vrf_name, req);
}

void BridgeAgentRouteTable::DeleteOvsPeerMulticastRoute(const Peer *peer,
uint32_t vxlan_id) {
void BridgeAgentRouteTable::DeleteOvsPeerMulticastRouteInternal(const Peer *peer,
uint32_t vxlan_id,
bool enqueue) {
const VrfEntry *vrf = vrf_entry();
DBRequest req(DBRequest::DB_ENTRY_DELETE);
req.key.reset(new BridgeRouteKey(peer,
vrf->GetName(),
MacAddress::BroadcastMac(),
vxlan_id));
req.data.reset(NULL);
BridgeTableProcess(agent(), vrf->GetName(), req);
if (enqueue) {
BridgeTableEnqueue(agent(), &req);
} else {
BridgeTableProcess(agent(), vrf->GetName(), req);
}
}

void BridgeAgentRouteTable::DeleteOvsPeerMulticastRouteReq(const Peer *peer,
uint32_t vxlan_id) {
DeleteOvsPeerMulticastRouteInternal(peer, vxlan_id, true);
}

void BridgeAgentRouteTable::DeleteOvsPeerMulticastRoute(const Peer *peer,
uint32_t vxlan_id) {
DeleteOvsPeerMulticastRouteInternal(peer, vxlan_id, false);
}

void BridgeAgentRouteTable::AddBridgeBroadcastRoute(const Peer *peer,
Expand Down
17 changes: 17 additions & 0 deletions src/vnsw/agent/oper/bridge_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class BridgeAgentRouteTable : public AgentRouteTable {
const std::string &vn_name,
Ip4Address vtep,
Ip4Address tor_ip);
void AddOvsPeerMulticastRouteReq(const Peer* peer,
uint32_t vxlan_id,
const std::string &vn_name,
Ip4Address vtep,
Ip4Address tor_ip);
void AddBridgeRoute(const AgentRoute *rt);
static void AddBridgeBroadcastRoute(const Peer *peer,
const std::string &vrf_name,
Expand Down Expand Up @@ -65,6 +70,8 @@ class BridgeAgentRouteTable : public AgentRouteTable {
uint32_t ethernet_tag,
COMPOSITETYPE type);
void DeleteBridgeRoute(const AgentRoute *rt);
void DeleteOvsPeerMulticastRouteReq(const Peer *peer,
uint32_t vxlan_id);
void DeleteOvsPeerMulticastRoute(const Peer *peer,
uint32_t vxlan_id);
void DeleteMacVmBindingRoute(const Peer *peer,
Expand All @@ -75,6 +82,16 @@ class BridgeAgentRouteTable : public AgentRouteTable {
BridgeRouteEntry *FindRoute(const MacAddress &mac);

private:
void AddOvsPeerMulticastRouteInternal(const Peer* peer,
uint32_t vxlan_id,
const std::string &vn_name,
Ip4Address vtep,
Ip4Address tor_ip,
bool enqueue);
void DeleteOvsPeerMulticastRouteInternal(const Peer *peer,
uint32_t vxlan_id,
bool enqueue);

DBTableWalker::WalkId walkid_;
DISALLOW_COPY_AND_ASSIGN(BridgeAgentRouteTable);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,66 @@ TEST_F(OvsBaseTest, MulticastLocal_on_del_vrf_vn_link) {
WAIT_FOR(1000, 10000, (VnGet(1) == NULL));
}

TEST_F(OvsBaseTest, tunnel_nh_ovs_multicast) {
IpAddress server = Ip4Address::from_string("1.1.1.1");
OvsPeer *peer = peer_manager_->Allocate(server);
EXPECT_TRUE(peer->export_to_controller());

AddEncapList("MPLSoUDP", "VXLAN", NULL);
client->WaitForIdle();
VrfAddReq("vrf1");
WAIT_FOR(100, 10000, (VrfGet("vrf1", false) != NULL));
VnAddReq(1, "vn1", "vrf1");
WAIT_FOR(100, 10000, (VnGet(1) != NULL));

MacAddress mac("ff:ff:ff:ff:ff:ff");
Ip4Address tor_ip = Ip4Address::from_string("111.111.111.111");
Ip4Address tsn_ip = Ip4Address::from_string("127.0.0.1");

VrfEntry *vrf = VrfGet("vrf1");
BridgeAgentRouteTable *table = static_cast<BridgeAgentRouteTable *>
(vrf->GetBridgeRouteTable());
WAIT_FOR(100, 100, (vrf->GetBridgeRouteTable() != NULL));
table->AddOvsPeerMulticastRouteReq(peer, 100, "dummy", tsn_ip, tor_ip);
WAIT_FOR(1000, 100, (L2RouteGet("vrf1", mac) != NULL));
client->WaitForIdle();

BridgeRouteEntry *rt = L2RouteGet("vrf1", mac);
const AgentPath *path = rt->GetActivePath();
EXPECT_TRUE(path->tunnel_dest() == tor_ip);
const TunnelNH *nh = dynamic_cast<const TunnelNH *>(rt->GetActiveNextHop());
EXPECT_TRUE(nh != NULL);
EXPECT_TRUE(*nh->GetDip() == tor_ip);
EXPECT_TRUE(*nh->GetSip() == tsn_ip);

AddEncapList("MPLSoUDP", NULL, NULL);
client->WaitForIdle();
WAIT_FOR(1000, 100, (L2RouteGet("vrf1", mac) != NULL));

rt = L2RouteGet("vrf1", mac);
path = rt->GetActivePath();
EXPECT_TRUE(path->tunnel_dest() == tor_ip);
nh = dynamic_cast<const TunnelNH *>(rt->GetActiveNextHop());
EXPECT_TRUE(nh != NULL);
EXPECT_TRUE(*nh->GetDip() == tor_ip);
EXPECT_TRUE(*nh->GetSip() == tsn_ip);

AddEncapList("MPLSoUDP", "VXLAN", NULL);
client->WaitForIdle();
WAIT_FOR(1000, 100, (L2RouteGet("vrf1", mac) != NULL));

table->DeleteOvsPeerMulticastRouteReq(peer, 100);
client->WaitForIdle();

// Change tunnel-type order
peer_manager_->Free(peer);
client->WaitForIdle();
VrfDelReq("vrf1");
VnDelReq(1);
WAIT_FOR(1000, 10000, (VrfGet("vrf1", true) == NULL));
WAIT_FOR(1000, 10000, (VnGet(1) == NULL));
}

int main(int argc, char *argv[]) {
GETUSERARGS();
// override with true to initialize ovsdb server and client
Expand Down

0 comments on commit 7b67fe3

Please sign in to comment.