summaryrefslogtreecommitdiff
path: root/samples/bpf/xdp_tx_iptunnel_user.c
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2017-04-27 19:11:13 +0300
committerDavid S. Miller <davem@davemloft.net>2017-04-27 19:49:26 +0300
commit3993f2cb983b2100409851f7b2abb21d685ea19c (patch)
tree8830b0c2f03b2ec010a4746392ad345516982763 /samples/bpf/xdp_tx_iptunnel_user.c
parent6d684e54690caef45cf14051ddeb7c71beeb681b (diff)
downloadlinux-3993f2cb983b2100409851f7b2abb21d685ea19c.tar.xz
samples/bpf: Add support for SKB_MODE to xdp1 and xdp_tx_iptunnel
Add option to xdp1 and xdp_tx_iptunnel to insert xdp program in SKB_MODE: - update set_link_xdp_fd to take a flags argument that is added to the RTM_SETLINK message - Add -S option to xdp1 and xdp_tx_iptunnel user code. When passed in XDP_FLAGS_SKB_MODE is set in the flags arg passed to set_link_xdp_fd Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples/bpf/xdp_tx_iptunnel_user.c')
-rw-r--r--samples/bpf/xdp_tx_iptunnel_user.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/samples/bpf/xdp_tx_iptunnel_user.c b/samples/bpf/xdp_tx_iptunnel_user.c
index 70e192fc61aa..cb2bda7b5346 100644
--- a/samples/bpf/xdp_tx_iptunnel_user.c
+++ b/samples/bpf/xdp_tx_iptunnel_user.c
@@ -5,6 +5,7 @@
* License as published by the Free Software Foundation.
*/
#include <linux/bpf.h>
+#include <linux/if_link.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
@@ -28,7 +29,7 @@ static int ifindex = -1;
static void int_exit(int sig)
{
if (ifindex > -1)
- set_link_xdp_fd(ifindex, -1);
+ set_link_xdp_fd(ifindex, -1, 0);
exit(0);
}
@@ -136,12 +137,13 @@ int main(int argc, char **argv)
{
unsigned char opt_flags[256] = {};
unsigned int kill_after_s = 0;
- const char *optstr = "i:a:p:s:d:m:T:P:h";
+ const char *optstr = "i:a:p:s:d:m:T:P:Sh";
int min_port = 0, max_port = 0;
struct iptnl_info tnl = {};
struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
struct vip vip = {};
char filename[256];
+ int flags = 0;
int opt;
int i;
@@ -201,6 +203,9 @@ int main(int argc, char **argv)
case 'T':
kill_after_s = atoi(optarg);
break;
+ case 'S':
+ flags |= XDP_FLAGS_SKB_MODE;
+ break;
default:
usage(argv[0]);
return 1;
@@ -243,14 +248,14 @@ int main(int argc, char **argv)
}
}
- if (set_link_xdp_fd(ifindex, prog_fd[0]) < 0) {
+ if (set_link_xdp_fd(ifindex, prog_fd[0], flags) < 0) {
printf("link set xdp fd failed\n");
return 1;
}
poll_stats(kill_after_s);
- set_link_xdp_fd(ifindex, -1);
+ set_link_xdp_fd(ifindex, -1, flags);
return 0;
}