-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add XDPLua #7
base: master-5.6
Are you sure you want to change the base?
add XDPLua #7
Changes from 2 commits
4d82fa2
ff7c9b9
f278687
7d184d9
7e405cf
13a42eb
5eb463c
e20f358
36ceb19
040b06b
50e056a
b6ca132
2eebe24
a768499
5e89868
deac020
114485e
234a3d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "lib/lunatik"] | ||
path = lib/lunatik | ||
url = https://github.com/luainkernel/lunatik.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -984,6 +984,9 @@ enum { | |
IFLA_XDP_DRV_PROG_ID, | ||
IFLA_XDP_SKB_PROG_ID, | ||
IFLA_XDP_HW_PROG_ID, | ||
#ifdef CONFIG_XDP_LUA | ||
IFLA_XDP_LUA_PROG, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we should uniformize our "namespace".. it looks like we should use |
||
#endif /* CONFIG_XDP_LUA */ | ||
__IFLA_XDP_MAX, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1307,6 +1307,12 @@ config HAVE_PCSPKR_PLATFORM | |
config BPF | ||
bool | ||
|
||
config LUNATIK | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we put this config on Lunatik module itself? |
||
bool "Lunatik" | ||
default n | ||
help | ||
Support for the Lua interpreter | ||
|
||
menuconfig EXPERT | ||
bool "Configure standard kernel features (expert users)" | ||
# Unhide debug options, to make the on-by-default options visible | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,12 @@ | |
* - netif_rx() feedback | ||
*/ | ||
|
||
#ifdef CONFIG_XDP_LUA | ||
#include <lua.h> | ||
#include <lauxlib.h> | ||
#include <lualib.h> | ||
#endif /* CONFIG_XDP_LUA */ | ||
|
||
#include <linux/uaccess.h> | ||
#include <linux/bitops.h> | ||
#include <linux/capability.h> | ||
|
@@ -164,6 +170,10 @@ static int call_netdevice_notifiers_extack(unsigned long val, | |
struct netlink_ext_ack *extack); | ||
static struct napi_struct *napi_by_id(unsigned int napi_id); | ||
|
||
#ifdef CONFIG_XDP_LUA | ||
struct list_head lua_state_cpu_list; | ||
#endif /* CONFIG_XDP_LUA */ | ||
|
||
/* | ||
* The @dev_base_head list is protected by @dev_base_lock and the rtnl | ||
* semaphore. | ||
|
@@ -4556,6 +4566,9 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, | |
|
||
rxqueue = netif_get_rxqueue(skb); | ||
xdp->rxq = &rxqueue->xdp_rxq; | ||
#ifdef CONFIG_XDP_LUA | ||
xdp->skb = skb; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we will get rid of this, right? so, I would remove the \n above as well.. |
||
#endif /* CONFIG_XDP_LUA */ | ||
|
||
act = bpf_prog_run_xdp(xdp_prog, xdp); | ||
|
||
|
@@ -5366,6 +5379,22 @@ static int generic_xdp_install(struct net_device *dev, struct netdev_bpf *xdp) | |
return ret; | ||
} | ||
|
||
#ifdef CONFIG_XDP_LUA | ||
int generic_xdp_lua_install_prog(char *lua_prog) | ||
{ | ||
struct lua_state_cpu *sc; | ||
|
||
list_for_each_entry(sc, &lua_state_cpu_list, list) { | ||
if (luaL_dostring(sc->L, lua_prog)) { | ||
pr_err(KERN_INFO "error: %s\nOn cpu: %d\n", | ||
lua_tostring(sc->L, -1), sc->cpu); | ||
return -EINVAL; | ||
} | ||
} | ||
return 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you can't fail, why not using void? is it some contract? |
||
} | ||
#endif /* CONFIG_XDP_LUA */ | ||
|
||
static int netif_receive_skb_internal(struct sk_buff *skb) | ||
{ | ||
int ret; | ||
|
@@ -10462,6 +10491,9 @@ static struct pernet_operations __net_initdata default_device_ops = { | |
static int __init net_dev_init(void) | ||
{ | ||
int i, rc = -ENOMEM; | ||
#ifdef CONFIG_XDP_LUA | ||
struct lua_state_cpu *new_state_cpu; | ||
#endif /* CONFIG_XDP_LUA */ | ||
|
||
BUG_ON(!dev_boot_phase); | ||
|
||
|
@@ -10476,6 +10508,9 @@ static int __init net_dev_init(void) | |
INIT_LIST_HEAD(&ptype_base[i]); | ||
|
||
INIT_LIST_HEAD(&offload_base); | ||
#ifdef CONFIG_XDP_LUA | ||
INIT_LIST_HEAD(&lua_state_cpu_list); | ||
#endif /* CONFIG_XDP_LUA */ | ||
|
||
if (register_pernet_subsys(&netdev_net_ops)) | ||
goto out; | ||
|
@@ -10506,6 +10541,25 @@ static int __init net_dev_init(void) | |
init_gro_hash(&sd->backlog); | ||
sd->backlog.poll = process_backlog; | ||
sd->backlog.weight = weight_p; | ||
|
||
#ifdef CONFIG_XDP_LUA | ||
new_state_cpu = (struct lua_state_cpu *) | ||
kmalloc(sizeof(struct lua_state_cpu), GFP_ATOMIC); | ||
if (!new_state_cpu) | ||
continue; | ||
|
||
new_state_cpu->L = luaL_newstate(); | ||
if (!new_state_cpu->L) { | ||
kfree(new_state_cpu); | ||
continue; | ||
} | ||
|
||
luaL_openlibs(new_state_cpu->L); | ||
lua_pop(new_state_cpu->L, 1); | ||
new_state_cpu->cpu = i; | ||
|
||
list_add(&new_state_cpu->list, &lua_state_cpu_list); | ||
#endif /* CONFIG_XDP_LUA */ | ||
} | ||
|
||
dev_boot_phase = 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the creation of
struct xdplua_create_work
there probably is no reason to modifystruct xdp_buff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed..