From a147522fb664bfbfdc0289c9a12d4e05b6ffae64 Mon Sep 17 00:00:00 2001 From: jperon Date: Mon, 12 Aug 2024 17:54:41 +0200 Subject: [PATCH] Fix skb len calculation Fix a bug that prevented TCP payload to be passed to lua scripts. --- lib/luaxtable.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/luaxtable.c b/lib/luaxtable.c index fde50bc8..c5dde3ad 100644 --- a/lib/luaxtable.c +++ b/lib/luaxtable.c @@ -77,11 +77,11 @@ static inline lunatik_object_t *luaxtable_getskb(lua_State *L, luaxtable_t *xtab static int luaxtable_pushparams(lua_State *L, const struct xt_action_param *par, luaxtable_t *xtable, const struct sk_buff *skb, uint8_t opt) { lunatik_object_t *data = luaxtable_getskb(L, xtable); - if (data == NULL) { - pr_err("could not find skb\n"); + if (unlikely(data == NULL || skb_linearize(skb) != 0)) { + pr_err("could not get skb\n"); return -1; } - luadata_reset(data, skb->data, skb_headlen(skb), opt); + luadata_reset(data, skb->data, skb->len, opt); lua_newtable(L); lua_pushboolean(L, par->hotdrop);