Skip to content

Commit cd9fff9

Browse files
fixup! fixup! add XDPLua
1 parent 2fda6a1 commit cd9fff9

9 files changed

Lines changed: 41 additions & 34 deletions

File tree

include/linux/filter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,14 +1229,14 @@ struct bpf_sockopt_kern {
12291229
s32 retval;
12301230
};
12311231

1232-
/* #ifdef CONFIG_XDPLUA */
1232+
#ifdef CONFIG_XDP_LUA
12331233
extern struct list_head lua_state_cpu_list;
12341234

12351235
struct lua_state_cpu {
12361236
struct lua_State *L;
12371237
int cpu;
12381238
struct list_head list;
12391239
};
1240-
/* #endif CONFIG_XDPLUA */
1240+
#endif /* CONFIG_XDP_LUA */
12411241

12421242
#endif /* __LINUX_FILTER_H__ */

include/linux/netdevice.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3684,9 +3684,9 @@ u32 __dev_xdp_query(struct net_device *dev, bpf_op_t xdp_op,
36843684
enum bpf_netdev_command cmd);
36853685
int xdp_umem_query(struct net_device *dev, u16 queue_id);
36863686

3687-
/* #ifdef CONFIG_XDPLUA */
3687+
#ifdef CONFIG_XDP_LUA
36883688
int generic_xdp_lua_install_prog(char *lua_prog);
3689-
/* #endif CONFIG_XDPLUA */
3689+
#endif /* CONFIG_XDP_LUA */
36903690

36913691
int __dev_forward_skb(struct net_device *dev, struct sk_buff *skb);
36923692
int dev_forward_skb(struct net_device *dev, struct sk_buff *skb);

include/net/xdp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ struct xdp_buff {
7070
void *data_hard_start;
7171
unsigned long handle;
7272
struct xdp_rxq_info *rxq;
73-
/* #ifdef CONFIG_XDPLUA */
73+
#ifdef CONFIG_XDP_LUA
7474
struct sk_buff *skb;
7575
struct lua_State *L;
76-
/* #endif CONFIG_XDPLUA */
76+
#endif /* CONFIG_XDP_LUA */
7777
};
7878

