summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2024-04-25 16:03:07 -0700
committerMaciej Żenczykowski <maze@google.com>2024-04-25 16:12:34 -0700
commit412b010569c0a1f0fcbcc5eca8874784f3e1f484 (patch)
tree531afe2b7ce0899642f5cee7cd313b9a0d9a5401
parenteda4335a21ec77b7445f037b32402bf0bf2aaa99 (diff)
downloadapf-412b010569c0a1f0fcbcc5eca8874784f3e1f484.tar.gz
v5: add one more function indirect for apf_run()
After: text data bss dec hex filename 4300 0 0 4300 10cc apf_interpreter.arm.o text data bss dec hex filename 5578 0 0 5578 15ca apf_interpreter.x86.o Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I1a7ea17ad4267143cb0a6babca46195f59acf842
-rw-r--r--v5/apf_interpreter.c20
-rw-r--r--v5/apf_interpreter_source.c20
2 files changed, 26 insertions, 14 deletions
diff --git a/v5/apf_interpreter.c b/v5/apf_interpreter.c
index c539f88..dabb3fe 100644
--- a/v5/apf_interpreter.c
+++ b/v5/apf_interpreter.c
@@ -1079,9 +1079,9 @@ static int do_apf_run(apf_context* ctx) {
return EXCEPTION;
}
-int apf_run(void* ctx, u32* const program, const u32 program_len,
- const u32 ram_len, const u8* const packet,
- const u32 packet_len, const u32 filter_age_16384ths) {
+static int apf_runner(void* ctx, u32* const program, const u32 program_len,
+ const u32 ram_len, const u8* const packet,
+ const u32 packet_len, const u32 filter_age_16384ths) {
/* Due to direct 32-bit read/write access to counters at end of ram */
/* APFv6 interpreter requires program & ram_len to be 4 byte aligned. */
if (3 & (uintptr_t)program) return EXCEPTION;
@@ -1092,10 +1092,6 @@ int apf_run(void* ctx, u32* const program, const u32 program_len,
/* We also don't want garbage like program_len == 0xFFFFFFFF */
if ((program_len | ram_len) >> 31) return EXCEPTION;
- /* Any valid ethernet packet should be at least ETH_HLEN long... */
- if (!packet) return EXCEPTION;
- if (packet_len < ETH_HLEN) return EXCEPTION;
-
{
apf_context apf_ctx = { 0 };
int ret;
@@ -1133,3 +1129,13 @@ int apf_run(void* ctx, u32* const program, const u32 program_len,
return ret;
}
}
+
+int apf_run(void* ctx, u32* const program, const u32 program_len,
+ const u32 ram_len, const u8* const packet,
+ const u32 packet_len, const u32 filter_age_16384ths) {
+ /* Any valid ethernet packet should be at least ETH_HLEN long... */
+ if (!packet) return EXCEPTION;
+ if (packet_len < ETH_HLEN) return EXCEPTION;
+
+ return apf_runner(ctx, program, program_len, ram_len, packet, packet_len, filter_age_16384ths);
+}
diff --git a/v5/apf_interpreter_source.c b/v5/apf_interpreter_source.c
index 9ab27bf..4db7aa6 100644
--- a/v5/apf_interpreter_source.c
+++ b/v5/apf_interpreter_source.c
@@ -538,9 +538,9 @@ static int do_apf_run(apf_context* ctx) {
return EXCEPTION;
}
-int apf_run(void* ctx, u32* const program, const u32 program_len,
- const u32 ram_len, const u8* const packet,
- const u32 packet_len, const u32 filter_age_16384ths) {
+static int apf_runner(void* ctx, u32* const program, const u32 program_len,
+ const u32 ram_len, const u8* const packet,
+ const u32 packet_len, const u32 filter_age_16384ths) {
// Due to direct 32-bit read/write access to counters at end of ram
// APFv6 interpreter requires program & ram_len to be 4 byte aligned.
if (3 & (uintptr_t)program) return EXCEPTION;
@@ -551,10 +551,6 @@ int apf_run(void* ctx, u32* const program, const u32 program_len,
// We also don't want garbage like program_len == 0xFFFFFFFF
if ((program_len | ram_len) >> 31) return EXCEPTION;
- // Any valid ethernet packet should be at least ETH_HLEN long...
- if (!packet) return EXCEPTION;
- if (packet_len < ETH_HLEN) return EXCEPTION;
-
{
apf_context apf_ctx = { 0 };
int ret;
@@ -592,3 +588,13 @@ int apf_run(void* ctx, u32* const program, const u32 program_len,
return ret;
}
}
+
+int apf_run(void* ctx, u32* const program, const u32 program_len,
+ const u32 ram_len, const u8* const packet,
+ const u32 packet_len, const u32 filter_age_16384ths) {
+ // Any valid ethernet packet should be at least ETH_HLEN long...
+ if (!packet) return EXCEPTION;
+ if (packet_len < ETH_HLEN) return EXCEPTION;
+
+ return apf_runner(ctx, program, program_len, ram_len, packet, packet_len, filter_age_16384ths);
+}