Skip to content

Commit

Permalink
fixup! add XDPLua
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorNogueiraRio committed Aug 27, 2020
1 parent e462d21 commit caec4fa
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
5 changes: 3 additions & 2 deletions net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -4854,15 +4854,16 @@ BPF_CALL_4(bpf_lua_pcall, struct xdp_buff *, ctx, char *, funcname,
goto clean_state;
}

lua_insert(ctx->L, 1);
lua_insert(ctx->L, base + 1);
if (lua_pcall(ctx->L, num_args, num_rets, 0)) {
pr_err("%s\n", lua_tostring(ctx->L, -1));
num_rets = 0;
goto clean_state;
}

clean_state:
base += num_rets;

clean_state:
lua_settop(ctx->L, base);
return num_rets;
}
Expand Down
2 changes: 1 addition & 1 deletion samples/bpf/xdplua_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int do_attach_lua(const char *name, char *lua_prog)
{
int err;

err = bpf_set_link_xdp_lua_prog(lua_prog, 0);
err = bpf_set_link_xdp_lua_prog(lua_prog);
if (err < 0)
fprintf(stderr, "ERROR: failed to attach lua script to %s\n", name);

Expand Down
11 changes: 1 addition & 10 deletions tools/lib/bpf/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags)
}

/* #ifdef CONFIG_XDPLUA */
int bpf_set_link_xdp_lua_prog(char *lua_prog, __u32 flags)
int bpf_set_link_xdp_lua_prog(char *lua_prog)
{
struct sockaddr_nl sa;
int sock, seq = 0, len, ret = -1;
Expand Down Expand Up @@ -693,15 +693,6 @@ int bpf_set_link_xdp_lua_prog(char *lua_prog, __u32 flags)
}
nla->nla_len += nla_xdp->nla_len;

/* if user passed in any flags, add those too */
if (flags) {
nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len);
nla_xdp->nla_type = IFLA_XDP_FLAGS;
nla_xdp->nla_len = NLA_HDRLEN + sizeof(flags);
memcpy((char *)nla_xdp + NLA_HDRLEN, &flags, sizeof(flags));
nla->nla_len += nla_xdp->nla_len;
}

req.nh.nlmsg_len += NLA_ALIGN(nla->nla_len);

if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) {
Expand Down
2 changes: 1 addition & 1 deletion tools/lib/bpf/libbpf.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ int bpf_prog_load(const char *file, enum bpf_prog_type type,

int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags);
/* #ifdef CONFIG_XDP_LUA */
int bpf_set_link_xdp_lua_prog(char *lua_prog, __u32 flags);
int bpf_set_link_xdp_lua_prog(char *lua_prog);
/* #endif CONFIG_XDP_LUA */

enum bpf_perf_event_ret {
Expand Down

0 comments on commit caec4fa

Please sign in to comment.