summaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2017-05-11 19:04:45 -0400
committerDavid S. Miller <davem@davemloft.net>2017-05-11 21:30:57 -0400
commit0489df9a430e9607de8130a6bc4bf4c02f96eaf1 (patch)
tree88f00a27ce3e1e8c94269f687dcbcf951b4c9f1b /samples
parent0a5539f66133a02b24f9cc43da5b84b7e6f3f436 (diff)
xdp: add flag to enforce driver mode
After commit b5cdae3291f7 ("net: Generic XDP") we automatically fall back to a generic XDP variant if the driver does not support native XDP. Allow for an option where the user can specify that always the native XDP variant should be selected and in case it's not supported by a driver, just bail out. Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'samples')
-rw-r--r--samples/bpf/xdp1_user.c8
-rw-r--r--samples/bpf/xdp_tx_iptunnel_user.c7
2 files changed, 12 insertions, 3 deletions
diff --git a/samples/bpf/xdp1_user.c b/samples/bpf/xdp1_user.c
index 378850c70eb8..17be9ea3ecb2 100644
--- a/samples/bpf/xdp1_user.c
+++ b/samples/bpf/xdp1_user.c
@@ -62,13 +62,14 @@ static void usage(const char *prog)
62 fprintf(stderr, 62 fprintf(stderr,
63 "usage: %s [OPTS] IFINDEX\n\n" 63 "usage: %s [OPTS] IFINDEX\n\n"
64 "OPTS:\n" 64 "OPTS:\n"
65 " -S use skb-mode\n", 65 " -S use skb-mode\n"
66 " -N enforce native mode\n",
66 prog); 67 prog);
67} 68}
68 69
69int main(int argc, char **argv) 70int main(int argc, char **argv)
70{ 71{
71 const char *optstr = "S"; 72 const char *optstr = "SN";
72 char filename[256]; 73 char filename[256];
73 int opt; 74 int opt;
74 75
@@ -77,6 +78,9 @@ int main(int argc, char **argv)
77 case 'S': 78 case 'S':
78 xdp_flags |= XDP_FLAGS_SKB_MODE; 79 xdp_flags |= XDP_FLAGS_SKB_MODE;
79 break; 80 break;
81 case 'N':
82 xdp_flags |= XDP_FLAGS_DRV_MODE;
83 break;
80 default: 84 default:
81 usage(basename(argv[0])); 85 usage(basename(argv[0]));
82 return 1; 86 return 1;
diff --git a/samples/bpf/xdp_tx_iptunnel_user.c b/samples/bpf/xdp_tx_iptunnel_user.c
index 92b8bde9337c..631cdcc41c97 100644
--- a/samples/bpf/xdp_tx_iptunnel_user.c
+++ b/samples/bpf/xdp_tx_iptunnel_user.c
@@ -79,6 +79,8 @@ static void usage(const char *cmd)
79 printf(" -m <dest-MAC> Used in sending the IP Tunneled pkt\n"); 79 printf(" -m <dest-MAC> Used in sending the IP Tunneled pkt\n");
80 printf(" -T <stop-after-X-seconds> Default: 0 (forever)\n"); 80 printf(" -T <stop-after-X-seconds> Default: 0 (forever)\n");
81 printf(" -P <IP-Protocol> Default is TCP\n"); 81 printf(" -P <IP-Protocol> Default is TCP\n");
82 printf(" -S use skb-mode\n");
83 printf(" -N enforce native mode\n");
82 printf(" -h Display this help\n"); 84 printf(" -h Display this help\n");
83} 85}
84 86
@@ -138,7 +140,7 @@ int main(int argc, char **argv)
138{ 140{
139 unsigned char opt_flags[256] = {}; 141 unsigned char opt_flags[256] = {};
140 unsigned int kill_after_s = 0; 142 unsigned int kill_after_s = 0;
141 const char *optstr = "i:a:p:s:d:m:T:P:Sh"; 143 const char *optstr = "i:a:p:s:d:m:T:P:SNh";
142 int min_port = 0, max_port = 0; 144 int min_port = 0, max_port = 0;
143 struct iptnl_info tnl = {}; 145 struct iptnl_info tnl = {};
144 struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY}; 146 struct rlimit r = {RLIM_INFINITY, RLIM_INFINITY};
@@ -206,6 +208,9 @@ int main(int argc, char **argv)
206 case 'S': 208 case 'S':
207 xdp_flags |= XDP_FLAGS_SKB_MODE; 209 xdp_flags |= XDP_FLAGS_SKB_MODE;
208 break; 210 break;
211 case 'N':
212 xdp_flags |= XDP_FLAGS_DRV_MODE;
213 break;
209 default: 214 default:
210 usage(argv[0]); 215 usage(argv[0]);
211 return 1; 216 return 1;