Skip to content

Commit

Permalink
Merge "Fix algorithm to identify l3 packets"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jan 13, 2015
2 parents da577fd + df6d0e6 commit 6a1d132
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 19 deletions.
25 changes: 17 additions & 8 deletions src/vnsw/agent/init/contrail_init_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ void ContrailInitCommon::CreateInterfaces() {
agent()->fabric_vrf_name(),
PhysicalInterface::FABRIC, type,
agent_param()->eth_port_no_arp(), nil_uuid());
PhysicalInterfaceKey physical_key(agent()->fabric_interface_name());
assert(table->FindActiveEntry(&physical_key));

InetInterface::Create(table, agent_param()->vhost_name(),
InetInterface::VHOST, agent()->fabric_vrf_name(),
Expand All @@ -167,6 +169,21 @@ void ContrailInitCommon::CreateInterfaces() {
agent_param()->vhost_gw(),
agent_param()->eth_port(),
agent()->fabric_vn_name());
InetInterfaceKey key(agent()->vhost_interface_name());
agent()->set_vhost_interface
(static_cast<Interface *>(table->FindActiveEntry(&key)));
assert(agent()->vhost_interface());

// Add L2 Receive route for vhost. We normally add L2 Receive route on
// VRF creation, but vhost is not present when fabric-vrf is created.
// So, add it now
EvpnAgentRouteTable *l2_table = agent()->fabric_l2_unicast_table();
const InetInterface *vhost = static_cast<const InetInterface *>
(agent()->vhost_interface());
l2_table->AddEvpnReceiveRoute(agent()->local_vm_peer(),
agent()->fabric_vrf_name(), 0,
vhost->xconnect()->mac(), "");

agent()->InitXenLinkLocalIntf();
if (agent_param()->isVmwareMode()) {
PhysicalInterface::Create(agent()->interface_table(),
Expand All @@ -177,14 +194,6 @@ void ContrailInitCommon::CreateInterfaces() {
nil_uuid());
}

InetInterfaceKey key(agent()->vhost_interface_name());
agent()->set_vhost_interface
(static_cast<Interface *>(table->FindActiveEntry(&key)));
assert(agent()->vhost_interface());

PhysicalInterfaceKey physical_key(agent()->fabric_interface_name());
assert(table->FindActiveEntry(&physical_key));

agent()->set_router_id(agent_param()->vhost_addr());
agent()->set_vhost_prefix_len(agent_param()->vhost_plen());
agent()->set_vhost_default_gateway(agent_param()->vhost_gw());
Expand Down
36 changes: 25 additions & 11 deletions src/vnsw/agent/pkt/pkt_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,38 @@ void PktHandler::HandleRcvPkt(const AgentHdr &hdr, const PacketBufferPtr &buff){
// Compute L2/L3 forwarding mode for pacekt.
// Forwarding mode is L3 if,
// - Packet uses L3 label
// - Packet uses L2 Label and DMAC matches VRRP-MAC or VHOST-MAC
// - Packet uses L2 Label and DMAC hits a route with L2-Receive NH
// Else forwarding mode is L2
void PktHandler::ComputeForwardingMode(PktInfo *pkt_info) const {
pkt_info->l3_forwarding = true;
if (pkt_info->l3_label) {
pkt_info->l3_forwarding = true;
return;
}

if (agent_->vhost_interface()) {
if (pkt_info->dmac != agent_->vrrp_mac() &&
pkt_info->dmac != agent_->vhost_interface()->mac()) {
pkt_info->l3_forwarding = false;
}
} else {
if (pkt_info->dmac != agent_->vrrp_mac()) {
pkt_info->l3_forwarding = false;
}
pkt_info->l3_forwarding = false;
VrfTable *table = static_cast<VrfTable *>(agent_->vrf_table());
VrfEntry *vrf = table->FindVrfFromId(pkt_info->agent_hdr.vrf);
if (vrf == NULL) {
return;
}
EvpnAgentRouteTable *l2_table = static_cast<EvpnAgentRouteTable *>
(vrf->GetEvpnRouteTable());
AgentRoute *rt = static_cast<AgentRoute *>
(l2_table->FindRoute(agent_, vrf->GetName(), pkt_info->dmac,
IpAddress()));
if (rt == NULL) {
return;
}

const NextHop *nh = rt->GetActiveNextHop();
if (nh == NULL) {
return;
}

if (nh->GetType() == NextHop::L2_RECEIVE) {
pkt_info->l3_forwarding = true;
}
return;
}

void PktHandler::SetOuterIp(PktInfo *pkt_info, uint8_t *pkt) {
Expand Down

0 comments on commit 6a1d132

Please sign in to comment.