Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/luanetfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ static int luanetfilter_hook_cb(lua_State *L, luanetfilter_t *luanf, struct sk_b

if (lua_pcall(L, 1, 2, 0) != LUA_OK) {
pr_err("%s\n", lua_tostring(L, -1));
luadata_clear(data);
return -1;
}

luadata_clear(data);

if (!lua_isnil(L, -1))
skb->mark = (u32)lua_tointeger(L, -1);
return lua_tointeger(L, -2);
Expand Down
7 changes: 6 additions & 1 deletion lib/luaxtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,13 @@ static int luaxtable_pushparams(lua_State *L, const struct xt_action_param *par,
return 0;
}

static inline int luaxtable_cleanup(luaxtable_t *xtable)
{
return luadata_clear(xtable->skb);
}

#define luaxtable_call(L, op, xtable, skb, par, info, opt) \
((luaxtable_pushparams(L, par, xtable, skb, opt) == -1) || (luaxtable_docall(L, xtable, info, op, 2, 1) == -1))
((luaxtable_pushparams(L, par, xtable, skb, opt) == -1) || (luaxtable_docall(L, xtable, info, op, 2, 1) == -1) || luaxtable_cleanup(xtable))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will only be called in case of success, right? as I mentioned, both cases should be handled

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, the best approach is to move the luadata_clear() call to luaxtable_docall() body..


static int luaxtable_domatch(lua_State *L, luaxtable_t *xtable, const struct sk_buff *skb, struct xt_action_param *par, int fallback)
{
Expand Down