Skip to content

Add luatc binding#571

Open
sneaky-potato wants to merge 8 commits into
sneaky-potato/gsoc26from
sneaky-potato/luatc
Open

Add luatc binding#571
sneaky-potato wants to merge 8 commits into
sneaky-potato/gsoc26from
sneaky-potato/luatc

Conversation

@sneaky-potato
Copy link
Copy Markdown
Member

@sneaky-potato sneaky-potato commented May 22, 2026

This patch adds the following

  • tc constants in autogen
  • tc binding for supporting bpf_luatc_run kfunc
  • tc related metadata in luaskb
  • tc classifier example

@sneaky-potato sneaky-potato force-pushed the sneaky-potato/luatc branch 2 times, most recently from 5947d2c to a22dd18 Compare May 24, 2026 14:52
Comment thread autogen/specs.lua Outdated
Comment thread lib/luaskb.c Outdated
const char *key = luaL_checkstring(L, 2);
for (const luaL_Reg *f = luaskb_getters; f->name; f++)
if (strcmp(f->name, key) == 0)
return f->func(L);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we have discussed this on matrix.. we should have a table instead of comparing strings.. btw, I think a better approach would be to have a table as an field of skb (e.g., skb.attr) for using __index and __newindex so we can avoid the verification on the top and a second table stored in the lib table itself to access getters and setters CFunctions directly, instead of comparing strings like this. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

perhaps, a better idea is to just expose getters and setters here and implement the table abstraction in Lua, e.g., skb/attr.lua

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

perhaps, a better idea is to just expose getters and setters here and implement the table abstraction in Lua, e.g., skb/attr.lua

I agree, this way C side will be straight forward

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Added lib/skb/attr.lua to handle the table abstraction

Comment thread lib/luatc.c

static char luatc_env_key;

static lunatik_object_t *luatc_runtimes = NULL;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should move this to our common layer, having something like lunatik_ebpf_runtimes.. btw, I was taking a look at the integration branch.. I don't think the header belongs to lib/, lunatik_* should be placed at /, also.. I would rename it to lunatik_ebpf.h, bpf is misnomer IMHO

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Working on a fixup for this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I have moved the following to the generic layer till now:

  • runtime lookup
  • BPF kfunc init and set macros

Comment thread lib/luatc.c
* @see data
* @within tc
*/
static int luatc_attach(lua_State *L)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

isn't there anything from attach on XDP and TC that we can generaliza to the lunatik_ebpf layer?

@sneaky-potato sneaky-potato force-pushed the sneaky-potato/luatc branch from b68ad89 to cb1a607 Compare May 27, 2026 19:28
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
@sneaky-potato sneaky-potato force-pushed the sneaky-potato/luatc branch from 6a231c4 to 53fd9ee Compare May 28, 2026 18:54
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Signed-off-by: Ashwani Kumar Kamal <ashwanikamal.im421@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants