Skip to content

Commit ca0a05c

Browse files
fixup! add XDPLua
1 parent 9949d1e commit ca0a05c

9 files changed

Lines changed: 40 additions & 40 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_XDPLUA */
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_XDPLUA */
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_XDPLUA */
36883688
int generic_xdp_lua_install_prog(char *lua_prog);
3689-
#endif /* CONFIG_XDPLUA */
3689+
/* #endif CONFIG_XDPLUA */
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_XDPLUA */
7474
struct sk_buff *skb;
7575
struct lua_State *L;
76-
#endif /* CONFIG_XDPLUA */
76+
/* #endif CONFIG_XDPLUA */
7777
};
7878

7979
struct xdp_frame {

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_XDPLUA */
978978
IFLA_XDP_LUA_PROG,
979-
#endif /* CONFIG_XDPLUA */
979+
/* #endif CONFIG_XDPLUA */
980980
__IFLA_XDP_MAX,
981981
};
982982

net/core/dev.c

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

71+
/* #ifdef CONFIG_XDPLUA */
72+
#include <lua.h>
73+
#include <lauxlib.h>
74+
#include <lualib.h>
75+
/* #endif CONFIG_XDPLUA */
76+
7177
#include <linux/uaccess.h>
7278
#include <linux/bitops.h>
7379
#include <linux/capability.h>
@@ -143,12 +149,6 @@
143149
#include <linux/indirect_call_wrapper.h>
144150
#include <net/devlink.h>
145151

146-
#ifdef CONFIG_XDPLUA
147-
#include <lua.h>
148-
#include <lauxlib.h>
149-
#include <lualib.h>
150-
#endif /* CONFIG_XDPLUA */
151-
152152
#include "net-sysfs.h"
153153

154154
#define MAX_GRO_SKBS 8
@@ -170,9 +170,9 @@ static int call_netdevice_notifiers_extack(unsigned long val,
170170
struct netlink_ext_ack *extack);
171171
static struct napi_struct *napi_by_id(unsigned int napi_id);
172172

173-
#ifdef CONFIG_XDPLUA
173+
/* #ifdef CONFIG_XDPLUA */
174174
struct list_head lua_state_cpu_list;
175-
#endif /* CONFIG_XDPLUA */
175+
/* #endif CONFIG_XDPLUA */
176176

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

43824382
rxqueue = netif_get_rxqueue(skb);
43834383
xdp->rxq = &rxqueue->xdp_rxq;
4384-
#ifdef CONFIG_XDPLUA
4384+
/* #ifdef CONFIG_XDPLUA */
43854385
xdp->skb = skb;
4386-
#endif /* CONFIG_XDPLUA */
4386+
/* #endif CONFIG_XDPLUA */
43874387

43884388
act = bpf_prog_run_xdp(xdp_prog, xdp);
43894389

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

5199-
#ifdef CONFIG_XDPLUA
5199+
/* #ifdef CONFIG_XDPLUA */
52005200
int generic_xdp_lua_install_prog(char *lua_prog)
52015201
{
52025202
struct lua_state_cpu *sc;
@@ -5210,7 +5210,7 @@ int generic_xdp_lua_install_prog(char *lua_prog)
52105210
}
52115211
return 0;
52125212
}
5213-
#endif /* CONFIG_XDPLUA */
5213+
/* #endif CONFIG_XDPLUA */
52145214

