Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/815222/?format=api
{ "id": 815222, "url": "http://patchwork.ozlabs.org/api/patches/815222/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170919003904.5124-12-tom@quantonium.net/", "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": "<20170919003904.5124-12-tom@quantonium.net>", "list_archive_url": null, "date": "2017-09-19T00:39:01", "name": "[net-next,11/14] net: Add a facility to support application defined GSO", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "caaaf315de5dc46e40616d9d4e00ce46cdb95161", "submitter": { "id": 72064, "url": "http://patchwork.ozlabs.org/api/people/72064/?format=api", "name": "Tom Herbert", "email": "tom@quantonium.net" }, "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/20170919003904.5124-12-tom@quantonium.net/mbox/", "series": [ { "id": 3758, "url": "http://patchwork.ozlabs.org/api/series/3758/?format=api", "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=3758", "date": "2017-09-19T00:38:50", "name": "gtp: Additional feature support", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/3758/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/815222/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/815222/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>)", "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=quantonium-net.20150623.gappssmtp.com\n\theader.i=@quantonium-net.20150623.gappssmtp.com\n\theader.b=\"gvbSt2QB\"; dkim-atps=neutral" ], "Received": [ "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xx3tV6DP8z9s5L\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 10:40:02 +1000 (AEST)", "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751519AbdISAkA (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 20:40:00 -0400", "from mail-pg0-f51.google.com ([74.125.83.51]:50972 \"EHLO\n\tmail-pg0-f51.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751499AbdISAj6 (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 20:39:58 -0400", "by mail-pg0-f51.google.com with SMTP id p5so1089298pgn.7\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 17:39:58 -0700 (PDT)", "from localhost.localdomain (c-73-162-13-107.hsd1.ca.comcast.net.\n\t[73.162.13.107]) by smtp.gmail.com with ESMTPSA id\n\tk78sm662018pfb.157.2017.09.18.17.39.56\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 18 Sep 2017 17:39:57 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=quantonium-net.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=GJl+09fmAlrEwxv1vLKSfsQl/6LdaWqjqzwCT7Jc+Yo=;\n\tb=gvbSt2QBVTpUdFHkMhd1y2FCrZOKlWTetOCMUuA5S/IFK+Bpt48qy6x4cm3yh4QpRv\n\tfeL4uHrcHtvW5sqI5w50SxWkzWDgIhzPLgMD3eAHfUZPMFkKVlqI24yTU4iP3C5ejzOm\n\tVhxo/CZA7AVHX7wEzxJTrtN7jiYwj4cTaVJP9JcUlcGym0XhzUeeDIiZGDKOWiois+IQ\n\taEYlUxDCRh94Bg65bpd7fntFOeTnMZuzVf5cJLCm/JpmD5Wbv4s9Wh3lmjrN7RZJqc6J\n\tt+HgZ7rc3V4UW52bFxnYmTW6C9aAqdh64scyPJI0YyVlmZFvJEY4dgTcFKiwfKQwc5kG\n\tMJrw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=GJl+09fmAlrEwxv1vLKSfsQl/6LdaWqjqzwCT7Jc+Yo=;\n\tb=I4/yp1K98WA7zXDhSX8dZUuZlr/gYJL9sYFXmhiNfkQFv6t+bTeMyPMLrBe2O8/lKD\n\t9hb+prTmHhLyuBuIqhad+jYNs4ml8NNXxDCYm+gY5qZqs4qJ6UcaZVjN6lVomFocFIWi\n\tRfMYEBoQNu6/UDJq/XPVzIDsYmVUzygSW5iJMEADSpIK2RdNc0A+RgO/B47UegaIUPiJ\n\tUahFWogM7n8GLhQJ3FR6q3wUGOzLYFxFS5Mo5UIDq9uyOU4i4QMuaBUhHrSyw54QK0wE\n\tb4bPWQB9VbKy5m4eICAOF7jhforWMlIRIwC0vVUV6GPTZ7lQcubWywxe3zh0xxhRD0JM\n\tftSQ==", "X-Gm-Message-State": "AHPjjUj8NAsBEB9VF14fQ4u3bI+R2crzYwl2XRrE0bGkZpM935PnnqpH\n\tTIR651nzo8e3DL7n", "X-Google-Smtp-Source": "AOwi7QCLoqP4o/U3u8sFdeXyCwl4Un5rHPFRD0+9cW2AqYFxgEejgW+ZgpA8QWynuHJwIf9kQgCkVA==", "X-Received": "by 10.84.179.165 with SMTP id b34mr341381plc.15.1505781598136;\n\tMon, 18 Sep 2017 17:39:58 -0700 (PDT)", "From": "Tom Herbert <tom@quantonium.net>", "To": "davem@davemloft.net", "Cc": "netdev@vger.kernel.org, pablo@netfilter.org, laforge@gnumonks.org,\n\trohit@quantonium.net, Tom Herbert <tom@quantonium.net>", "Subject": "[PATCH net-next 11/14] net: Add a facility to support application\n\tdefined GSO", "Date": "Mon, 18 Sep 2017 17:39:01 -0700", "Message-Id": "<20170919003904.5124-12-tom@quantonium.net>", "X-Mailer": "git-send-email 2.11.0", "In-Reply-To": "<20170919003904.5124-1-tom@quantonium.net>", "References": "<20170919003904.5124-1-tom@quantonium.net>", "Sender": "netdev-owner@vger.kernel.org", "Precedence": "bulk", "List-ID": "<netdev.vger.kernel.org>", "X-Mailing-List": "netdev@vger.kernel.org" }, "content": "Allow applications or encapsulation protocols to register a GSO segment\nfunction to their specific protocol. To faciliate this I reserved the\nupper four bits in the gso_type to indicate the application specific GSO\ntype. Zero in these bits indicates no application GSO, so there are\nfifteen instance that can be defined.\n\nAn application registers a a gso_segment using the skb_gso_app_register\nthis takes a struct skb_gso_app that indicates a callback function as\nwell as a set of GSO types for which at least one must be matched before\ncalling he segment function. GSO returns one of the application GSO\ntypes described above (not a fixed value for the applications).\nSubsequently, when the application sends a GSO packet the application\ngso_type is set in the skb gso_type along with any other types.\n\nskb_gso_app_segment is the function called from another GSO segment\nfunction to handle segmentation of the application or encapsulation\nprotocol. This function includes check flags that provides context for\nthe appropriate GSO instance to match. For instance, in order to handle\na protocol encapsulated in UDP (GTP for instance) skb_gso_app_segment is\ncall from udp_tunnel_segment and check flags would be\nSKB_GSO_UDP_TUNNEL_CSUM | SKB_GSO_UDP_TUNNEL.\n\nSigned-off-by: Tom Herbert <tom@quantonium.net>\n---\n include/linux/netdevice.h | 31 +++++++++++++++++++++++++++++++\n include/linux/skbuff.h | 25 +++++++++++++++++++++++++\n net/core/dev.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++\n net/ipv4/ip_tunnel_core.c | 6 ++++++\n net/ipv4/udp_offload.c | 20 +++++++++++++++-----\n 5 files changed, 124 insertions(+), 5 deletions(-)", "diff": "diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h\nindex f535779d9dc1..f3bed4f8ba83 100644\n--- a/include/linux/netdevice.h\n+++ b/include/linux/netdevice.h\n@@ -3932,6 +3932,37 @@ struct sk_buff *__skb_gso_segment(struct sk_buff *skb,\n struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,\n \t\t\t\t netdev_features_t features);\n \n+struct skb_gso_app {\n+\tunsigned int check_flags;\n+\tstruct sk_buff *(*gso_segment)(struct sk_buff *skb,\n+\t\t\t\t netdev_features_t features);\n+};\n+\n+extern struct skb_gso_app *skb_gso_apps[];\n+int skb_gso_app_register(const struct skb_gso_app *app);\n+void skb_gso_app_unregister(int num, const struct skb_gso_app *app);\n+\n+/* rcu_read_lock() must be held */\n+static inline struct skb_gso_app *skb_gso_app_lookup(struct sk_buff *skb,\n+\t\t\t\t\t\t netdev_features_t features,\n+\t\t\t\t\t\t unsigned int check_flags)\n+{\n+\tstruct skb_gso_app *app;\n+\tint type;\n+\n+\tif (!(skb_shinfo(skb)->gso_type & SKB_GSO_APP_MASK))\n+\t\treturn false;\n+\n+\ttype = skb_gso_app_to_index(skb_shinfo(skb)->gso_type);\n+\n+\tapp = rcu_dereference(skb_gso_apps[type]);\n+\tif (app && app->gso_segment &&\n+\t (check_flags & app->check_flags))\n+\t\treturn app;\n+\n+\treturn NULL;\n+}\n+\n struct netdev_bonding_info {\n \tifslave\tslave;\n \tifbond\tmaster;\ndiff --git a/include/linux/skbuff.h b/include/linux/skbuff.h\nindex 72299ef00061..ea45fb93897c 100644\n--- a/include/linux/skbuff.h\n+++ b/include/linux/skbuff.h\n@@ -535,6 +535,9 @@ enum {\n \tSKB_FCLONE_CLONE,\t/* companion fclone skb (from fclone_cache) */\n };\n \n+#define SKB_GSO_APP_LOW_SHIFT\t28\n+#define SKB_GSO_APP_HIGH_SHIFT\t31\n+\n enum {\n \tSKB_GSO_TCPV4 = 1 << 0,\n \n@@ -569,8 +572,30 @@ enum {\n \tSKB_GSO_SCTP = 1 << 14,\n \n \tSKB_GSO_ESP = 1 << 15,\n+\n+\t/* UDP encapsulation specific GSO consumes bits 28 through 31 */\n+\n+\tSKB_GSO_APP_LOW = 1 << SKB_GSO_APP_LOW_SHIFT,\n+\n+\tSKB_GSO_APP_HIGH = 1 << SKB_GSO_APP_HIGH_SHIFT,\n };\n \n+#define SKB_GSO_APP_MASK ((-1U << SKB_GSO_APP_LOW_SHIFT) & \\\n+\t\t\t (-1U >> (8*sizeof(u32) - SKB_GSO_APP_HIGH_SHIFT - 1)))\n+#define SKB_GSO_APP_NUM (SKB_GSO_APP_MASK >> SKB_GSO_APP_LOW_SHIFT)\n+\n+static inline int skb_gso_app_to_index(unsigned int x)\n+{\n+\t/* Caller should check that app bits are non-zero */\n+\n+\treturn ((SKB_GSO_APP_MASK & x) >> SKB_GSO_APP_LOW_SHIFT) - 1;\n+}\n+\n+static inline int skb_gso_app_to_gso_type(unsigned int x)\n+{\n+\treturn (x + 1) << SKB_GSO_APP_LOW_SHIFT;\n+}\n+\n #if BITS_PER_LONG > 32\n #define NET_SKBUFF_DATA_USES_OFFSET 1\n #endif\ndiff --git a/net/core/dev.c b/net/core/dev.c\nindex fb766d906148..c77fca112e67 100644\n--- a/net/core/dev.c\n+++ b/net/core/dev.c\n@@ -156,6 +156,7 @@\n \n static DEFINE_SPINLOCK(ptype_lock);\n static DEFINE_SPINLOCK(offload_lock);\n+static DEFINE_SPINLOCK(skb_gso_app_lock);\n struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly;\n struct list_head ptype_all __read_mostly;\t/* Taps */\n static struct list_head offload_base __read_mostly;\n@@ -2725,6 +2726,52 @@ struct sk_buff *skb_mac_gso_segment(struct sk_buff *skb,\n }\n EXPORT_SYMBOL(skb_mac_gso_segment);\n \n+struct skb_gso_app *skb_gso_apps[SKB_GSO_APP_NUM];\n+EXPORT_SYMBOL(skb_gso_apps);\n+\n+int skb_gso_app_register(const struct skb_gso_app *app)\n+{\n+\tint i, ret = 0;\n+\n+\tspin_lock(&skb_gso_app_lock);\n+\n+\tfor (i = 0; i < SKB_GSO_APP_NUM; i++) {\n+\t\tif (!rcu_dereference_protected(skb_gso_apps[i],\n+\t\t\t\tlockdep_is_held(&skb_gso_app_lock))) {\n+\t\t\t/* Found an empty slot */\n+\t\t\trcu_assign_pointer(skb_gso_apps[i], app);\n+\n+\t\t\tret = skb_gso_app_to_gso_type(i);\n+\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tspin_unlock(&skb_gso_app_lock);\n+\n+\treturn ret;\n+return 0;\n+}\n+EXPORT_SYMBOL(skb_gso_app_register);\n+\n+void skb_gso_app_unregister(int num, const struct skb_gso_app *app)\n+{\n+\tif (!num)\n+\t\treturn;\n+\n+\tnum = skb_gso_app_to_index(num);\n+\n+\tspin_lock(&skb_gso_app_lock);\n+\n+\tif (app == rcu_dereference_protected(skb_gso_apps[num],\n+\t\t\t\tlockdep_is_held(&skb_gso_app_lock))) {\n+\t\t/* Matched entry */\n+\t\trcu_assign_pointer(skb_gso_apps[num], NULL);\n+\t}\n+\n+\tspin_unlock(&skb_gso_app_lock);\n+}\n+EXPORT_SYMBOL(skb_gso_app_unregister);\n \n /* openvswitch calls this on rx path, so we need a different check.\n */\ndiff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c\nindex 2f39479be92f..f2fd96d55c4e 100644\n--- a/net/ipv4/ip_tunnel_core.c\n+++ b/net/ipv4/ip_tunnel_core.c\n@@ -171,6 +171,12 @@ int iptunnel_handle_offloads(struct sk_buff *skb,\n \t\terr = skb_header_unclone(skb, GFP_ATOMIC);\n \t\tif (unlikely(err))\n \t\t\treturn err;\n+\t\tif (!!(gso_type_mask & SKB_GSO_APP_MASK) &&\n+\t\t !!(skb_shinfo(skb)->gso_type & SKB_GSO_APP_MASK)) {\n+\t\t\t/* Only allow one GSO app per packet */\n+\t\t\treturn -EALREADY;\n+\t\t}\n+\n \t\tskb_shinfo(skb)->gso_type |= gso_type_mask;\n \t\treturn 0;\n \t}\ndiff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c\nindex 97658bfc1b58..ba58b36b35b2 100644\n--- a/net/ipv4/udp_offload.c\n+++ b/net/ipv4/udp_offload.c\n@@ -152,19 +152,29 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,\n \t\t\t\t netdev_features_t features,\n \t\t\t\t bool is_ipv6)\n {\n-\t__be16 protocol = skb->protocol;\n-\tconst struct net_offload **offloads;\n-\tconst struct net_offload *ops;\n-\tstruct sk_buff *segs = ERR_PTR(-EINVAL);\n \tstruct sk_buff *(*gso_inner_segment)(struct sk_buff *skb,\n \t\t\t\t\t netdev_features_t features);\n+\tconst struct net_offload **offloads;\n+\t__be16 protocol = skb->protocol;\n+\tstruct skb_gso_app *gso_app;\n+\tconst struct net_offload *ops;\n+\tstruct sk_buff *segs;\n+\n+\tsegs = ERR_PTR(-EINVAL);\n \n \trcu_read_lock();\n \n+\tgso_app = skb_gso_app_lookup(skb, features,\n+\t\t\t\t SKB_GSO_UDP_TUNNEL_CSUM |\n+\t\t\t\t SKB_GSO_UDP_TUNNEL);\n+\n \tswitch (skb->inner_protocol_type) {\n \tcase ENCAP_TYPE_ETHER:\n \t\tprotocol = skb->inner_protocol;\n-\t\tgso_inner_segment = skb_mac_gso_segment;\n+\t\tif (gso_app && gso_app->gso_segment)\n+\t\t\tgso_inner_segment = gso_app->gso_segment;\n+\t\telse\n+\t\t\tgso_inner_segment = skb_mac_gso_segment;\n \t\tbreak;\n \tcase ENCAP_TYPE_IPPROTO:\n \t\toffloads = is_ipv6 ? inet6_offloads : inet_offloads;\n", "prefixes": [ "net-next", "11/14" ] }