Use general protocol header length in protocol filter.

This commit is contained in:
logwang 2017-11-21 11:20:14 +08:00
parent 35a813994b
commit f17ba62bb6
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 static enum FilterReturn
protocol_filter(const void *data, uint16_t len) protocol_filter(const void *data, uint16_t len)
{ {
if(len < sizeof(struct ether_hdr)) if(len < ETHER_HDR_LEN)
return FILTER_UNKNOWN; return FILTER_UNKNOWN;
const struct ether_hdr *hdr; 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; hdr = (const struct ipv4_hdr *)data;
int hdr_len = (hdr->version_ihl & 0x0f) << 2; int hdr_len = (hdr->version_ihl & 0x0f) << 2;
if (len < hdr_len)
return FILTER_UNKNOWN;
void *next = (void *)data + hdr_len; void *next = (void *)data + hdr_len;
uint16_t next_len = len - hdr_len; uint16_t next_len = len - hdr_len;