Skip to content

Commit

Permalink
Handle IPv6 fragment in packet parsing
Browse files Browse the repository at this point in the history
Parse IPv6 fragment next header to setup flow for the same correctly.

Change-Id: Ia9b55057e31b3eb7f56112e65b6f0ab23c3adf0f
partial-bug: #1702675
  • Loading branch information
haripk committed Sep 13, 2017
1 parent 8edca6b commit b7b5e84
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/vnsw/agent/pkt/pkt_handler.cc
Expand Up @@ -370,6 +370,12 @@ int PktHandler::ParseIpPacket(PktInfo *pkt_info, PktType::Type &pkt_type,

uint8_t proto = ip->ip6_ctlun.ip6_un1.ip6_un1_nxt;
len += sizeof(ip6_hdr);
if (proto == IPPROTO_FRAGMENT) {
ip6_frag *nxt = (ip6_frag *)(pkt + len);
proto = nxt->ip6f_nxt;
len += sizeof(ip6_frag);
}

pkt_info->ip_proto = proto;
} else {
assert(0);
Expand Down Expand Up @@ -683,13 +689,17 @@ void PktHandler::SendMessage(PktModuleName mod, InterTaskMsg *msg) {
}

bool PktHandler::IgnoreFragmentedPacket(PktInfo *pkt_info) {
if (!pkt_info->ip)
return false;
if (pkt_info->ip) {
uint16_t offset = htons(pkt_info->ip->ip_off);
if (((offset & IP_MF) || (offset & IP_OFFMASK)) &&
!IsFlowPacket(pkt_info))
return true;
} else if (pkt_info->ip6) {
uint8_t proto = pkt_info->ip6->ip6_ctlun.ip6_un1.ip6_un1_nxt;
if (proto == IPPROTO_FRAGMENT && !IsFlowPacket(pkt_info))
return true;
}

uint16_t offset = htons(pkt_info->ip->ip_off);
if (((offset & IP_MF) || (offset & IP_OFFMASK)) &&
!IsFlowPacket(pkt_info))
return true;
return false;
}

Expand Down

0 comments on commit b7b5e84

Please sign in to comment.