Skip to content

Commit

Permalink
samples/bpf: fix XDP_FLAGS_SKB_MODE detach for xdp_tx_iptunnel
Browse files Browse the repository at this point in the history
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: 3993f2c ("samples/bpf: Add support for SKB_MODE to xdp1 and xdp_tx_iptunnel")
Signed-off-by: Jesper Dangaard Brouer <[email protected]>
Acked-by: Daniel Borkmann <[email protected]>
Reviewed-by: Andy Gospodarek <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
netoptimizer authored and davem330 committed May 1, 2017
1 parent 6387d01 commit f76254a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/bpf/xdp_tx_iptunnel_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f76254a

Please sign in to comment.