Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/807128/?format=api
{ "id": 807128, "url": "http://patchwork.ozlabs.org/api/patches/807128/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/150401748630.16384.478521489037692464.stgit@firesoul/", "project": { "id": 7, "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api", "name": "Linux network development", "link_name": "netdev", "list_id": "netdev.vger.kernel.org", "list_email": "netdev@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<150401748630.16384.478521489037692464.stgit@firesoul>", "list_archive_url": null, "date": "2017-08-29T14:38:06", "name": "[net-next,6/7] samples/bpf: xdp_redirect load XDP dummy prog on TX device", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "df707c278e4823f29bad5885cff0a268815fbd3a", "submitter": { "id": 13625, "url": "http://patchwork.ozlabs.org/api/people/13625/?format=api", "name": "Jesper Dangaard Brouer", "email": "brouer@redhat.com" }, "delegate": { "id": 34, "url": "http://patchwork.ozlabs.org/api/users/34/?format=api", "username": "davem", "first_name": "David", "last_name": "Miller", "email": "davem@davemloft.net" }, "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/150401748630.16384.478521489037692464.stgit@firesoul/mbox/", "series": [ { "id": 382, "url": "http://patchwork.ozlabs.org/api/series/382/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=382", "date": "2017-08-29T14:37:35", "name": "XDP redirect tracepoints", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/382/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/807128/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/807128/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<netdev-owner@vger.kernel.org>", "X-Original-To": "patchwork-incoming@ozlabs.org", "Delivered-To": "patchwork-incoming@ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)", "ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com", "ext-mx06.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=brouer@redhat.com" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xhWTK4mt6z9t38\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 30 Aug 2017 00:38:13 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1754561AbdH2OiM (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 29 Aug 2017 10:38:12 -0400", "from mx1.redhat.com ([209.132.183.28]:50328 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1754556AbdH2OiK (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tTue, 29 Aug 2017 10:38:10 -0400", "from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 57158285C1;\n\tTue, 29 Aug 2017 14:38:10 +0000 (UTC)", "from firesoul.localdomain (ovpn-200-32.brq.redhat.com\n\t[10.40.200.32])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 2F6D16BF9C;\n\tTue, 29 Aug 2017 14:38:07 +0000 (UTC)", "from [192.168.5.1] (localhost [IPv6:::1])\n\tby firesoul.localdomain (Postfix) with ESMTP id 5CC7130F12C9F;\n\tTue, 29 Aug 2017 16:38:06 +0200 (CEST)" ], "DMARC-Filter": "OpenDMARC Filter v1.3.2 mx1.redhat.com 57158285C1", "Subject": "[PATCH net-next 6/7] samples/bpf: xdp_redirect load XDP dummy prog\n\ton TX device", "From": "Jesper Dangaard Brouer <brouer@redhat.com>", "To": "netdev@vger.kernel.org", "Cc": "John Fastabend <john.fastabend@gmail.com>,\n\tJesper Dangaard Brouer <brouer@redhat.com>", "Date": "Tue, 29 Aug 2017 16:38:06 +0200", "Message-ID": "<150401748630.16384.478521489037692464.stgit@firesoul>", "In-Reply-To": "<150401743083.16384.15778781741742858567.stgit@firesoul>", "References": "<150401743083.16384.15778781741742858567.stgit@firesoul>", "User-Agent": "StGit/0.17.1-dirty", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13", "X-Greylist": "Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.30]);\n\tTue, 29 Aug 2017 14:38:10 +0000 (UTC)", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "For supporting XDP_REDIRECT, a device driver must (obviously)\nimplement the \"TX\" function ndo_xdp_xmit(). An additional requirement\nis you cannot TX out a device, unless it also have a xdp bpf program\nattached. This dependency is caused by the driver code need to setup\nXDP resources before it can ndo_xdp_xmit.\n\nUpdate bpf samples xdp_redirect and xdp_redirect_map to automatically\nattach a dummy XDP program to the configured ifindex_out device. Use\nthe XDP flag XDP_FLAGS_UPDATE_IF_NOEXIST on the dummy load, to avoid\noverriding an existing XDP prog on the device.\n\nSigned-off-by: Jesper Dangaard Brouer <brouer@redhat.com>\n---\n samples/bpf/xdp_redirect_kern.c | 11 ++++++++++-\n samples/bpf/xdp_redirect_map_kern.c | 11 ++++++++++-\n samples/bpf/xdp_redirect_map_user.c | 22 +++++++++++++++-------\n samples/bpf/xdp_redirect_user.c | 21 +++++++++++++++------\n 4 files changed, 50 insertions(+), 15 deletions(-)", "diff": "diff --git a/samples/bpf/xdp_redirect_kern.c b/samples/bpf/xdp_redirect_kern.c\nindex a34ad457a684..1c90288d0203 100644\n--- a/samples/bpf/xdp_redirect_kern.c\n+++ b/samples/bpf/xdp_redirect_kern.c\n@@ -26,6 +26,9 @@ struct bpf_map_def SEC(\"maps\") tx_port = {\n \t.max_entries = 1,\n };\n \n+/* Count RX packets, as XDP bpf_prog doesn't get direct TX-success\n+ * feedback. Redirect TX errors can be caught via a tracepoint.\n+ */\n struct bpf_map_def SEC(\"maps\") rxcnt = {\n \t.type = BPF_MAP_TYPE_PERCPU_ARRAY,\n \t.key_size = sizeof(u32),\n@@ -33,7 +36,6 @@ struct bpf_map_def SEC(\"maps\") rxcnt = {\n \t.max_entries = 1,\n };\n \n-\n static void swap_src_dst_mac(void *data)\n {\n \tunsigned short *p = data;\n@@ -78,4 +80,11 @@ int xdp_redirect_prog(struct xdp_md *ctx)\n \treturn bpf_redirect(*ifindex, 0);\n }\n \n+/* Redirect require an XDP bpf_prog loaded on the TX device */\n+SEC(\"xdp_redirect_dummy\")\n+int xdp_redirect_dummy(struct xdp_md *ctx)\n+{\n+\treturn XDP_PASS;\n+}\n+\n char _license[] SEC(\"license\") = \"GPL\";\ndiff --git a/samples/bpf/xdp_redirect_map_kern.c b/samples/bpf/xdp_redirect_map_kern.c\nindex 2faf196e17ea..79795d41ad0d 100644\n--- a/samples/bpf/xdp_redirect_map_kern.c\n+++ b/samples/bpf/xdp_redirect_map_kern.c\n@@ -26,6 +26,9 @@ struct bpf_map_def SEC(\"maps\") tx_port = {\n \t.max_entries = 100,\n };\n \n+/* Count RX packets, as XDP bpf_prog doesn't get direct TX-success\n+ * feedback. Redirect TX errors can be caught via a tracepoint.\n+ */\n struct bpf_map_def SEC(\"maps\") rxcnt = {\n \t.type = BPF_MAP_TYPE_PERCPU_ARRAY,\n \t.key_size = sizeof(u32),\n@@ -33,7 +36,6 @@ struct bpf_map_def SEC(\"maps\") rxcnt = {\n \t.max_entries = 1,\n };\n \n-\n static void swap_src_dst_mac(void *data)\n {\n \tunsigned short *p = data;\n@@ -80,4 +82,11 @@ int xdp_redirect_map_prog(struct xdp_md *ctx)\n \treturn bpf_redirect_map(&tx_port, vport, 0);\n }\n \n+/* Redirect require an XDP bpf_prog loaded on the TX device */\n+SEC(\"xdp_redirect_dummy\")\n+int xdp_redirect_dummy(struct xdp_md *ctx)\n+{\n+\treturn XDP_PASS;\n+}\n+\n char _license[] SEC(\"license\") = \"GPL\";\ndiff --git a/samples/bpf/xdp_redirect_map_user.c b/samples/bpf/xdp_redirect_map_user.c\nindex a1ad00fdaa8a..d4d86a273fba 100644\n--- a/samples/bpf/xdp_redirect_map_user.c\n+++ b/samples/bpf/xdp_redirect_map_user.c\n@@ -16,6 +16,7 @@\n #include <signal.h>\n #include <stdio.h>\n #include <stdlib.h>\n+#include <stdbool.h>\n #include <string.h>\n #include <unistd.h>\n #include <libgen.h>\n@@ -26,17 +27,18 @@\n \n static int ifindex_in;\n static int ifindex_out;\n+static bool ifindex_out_xdp_dummy_attached = true;\n \n static __u32 xdp_flags;\n \n static void int_exit(int sig)\n {\n \tset_link_xdp_fd(ifindex_in, -1, xdp_flags);\n+\tif (ifindex_out_xdp_dummy_attached)\n+\t\tset_link_xdp_fd(ifindex_out, -1, xdp_flags);\n \texit(0);\n }\n \n-/* simple per-protocol drop counter\n- */\n static void poll_stats(int interval, int ifindex)\n {\n \tunsigned int nr_cpus = bpf_num_possible_cpus();\n@@ -70,7 +72,6 @@ static void usage(const char *prog)\n \t\tprog);\n }\n \n-\n int main(int argc, char **argv)\n {\n \tconst char *optstr = \"SN\";\n@@ -112,14 +113,21 @@ int main(int argc, char **argv)\n \t\treturn 1;\n \t}\n \n-\tsignal(SIGINT, int_exit);\n-\tsignal(SIGTERM, int_exit);\n-\n \tif (set_link_xdp_fd(ifindex_in, prog_fd[0], xdp_flags) < 0) {\n-\t\tprintf(\"link set xdp fd failed\\n\");\n+\t\tprintf(\"ERROR: link set xdp fd failed on %d\\n\", ifindex_in);\n \t\treturn 1;\n \t}\n \n+\t/* Loading dummy XDP prog on out-device */\n+\tif (set_link_xdp_fd(ifindex_out, prog_fd[1],\n+\t\t\t (xdp_flags | XDP_FLAGS_UPDATE_IF_NOEXIST)) < 0) {\n+\t\tprintf(\"WARN: link set xdp fd failed on %d\\n\", ifindex_out);\n+\t\tifindex_out_xdp_dummy_attached = false;\n+\t}\n+\n+\tsignal(SIGINT, int_exit);\n+\tsignal(SIGTERM, int_exit);\n+\n \tprintf(\"map[0] (vports) = %i, map[1] (map) = %i, map[2] (count) = %i\\n\",\n \t\tmap_fd[0], map_fd[1], map_fd[2]);\n \ndiff --git a/samples/bpf/xdp_redirect_user.c b/samples/bpf/xdp_redirect_user.c\nindex f705a1905d2d..4475d837bf2c 100644\n--- a/samples/bpf/xdp_redirect_user.c\n+++ b/samples/bpf/xdp_redirect_user.c\n@@ -16,6 +16,7 @@\n #include <signal.h>\n #include <stdio.h>\n #include <stdlib.h>\n+#include <stdbool.h>\n #include <string.h>\n #include <unistd.h>\n #include <libgen.h>\n@@ -26,17 +27,18 @@\n \n static int ifindex_in;\n static int ifindex_out;\n+static bool ifindex_out_xdp_dummy_attached = true;\n \n static __u32 xdp_flags;\n \n static void int_exit(int sig)\n {\n \tset_link_xdp_fd(ifindex_in, -1, xdp_flags);\n+\tif (ifindex_out_xdp_dummy_attached)\n+\t\tset_link_xdp_fd(ifindex_out, -1, xdp_flags);\n \texit(0);\n }\n \n-/* simple per-protocol drop counter\n- */\n static void poll_stats(int interval, int ifindex)\n {\n \tunsigned int nr_cpus = bpf_num_possible_cpus();\n@@ -112,14 +114,21 @@ int main(int argc, char **argv)\n \t\treturn 1;\n \t}\n \n-\tsignal(SIGINT, int_exit);\n-\tsignal(SIGTERM, int_exit);\n-\n \tif (set_link_xdp_fd(ifindex_in, prog_fd[0], xdp_flags) < 0) {\n-\t\tprintf(\"link set xdp fd failed\\n\");\n+\t\tprintf(\"ERROR: link set xdp fd failed on %d\\n\", ifindex_in);\n \t\treturn 1;\n \t}\n \n+\t/* Loading dummy XDP prog on out-device */\n+\tif (set_link_xdp_fd(ifindex_out, prog_fd[1],\n+\t\t\t (xdp_flags | XDP_FLAGS_UPDATE_IF_NOEXIST)) < 0) {\n+\t\tprintf(\"WARN: link set xdp fd failed on %d\\n\", ifindex_out);\n+\t\tifindex_out_xdp_dummy_attached = false;\n+\t}\n+\n+\tsignal(SIGINT, int_exit);\n+\tsignal(SIGTERM, int_exit);\n+\n \t/* bpf redirect port */\n \tret = bpf_map_update_elem(map_fd[0], &key, &ifindex_out, 0);\n \tif (ret) {\n", "prefixes": [ "net-next", "6/7" ] }