7979
struct xdp_frame {

include/uapi/linux/bpf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2825,7 +2825,7 @@ union bpf_attr {
28252825
FN(sk_storage_get), \
28262826
FN(sk_storage_delete), \
28272827
FN(send_signal), \
2828-
/* #ifdef CONFIG_XDPLUA */ \
2828+
/* #ifdef CONFIG_XDP_LUA */ \
28292829
FN(lua_dataref), \
28302830
FN(lua_dataunref), \
28312831
FN(lua_pcall), \
@@ -2839,7 +2839,7 @@ union bpf_attr {
28392839
FN(lua_setstate), \
28402840
FN(lua_toboolean), \
28412841
FN(lua_tointeger),
2842-
/* #endif CONFIG_XDPLUA */
2842+
/* #endif CONFIG_XDP_LUA */
28432843

28442844
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
28452845
* function eBPF program intends to call

include/uapi/linux/if_link.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,9 @@ enum {
974974
IFLA_XDP_DRV_PROG_ID,
975975
IFLA_XDP_SKB_PROG_ID,
976976
IFLA_XDP_HW_PROG_ID,
977-
/* #ifdef CONFIG_XDPLUA */
977+
#ifdef CONFIG_XDP_LUA
978978
IFLA_XDP_LUA_PROG,
979-
/* #endif CONFIG_XDPLUA */
979+
#endif /* CONFIG_XDP_LUA */
980980
__IFLA_XDP_MAX,
981981
};
982982

net/core/dev.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@
6868
* - netif_rx() feedback
6969
*/
7070

71-
/* #ifdef CONFIG_XDPLUA */
71+
#ifdef CONFIG_XDP_LUA
7272
#include <lua.h>
7373
#include <lauxlib.h>
7474
#include <lualib.h>
7575
#include <luadata.h>
76-
/* #endif CONFIG_XDPLUA */
76+
#endif /* CONFIG_XDP_LUA */
7777

7878
#include <linux/uaccess.h>
7979
#include <linux/bitops.h>
@@ -171,9 +171,9 @@ static int call_netdevice_notifiers_extack(unsigned long val,
171171
struct netlink_ext_ack *extack);
172172
static struct napi_struct *napi_by_id(unsigned int napi_id);
173173

174-
/* #ifdef CONFIG_XDPLUA */
174+
#ifdef CONFIG_XDP_LUA
175175
struct list_head lua_state_cpu_list;
176-
/* #endif CONFIG_XDPLUA */
176+
#endif /* CONFIG_XDP_LUA */
177177

178178
/*
179179
* The @dev_base_head list is protected by @dev_base_lock and the rtnl
@@ -4382,9 +4382,9 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
43824382

43834383
rxqueue = netif_get_rxqueue(skb);
43844384
xdp->rxq = &rxqueue->xdp_rxq;
4385-
/* #ifdef CONFIG_XDPLUA */
4385+
#ifdef CONFIG_XDP_LUA
43864386
xdp->skb = skb;
4387-
/* #endif CONFIG_XDPLUA */
4387+
#endif /* CONFIG_XDP_LUA */
43884388

43894389
act = bpf_prog_run_xdp(xdp_prog, xdp);
43904390

@@ -5197,7 +5197,7 @@ static int generic_xdp_install(struct net_device *dev, struct netdev_bpf *xdp)
51975197
return ret;
51985198
}
51995199

5200-
/* #ifdef CONFIG_XDPLUA */
5200+
#ifdef CONFIG_XDP_LUA
52015201
int generic_xdp_lua_install_prog(char *lua_prog)
52025202
{
52035203
struct lua_state_cpu *sc;
@@ -5211,7 +5211,7 @@ int generic_xdp_lua_install_prog(char *lua_prog)
52115211
}
52125212
return 0;
52135213
}
5214-
/* #endif CONFIG_XDPLUA */
5214+
#endif /* CONFIG_XDP_LUA */
52155215

52165216
static int netif_receive_skb_internal(struct sk_buff *skb)
52175217
{
@@ -9830,9 +9830,9 @@ static struct pernet_operations __net_initdata default_device_ops = {
98309830
static int __init net_dev_init(void)
98319831
{
98329832
int i, rc = -ENOMEM;
9833-
/* #ifdef CONFIG_XDPLUA */
9833+
#ifdef CONFIG_XDP_LUA
98349834
struct lua_state_cpu *new_state_cpu;
9835-
/* #endif CONFIG_XDPLUA */
9835+
#endif /* CONFIG_XDP_LUA */
98369836

98379837
BUG_ON(!dev_boot_phase);
98389838

@@ -9847,9 +9847,9 @@ static int __init net_dev_init(void)
98479847
INIT_LIST_HEAD(&ptype_base[i]);
98489848

98499849
INIT_LIST_HEAD(&offload_base);
9850-
/* #ifdef CONFIG_XDPLUA */
9850+
#ifdef CONFIG_XDP_LUA
98519851
INIT_LIST_HEAD(&lua_state_cpu_list);
9852-
/* #endif CONFIG_XDPLUA */
9852+
#endif /* CONFIG_XDP_LUA */
98539853

98549854
if (register_pernet_subsys(&netdev_net_ops))
98559855
goto out;
@@ -9881,7 +9881,7 @@ static int __init net_dev_init(void)
98819881
sd->backlog.poll = process_backlog;
98829882
sd->backlog.weight = weight_p;
98839883

9884-
/* #ifdef CONFIG_XDPLUA */
9884+
#ifdef CONFIG_XDP_LUA
98859885
new_state_cpu = (struct lua_state_cpu *)
98869886
kmalloc(sizeof(struct lua_state_cpu), GFP_ATOMIC);
98879887
if (!new_state_cpu)
@@ -9899,7 +9899,7 @@ static int __init net_dev_init(void)
98999899
new_state_cpu->cpu = i;
99009900

99019901
list_add(&new_state_cpu->list, &lua_state_cpu_list);
9902-
/* #endif CONFIG_XDPLUA */
9902+
#endif /* CONFIG_XDP_LUA */
99039903
}
99049904

99059905
dev_boot_phase = 0;

net/core/filter.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@
7474
#include <net/ipv6_stubs.h>
7575
#include <net/bpf_sk_storage.h>
7676

77-
/* #ifdef CONFIG_XDPLUA */
77+
#ifdef CONFIG_XDP_LUA
7878
#include <lua.h>
7979
#include <luadata.h>
80-
/* #endif CONFIG_XDPLUA */
80+
#endif /* CONFIG_XDP_LUA */
8181

8282
/**
8383
* sk_filter_trim_cap - run a packet through a socket filter
@@ -5857,7 +5857,7 @@ static const struct bpf_func_proto bpf_tcp_check_syncookie_proto = {
58575857

58585858
#endif /* CONFIG_INET */
58595859

5860-
/* #ifdef CONFIG_XDPLUA */
5860+
#ifdef CONFIG_XDP_LUA
58615861
BPF_CALL_2(bpf_lua_dataref, struct xdp_buff *, ctx, int, offset) {
58625862
if (offset + ctx->data < ctx->data_end) {
58635863
int data_ref;
@@ -6065,7 +6065,7 @@ static const struct bpf_func_proto bpf_lua_tointeger_proto = {
60656065
.arg1_type = ARG_PTR_TO_CTX,
60666066
.arg2_type = ARG_ANYTHING,
60676067
};
6068-
/* #endif CONFIG_XDPLUA */
6068+
#endif /* CONFIG_XDP_LUA */
60696069

60706070
bool bpf_helper_changes_pkt_data(void *func)
60716071
{
@@ -6141,7 +6141,7 @@ bpf_base_func_proto(enum bpf_func_id func_id)
61416141
return &bpf_spin_unlock_proto;
61426142
case BPF_FUNC_trace_printk:
61436143
return bpf_get_trace_printk_proto();
6144-
/* #ifdef CONFIG_XDPLUA */
6144+
#ifdef CONFIG_XDP_LUA
61456145
case BPF_FUNC_lua_dataref:
61466146
return &bpf_lua_dataref_proto;
61476147
case BPF_FUNC_lua_dataunref:
@@ -6168,7 +6168,7 @@ bpf_base_func_proto(enum bpf_func_id func_id)
61686168
return &bpf_lua_toboolean_proto;
61696169
case BPF_FUNC_lua_tointeger:
61706170
return &bpf_lua_tointeger_proto;
6171-
/* #endif CONFIG_XDPLUA */
6171+
#endif /* CONFIG_XDP_LUA */
61726172
default:
61736173
return NULL;
61746174
}

net/core/rtnetlink.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,9 +1799,9 @@ static const struct nla_policy ifla_xdp_policy[IFLA_XDP_MAX + 1] = {
17991799
[IFLA_XDP_ATTACHED] = { .type = NLA_U8 },
18001800
[IFLA_XDP_FLAGS] = { .type = NLA_U32 },
18011801
[IFLA_XDP_PROG_ID] = { .type = NLA_U32 },
1802-
/* #ifdef CONFIG_XDPLUA */
1802+
#ifdef CONFIG_XDP_LUA
18031803
[IFLA_XDP_LUA_PROG] = { .type = NLA_STRING, .len = 8192 },
1804-
/* #endif CONFIG_XDPLUA */
1804+
#endif /* CONFIG_XDP_LUA */
18051805
};
18061806

18071807
static const struct rtnl_link_ops *linkinfo_to_kind_ops(const struct nlattr *nla)
@@ -2711,7 +2711,7 @@ static int do_setlink(const struct sk_buff *skb,
27112711
status |= DO_SETLINK_NOTIFY;
27122712
}
27132713

2714-
/* #ifdef CONFIG_XDPLUA */
2714+
#ifdef CONFIG_XDP_LUA
27152715
if (xdp[IFLA_XDP_LUA_PROG]) {
27162716
char *lua_prog = nla_data(xdp[IFLA_XDP_LUA_PROG]);
27172717
if (!lua_prog) {
@@ -2723,7 +2723,7 @@ static int do_setlink(const struct sk_buff *skb,
27232723
if (err)
27242724
goto errout;
27252725
}
2726-
/* #endif CONFIG_XDPLUA */
2726+
#endif /* CONFIG_XDP_LUA */
27272727

27282728
}
27292729

net/xdp/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ config XDP_SOCKETS_DIAG
1414
help
1515
Support for PF_XDP sockets monitoring interface used by the ss tool.
1616
If unsure, say Y.
17+
18+
config XDP_LUA
19+
bool "XDP LUA"
20+
depends on BPF_SYSCALL && LUNATIK
21+
default n
22+
help
23+
Support for Lua scripts inside XDP

0 commit comments

Comments
 (0)