[<prev] [next>] [day] [month] [year] [list]
Message-ID: <039ED4275CED7440929022BC67E70611532FB219@SHSMSX103.ccr.corp.intel.com>
Date: Sat, 8 Dec 2018 10:08:12 +0000
From: "Zhang, Qi Z" <qi.z.zhang@...el.com>
To: Björn Töpel <bjorn.topel@...il.com>,
"Karlsson, Magnus" <magnus.karlsson@...el.com>,
"magnus.karlsson@...il.com" <magnus.karlsson@...il.com>,
"ast@...nel.org" <ast@...nel.org>,
"daniel@...earbox.net" <daniel@...earbox.net>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: "Topel, Bjorn" <bjorn.topel@...el.com>,
"brouer@...hat.com" <brouer@...hat.com>,
"u9012063@...il.com" <u9012063@...il.com>
Subject: RE: [PATCH bpf-next 7/7] samples: bpf: add support for XDP_ATTACH
to xdpsock
Hi:
Seems there are only 6 patches of the patch set in patchwork
https://patchwork.ozlabs.org/project/netdev/list/?submitter=70569
https://patchwork.ozlabs.org/project/netdev/list/?series=80389
Anyone can help to check why patch 7/7 is missing?
Thanks
Qi
> -----Original Message-----
> From: Björn Töpel [mailto:bjorn.topel@...il.com]
> Sent: Friday, December 7, 2018 7:45 PM
> To: bjorn.topel@...il.com; Karlsson, Magnus <magnus.karlsson@...el.com>;
> magnus.karlsson@...il.com; ast@...nel.org; daniel@...earbox.net;
> netdev@...r.kernel.org
> Cc: Topel, Bjorn <bjorn.topel@...el.com>; brouer@...hat.com;
> u9012063@...il.com; Zhang, Qi Z <qi.z.zhang@...el.com>
> Subject: [PATCH bpf-next 7/7] samples: bpf: add support for XDP_ATTACH to
> xdpsock
>
> From: Björn Töpel <bjorn.topel@...el.com>
>
> Teach the sample xdpsock application about XDP_ATTACH.
>
> Signed-off-by: Björn Töpel <bjorn.topel@...el.com>
> ---
> samples/bpf/xdpsock_user.c | 108 +++++++++++++++++++++++--------------
> 1 file changed, 67 insertions(+), 41 deletions(-)
>
> diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c index
> 57ecadc58403..12f908b60468 100644
> --- a/samples/bpf/xdpsock_user.c
> +++ b/samples/bpf/xdpsock_user.c
> @@ -633,7 +633,8 @@ static void int_exit(int sig) {
> (void)sig;
> dump_stats();
> - bpf_set_link_xdp_fd(opt_ifindex, -1, opt_xdp_flags);
> + if (!(opt_xdp_bind_flags & XDP_ATTACH))
> + bpf_set_link_xdp_fd(opt_ifindex, -1, opt_xdp_flags);
> exit(EXIT_SUCCESS);
> }
>
> @@ -650,6 +651,7 @@ static struct option long_options[] = {
> {"interval", required_argument, 0, 'n'},
> {"zero-copy", no_argument, 0, 'z'},
> {"copy", no_argument, 0, 'c'},
> + {"attach", no_argument, 0, 'a'},
> {0, 0, 0, 0}
> };
>
> @@ -670,6 +672,7 @@ static void usage(const char *prog)
> " -n, --interval=n Specify statistics update interval (default 1
> sec).\n"
> " -z, --zero-copy Force zero-copy mode.\n"
> " -c, --copy Force copy mode.\n"
> + " -a, --attach XDP_ATTACH mode.\n"
> "\n";
> fprintf(stderr, str, prog);
> exit(EXIT_FAILURE);
> @@ -682,7 +685,7 @@ static void parse_command_line(int argc, char **argv)
> opterr = 0;
>
> for (;;) {
> - c = getopt_long(argc, argv, "rtli:q:psSNn:cz", long_options,
> + c = getopt_long(argc, argv, "rtli:q:psSNn:cza", long_options,
> &option_index);
> if (c == -1)
> break;
> @@ -725,11 +728,22 @@ static void parse_command_line(int argc, char
> **argv)
> case 'c':
> opt_xdp_bind_flags |= XDP_COPY;
> break;
> + case 'a':
> + opt_xdp_bind_flags |= XDP_ATTACH;
> + break;
> default:
> usage(basename(argv[0]));
> }
> }
>
> + if (opt_xdp_bind_flags & XDP_ATTACH) {
> + if (opt_xdp_flags & XDP_FLAGS_DRV_MODE)
> + opt_xdp_bind_flags |= XDP_BUILTIN_DRV_MODE;
> + if (opt_xdp_flags & XDP_FLAGS_SKB_MODE)
> + opt_xdp_bind_flags |= XDP_BUILTIN_SKB_MODE;
> +
> + }
> +
> opt_ifindex = if_nametoindex(opt_if);
> if (!opt_ifindex) {
> fprintf(stderr, "ERROR: interface \"%s\" does not exist\n", @@
> -903,7 +917,7 @@ int main(int argc, char **argv)
> struct bpf_prog_load_attr prog_load_attr = {
> .prog_type = BPF_PROG_TYPE_XDP,
> };
> - int prog_fd, qidconf_map, xsks_map;
> + int prog_fd, qidconf_map, xsks_map = -1;
> struct bpf_object *obj;
> char xdp_filename[256];
> struct bpf_map *map;
> @@ -918,59 +932,71 @@ int main(int argc, char **argv)
> exit(EXIT_FAILURE);
> }
>
> - snprintf(xdp_filename, sizeof(xdp_filename), "%s_kern.o", argv[0]);
> - prog_load_attr.file = xdp_filename;
> + if (!(opt_xdp_bind_flags & XDP_ATTACH)) {
> + snprintf(xdp_filename, sizeof(xdp_filename), "%s_kern.o",
> + argv[0]);
> + prog_load_attr.file = xdp_filename;
>
> - if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd))
> - exit(EXIT_FAILURE);
> - if (prog_fd < 0) {
> - fprintf(stderr, "ERROR: no program found: %s\n",
> - strerror(prog_fd));
> - exit(EXIT_FAILURE);
> - }
> + if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd))
> + exit(EXIT_FAILURE);
> + if (prog_fd < 0) {
> + fprintf(stderr, "ERROR: no program found: %s\n",
> + strerror(prog_fd));
> + exit(EXIT_FAILURE);
> + }
>
> - map = bpf_object__find_map_by_name(obj, "qidconf_map");
> - qidconf_map = bpf_map__fd(map);
> - if (qidconf_map < 0) {
> - fprintf(stderr, "ERROR: no qidconf map found: %s\n",
> - strerror(qidconf_map));
> - exit(EXIT_FAILURE);
> - }
> + map = bpf_object__find_map_by_name(obj, "qidconf_map");
> + qidconf_map = bpf_map__fd(map);
> + if (qidconf_map < 0) {
> + fprintf(stderr, "ERROR: no qidconf map found: %s\n",
> + strerror(qidconf_map));
> + exit(EXIT_FAILURE);
> + }
>
> - map = bpf_object__find_map_by_name(obj, "xsks_map");
> - xsks_map = bpf_map__fd(map);
> - if (xsks_map < 0) {
> - fprintf(stderr, "ERROR: no xsks map found: %s\n",
> - strerror(xsks_map));
> - exit(EXIT_FAILURE);
> - }
> + map = bpf_object__find_map_by_name(obj, "xsks_map");
> + xsks_map = bpf_map__fd(map);
> + if (xsks_map < 0) {
> + fprintf(stderr, "ERROR: no xsks map found: %s\n",
> + strerror(xsks_map));
> + exit(EXIT_FAILURE);
> + }
>
> - if (bpf_set_link_xdp_fd(opt_ifindex, prog_fd, opt_xdp_flags) < 0) {
> - fprintf(stderr, "ERROR: link set xdp fd failed\n");
> - exit(EXIT_FAILURE);
> - }
> + if (bpf_set_link_xdp_fd(opt_ifindex, prog_fd,
> + opt_xdp_flags) < 0) {
> + fprintf(stderr, "ERROR: link set xdp fd failed\n");
> + exit(EXIT_FAILURE);
> + }
>
> - ret = bpf_map_update_elem(qidconf_map, &key, &opt_queue, 0);
> - if (ret) {
> - fprintf(stderr, "ERROR: bpf_map_update_elem qidconf\n");
> - exit(EXIT_FAILURE);
> + ret = bpf_map_update_elem(qidconf_map, &key, &opt_queue, 0);
> + if (ret) {
> + fprintf(stderr, "ERROR: bpf_map_update_elem qidconf\n");
> + exit(EXIT_FAILURE);
> + }
> }
>
> /* Create sockets... */
> xsks[num_socks++] = xsk_configure(NULL);
>
> #if RR_LB
> + if (opt_xdp_bind_flags & XDP_ATTACH)
> + exit(EXIT_FAILURE);
> +
> for (i = 0; i < MAX_SOCKS - 1; i++)
> xsks[num_socks++] = xsk_configure(xsks[0]->umem); #endif
>
> - /* ...and insert them into the map. */
> - for (i = 0; i < num_socks; i++) {
> - key = i;
> - ret = bpf_map_update_elem(xsks_map, &key, &xsks[i]->sfd, 0);
> - if (ret) {
> - fprintf(stderr, "ERROR: bpf_map_update_elem %d\n", i);
> - exit(EXIT_FAILURE);
> + if (!(opt_xdp_bind_flags & XDP_ATTACH)) {
> + /* ...and insert them into the map. */
> + for (i = 0; i < num_socks; i++) {
> + key = i;
> + ret = bpf_map_update_elem(xsks_map, &key,
> + &xsks[i]->sfd, 0);
> + if (ret) {
> + fprintf(stderr,
> + "ERROR: bpf_map_update_elem %d\n",
> + i);
> + exit(EXIT_FAILURE);
> + }
> }
> }
>
> --
> 2.19.1
Powered by blists - more mailing lists