Skip to content

Commit

Permalink
Merge "Do not consider flow trap packets for DHCP handling."
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed May 25, 2016
2 parents 1e490fd + 08c50ee commit 70b54be
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/vnsw/agent/pkt/pkt_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ PktHandler::PktModuleName PktHandler::ParsePacket(const AgentHdr &hdr,
Interface *intf = NULL;

pkt_info->agent_hdr = hdr;
agent_->stats()->incr_pkt_exceptions();
if (!IsValidInterface(hdr.ifindex, &intf)) {
return INVALID;
}
Expand All @@ -168,9 +167,10 @@ PktHandler::PktModuleName PktHandler::ParsePacket(const AgentHdr &hdr,

pkt_info->vrf = pkt_info->agent_hdr.vrf;

bool is_flow_packet = IsFlowPacket(pkt_info);
// Look for DHCP packets if corresponding service is enabled
// Service processing over-rides ACL/Flow and forwarding configuration
if (intf->dhcp_enabled() && (pkt_type == PktType::UDP)) {
if (!is_flow_packet && intf->dhcp_enabled() && (pkt_type == PktType::UDP)) {
if (pkt_info->ip && (pkt_info->dport == DHCP_SERVER_PORT ||
pkt_info->sport == DHCP_CLIENT_PORT)) {
return DHCP;
Expand Down Expand Up @@ -204,7 +204,7 @@ PktHandler::PktModuleName PktHandler::ParsePacket(const AgentHdr &hdr,
}

// Packets needing flow
if (IsFlowPacket(pkt_info)) {
if (is_flow_packet) {
CalculatePort(pkt_info);
if ((pkt_info->ip && pkt_info->family == Address::INET) ||
(pkt_info->ip6 && pkt_info->family == Address::INET6)) {
Expand Down Expand Up @@ -270,6 +270,7 @@ void PktHandler::HandleRcvPkt(const AgentHdr &hdr, const PacketBufferPtr &buff){
}

bool PktHandler::ProcessPacket(boost::shared_ptr<PacketBufferEnqueueItem> item) {
agent_->stats()->incr_pkt_exceptions();
const AgentHdr &hdr = item->hdr;
const PacketBufferPtr &buff = item->buff;
boost::shared_ptr<PktInfo> pkt_info (new PktInfo(buff));
Expand Down
25 changes: 25 additions & 0 deletions src/vnsw/agent/pkt/test/test_pkt_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,31 @@ TEST_F(PktParseTest, IPv6_Invalid_GRE_On_Enet_1) {
delete pkt;
}

// check that flow UDP packet with DHCP port is not enqueued to DHCP
TEST_F(PktParseTest, FlowOverridesDHCP) {
unsigned int dhcp_count = GetPktModuleCount(PktHandler::DHCP);
unsigned int flow_count = GetPktModuleCount(PktHandler::FLOW);
unsigned int invalid_count = GetPktModuleCount(PktHandler::INVALID);
VmInterface *vnet1 = VmInterfaceGet(1);

std::auto_ptr<PktGen> pkt(new PktGen());
pkt->AddEthHdr("00:00:00:00:00:01", "00:00:00:00:00:02", 0x800);
pkt->AddAgentHdr(vnet1->id(), AGENT_TRAP_FLOW_MISS);
pkt->AddEthHdr("00:00:00:00:00:01", "00:00:00:00:00:02", 0x800);
pkt->AddIpHdr("1.1.1.1", "1.1.1.2", 1);
pkt->AddUdpHdr(68, 67, 128);
uint8_t *ptr(new uint8_t[pkt->GetBuffLen()]);
memcpy(ptr, pkt->GetBuff(), pkt->GetBuffLen());
client->agent_init()->pkt0()->ProcessFlowPacket
(ptr, pkt->GetBuffLen(), pkt->GetBuffLen());
// (ptr, (sizeof(struct ether_header) + sizeof(agent_hdr)), pkt->GetBuffLen());

client->WaitForIdle();
EXPECT_EQ(dhcp_count, GetPktModuleCount(PktHandler::DHCP));
EXPECT_EQ((flow_count + 1), GetPktModuleCount(PktHandler::FLOW));
EXPECT_EQ(invalid_count, GetPktModuleCount(PktHandler::INVALID));
}

int main(int argc, char *argv[]) {
GETUSERARGS();

Expand Down

0 comments on commit 70b54be

Please sign in to comment.