From 7f6b5a0ef606aa98babd757055ebed977a68a0b1 Mon Sep 17 00:00:00 2001 From: Christian Deacon Date: Wed, 6 May 2020 03:27:09 +0000 Subject: [PATCH] Updated XDP program (not payload matching support). --- src/xdpfw_kern.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/xdpfw_kern.c b/src/xdpfw_kern.c index f0baf46..ccf77dd 100644 --- a/src/xdpfw_kern.c +++ b/src/xdpfw_kern.c @@ -212,19 +212,20 @@ int xdp_prog_main(struct xdp_md *ctx) } // Payload match. + /* if (filter[i]->payloadLen > 0) { + uint8_t found = 1; + uint16_t len = filter[i]->payloadLen; + // Initialize packet data. uint8_t *pcktData = (data + sizeof(struct ethhdr) + (iph->ihl * 4) + l4headerLen); - // Now check packet data and ensure we have enough to match. - if (pcktData + (filter[i]->payloadLen) > (uint8_t *)data_end) + if (pcktData + len > (uint8_t *)data_end) { continue; } - uint8_t found = 1; - for (uint16_t j = 0; j < filter[i]->payloadLen; j++) { if ((*pcktData++) == filter[i]->payloadMatch[j]) @@ -242,6 +243,7 @@ int xdp_prog_main(struct xdp_md *ctx) continue; } } + */ // Check layer 4 filters. if (iph->protocol == IPPROTO_TCP && !filter[i]->tcpopts.enabled)