Skip to content

Commit f17ba62

Browse files
author
logwang
committed
Use general protocol header length in protocol filter.
1 parent 35a8139 commit f17ba62

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/ff_dpdk_if.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ ff_veth_input(const struct ff_dpdk_if_context *ctx, struct rte_mbuf *pkt)
878878
static enum FilterReturn
879879
protocol_filter(const void *data, uint16_t len)
880880
{
881-
if(len < sizeof(struct ether_hdr))
881+
if(len < ETHER_HDR_LEN)
882882
return FILTER_UNKNOWN;
883883

884884
const struct ether_hdr *hdr;

lib/ff_dpdk_kni.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,9 @@ protocol_filter_ip(const void *data, uint16_t len)
258258
hdr = (const struct ipv4_hdr *)data;
259259

260260
int hdr_len = (hdr->version_ihl & 0x0f) << 2;
261+
if (len < hdr_len)
262+
return FILTER_UNKNOWN;
263+
261264
void *next = (void *)data + hdr_len;
262265
uint16_t next_len = len - hdr_len;
263266

0 commit comments

Comments
 (0)