bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default
@ 2019-12-16 11:07 Toke Høiland-Jørgensen
  2019-12-16 14:35 ` Jesper Dangaard Brouer
  2019-12-16 15:01 ` David Ahern
  0 siblings, 2 replies; 5+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-12-16 11:07 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: Toke Høiland-Jørgensen, netdev, bpf, David Ahern,
	Jesper Dangaard Brouer

When attaching XDP programs, userspace can set flags to request the attach
mode (generic/SKB mode, driver mode or hw offloaded mode). If no such flags
are requested, the kernel will attempt to attach in driver mode, and then
silently fall back to SKB mode if this fails.

The silent fallback is a major source of user confusion, as users will try
to load a program on a device without XDP support, and instead of an error
they will get the silent fallback behaviour, not notice, and then wonder
why performance is not what they were expecting.

In an attempt to combat this, let's switch all the samples to default to
explicitly requesting driver-mode attach. As part of this, ensure that all
the userspace utilities have a switch to enable SKB mode. For those that
have a switch to request driver mode, keep it but turn it into a no-op.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
---
 samples/bpf/xdp1_user.c             |  5 ++++-
 samples/bpf/xdp_adjust_tail_user.c  |  5 ++++-
 samples/bpf/xdp_fwd_user.c          | 17 ++++++++++++++---
 samples/bpf/xdp_redirect_cpu_user.c |  4 ++++
 samples/bpf/xdp_redirect_map_user.c |  5 ++++-
 samples/bpf/xdp_redirect_user.c     |  5 ++++-
 samples/bpf/xdp_router_ipv4_user.c  |  3 +++
 samples/bpf/xdp_rxq_info_user.c     |  4 ++++
 samples/bpf/xdp_sample_pkts_user.c  | 12 +++++++++---
 samples/bpf/xdp_tx_iptunnel_user.c  |  5 ++++-
 samples/bpf/xdpsock_user.c          |  5 ++++-
 11 files changed, 58 insertions(+), 12 deletions(-)

diff --git a/samples/bpf/xdp1_user.c b/samples/bpf/xdp1_user.c
index 3e553eed95a7..38a8852cb57f 100644
--- a/samples/bpf/xdp1_user.c
+++ b/samples/bpf/xdp1_user.c
@@ -98,7 +98,7 @@ int main(int argc, char **argv)
 			xdp_flags |= XDP_FLAGS_SKB_MODE;
 			break;
 		case 'N':
-			xdp_flags |= XDP_FLAGS_DRV_MODE;
+			/* default, set below */
 			break;
 		case 'F':
 			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
