Use general protocol header length in protocol filter.

dev
logwang 2017-11-21 11:20:14 +08:00
parent 5ac59bc49a
commit 49e481768a
2 changed files with 4 additions and 1 deletions

View File

@ -878,7 +878,7 @@ ff_veth_input(const struct ff_dpdk_if_context *ctx, struct rte_mbuf *pkt)
static enum FilterReturn
protocol_filter(const void *data, uint16_t len)
{
if(len < sizeof(struct ether_hdr))
if(len < ETHER_HDR_LEN)
return FILTER_UNKNOWN;
const struct ether_hdr *hdr;

View File

@ -258,6 +258,9 @@ protocol_filter_ip(const void *data, uint16_t len)
hdr = (const struct ipv4_hdr *)data;
int hdr_len = (hdr->version_ihl & 0x0f) << 2;
if (len < hdr_len)
return FILTER_UNKNOWN;
void *next = (void *)data + hdr_len;
uint16_t next_len = len - hdr_len;