提交 f76254a8 编写于 作者: J Jesper Dangaard Brouer 提交者: David S. Miller

samples/bpf: fix XDP_FLAGS_SKB_MODE detach for xdp_tx_iptunnel

The xdp_tx_iptunnel program can be terminated in two ways, after
N-seconds or via Ctrl-C SIGINT.  The SIGINT code path does not
handle detatching the correct XDP program, in-case the program
was attached with XDP_FLAGS_SKB_MODE.

Fix this by storing the XDP flags as a global variable, which is
available for the SIGINT handler function.

Fixes: 3993f2cb ("samples/bpf: Add support for SKB_MODE to xdp1 and xdp_tx_iptunnel")
Signed-off-by: NJesper Dangaard Brouer <brouer@redhat.com>
Acked-by: NDaniel Borkmann <daniel@iogearbox.net>
Reviewed-by: NAndy Gospodarek <andy@greyhouse.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6387d011
......@@ -25,11 +25,12 @@
#define STATS_INTERVAL_S 2U
static int ifindex = -1;
static __u32 xdp_flags = 0;
static void int_exit(int sig)
{
if (ifindex > -1)
set_link_xdp_fd(ifindex, -1, 0);
set_link_xdp_fd(ifindex, -1, xdp_flags);
exit(0);
}
......@@ -142,7 +143,6 @@ int main(int argc, char **argv)
struct iptnl_info tnl = {};
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
struct vip vip = {};
__u32 xdp_flags = 0;
char filename[256];
int opt;
int i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册