get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 815220,
    "url": "http://patchwork.ozlabs.org/api/patches/815220/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/20170919003904.5124-8-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-8-tom@quantonium.net>",
    "list_archive_url": null,
    "date": "2017-09-19T00:38:57",
    "name": "[net-next,07/14] gtp: Support encapsulation of IPv6 packets",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "ab7488878ae3a33658a22b0ae99b9e7e6950922b",
    "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-8-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/815220/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/815220/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=\"Mo3c9R3T\"; dkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xx3tP3Gdjz9s5L\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 19 Sep 2017 10:39:57 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751479AbdISAjx (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 18 Sep 2017 20:39:53 -0400",
            "from mail-pg0-f50.google.com ([74.125.83.50]:46857 \"EHLO\n\tmail-pg0-f50.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751451AbdISAjt (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 18 Sep 2017 20:39:49 -0400",
            "by mail-pg0-f50.google.com with SMTP id i130so1093412pgc.3\n\tfor <netdev@vger.kernel.org>; Mon, 18 Sep 2017 17:39:49 -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.47\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 18 Sep 2017 17:39:48 -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=7jj9tsecwYu6QUxWcVnpBBA/85fR3gTlsBVddo9iDmU=;\n\tb=Mo3c9R3TmFDSYL327GzljBdmSs8lVrhywRkaDclRvdhX6saj0wFv0M1OJ3tRdb9api\n\t3GrhwvyzUCl2FVOPyqpKNgyYwLQEdVci8LE4xg316wMqWqG3u0oIP2OkhEANlxI+9Odh\n\t8NaSp3XwCPyD+03P1OqAdZtKhOPHYxxCDcLn83Cp59nCfBXDBejp1Gtq2EiL72TpSzwI\n\tMunTpRasvv+Wg8Am/GMG8EGurWjWJlcfrBIJl7Az2KNcbHZtxmMGrsPyTeYx/lfCLqIu\n\tku2D9oOL2BeqMMX8UCWi3caAEF+e6ASAhCektSiFSbTuoB0zWZ9wTWuUTP9DkRrOOZVf\n\t6mQg==",
        "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=7jj9tsecwYu6QUxWcVnpBBA/85fR3gTlsBVddo9iDmU=;\n\tb=QGtgWk4Vs2ETVnIj9639gSQxUmfmQm9BAM84qAVAQJSBz4vyErDRXlouJNW6auIXE0\n\tQobM8RxF6BvBsnoSrJ1Ix2WmSFdMpKb9h2yaVrGxUjLc6WsqERkEu7hltus8YcoaJS2Y\n\tR8aQ/hxDqPJpgSULpE1/m8epaIxkZKVKK5rWBiTirGOrWzNIngm7qZVByIwu++UQKbQf\n\t9MV+2Jr4ROdOh/AjyMbt7td/AThouDtkQa/9Tkp9N8Dr3bPVVqKlHLp4EIJHAEYVXoZW\n\tQuR8Pod5yxqRMqWTIqnAZ+Yx6Qn9IPQbtWhD6JzrPz669bNiTJb1irTD+a4nuIrAjssK\n\tTbVg==",
        "X-Gm-Message-State": "AHPjjUhTpb5O9sv6SJ9u6ciXrPNzglt/LD8tjbKnoOlWvQTNs8f6qJQx\n\tq2YfXeyGxt6QpG7P",
        "X-Google-Smtp-Source": "AOwi7QDI1MWfjgGa+M1Xy0UVapOTzF+OUhWD5Msc2KxkRlRyKKs0A2s7tl8oSwnTPphY5RCegV7wDQ==",
        "X-Received": "by 10.98.71.20 with SMTP id u20mr325073pfa.23.1505781589009;\n\tMon, 18 Sep 2017 17:39:49 -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 07/14] gtp: Support encapsulation of IPv6 packets",
        "Date": "Mon, 18 Sep 2017 17:38:57 -0700",
        "Message-Id": "<20170919003904.5124-8-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 IPv6 mobile subscriber packets. This entails adding an IPv6 mobile\nsubscriber address to pdp context and IPv6 specific variants to find pdp\ncontexts by address.\n\nSigned-off-by: Tom Herbert <tom@quantonium.net>\n---\n drivers/net/gtp.c        | 259 +++++++++++++++++++++++++++++++++++++----------\n include/uapi/linux/gtp.h |   1 +\n 2 files changed, 209 insertions(+), 51 deletions(-)",
    "diff": "diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c\nindex a928279c382c..62c0c968efa6 100644\n--- a/drivers/net/gtp.c\n+++ b/drivers/net/gtp.c\n@@ -54,9 +54,13 @@ struct pdp_ctx {\n \t} u;\n \tu8\t\t\tgtp_version;\n \t__be16\t\t\tgtp_port;\n-\tu16\t\t\taf;\n \n-\tstruct in_addr\t\tms_addr_ip4;\n+\tu16\t\t\tms_af;\n+\tunion {\n+\t\tstruct in_addr\tms_addr_ip4;\n+\t\tstruct in6_addr\tms_addr_ip6;\n+\t};\n+\n \tstruct in_addr\t\tpeer_addr_ip4;\n \n \tstruct sock\t\t*sk;\n@@ -80,7 +84,9 @@ struct gtp_dev {\n \tunsigned int\t\trole;\n \tunsigned int\t\thash_size;\n \tstruct hlist_head\t*tid_hash;\n-\tstruct hlist_head\t*addr_hash;\n+\n+\tstruct hlist_head\t*addr4_hash;\n+\tstruct hlist_head\t*addr6_hash;\n \n \tstruct gro_cells\tgro_cells;\n };\n@@ -98,6 +104,7 @@ static void pdp_context_delete(struct pdp_ctx *pctx);\n static inline u32 gtp0_hashfn(u64 tid)\n {\n \tu32 *tid32 = (u32 *) &tid;\n+\n \treturn jhash_2words(tid32[0], tid32[1], gtp_h_initval);\n }\n \n@@ -111,6 +118,11 @@ static inline u32 ipv4_hashfn(__be32 ip)\n \treturn jhash_1word((__force u32)ip, gtp_h_initval);\n }\n \n+static inline u32 ipv6_hashfn(const struct in6_addr *a)\n+{\n+\treturn __ipv6_addr_jhash(a, gtp_h_initval);\n+}\n+\n /* Resolve a PDP context structure based on the 64bit TID. */\n static struct pdp_ctx *gtp0_pdp_find(struct gtp_dev *gtp, u64 tid)\n {\n@@ -149,10 +161,10 @@ static struct pdp_ctx *ipv4_pdp_find(struct gtp_dev *gtp, __be32 ms_addr)\n \tstruct hlist_head *head;\n \tstruct pdp_ctx *pdp;\n \n-\thead = &gtp->addr_hash[ipv4_hashfn(ms_addr) % gtp->hash_size];\n+\thead = &gtp->addr4_hash[ipv4_hashfn(ms_addr) % gtp->hash_size];\n \n \thlist_for_each_entry_rcu(pdp, head, hlist_addr) {\n-\t\tif (pdp->af == AF_INET &&\n+\t\tif (pdp->ms_af == AF_INET &&\n \t\t    pdp->ms_addr_ip4.s_addr == ms_addr)\n \t\t\treturn pdp;\n \t}\n@@ -176,32 +188,95 @@ static bool gtp_check_ms_ipv4(struct sk_buff *skb, struct pdp_ctx *pctx,\n \t\treturn iph->saddr == pctx->ms_addr_ip4.s_addr;\n }\n \n+/* Resolve a PDP context based on IPv6 address of MS. */\n+static struct pdp_ctx *ipv6_pdp_find(struct gtp_dev *gtp,\n+\t\t\t\t     const struct in6_addr *ms_addr)\n+{\n+\tstruct hlist_head *head;\n+\tstruct pdp_ctx *pdp;\n+\n+\thead = &gtp->addr6_hash[ipv6_hashfn(ms_addr) % gtp->hash_size];\n+\n+\thlist_for_each_entry_rcu(pdp, head, hlist_addr) {\n+\t\tif (pdp->ms_af == AF_INET6 &&\n+\t\t    ipv6_addr_equal(&pdp->ms_addr_ip6, ms_addr))\n+\t\t\treturn pdp;\n+\t}\n+\n+\treturn NULL;\n+}\n+\n+static bool gtp_check_ms_ipv6(struct sk_buff *skb, struct pdp_ctx *pctx,\n+\t\t\t      unsigned int hdrlen, unsigned int role)\n+{\n+\tstruct ipv6hdr *ipv6h;\n+\n+\tif (!pskb_may_pull(skb, hdrlen + sizeof(struct ipv6hdr)))\n+\t\treturn false;\n+\n+\tipv6h = (struct ipv6hdr *)(skb->data + hdrlen);\n+\n+\tif (role == GTP_ROLE_SGSN)\n+\t\treturn ipv6_addr_equal(&ipv6h->daddr, &pctx->ms_addr_ip6);\n+\telse\n+\t\treturn ipv6_addr_equal(&ipv6h->saddr, &pctx->ms_addr_ip6);\n+}\n+\n /* Check if the inner IP address in this packet is assigned to any\n  * existing mobile subscriber.\n  */\n static bool gtp_check_ms(struct sk_buff *skb, struct pdp_ctx *pctx,\n \t\t\t     unsigned int hdrlen, unsigned int role)\n {\n-\tswitch (ntohs(skb->protocol)) {\n-\tcase ETH_P_IP:\n+\tstruct iphdr *iph;\n+\n+\t/* Minimally there needs to be an IPv4 header */\n+\tif (!pskb_may_pull(skb, hdrlen + sizeof(struct iphdr)))\n+\t\treturn false;\n+\n+\tiph = (struct iphdr *)(skb->data + hdrlen);\n+\n+\tswitch (iph->version) {\n+\tcase 4:\n \t\treturn gtp_check_ms_ipv4(skb, pctx, hdrlen, role);\n+\tcase 6:\n+\t\treturn gtp_check_ms_ipv6(skb, pctx, hdrlen, role);\n \t}\n+\n \treturn false;\n }\n \n+static u16 ipver_to_eth(struct iphdr *iph)\n+{\n+\tswitch (iph->version) {\n+\tcase 4:\n+\t\treturn htons(ETH_P_IP);\n+\tcase 6:\n+\t\treturn htons(ETH_P_IPV6);\n+\tdefault:\n+\t\treturn 0;\n+\t}\n+}\n+\n static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb,\n-\t\t\tunsigned int hdrlen, unsigned int role)\n+\t\t  unsigned int hdrlen, unsigned int role)\n {\n \tstruct pcpu_sw_netstats *stats;\n+\tu16 inner_protocol;\n \n \tif (!gtp_check_ms(skb, pctx, hdrlen, role)) {\n \t\tnetdev_dbg(pctx->dev, \"No PDP ctx for this MS\\n\");\n \t\treturn 1;\n \t}\n \n+\tinner_protocol = ipver_to_eth((struct iphdr *)(skb->data + hdrlen));\n+\tif (!inner_protocol)\n+\t\treturn -1;\n+\n \t/* Get rid of the GTP + UDP headers. */\n-\tif (iptunnel_pull_header(skb, hdrlen, skb->protocol,\n-\t\t\t\t !net_eq(sock_net(pctx->sk), dev_net(pctx->dev))))\n+\tif (iptunnel_pull_header(skb, hdrlen, inner_protocol,\n+\t\t\t\t !net_eq(sock_net(pctx->sk),\n+\t\t\t\t\t dev_net(pctx->dev))))\n \t\treturn -1;\n \n \tnetdev_dbg(pctx->dev, \"forwarding packet from GGSN to uplink\\n\");\n@@ -239,7 +314,8 @@ static int gtp0_udp_encap_recv(struct sock *sk, struct sk_buff *skb)\n \tif (!gtp)\n \t\tgoto pass;\n \n-\tif (!pskb_may_pull(skb, hdrlen))\n+\t/* Pull through IP header since gtp_rx looks at IP version */\n+\tif (!pskb_may_pull(skb, hdrlen + sizeof(struct iphdr)))\n \t\tgoto drop;\n \n \tgtp0 = (struct gtp0_header *)(skb->data + sizeof(struct udphdr));\n@@ -285,7 +361,8 @@ static int gtp1u_udp_encap_recv(struct sock *sk, struct sk_buff *skb)\n \tif (!gtp)\n \t\tgoto pass;\n \n-\tif (!pskb_may_pull(skb, hdrlen))\n+\t/* Pull through IP header since gtp_rx looks at IP version */\n+\tif (!pskb_may_pull(skb, hdrlen + sizeof(struct iphdr)))\n \t\tgoto drop;\n \n \tgtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr));\n@@ -307,8 +384,10 @@ static int gtp1u_udp_encap_recv(struct sock *sk, struct sk_buff *skb)\n \tif (gtp1->flags & GTP1_F_MASK)\n \t\thdrlen += 4;\n \n-\t/* Make sure the header is larger enough, including extensions. */\n-\tif (!pskb_may_pull(skb, hdrlen))\n+\t/* Make sure the header is larger enough, including extensions and\n+\t * also an IP header since gtp_rx looks at IP version\n+\t */\n+\tif (!pskb_may_pull(skb, hdrlen + sizeof(struct iphdr)))\n \t\tgoto drop;\n \n \tgtp1 = (struct gtp1_header *)(skb->data + sizeof(struct udphdr));\n@@ -389,7 +468,8 @@ static inline void gtp0_push_header(struct sk_buff *skb, struct pdp_ctx *pctx)\n \tgtp0->flags\t= 0x1e; /* v0, GTP-non-prime. */\n \tgtp0->type\t= GTP_TPDU;\n \tgtp0->length\t= htons(payload_len);\n-\tgtp0->seq\t= htons((atomic_inc_return(&pctx->tx_seq) - 1) % 0xffff);\n+\tgtp0->seq\t= htons((atomic_inc_return(&pctx->tx_seq) - 1) %\n+\t\t\t\t0xffff);\n \tgtp0->flow\t= htons(pctx->u.v0.flow);\n \tgtp0->number\t= 0xff;\n \tgtp0->spare[0]\t= gtp0->spare[1] = gtp0->spare[2] = 0xff;\n@@ -507,6 +587,23 @@ static netdev_tx_t gtp_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n \n \t\tbreak;\n \t}\n+\tcase ETH_P_IPV6: {\n+\t\tstruct ipv6hdr *ipv6h = ipv6_hdr(skb);\n+\n+\t\tif (gtp->role == GTP_ROLE_SGSN)\n+\t\t\tpctx = ipv6_pdp_find(gtp, &ipv6h->saddr);\n+\t\telse\n+\t\t\tpctx = ipv6_pdp_find(gtp, &ipv6h->daddr);\n+\n+\t\tif (!pctx) {\n+\t\t\tnetdev_dbg(dev, \"no PDP ctx found for %pI6, skip\\n\",\n+\t\t\t\t   &ipv6h->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\tgoto tx_err;\n@@ -674,23 +771,32 @@ static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize)\n {\n \tint i;\n \n-\tgtp->addr_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL);\n-\tif (gtp->addr_hash == NULL)\n-\t\treturn -ENOMEM;\n+\tgtp->addr4_hash = kmalloc_array(hsize, sizeof(*gtp->addr4_hash),\n+\t\t\t\t\tGFP_KERNEL);\n+\tif (!gtp->addr4_hash)\n+\t\tgoto err;\n+\n+\tgtp->addr6_hash = kmalloc_array(hsize, sizeof(*gtp->addr6_hash),\n+\t\t\t\t\tGFP_KERNEL);\n+\tif (!gtp->addr6_hash)\n+\t\tgoto err;\n \n-\tgtp->tid_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL);\n-\tif (gtp->tid_hash == NULL)\n-\t\tgoto err1;\n+\tgtp->tid_hash = kmalloc_array(hsize, sizeof(struct hlist_head),\n+\t\t\t\t      GFP_KERNEL);\n+\tif (!gtp->tid_hash)\n+\t\tgoto err;\n \n \tgtp->hash_size = hsize;\n \n \tfor (i = 0; i < hsize; i++) {\n-\t\tINIT_HLIST_HEAD(&gtp->addr_hash[i]);\n+\t\tINIT_HLIST_HEAD(&gtp->addr4_hash[i]);\n+\t\tINIT_HLIST_HEAD(&gtp->addr6_hash[i]);\n \t\tINIT_HLIST_HEAD(&gtp->tid_hash[i]);\n \t}\n \treturn 0;\n-err1:\n-\tkfree(gtp->addr_hash);\n+err:\n+\tkfree(gtp->addr4_hash);\n+\tkfree(gtp->addr6_hash);\n \treturn -ENOMEM;\n }\n \n@@ -704,7 +810,8 @@ static void gtp_hashtable_free(struct gtp_dev *gtp)\n \t\t\tpdp_context_delete(pctx);\n \n \tsynchronize_rcu();\n-\tkfree(gtp->addr_hash);\n+\tkfree(gtp->addr4_hash);\n+\tkfree(gtp->addr6_hash);\n \tkfree(gtp->tid_hash);\n }\n \n@@ -826,16 +933,13 @@ static struct gtp_dev *gtp_find_dev(struct net *src_net, struct nlattr *nla[])\n \treturn gtp;\n }\n \n-static void ipv4_pdp_fill(struct pdp_ctx *pctx, struct genl_info *info)\n+static void 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 \t\tnla_get_be32(info->attrs[GTPA_PEER_ADDRESS]);\n-\tpctx->ms_addr_ip4.s_addr =\n-\t\tnla_get_be32(info->attrs[GTPA_MS_ADDRESS]);\n \n \tswitch (pctx->gtp_version) {\n \tcase GTP_V0:\n@@ -862,33 +966,46 @@ static void ipv4_pdp_fill(struct pdp_ctx *pctx, struct genl_info *info)\n \t\tpctx->gtp_port = default_port;\n }\n \n-static int ipv4_pdp_add(struct gtp_dev *gtp, struct sock *sk,\n-\t\t\tstruct genl_info *info)\n+static int gtp_pdp_add(struct gtp_dev *gtp, struct sock *sk,\n+\t\t       struct genl_info *info)\n {\n \tstruct net_device *dev = gtp->dev;\n+\tstruct hlist_head *addr_list;\n+\tstruct pdp_ctx *pctx = NULL;\n \tu32 hash_ms, hash_tid = 0;\n-\tstruct pdp_ctx *pctx;\n-\tbool found = false;\n-\t__be32 ms_addr;\n+\tstruct in6_addr ms6_addr;\n+\t__be32 ms_addr = 0;\n+\tint ms_af;\n \tint err;\n \n-\tms_addr = nla_get_be32(info->attrs[GTPA_MS_ADDRESS]);\n-\thash_ms = ipv4_hashfn(ms_addr) % gtp->hash_size;\n+\t/* Caller ensures we have either v4 or v6 mobile subscriber address */\n+\tif (info->attrs[GTPA_MS_ADDRESS]) {\n+\t\t/* IPv4 mobile subscriber */\n \n-\thlist_for_each_entry_rcu(pctx, &gtp->addr_hash[hash_ms], hlist_addr) {\n-\t\tif (pctx->ms_addr_ip4.s_addr == ms_addr) {\n-\t\t\tfound = true;\n-\t\t\tbreak;\n-\t\t}\n+\t\tms_addr = nla_get_in_addr(info->attrs[GTPA_MS_ADDRESS]);\n+\t\thash_ms = ipv4_hashfn(ms_addr) % gtp->hash_size;\n+\t\taddr_list = &gtp->addr4_hash[hash_ms];\n+\t\tms_af = AF_INET;\n+\n+\t\tpctx = ipv4_pdp_find(gtp, ms_addr);\n+\t} else {\n+\t\t/* IPv6 mobile subscriber */\n+\n+\t\tms6_addr = nla_get_in6_addr(info->attrs[GTPA_MS6_ADDRESS]);\n+\t\thash_ms = ipv6_hashfn(&ms6_addr) % gtp->hash_size;\n+\t\taddr_list = &gtp->addr6_hash[hash_ms];\n+\t\tms_af = AF_INET6;\n+\n+\t\tpctx = ipv6_pdp_find(gtp, &ms6_addr);\n \t}\n \n-\tif (found) {\n+\tif (pctx) {\n \t\tif (info->nlhdr->nlmsg_flags & NLM_F_EXCL)\n \t\t\treturn -EEXIST;\n \t\tif (info->nlhdr->nlmsg_flags & NLM_F_REPLACE)\n \t\t\treturn -EOPNOTSUPP;\n \n-\t\tipv4_pdp_fill(pctx, info);\n+\t\tpdp_fill(pctx, info);\n \n \t\tif (pctx->gtp_version == GTP_V0)\n \t\t\tnetdev_dbg(dev, \"GTPv0-U: update tunnel id = %llx (pdp %p)\\n\",\n@@ -914,7 +1031,18 @@ static int ipv4_pdp_add(struct gtp_dev *gtp, struct sock *sk,\n \tsock_hold(sk);\n \tpctx->sk = sk;\n \tpctx->dev = gtp->dev;\n-\tipv4_pdp_fill(pctx, info);\n+\tpctx->ms_af = ms_af;\n+\n+\tswitch (ms_af) {\n+\tcase AF_INET:\n+\t\tpctx->ms_addr_ip4.s_addr = ms_addr;\n+\t\tbreak;\n+\tcase AF_INET6:\n+\t\tpctx->ms_addr_ip6 = ms6_addr;\n+\t\tbreak;\n+\t}\n+\n+\tpdp_fill(pctx, info);\n \tatomic_set(&pctx->tx_seq, 0);\n \n \tswitch (pctx->gtp_version) {\n@@ -931,7 +1059,7 @@ static int ipv4_pdp_add(struct gtp_dev *gtp, struct sock *sk,\n \t\tbreak;\n \t}\n \n-\thlist_add_head_rcu(&pctx->hlist_addr, &gtp->addr_hash[hash_ms]);\n+\thlist_add_head_rcu(&pctx->hlist_addr, addr_list);\n \thlist_add_head_rcu(&pctx->hlist_tid, &gtp->tid_hash[hash_tid]);\n \n \tswitch (pctx->gtp_version) {\n@@ -973,11 +1101,17 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)\n \tint err;\n \n \tif (!info->attrs[GTPA_VERSION] ||\n-\t    !info->attrs[GTPA_LINK] ||\n-\t    !info->attrs[GTPA_PEER_ADDRESS] ||\n-\t    !info->attrs[GTPA_MS_ADDRESS])\n+\t   !info->attrs[GTPA_LINK] ||\n+\t   !info->attrs[GTPA_PEER_ADDRESS])\n \t\treturn -EINVAL;\n \n+\tif (!(!!info->attrs[GTPA_MS_ADDRESS] ^\n+\t      !!info->attrs[GTPA_MS6_ADDRESS])) {\n+\t\t/* Either v4 or v6 mobile subscriber address must be set */\n+\n+\t\treturn -EINVAL;\n+\t}\n+\n \tversion = nla_get_u32(info->attrs[GTPA_VERSION]);\n \n \tswitch (version) {\n@@ -1016,7 +1150,7 @@ static int gtp_genl_new_pdp(struct sk_buff *skb, struct genl_info *info)\n \t\tgoto out_unlock;\n \t}\n \n-\terr = ipv4_pdp_add(gtp, sk, info);\n+\terr = gtp_pdp_add(gtp, sk, info);\n \n out_unlock:\n \trcu_read_unlock();\n@@ -1036,6 +1170,11 @@ static struct pdp_ctx *gtp_find_pdp_by_link(struct net *net,\n \t\t__be32 ip = nla_get_be32(nla[GTPA_MS_ADDRESS]);\n \n \t\treturn ipv4_pdp_find(gtp, ip);\n+\t} else if (nla[GTPA_MS6_ADDRESS]) {\n+\t\tstruct in6_addr ip6 =\n+\t\t    nla_get_in6_addr(nla[GTPA_MS6_ADDRESS]);\n+\n+\t\treturn ipv6_pdp_find(gtp, &ip6);\n \t} else if (nla[GTPA_VERSION]) {\n \t\tu32 gtp_version = nla_get_u32(nla[GTPA_VERSION]);\n \n@@ -1106,10 +1245,26 @@ static int gtp_genl_fill_info(struct sk_buff *skb, u32 snd_portid, u32 snd_seq,\n \t\tgoto nlmsg_failure;\n \n \tif (nla_put_u32(skb, GTPA_VERSION, pctx->gtp_version) ||\n-\t    nla_put_be32(skb, GTPA_PEER_ADDRESS, pctx->peer_addr_ip4.s_addr) ||\n-\t    nla_put_be32(skb, GTPA_MS_ADDRESS, pctx->ms_addr_ip4.s_addr))\n+\t    nla_put_be32(skb, GTPA_PEER_ADDRESS, pctx->peer_addr_ip4.s_addr))\n \t\tgoto nla_put_failure;\n \n+\tswitch (pctx->ms_af) {\n+\tcase AF_INET:\n+\t\tif (nla_put_be32(skb, GTPA_MS_ADDRESS,\n+\t\t\t\t pctx->ms_addr_ip4.s_addr))\n+\t\t\tgoto nla_put_failure;\n+\n+\t\tbreak;\n+\tcase AF_INET6:\n+\t\tif (nla_put_in6_addr(skb, GTPA_MS6_ADDRESS,\n+\t\t\t\t     &pctx->ms_addr_ip6))\n+\t\t\tgoto nla_put_failure;\n+\n+\t\tbreak;\n+\tdefault:\n+\t\tgoto nla_put_failure;\n+\t}\n+\n \tswitch (pctx->gtp_version) {\n \tcase GTP_V0:\n \t\tif (nla_put_u64_64bit(skb, GTPA_TID, pctx->u.v0.tid, GTPA_PAD) ||\n@@ -1219,6 +1374,8 @@ static struct nla_policy gtp_genl_policy[GTPA_MAX + 1] = {\n \t[GTPA_TID]\t\t= { .type = NLA_U64, },\n \t[GTPA_PEER_ADDRESS]\t= { .type = NLA_U32, },\n \t[GTPA_MS_ADDRESS]\t= { .type = NLA_U32, },\n+\t[GTPA_MS6_ADDRESS]\t= { .len = FIELD_SIZEOF(struct ipv6hdr,\n+\t\t\t\t\t\t\tdaddr) },\n \t[GTPA_FLOW]\t\t= { .type = NLA_U16, },\n \t[GTPA_NET_NS_FD]\t= { .type = NLA_U32, },\n \t[GTPA_I_TEI]\t\t= { .type = NLA_U32, },\ndiff --git a/include/uapi/linux/gtp.h b/include/uapi/linux/gtp.h\nindex b2283a5c6d7f..ae4e632c0360 100644\n--- a/include/uapi/linux/gtp.h\n+++ b/include/uapi/linux/gtp.h\n@@ -28,6 +28,7 @@ enum gtp_attrs {\n \tGTPA_O_TEI,\t/* for GTPv1 only */\n \tGTPA_PAD,\n \tGTPA_PORT,\n+\tGTPA_MS6_ADDRESS,\n \t__GTPA_MAX,\n };\n #define GTPA_MAX (__GTPA_MAX + 1)\n",
    "prefixes": [
        "net-next",
        "07/14"
    ]
}