@@ -109,6 +109,9 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	if (optind == argc) {
 		usage(basename(argv[0]));
 		return 1;
diff --git a/samples/bpf/xdp_adjust_tail_user.c b/samples/bpf/xdp_adjust_tail_user.c
index d86e9ad0356b..008789eb6ada 100644
--- a/samples/bpf/xdp_adjust_tail_user.c
+++ b/samples/bpf/xdp_adjust_tail_user.c
@@ -120,7 +120,7 @@ int main(int argc, char **argv)
 			xdp_flags |= XDP_FLAGS_SKB_MODE;
 			break;
 		case 'N':
-			xdp_flags |= XDP_FLAGS_DRV_MODE;
+			/* default, set below */
 			break;
 		case 'F':
 			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
@@ -132,6 +132,9 @@ int main(int argc, char **argv)
 		opt_flags[opt] = 0;
 	}
 
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	for (i = 0; i < strlen(optstr); i++) {
 		if (opt_flags[(unsigned int)optstr[i]]) {
 			fprintf(stderr, "Missing argument -%c\n", optstr[i]);
diff --git a/samples/bpf/xdp_fwd_user.c b/samples/bpf/xdp_fwd_user.c
index 97ff1dad7669..c30f9acfdb84 100644
--- a/samples/bpf/xdp_fwd_user.c
+++ b/samples/bpf/xdp_fwd_user.c
@@ -27,11 +27,13 @@
 #include "libbpf.h"
 #include <bpf/bpf.h>
 
+static __u32 xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
+
 static int do_attach(int idx, int prog_fd, int map_fd, const char *name)
 {
 	int err;
 
-	err = bpf_set_link_xdp_fd(idx, prog_fd, 0);
+	err = bpf_set_link_xdp_fd(idx, prog_fd, xdp_flags);
 	if (err < 0) {
 		printf("ERROR: failed to attach program to %s\n", name);
 		return err;
@@ -49,7 +51,7 @@ static int do_detach(int idx, const char *name)
 {
 	int err;
 
-	err = bpf_set_link_xdp_fd(idx, -1, 0);
+	err = bpf_set_link_xdp_fd(idx, -1, xdp_flags);
 	if (err < 0)
 		printf("ERROR: failed to detach program from %s\n", name);
 
@@ -83,11 +85,17 @@ int main(int argc, char **argv)
 	int attach = 1;
 	int ret = 0;
 
-	while ((opt = getopt(argc, argv, ":dD")) != -1) {
+	while ((opt = getopt(argc, argv, ":dDSF")) != -1) {
 		switch (opt) {
 		case 'd':
 			attach = 0;
 			break;
+		case 'S':
+			xdp_flags |= XDP_FLAGS_SKB_MODE;
+			break;
+		case 'F':
+			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
+			break;
 		case 'D':
 			prog_name = "xdp_fwd_direct";
 			break;
@@ -97,6 +105,9 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	if (optind == argc) {
 		usage(basename(argv[0]));
 		return 1;
diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c
index 0da6e9e7132e..72af628529b5 100644
--- a/samples/bpf/xdp_redirect_cpu_user.c
+++ b/samples/bpf/xdp_redirect_cpu_user.c
@@ -728,6 +728,10 @@ int main(int argc, char **argv)
 			return EXIT_FAIL_OPTION;
 		}
 	}
+
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	/* Required option */
 	if (ifindex == -1) {
 		fprintf(stderr, "ERR: required option --dev missing\n");
diff --git a/samples/bpf/xdp_redirect_map_user.c b/samples/bpf/xdp_redirect_map_user.c
index f70ee33907fd..cc840661faab 100644
--- a/samples/bpf/xdp_redirect_map_user.c
+++ b/samples/bpf/xdp_redirect_map_user.c
@@ -116,7 +116,7 @@ int main(int argc, char **argv)
 			xdp_flags |= XDP_FLAGS_SKB_MODE;
 			break;
 		case 'N':
-			xdp_flags |= XDP_FLAGS_DRV_MODE;
+			/* default, set below */
 			break;
 		case 'F':
 			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
@@ -127,6 +127,9 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	if (optind == argc) {
 		printf("usage: %s <IFNAME|IFINDEX>_IN <IFNAME|IFINDEX>_OUT\n", argv[0]);
 		return 1;
diff --git a/samples/bpf/xdp_redirect_user.c b/samples/bpf/xdp_redirect_user.c
index 5440cd620607..71dff8e3382a 100644
--- a/samples/bpf/xdp_redirect_user.c
+++ b/samples/bpf/xdp_redirect_user.c
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
 			xdp_flags |= XDP_FLAGS_SKB_MODE;
 			break;
 		case 'N':
-			xdp_flags |= XDP_FLAGS_DRV_MODE;
+			/* default, set below */
 			break;
 		case 'F':
 			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
@@ -128,6 +128,9 @@ int main(int argc, char **argv)
 		}
 	}
 
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	if (optind == argc) {
 		printf("usage: %s <IFNAME|IFINDEX>_IN <IFNAME|IFINDEX>_OUT\n", argv[0]);
 		return 1;
diff --git a/samples/bpf/xdp_router_ipv4_user.c b/samples/bpf/xdp_router_ipv4_user.c
index 1469b66ebad1..fef286c5add2 100644
--- a/samples/bpf/xdp_router_ipv4_user.c
+++ b/samples/bpf/xdp_router_ipv4_user.c
@@ -662,6 +662,9 @@ int main(int ac, char **argv)
 		}
 	}
 
+	if (!(flags & XDP_FLAGS_SKB_MODE))
+		flags |= XDP_FLAGS_DRV_MODE;
+
 	if (optind == ac) {
 		usage(basename(argv[0]));
 		return 1;
diff --git a/samples/bpf/xdp_rxq_info_user.c b/samples/bpf/xdp_rxq_info_user.c
index 8fc3ad01de72..fc4983fd6959 100644
--- a/samples/bpf/xdp_rxq_info_user.c
+++ b/samples/bpf/xdp_rxq_info_user.c
@@ -551,6 +551,10 @@ int main(int argc, char **argv)
 			return EXIT_FAIL_OPTION;
 		}
 	}
+
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	/* Required option */
 	if (ifindex == -1) {
 		fprintf(stderr, "ERR: required option --dev missing\n");
diff --git a/samples/bpf/xdp_sample_pkts_user.c b/samples/bpf/xdp_sample_pkts_user.c
index a5760e8bf2c4..8c1af1b7372d 100644
--- a/samples/bpf/xdp_sample_pkts_user.c
+++ b/samples/bpf/xdp_sample_pkts_user.c
@@ -52,13 +52,13 @@ static int do_detach(int idx, const char *name)
 	__u32 curr_prog_id = 0;
 	int err = 0;
 
-	err = bpf_get_link_xdp_id(idx, &curr_prog_id, 0);
+	err = bpf_get_link_xdp_id(idx, &curr_prog_id, xdp_flags);
 	if (err) {
 		printf("bpf_get_link_xdp_id failed\n");
 		return err;
 	}
 	if (prog_id == curr_prog_id) {
-		err = bpf_set_link_xdp_fd(idx, -1, 0);
+		err = bpf_set_link_xdp_fd(idx, -1, xdp_flags);
 		if (err < 0)
 			printf("ERROR: failed to detach prog from %s\n", name);
 	} else if (!curr_prog_id) {
@@ -115,7 +115,7 @@ int main(int argc, char **argv)
 		.prog_type	= BPF_PROG_TYPE_XDP,
 	};
 	struct perf_buffer_opts pb_opts = {};
-	const char *optstr = "F";
+	const char *optstr = "FS";
 	int prog_fd, map_fd, opt;
 	struct bpf_object *obj;
 	struct bpf_map *map;
@@ -127,12 +127,18 @@ int main(int argc, char **argv)
 		case 'F':
 			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
 			break;
+		case 'S':
+			xdp_flags |= XDP_FLAGS_SKB_MODE;
+			break;
 		default:
 			usage(basename(argv[0]));
 			return 1;
 		}
 	}
 
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	if (optind == argc) {
 		usage(basename(argv[0]));
 		return 1;
diff --git a/samples/bpf/xdp_tx_iptunnel_user.c b/samples/bpf/xdp_tx_iptunnel_user.c
index 2fe4c7f5ffe5..5f33b5530032 100644
--- a/samples/bpf/xdp_tx_iptunnel_user.c
+++ b/samples/bpf/xdp_tx_iptunnel_user.c
@@ -231,7 +231,7 @@ int main(int argc, char **argv)
 			xdp_flags |= XDP_FLAGS_SKB_MODE;
 			break;
 		case 'N':
-			xdp_flags |= XDP_FLAGS_DRV_MODE;
+			/* default, set below */
 			break;
 		case 'F':
 			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
@@ -243,6 +243,9 @@ int main(int argc, char **argv)
 		opt_flags[opt] = 0;
 	}
 
+	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
+		xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	for (i = 0; i < strlen(optstr); i++) {
 		if (opt_flags[(unsigned int)optstr[i]]) {
 			fprintf(stderr, "Missing argument -%c\n", optstr[i]);
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index a15480010828..e7829e5baaff 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -440,7 +440,7 @@ static void parse_command_line(int argc, char **argv)
 			opt_xdp_bind_flags |= XDP_COPY;
 			break;
 		case 'N':
-			opt_xdp_flags |= XDP_FLAGS_DRV_MODE;
+			/* default, set below */
 			break;
 		case 'n':
 			opt_interval = atoi(optarg);
@@ -474,6 +474,9 @@ static void parse_command_line(int argc, char **argv)
 		}
 	}
 
+	if (!(opt_xdp_flags & XDP_FLAGS_SKB_MODE))
+		opt_xdp_flags |= XDP_FLAGS_DRV_MODE;
+
 	opt_ifindex = if_nametoindex(opt_if);
 	if (!opt_ifindex) {
 		fprintf(stderr, "ERROR: interface \"%s\" does not exist\n",
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default
  2019-12-16 11:07 [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default Toke Høiland-Jørgensen
@ 2019-12-16 14:35 ` Jesper Dangaard Brouer
  2019-12-16 14:55   ` Jesper Dangaard Brouer
  2019-12-16 15:01 ` David Ahern
  1 sibling, 1 reply; 5+ messages in thread
From: Jesper Dangaard Brouer @ 2019-12-16 14:35 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Alexei Starovoitov, Daniel Borkmann, netdev, bpf, David Ahern, brouer

On Mon, 16 Dec 2019 12:07:42 +0100
Toke Høiland-Jørgensen <toke@redhat.com> wrote:

> When attaching XDP programs, userspace can set flags to request the attach
> mode (generic/SKB mode, driver mode or hw offloaded mode). If no such flags
> are requested, the kernel will attempt to attach in driver mode, and then
> silently fall back to SKB mode if this fails.
> 
> The silent fallback is a major source of user confusion, as users will try
> to load a program on a device without XDP support, and instead of an error
> they will get the silent fallback behaviour, not notice, and then wonder
> why performance is not what they were expecting.
> 
> In an attempt to combat this, let's switch all the samples to default to
> explicitly requesting driver-mode attach. As part of this, ensure that all
> the userspace utilities have a switch to enable SKB mode. For those that
> have a switch to request driver mode, keep it but turn it into a no-op.
> 
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> ---

I agree, that this is a good way forward.

What is the observed behavior / error-message after this change?

I wanted to test this myself, but compiling samples/bpf/ is breaking
(again) on my system...

> diff --git a/samples/bpf/xdp1_user.c b/samples/bpf/xdp1_user.c
> index 3e553eed95a7..38a8852cb57f 100644
> --- a/samples/bpf/xdp1_user.c
> +++ b/samples/bpf/xdp1_user.c
> @@ -98,7 +98,7 @@ int main(int argc, char **argv)
>  			xdp_flags |= XDP_FLAGS_SKB_MODE;
>  			break;
>  		case 'N':
> -			xdp_flags |= XDP_FLAGS_DRV_MODE;
> +			/* default, set below */
>  			break;
>  		case 'F':
>  			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
> @@ -109,6 +109,9 @@ int main(int argc, char **argv)
>  		}
>  	}
>  
> +	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
> +		xdp_flags |= XDP_FLAGS_DRV_MODE;
> +
>  	if (optind == argc) {
>  		usage(basename(argv[0]));
>  		return 1;


-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default
  2019-12-16 14:35 ` Jesper Dangaard Brouer
@ 2019-12-16 14:55   ` Jesper Dangaard Brouer
  0 siblings, 0 replies; 5+ messages in thread
From: Jesper Dangaard Brouer @ 2019-12-16 14:55 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen
  Cc: Alexei Starovoitov, Daniel Borkmann, netdev, bpf, David Ahern, brouer

On Mon, 16 Dec 2019 15:35:01 +0100
Jesper Dangaard Brouer <brouer@redhat.com> wrote:

> On Mon, 16 Dec 2019 12:07:42 +0100
> Toke Høiland-Jørgensen <toke@redhat.com> wrote:
> 
> > When attaching XDP programs, userspace can set flags to request the attach
> > mode (generic/SKB mode, driver mode or hw offloaded mode). If no such flags
> > are requested, the kernel will attempt to attach in driver mode, and then
> > silently fall back to SKB mode if this fails.
> > 
> > The silent fallback is a major source of user confusion, as users will try
> > to load a program on a device without XDP support, and instead of an error
> > they will get the silent fallback behaviour, not notice, and then wonder
> > why performance is not what they were expecting.
> > 
> > In an attempt to combat this, let's switch all the samples to default to
> > explicitly requesting driver-mode attach. As part of this, ensure that all
> > the userspace utilities have a switch to enable SKB mode. For those that
> > have a switch to request driver mode, keep it but turn it into a no-op.
> > 
> > Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> > ---  
> 
> I agree, that this is a good way forward.
> 
> What is the observed behavior / error-message after this change?

The error message looks fine:

 $ sudo ./xdp1 enp0s31f6
 libbpf: Kernel error message: underlying driver does not support XDP in native mode
 link set xdp fd failed
 
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>

> I wanted to test this myself, but compiling samples/bpf/ is breaking
> (again) on my system...

I saw your other compile fixes on the list and used those... thanks!


> > diff --git a/samples/bpf/xdp1_user.c b/samples/bpf/xdp1_user.c
> > index 3e553eed95a7..38a8852cb57f 100644
> > --- a/samples/bpf/xdp1_user.c
> > +++ b/samples/bpf/xdp1_user.c
> > @@ -98,7 +98,7 @@ int main(int argc, char **argv)
> >  			xdp_flags |= XDP_FLAGS_SKB_MODE;
> >  			break;
> >  		case 'N':
> > -			xdp_flags |= XDP_FLAGS_DRV_MODE;
> > +			/* default, set below */
> >  			break;
> >  		case 'F':
> >  			xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
> > @@ -109,6 +109,9 @@ int main(int argc, char **argv)
> >  		}
> >  	}
> >  
> > +	if (!(xdp_flags & XDP_FLAGS_SKB_MODE))
> > +		xdp_flags |= XDP_FLAGS_DRV_MODE;
> > +
> >  	if (optind == argc) {
> >  		usage(basename(argv[0]));
> >  		return 1;  

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default
  2019-12-16 11:07 [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default Toke Høiland-Jørgensen
  2019-12-16 14:35 ` Jesper Dangaard Brouer
@ 2019-12-16 15:01 ` David Ahern
  2019-12-16 15:06   ` Alexei Starovoitov
  1 sibling, 1 reply; 5+ messages in thread
From: David Ahern @ 2019-12-16 15:01 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Alexei Starovoitov, Daniel Borkmann
  Cc: netdev, bpf, Jesper Dangaard Brouer

On 12/16/19 4:07 AM, Toke Høiland-Jørgensen wrote:
> When attaching XDP programs, userspace can set flags to request the attach
> mode (generic/SKB mode, driver mode or hw offloaded mode). If no such flags
> are requested, the kernel will attempt to attach in driver mode, and then
> silently fall back to SKB mode if this fails.
> 
> The silent fallback is a major source of user confusion, as users will try
> to load a program on a device without XDP support, and instead of an error
> they will get the silent fallback behaviour, not notice, and then wonder
> why performance is not what they were expecting.
> 
> In an attempt to combat this, let's switch all the samples to default to
> explicitly requesting driver-mode attach. As part of this, ensure that all
> the userspace utilities have a switch to enable SKB mode. For those that
> have a switch to request driver mode, keep it but turn it into a no-op.
> 
> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> ---
>  samples/bpf/xdp1_user.c             |  5 ++++-
>  samples/bpf/xdp_adjust_tail_user.c  |  5 ++++-
>  samples/bpf/xdp_fwd_user.c          | 17 ++++++++++++++---
>  samples/bpf/xdp_redirect_cpu_user.c |  4 ++++
>  samples/bpf/xdp_redirect_map_user.c |  5 ++++-
>  samples/bpf/xdp_redirect_user.c     |  5 ++++-
>  samples/bpf/xdp_router_ipv4_user.c  |  3 +++
>  samples/bpf/xdp_rxq_info_user.c     |  4 ++++
>  samples/bpf/xdp_sample_pkts_user.c  | 12 +++++++++---
>  samples/bpf/xdp_tx_iptunnel_user.c  |  5 ++++-
>  samples/bpf/xdpsock_user.c          |  5 ++++-
>  11 files changed, 58 insertions(+), 12 deletions(-)
> 

Acked-by: David Ahern <dsahern@gmail.com>

Thanks for doing this, Toke.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default
  2019-12-16 15:01 ` David Ahern
@ 2019-12-16 15:06   ` Alexei Starovoitov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2019-12-16 15:06 UTC (permalink / raw)
  To: David Ahern
  Cc: Toke Høiland-Jørgensen, Alexei Starovoitov,
	Daniel Borkmann, Network Development, bpf,
	Jesper Dangaard Brouer

On Mon, Dec 16, 2019 at 7:01 AM David Ahern <dsahern@gmail.com> wrote:
>
> On 12/16/19 4:07 AM, Toke Høiland-Jørgensen wrote:
> > When attaching XDP programs, userspace can set flags to request the attach
> > mode (generic/SKB mode, driver mode or hw offloaded mode). If no such flags
> > are requested, the kernel will attempt to attach in driver mode, and then
> > silently fall back to SKB mode if this fails.
> >
> > The silent fallback is a major source of user confusion, as users will try
> > to load a program on a device without XDP support, and instead of an error
> > they will get the silent fallback behaviour, not notice, and then wonder
> > why performance is not what they were expecting.
> >
> > In an attempt to combat this, let's switch all the samples to default to
> > explicitly requesting driver-mode attach. As part of this, ensure that all
> > the userspace utilities have a switch to enable SKB mode. For those that
> > have a switch to request driver mode, keep it but turn it into a no-op.
> >
> > Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
> > ---
> >  samples/bpf/xdp1_user.c             |  5 ++++-
> >  samples/bpf/xdp_adjust_tail_user.c  |  5 ++++-
> >  samples/bpf/xdp_fwd_user.c          | 17 ++++++++++++++---
> >  samples/bpf/xdp_redirect_cpu_user.c |  4 ++++
> >  samples/bpf/xdp_redirect_map_user.c |  5 ++++-
> >  samples/bpf/xdp_redirect_user.c     |  5 ++++-
> >  samples/bpf/xdp_router_ipv4_user.c  |  3 +++
> >  samples/bpf/xdp_rxq_info_user.c     |  4 ++++
> >  samples/bpf/xdp_sample_pkts_user.c  | 12 +++++++++---
> >  samples/bpf/xdp_tx_iptunnel_user.c  |  5 ++++-
> >  samples/bpf/xdpsock_user.c          |  5 ++++-
> >  11 files changed, 58 insertions(+), 12 deletions(-)
> >
>
> Acked-by: David Ahern <dsahern@gmail.com>

Applied. Thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-16 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-16 11:07 [PATCH bpf-next] samples/bpf: Attach XDP programs in driver mode by default Toke Høiland-Jørgensen
2019-12-16 14:35 ` Jesper Dangaard Brouer
2019-12-16 14:55   ` Jesper Dangaard Brouer
2019-12-16 15:01 ` David Ahern
2019-12-16 15:06   ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).