|
20 | 20 | #include <linux/bpf.h> |
21 | 21 |
|
22 | 22 | #include <lunatik.h> |
| 23 | +#include <lunatik_ebpf.h> |
23 | 24 |
|
24 | 25 | #include "luarcu.h" |
25 | 26 | #include "luadata.h" |
26 | | -#include "lunatik_bpf.h" |
27 | 27 |
|
28 | 28 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)) |
29 | 29 | #include <linux/btf.h> |
@@ -157,31 +157,13 @@ static int luaxdp_handler(lua_State *L, luaxdp_ctx_t *ctx) |
157 | 157 | return 0; |
158 | 158 | } |
159 | 159 |
|
160 | | -static inline int luaxdp_checkruntimes(void) |
161 | | -{ |
162 | | - const char *key = "runtimes"; |
163 | | - if (luaxdp_runtimes == NULL && |
164 | | - (luaxdp_runtimes = luarcu_getobject(lunatik_env, key, sizeof(key))) == NULL) |
165 | | - return -1; |
166 | | - return 0; |
167 | | -} |
168 | | - |
169 | 160 | __bpf_kfunc int bpf_luaxdp_run(char *key, size_t key__sz, struct xdp_md *xdp_ctx, void *arg, size_t arg__sz) |
170 | 161 | { |
171 | | - lunatik_object_t *runtime; |
172 | 162 | int action = -1; |
173 | | - size_t keylen = key__sz - 1; |
174 | 163 |
|
175 | | - if (unlikely(luaxdp_checkruntimes() != 0)) { |
176 | | - pr_err("couldn't find _ENV.runtimes\n"); |
| 164 | + lunatik_object_t *runtime = lunatik_ebpf_lookup(luaxdp_runtimes, key, key__sz); |
| 165 | + if (runtime == NULL) |
177 | 166 | goto out; |
178 | | - } |
179 | | - |
180 | | - key[keylen] = '\0'; |
181 | | - if ((runtime = luarcu_getobject(luaxdp_runtimes, key, keylen)) == NULL) { |
182 | | - pr_err("couldn't find runtime '%s'\n", key); |
183 | | - goto out; |
184 | | - } |
185 | 167 |
|
186 | 168 | luaxdp_ctx_t ctx = { |
187 | 169 | .xdp = (struct xdp_buff *)xdp_ctx, |
@@ -272,7 +254,7 @@ static int luaxdp_detach(lua_State *L) |
272 | 254 | * local function my_packet_processor(ctx) |
273 | 255 | * local packet_buffer = ctx:packet() |
274 | 256 | * print("Packet received, size:", #packet_buffer) |
275 | | -* ctx:action(XDP_PASS) |
| 257 | +* ctx:action(action.PASS) |
276 | 258 | * return nil |
277 | 259 | * end |
278 | 260 | * xdp.attach(my_packet_processor) |
|
0 commit comments