get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/818038/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 818038,
    "url": "http://patchwork.ozlabs.org/api/patches/818038/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170925032941.14586-10-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": "<20170925032941.14586-10-tom@quantonium.net>",
    "list_archive_url": null,
    "date": "2017-09-25T03:29:38",
    "name": "[v3,net-next,09/12] gtp: Eliminate pktinfo and add port configuration",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "7a12c91e92bb2e343a57c409e9f46e179f10c51f",
    "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/20170925032941.14586-10-tom@quantonium.net/mbox/",
    "series": [
        {
            "id": 4865,
            "url": "http://patchwork.ozlabs.org/api/series/4865/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=4865",
            "date": "2017-09-25T03:29:29",
            "name": "gtp: Additional feature support - Part I",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/4865/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/818038/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/818038/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=\"wekvWgSC\"; dkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3y0qNL3Gnxz9t3t\n\tfor <patchwork-incoming@ozlabs.org>;\n\tMon, 25 Sep 2017 13:30:26 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S933068AbdIYDaY (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSun, 24 Sep 2017 23:30:24 -0400",
            "from mail-pf0-f177.google.com ([209.85.192.177]:54487 \"EHLO\n\tmail-pf0-f177.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S933044AbdIYDaU (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Sun, 24 Sep 2017 23:30:20 -0400",
            "by mail-pf0-f177.google.com with SMTP id d187so3136914pfg.11\n\tfor <netdev@vger.kernel.org>; Sun, 24 Sep 2017 20:30:20 -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\tj2sm9112907pgn.26.2017.09.24.20.30.18\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 24 Sep 2017 20:30:19 -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=1jPs//2PQQ6nFjehrosWRdlrzA317lfzDVLuu7P/x9Q=;\n\tb=wekvWgSCQM3g9tOnMsDItoe5Q9sJGDJ9hgFQZkvWmndL7LDAOJswCjPkBdhjzGGBAk\n\tMY1Kx2IqFz/jpgfHM/xguBfgRjEjUeBfMH6PlnCCRFAMcWAW/+AgdIeOtBAVafd9ihsX\n\tDVWpms4xcUxJik+glraIELsUtQG5Taw+JJBTSoxLFVZGZyMCmAzMUAhpHKrk27qKRZqM\n\tLw3PPh35AO4Wpp0lcrr9fa771SAh4Lbx++kyKLvzjq2Pq+nykwWTolcvZwX6unX51rIt\n\tktKYZHe79RURCxLOuWInNdbwU2UhX505zhbpOZ4jMENnHa/WuVDDaTWQGpHraEaKlUcB\n\tIdAw==",
        "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=1jPs//2PQQ6nFjehrosWRdlrzA317lfzDVLuu7P/x9Q=;\n\tb=qFh9/GmqpQyiKPlNuoL/vDp+zgE8l9R2WUh3KFss9+MakNF5kmyMfeA4jyBnaSGQ/p\n\tTk8MlCpKKURTVwlOZ2qb/JuYkpLDGygS5OdqRG+2Eqve7Uh6Uce8NqRBi25oIV3hz1oP\n\tyfRW98G1rZ2X/zWdIxyqe3qsuxDT2lR/TS7UOIqfJaaj4q2Ld5d+LhVnj5kdUAYqV5rn\n\t3WTB2PRS2wsZymazX1YLxCH1Dmtf6Q8PznQ5rOkSNfP83JBmEqpSJc7cAQp7FUV197tQ\n\tDiSAQAJvYq8NhCvC+mroa43+Hn8U9ryzh/WSYdUkaw1A0XoBTI58tST4blpmMI8mmMcU\n\tfHJQ==",
        "X-Gm-Message-State": "AHPjjUgYG0YwZFBmmtGinhyVzIVWwpU30xvmHaGnN+BcKRnpiC+InT1k\n\t4kz3g32gIMFNJm39J/NK8e6s2HEB",
        "X-Google-Smtp-Source": "AOwi7QDrq3n6iQllG/6dqSE+2O1k64wUdD15+sctNNgi9e4/jsv9w+GcPvqvy1iNaF0NWq/uirBhmw==",
        "X-Received": "by 10.84.134.35 with SMTP id 32mr6375508plg.20.1506310220181;\n\tSun, 24 Sep 2017 20:30:20 -0700 (PDT)",
        "From": "Tom Herbert <tom@quantonium.net>",
        "To": "davem@davemloft.net",
        "Cc": "pablo@netfilter.org, laforge@gnumonks.org, aschultz@tpip.net,\n\tnetdev@vger.kernel.org, rohit@quantonium.net,\n\tTom Herbert <tom@quantonium.net>",
        "Subject": "[PATCH v3 net-next 09/12] gtp: Eliminate pktinfo and add port\n\tconfiguration",
        "Date": "Sun, 24 Sep 2017 20:29:38 -0700",
        "Message-Id": "<20170925032941.14586-10-tom@quantonium.net>",
        "X-Mailer": "git-send-email 2.11.0",
        "In-Reply-To": "<20170925032941.14586-1-tom@quantonium.net>",
        "References": "<20170925032941.14586-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": "The gtp pktinfo structure is unnecessary and needs a lot of code to\nmanage it. Remove it. Also, add per pdp port configuration for transmit.\n\nSigned-off-by: Tom Herbert <tom@quantonium.net>\n---\n drivers/net/gtp.c        | 177 +++++++++++++++++++++--------------------------\n include/uapi/linux/gtp.h |   1 +\n 2 files changed, 80 insertions(+), 98 deletions(-)",
    "diff": "diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c\nindex bbb08f8849d3..44844eba8df2 100644\n--- a/drivers/net/gtp.c\n+++ b/drivers/net/gtp.c\n@@ -54,6 +54,7 @@ struct pdp_ctx {\n \t} u;\n \tu8\t\t\tgtp_version;\n \tu8\t\t\thlen;\n+\t__be16\t\t\tgtp_port;\n \tu16\t\t\taf;\n \n \tstruct in_addr\t\tms_addr_ip4;\n@@ -420,73 +421,36 @@ static inline void gtp1_push_header(struct sk_buff *skb, struct pdp_ctx *pctx)\n \t */\n }\n \n-struct gtp_pktinfo {\n-\tstruct sock\t\t*sk;\n-\tstruct iphdr\t\t*iph;\n-\tstruct flowi4\t\tfl4;\n-\tstruct rtable\t\t*rt;\n-\tstruct pdp_ctx\t\t*pctx;\n-\tstruct net_device\t*dev;\n-\t__be16\t\t\tgtph_port;\n-};\n-\n-static void gtp_push_header(struct sk_buff *skb, struct gtp_pktinfo *pktinfo)\n+static void gtp_push_header(struct sk_buff *skb, struct pdp_ctx *pctx)\n {\n-\tswitch (pktinfo->pctx->gtp_version) {\n+\tswitch (pctx->gtp_version) {\n \tcase GTP_V0:\n-\t\tpktinfo->gtph_port = htons(GTP0_PORT);\n-\t\tgtp0_push_header(skb, pktinfo->pctx);\n+\t\tgtp0_push_header(skb, pctx);\n \t\tbreak;\n \tcase GTP_V1:\n-\t\tpktinfo->gtph_port = htons(GTP1U_PORT);\n-\t\tgtp1_push_header(skb, pktinfo->pctx);\n+\t\tgtp1_push_header(skb, pctx);\n \t\tbreak;\n \t}\n }\n \n-static inline void gtp_set_pktinfo_ipv4(struct gtp_pktinfo *pktinfo,\n-\t\t\t\t\tstruct sock *sk, struct iphdr *iph,\n-\t\t\t\t\tstruct pdp_ctx *pctx, struct rtable *rt,\n-\t\t\t\t\tstruct flowi4 *fl4,\n-\t\t\t\t\tstruct net_device *dev)\n-{\n-\tpktinfo->sk\t= sk;\n-\tpktinfo->iph\t= iph;\n-\tpktinfo->pctx\t= pctx;\n-\tpktinfo->rt\t= rt;\n-\tpktinfo->fl4\t= *fl4;\n-\tpktinfo->dev\t= dev;\n-}\n-\n-static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev,\n-\t\t\t     struct gtp_pktinfo *pktinfo)\n+static int gtp_xmit(struct sk_buff *skb, struct net_device *dev,\n+\t\t    struct pdp_ctx *pctx)\n {\n-\tstruct gtp_dev *gtp = netdev_priv(dev);\n-\tstruct pdp_ctx *pctx;\n+\tstruct iphdr *inner_iph = NULL;\n+\tstruct sock *sk = pctx->sk;\n+\t__be32 saddr = inet_sk(sk)->inet_saddr;\n \tstruct rtable *rt;\n-\tstruct flowi4 fl4;\n-\tstruct iphdr *iph;\n-\tstruct sock *sk;\n-\t__be32 saddr;\n+\tint err = 0;\n \n-\t/* Read the IP destination address and resolve the PDP context.\n-\t * Prepend PDP header with TEI/TID from PDP ctx.\n-\t */\n-\tiph = ip_hdr(skb);\n-\tif (gtp->role == GTP_ROLE_SGSN)\n-\t\tpctx = ipv4_pdp_find(gtp, iph->saddr);\n-\telse\n-\t\tpctx = ipv4_pdp_find(gtp, iph->daddr);\n+\tif (skb->protocol == ETH_P_IP)\n+\t\tinner_iph = ip_hdr(skb);\n \n-\tif (!pctx) {\n-\t\tnetdev_dbg(dev, \"no PDP ctx found for %pI4, skip\\n\",\n-\t\t\t   &iph->daddr);\n-\t\treturn -ENOENT;\n-\t}\n-\tnetdev_dbg(dev, \"found PDP context %p\\n\", pctx);\n+\t/* Ensure there is sufficient headroom. */\n+\terr = skb_cow_head(skb, dev->needed_headroom);\n+\tif (unlikely(err))\n+\t\tgoto out_err;\n \n-\tsk = pctx->sk;\n-\tsaddr = inet_sk(sk)->inet_saddr;\n+\tskb_reset_inner_headers(skb);\n \n \t/* Source address returned by route lookup is ignored since\n \t * we get the address from a socket.\n@@ -494,81 +458,89 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev,\n \trt = ip_tunnel_get_route(dev, skb, sk->sk_protocol,\n \t\t\t\t sk->sk_bound_dev_if, RT_CONN_FLAGS(sk),\n \t\t\t\t pctx->peer_addr_ip4.s_addr, &saddr,\n-\t\t\t\t pktinfo->gtph_port, pktinfo->gtph_port,\n+\t\t\t\t pctx->gtp_port, pctx->gtp_port,\n \t\t\t\t &pctx->dst_cache, NULL);\n \n \tif (IS_ERR(rt)) {\n-\t\tif (rt == ERR_PTR(-ELOOP)) {\n-\t\t\tnetdev_dbg(dev, \"circular route to SSGN %pI4\\n\",\n-\t\t\t\t   &pctx->peer_addr_ip4.s_addr);\n-\t\t\tdev->stats.collisions++;\n-\t\t\tgoto err_rt;\n-\t\t} else {\n-\t\t\tnetdev_dbg(dev, \"no route to SSGN %pI4\\n\",\n-\t\t\t\t   &pctx->peer_addr_ip4.s_addr);\n-\t\t\tdev->stats.tx_carrier_errors++;\n-\t\t\tgoto err;\n-\t\t}\n+\t\terr = PTR_ERR(rt);\n+\t\tgoto out_err;\n \t}\n \n \tskb_dst_drop(skb);\n \n-\tgtp_set_pktinfo_ipv4(pktinfo, sk, iph, pctx, rt, &fl4, dev);\n-\tgtp_push_header(skb, pktinfo);\n+\tgtp_push_header(skb, pctx);\n+\n+\tif (inner_iph)\n+\t\t__iptunnel_update_pmtu(dev, skb, &rt->dst,\n+\t\t\t\t       !!inner_iph->frag_off,\n+\t\t\t\t       inner_iph, pctx->hlen,\n+\t\t\t\t       pctx->peer_addr_ip4.s_addr);\n \n-\t__iptunnel_update_pmtu(dev, skb, &rt->dst, !!iph->frag_off, iph,\n-\t\t\t       pctx->hlen, pctx->peer_addr_ip4.s_addr);\n+\tudp_tunnel_xmit_skb(rt, sk, skb, saddr,\n+\t\t\t    pctx->peer_addr_ip4.s_addr,\n+\t\t\t    0, ip4_dst_hoplimit(&rt->dst), 0,\n+\t\t\t    pctx->gtp_port, pctx->gtp_port,\n+\t\t\t    false, false);\n+\n+\tnetdev_dbg(dev, \"gtp -> IP src: %pI4 dst: %pI4\\n\",\n+\t\t   &saddr, &pctx->peer_addr_ip4.s_addr);\n \n \treturn 0;\n-err_rt:\n-\tip_rt_put(rt);\n-err:\n-\treturn -EBADMSG;\n+\n+out_err:\n+\tif (err == -ELOOP)\n+\t\tdev->stats.collisions++;\n+\telse\n+\t\tdev->stats.tx_carrier_errors++;\n+\n+\treturn err;\n }\n \n static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n {\n \tunsigned int proto = ntohs(skb->protocol);\n-\tstruct gtp_pktinfo pktinfo;\n+\tstruct gtp_dev *gtp = netdev_priv(dev);\n+\tstruct pdp_ctx *pctx;\n \tint err;\n \n-\t/* Ensure there is sufficient headroom. */\n-\tif (skb_cow_head(skb, dev->needed_headroom))\n-\t\tgoto tx_err;\n-\n-\tskb_reset_inner_headers(skb);\n-\n \t/* PDP context lookups in gtp_build_skb_*() need rcu read-side lock. */\n \trcu_read_lock();\n \tswitch (proto) {\n-\tcase ETH_P_IP:\n-\t\terr = gtp_build_skb_ip4(skb, dev, &pktinfo);\n+\tcase ETH_P_IP: {\n+\t\tstruct iphdr *iph = ip_hdr(skb);\n+\n+\t\tif (gtp->role == GTP_ROLE_SGSN)\n+\t\t\tpctx = ipv4_pdp_find(gtp, iph->saddr);\n+\t\telse\n+\t\t\tpctx = ipv4_pdp_find(gtp, iph->daddr);\n+\n+\t\tif (!pctx) {\n+\t\t\tnetdev_dbg(dev, \"no PDP ctx found for %pI4, skip\\n\",\n+\t\t\t\t   &iph->daddr);\n+\t\t\terr = -ENOENT;\n+\t\t\tgoto tx_err;\n+\t\t}\n+\n \t\tbreak;\n+\t}\n \tdefault:\n \t\terr = -EOPNOTSUPP;\n-\t\tbreak;\n+\t\tgoto tx_err;\n \t}\n-\trcu_read_unlock();\n+\n+\tnetdev_dbg(dev, \"found PDP context %p\\n\", pctx);\n+\n+\terr = gtp_xmit(skb, dev, pctx);\n \n \tif (err < 0)\n \t\tgoto tx_err;\n \n-\tswitch (proto) {\n-\tcase ETH_P_IP:\n-\t\tnetdev_dbg(pktinfo.dev, \"gtp -> IP src: %pI4 dst: %pI4\\n\",\n-\t\t\t   &pktinfo.iph->saddr, &pktinfo.iph->daddr);\n-\t\tudp_tunnel_xmit_skb(pktinfo.rt, pktinfo.sk, skb,\n-\t\t\t\t    pktinfo.fl4.saddr, pktinfo.fl4.daddr,\n-\t\t\t\t    pktinfo.iph->tos,\n-\t\t\t\t    ip4_dst_hoplimit(&pktinfo.rt->dst),\n-\t\t\t\t    0,\n-\t\t\t\t    pktinfo.gtph_port, pktinfo.gtph_port,\n-\t\t\t\t    true, false);\n-\t\tbreak;\n-\t}\n+\trcu_read_unlock();\n \n \treturn NETDEV_TX_OK;\n+\n tx_err:\n+\trcu_read_unlock();\n \tdev->stats.tx_errors++;\n \tdev_kfree_skb(skb);\n \treturn NETDEV_TX_OK;\n@@ -874,6 +846,8 @@ static struct gtp_dev *gtp_find_dev(struct net *src_net, struct nlattr *nla[])\n \n static void ipv4_pdp_fill(struct pdp_ctx *pctx, struct genl_info *info)\n {\n+\t__be16 default_port = 0;\n+\n \tpctx->gtp_version = nla_get_u32(info->attrs[GTPA_VERSION]);\n \tpctx->af = AF_INET;\n \tpctx->peer_addr_ip4.s_addr =\n@@ -890,15 +864,22 @@ static void ipv4_pdp_fill(struct pdp_ctx *pctx, struct genl_info *info)\n \t\tpctx->u.v0.tid = nla_get_u64(info->attrs[GTPA_TID]);\n \t\tpctx->u.v0.flow = nla_get_u16(info->attrs[GTPA_FLOW]);\n \t\tpctx->hlen = sizeof(struct udphdr) + sizeof(struct gtp0_header);\n+\t\tdefault_port = htons(GTP0_PORT);\n \t\tbreak;\n \tcase GTP_V1:\n \t\tpctx->u.v1.i_tei = nla_get_u32(info->attrs[GTPA_I_TEI]);\n \t\tpctx->u.v1.o_tei = nla_get_u32(info->attrs[GTPA_O_TEI]);\n \t\tpctx->hlen = sizeof(struct udphdr) + sizeof(struct gtp1_header);\n+\t\tdefault_port = htons(GTP1U_PORT);\n \t\tbreak;\n \tdefault:\n \t\tbreak;\n \t}\n+\n+\tif (info->attrs[GTPA_PORT])\n+\t\tpctx->gtp_port = nla_get_u16(info->attrs[GTPA_PORT]);\n+\telse\n+\t\tpctx->gtp_port = default_port;\n }\n \n static int ipv4_pdp_add(struct gtp_dev *gtp, struct sock *sk,\ndiff --git a/include/uapi/linux/gtp.h b/include/uapi/linux/gtp.h\nindex 57d1edb8efd9..b2283a5c6d7f 100644\n--- a/include/uapi/linux/gtp.h\n+++ b/include/uapi/linux/gtp.h\n@@ -27,6 +27,7 @@ enum gtp_attrs {\n \tGTPA_I_TEI,\t/* for GTPv1 only */\n \tGTPA_O_TEI,\t/* for GTPv1 only */\n \tGTPA_PAD,\n+\tGTPA_PORT,\n \t__GTPA_MAX,\n };\n #define GTPA_MAX (__GTPA_MAX + 1)\n",
    "prefixes": [
        "v3",
        "net-next",
        "09/12"
    ]
}