52155215
static int netif_receive_skb_internal(struct sk_buff *skb)
52165216
{
@@ -9829,9 +9829,9 @@ static struct pernet_operations __net_initdata default_device_ops = {
98299829
static int __init net_dev_init(void)
98309830
{
98319831
int i, rc = -ENOMEM;
9832-
#ifdef CONFIG_XDPLUA
9832+
/* #ifdef CONFIG_XDPLUA */
98339833
struct lua_state_cpu *new_state_cpu;
9834-
#endif /* CONFIG_XDPLUA */
9834+
/* #endif CONFIG_XDPLUA */
98359835

98369836
BUG_ON(!dev_boot_phase);
98379837

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

98489848
INIT_LIST_HEAD(&offload_base);
9849-
#ifdef CONFIG_XDPLUA
9849+
/* #ifdef CONFIG_XDPLUA */
98509850
INIT_LIST_HEAD(&lua_state_cpu_list);
9851-
#endif /* CONFIG_XDPLUA */
9851+
/* #endif CONFIG_XDPLUA */
98529852

98539853
if (register_pernet_subsys(&netdev_net_ops))
98549854
goto out;
@@ -9880,9 +9880,9 @@ static int __init net_dev_init(void)
98809880
sd->backlog.poll = process_backlog;
98819881
sd->backlog.weight = weight_p;
98829882

9883-
#ifdef CONFIG_XDPLUA
9883+
/* #ifdef CONFIG_XDPLUA */
98849884
new_state_cpu = (struct lua_state_cpu *)
9885-
kmalloc(sizeof(lua_state_cpu), GFP_ATOMIC);
9885+
kmalloc(sizeof(struct lua_state_cpu), GFP_ATOMIC);
98869886
if (!new_state_cpu)
98879887
continue;
98889888

@@ -9893,12 +9893,11 @@ static int __init net_dev_init(void)
98939893
}
98949894

98959895
luaL_openlibs(new_state_cpu->L);
9896-
luaL_requiref(new_state_cpu->L, "data", luaopen_data, 1);
98979896
lua_pop(new_state_cpu->L, 1);
98989897
new_state_cpu->cpu = i;
98999898

99009899
list_add(&new_state_cpu->list, &lua_state_cpu_list);
9901-
#endif /* CONFIG_XDPLUA */
9900+
/* #endif CONFIG_XDPLUA */
99029901
}
99039902

99049903
dev_boot_phase = 0;

net/core/filter.c

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

77-
#ifdef CONFIG_XDPLUA
77+
/* #ifdef CONFIG_XDPLUA */
7878
#include <lua.h>
79-
#endif /* CONFIG_XDPLUA */
79+
/* #endif CONFIG_XDPLUA */
8080

8181
/**
8282
* sk_filter_trim_cap - run a packet through a socket filter
@@ -5856,7 +5856,7 @@ static const struct bpf_func_proto bpf_tcp_check_syncookie_proto = {
58565856

58575857
#endif /* CONFIG_INET */
58585858

5859-
#ifdef CONFIG_XDPLUA
5859+
/* #ifdef CONFIG_XDPLUA */
58605860
BPF_CALL_2(bpf_lua_dataref, struct xdp_buff *, ctx, int, offset) {
58615861
if (offset + ctx->data < ctx->data_end) {
58625862
int data_ref;
@@ -6064,7 +6064,7 @@ static const struct bpf_func_proto bpf_lua_tointeger_proto = {
60646064
.arg1_type = ARG_PTR_TO_CTX,
60656065
.arg2_type = ARG_ANYTHING,
60666066
};
6067-
#endif /* CONFIG_XDPLUA */
6067+
/* #endif CONFIG_XDPLUA */
60686068

60696069
bool bpf_helper_changes_pkt_data(void *func)
60706070
{
@@ -6140,7 +6140,7 @@ bpf_base_func_proto(enum bpf_func_id func_id)
61406140
return &bpf_spin_unlock_proto;
61416141
case BPF_FUNC_trace_printk:
61426142
return bpf_get_trace_printk_proto();
6143-
#ifdef CONFIG_XDPLUA
6143+
/* #ifdef CONFIG_XDPLUA */
61446144
case BPF_FUNC_lua_dataref:
61456145
return &bpf_lua_dataref_proto;
61466146
case BPF_FUNC_lua_dataunref:
@@ -6167,7 +6167,7 @@ bpf_base_func_proto(enum bpf_func_id func_id)
61676167
return &bpf_lua_toboolean_proto;
61686168
case BPF_FUNC_lua_tointeger:
61696169
return &bpf_lua_tointeger_proto;
6170-
#endif /* CONFIG_XDPLUA */
6170+
/* #endif CONFIG_XDPLUA */
61716171
default:
61726172
return NULL;
61736173
}

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_XDPLUA */
18031803
[IFLA_XDP_LUA_PROG] = { .type = NLA_STRING, .len = 8192 },
1804-
#endif /* CONFIG_XDPLUA */
1804+
/* #endif CONFIG_XDPLUA */
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_XDPLUA */
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_XDPLUA */
27272727

27282728
}
27292729

tools/include/uapi/linux/bpf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,6 +2824,7 @@ union bpf_attr {
28242824
FN(strtoul), \
28252825
FN(sk_storage_get), \
28262826
FN(sk_storage_delete), \
2827+
FN(send_signal), \
28272828
/* #ifdef CONFIG_XDPLUA */ \
28282829
FN(lua_dataref), \
28292830
FN(lua_dataunref), \

tools/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

0 commit comments

Comments
 (0)