From caec4fa7191efc1bc2f8dfde995df117b043a5ff Mon Sep 17 00:00:00 2001 From: Victor Nogueira Date: Thu, 27 Aug 2020 13:22:45 -0300 Subject: [PATCH] fixup! add XDPLua --- net/core/filter.c | 5 +++-- samples/bpf/xdplua_user.c | 2 +- tools/lib/bpf/bpf.c | 11 +---------- tools/lib/bpf/libbpf.h | 2 +- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index 5d5d3d685a4250..42088c017338de 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -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; } diff --git a/samples/bpf/xdplua_user.c b/samples/bpf/xdplua_user.c index d9b5acc665e1fc..e6c5f9da114177 100644 --- a/samples/bpf/xdplua_user.c +++ b/samples/bpf/xdplua_user.c @@ -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); diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 57cc5e26369812..7af691667a961b 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -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; @@ -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) { diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 523ada3fa48b81..1b88e4b5634b74 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -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 {