get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1145974,
    "url": "http://patchwork.ozlabs.org/api/patches/1145974/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1565657261-15979-3-git-send-email-tom@quantonium.net/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<1565657261-15979-3-git-send-email-tom@quantonium.net>",
    "list_archive_url": null,
    "date": "2019-08-13T00:47:36",
    "name": "[net-next,2/7] ipeh: Move generic EH functions to exthdrs_common.c",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "c4acd2c255df5c89fd250c2a82abdf7862f265aa",
    "submitter": {
        "id": 65986,
        "url": "http://patchwork.ozlabs.org/api/people/65986/?format=api",
        "name": "Tom Herbert",
        "email": "tom@herbertland.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1565657261-15979-3-git-send-email-tom@quantonium.net/mbox/",
    "series": [
        {
            "id": 124709,
            "url": "http://patchwork.ozlabs.org/api/series/124709/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=124709",
            "date": "2019-08-13T00:47:39",
            "name": "ipv6: Extension header infrastructure",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/124709/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1145974/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1145974/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "Intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "Intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": [
            "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.138; helo=whitealder.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dmarc=none (p=none dis=none)\n\theader.from=herbertland.com",
            "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=herbertland-com.20150623.gappssmtp.com\n\theader.i=@herbertland-com.20150623.gappssmtp.com\n\theader.b=\"i0QVIVgZ\"; dkim-atps=neutral"
        ],
        "Received": [
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 466vRY3Q91z9sND\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 13 Aug 2019 10:56:25 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 01B91869D7;\n\tTue, 13 Aug 2019 00:56:24 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id Zl2IMTbA244X; Tue, 13 Aug 2019 00:56:21 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 4B1BA86970;\n\tTue, 13 Aug 2019 00:56:21 +0000 (UTC)",
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id E9A201BF989\n\tfor <Intel-wired-lan@lists.osuosl.org>;\n\tTue, 13 Aug 2019 00:56:19 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id E1889840EA\n\tfor <Intel-wired-lan@lists.osuosl.org>;\n\tTue, 13 Aug 2019 00:56:19 +0000 (UTC)",
            "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 3MiW8GkHlYpq for <Intel-wired-lan@lists.osuosl.org>;\n\tTue, 13 Aug 2019 00:56:18 +0000 (UTC)",
            "from mail-pf1-f193.google.com (mail-pf1-f193.google.com\n\t[209.85.210.193])\n\tby hemlock.osuosl.org (Postfix) with ESMTPS id 23D9E82033\n\tfor <Intel-wired-lan@lists.osuosl.org>;\n\tTue, 13 Aug 2019 00:56:18 +0000 (UTC)",
            "by mail-pf1-f193.google.com with SMTP id r7so50576990pfl.3\n\tfor <Intel-wired-lan@lists.osuosl.org>;\n\tMon, 12 Aug 2019 17:56:18 -0700 (PDT)",
            "from localhost.localdomain (c-73-202-182-113.hsd1.ca.comcast.net.\n\t[73.202.182.113]) by smtp.gmail.com with ESMTPSA id\n\t14sm105671426pfy.40.2019.08.12.17.48.04\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tMon, 12 Aug 2019 17:48:04 -0700 (PDT)"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "from auto-whitelisted by SQLgrey-1.7.6",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=herbertland-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=bjhC/VyjvBcbjha6mXOPSb/jMEI0dJPHxiTfPqwDodk=;\n\tb=i0QVIVgZ7B1tdn4+H6ZEKoOXZO75DquHlvkbNIwDAqckJ2AwCFr2XYK4B0kcU7AiZM\n\t6t42VzAbffmL7HLqDB5Ft6D69pcPJiloqjvEIi6K0nmrlkm49qSHD8jFKBGqdVAhS8Vs\n\tEzMw4tJIfzdrCu4fng0W5fPBJRcu60hjSUngfWZn17bpwdc1mMZXhBiHOg3Hlk9x3jVq\n\t+KgQnrtohejfptdoA91AeLvYbgqc6VvleqO4aVO9fK433dweE3+fwUNEYeD0s4RUzGyj\n\tyEC6SshqveV9DT/IoxlQlnv1cXKgh3/RkCUQKgXHuw/TXcn5W00u9McUaW9Ecm86IyY0\n\tpk1A==",
        "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=bjhC/VyjvBcbjha6mXOPSb/jMEI0dJPHxiTfPqwDodk=;\n\tb=m17i51Q6Qk62LJqixk2lGmTZKo7w1iFUEmz/YfqmK1Vmg1PZteWiEGKSnX8aWXCYV4\n\t8QlDVFTD6rR4yGq9wY93hlfYUkLls9HFz0sDYJTSI3dN5FGvtQeqxeabzq6jKfIXcvxn\n\tO1XtlvsPJMTOX5M+rZvPZO3Aywzic3s99xCOKkmOfgCV4JLhh74c70uylqOytxXRBlfq\n\tUNxZzeGhrFnsPihYRSnRV1ysQpyIAoxCfPmTe2kzEVx1ELQIpGm1MzmA2+06hHi8nowi\n\tsoORfuxL/yWM00lzq4KvRB16kxt1rMIJkdUU8gnGr3ceQaWbdom+ZRT0z+nP+tb7inpi\n\tN1+Q==",
        "X-Gm-Message-State": "APjAAAVhOBo8slPUYHSASURSKDLnrxGjL8opiaKI0KTS23nelEPWcsTB\n\t81aixo/fRJMuBYmfdJbzC85io50StAI=",
        "X-Google-Smtp-Source": "APXvYqyy0RSs8WcSYN6U6KQrWdEICaATruDcqf4HOv5tg+0RTi15rKTJbYDF32v+FmzafOeqfyT45g==",
        "X-Received": "by 2002:a17:90a:b946:: with SMTP id\n\tf6mr1822576pjw.86.1565657285150; \n\tMon, 12 Aug 2019 17:48:05 -0700 (PDT)",
        "From": "Tom Herbert <tom@herbertland.com>",
        "X-Google-Original-From": "Tom Herbert <tom@quantonium.net>",
        "To": "Intel-wired-lan@lists.osuosl.org",
        "Date": "Mon, 12 Aug 2019 17:47:36 -0700",
        "Message-Id": "<1565657261-15979-3-git-send-email-tom@quantonium.net>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1565657261-15979-1-git-send-email-tom@quantonium.net>",
        "References": "<1565657261-15979-1-git-send-email-tom@quantonium.net>",
        "Subject": "[Intel-wired-lan] [PATCH net-next 2/7] ipeh: Move generic EH\n\tfunctions to exthdrs_common.c",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Cc": "Tom Herbert <tom@quantonium.net>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "Move generic functions in exthdrs.c to new exthdrs_common.c so that\nexthdrs.c only contains functions that are specific to IPv6 processing,\nand exthdrs_common.c contains functions that are generic. These\nfunctions include those that will be used with IPv4 extension headers.\nGeneric extension header related functions are prefixed by ipeh_.\n\nSigned-off-by: Tom Herbert <tom@quantonium.net>\n---\n include/net/ipeh.h        |   9 +++\n include/net/ipv6.h        |   9 ---\n net/dccp/ipv6.c           |   2 +-\n net/ipv6/Kconfig          |   4 ++\n net/ipv6/Makefile         |   1 +\n net/ipv6/calipso.c        |   6 +-\n net/ipv6/exthdrs.c        | 138 --------------------------------------------\n net/ipv6/exthdrs_common.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++\n net/ipv6/ipv6_sockglue.c  |   2 +-\n net/ipv6/raw.c            |   2 +-\n net/ipv6/tcp_ipv6.c       |   2 +-\n net/ipv6/udp.c            |   2 +-\n net/l2tp/l2tp_ip6.c       |   2 +-\n net/sctp/ipv6.c           |   2 +-\n 14 files changed, 168 insertions(+), 157 deletions(-)\n create mode 100644 net/ipv6/exthdrs_common.c",
    "diff": "diff --git a/include/net/ipeh.h b/include/net/ipeh.h\nindex 0e775e1..c367ce6 100644\n--- a/include/net/ipeh.h\n+++ b/include/net/ipeh.h\n@@ -17,4 +17,13 @@ struct tlvtype_proc {\n extern const struct tlvtype_proc tlvprocdestopt_lst[];\n extern const struct tlvtype_proc tlvprochopopt_lst[];\n \n+struct ipv6_txoptions *ipeh_dup_options(struct sock *sk,\n+\t\t\t\t\tstruct ipv6_txoptions *opt);\n+struct ipv6_txoptions *ipeh_renew_options(struct sock *sk,\n+\t\t\t\t\t  struct ipv6_txoptions *opt,\n+\t\t\t\t\t  int newtype,\n+\t\t\t\t\t  struct ipv6_opt_hdr *newopt);\n+struct ipv6_txoptions *ipeh_fixup_options(struct ipv6_txoptions *opt_space,\n+\t\t\t\t\t  struct ipv6_txoptions *opt);\n+\n #endif /* _NET_IPEH_H */\ndiff --git a/include/net/ipv6.h b/include/net/ipv6.h\nindex ec10fca..1c6878b 100644\n--- a/include/net/ipv6.h\n+++ b/include/net/ipv6.h\n@@ -429,15 +429,6 @@ int ip6_ra_control(struct sock *sk, int sel);\n \n int ipv6_parse_hopopts(struct sk_buff *skb);\n \n-struct ipv6_txoptions *ipv6_dup_options(struct sock *sk,\n-\t\t\t\t\tstruct ipv6_txoptions *opt);\n-struct ipv6_txoptions *ipv6_renew_options(struct sock *sk,\n-\t\t\t\t\t  struct ipv6_txoptions *opt,\n-\t\t\t\t\t  int newtype,\n-\t\t\t\t\t  struct ipv6_opt_hdr *newopt);\n-struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,\n-\t\t\t\t\t  struct ipv6_txoptions *opt);\n-\n bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb,\n \t\t       const struct inet6_skb_parm *opt);\n struct ipv6_txoptions *ipv6_update_options(struct sock *sk,\ndiff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c\nindex 1b7381f..0b83a04 100644\n--- a/net/dccp/ipv6.c\n+++ b/net/dccp/ipv6.c\n@@ -514,7 +514,7 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk,\n \tif (!opt)\n \t\topt = rcu_dereference(np->opt);\n \tif (opt) {\n-\t\topt = ipv6_dup_options(newsk, opt);\n+\t\topt = ipeh_dup_options(newsk, opt);\n \t\tRCU_INIT_POINTER(newnp->opt, opt);\n \t}\n \tinet_csk(newsk)->icsk_ext_hdr_len = 0;\ndiff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig\nindex ae1344e..700fcea 100644\n--- a/net/ipv6/Kconfig\n+++ b/net/ipv6/Kconfig\n@@ -3,9 +3,13 @@\n # IPv6 configuration\n #\n \n+config EXTHDRS\n+\tbool\n+\n #   IPv6 as module will cause a CRASH if you try to unload it\n menuconfig IPV6\n \ttristate \"The IPv6 protocol\"\n+\tselect EXTHDRS\n \tdefault y\n \t---help---\n \t  Support for IP version 6 (IPv6).\ndiff --git a/net/ipv6/Makefile b/net/ipv6/Makefile\nindex df3919b..0bcab81 100644\n--- a/net/ipv6/Makefile\n+++ b/net/ipv6/Makefile\n@@ -44,6 +44,7 @@ obj-$(CONFIG_IPV6_SIT) += sit.o\n obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o\n obj-$(CONFIG_IPV6_GRE) += ip6_gre.o\n obj-$(CONFIG_IPV6_FOU) += fou6.o\n+obj-$(CONFIG_EXTHDRS) += exthdrs_common.o\n \n obj-y += addrconf_core.o exthdrs_core.o ip6_checksum.o ip6_icmp.o\n obj-$(CONFIG_INET) += output_core.o protocol.o $(ipv6-offload)\ndiff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c\nindex 221c81f..9c84848 100644\n--- a/net/ipv6/calipso.c\n+++ b/net/ipv6/calipso.c\n@@ -785,7 +785,7 @@ static int calipso_opt_update(struct sock *sk, struct ipv6_opt_hdr *hop)\n {\n \tstruct ipv6_txoptions *old = txopt_get(inet6_sk(sk)), *txopts;\n \n-\ttxopts = ipv6_renew_options(sk, old, IPV6_HOPOPTS, hop);\n+\ttxopts = ipeh_renew_options(sk, old, IPV6_HOPOPTS, hop);\n \ttxopt_put(old);\n \tif (IS_ERR(txopts))\n \t\treturn PTR_ERR(txopts);\n@@ -1207,7 +1207,7 @@ static int calipso_req_setattr(struct request_sock *req,\n \tif (IS_ERR(new))\n \t\treturn PTR_ERR(new);\n \n-\ttxopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);\n+\ttxopts = ipeh_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);\n \n \tkfree(new);\n \n@@ -1244,7 +1244,7 @@ static void calipso_req_delattr(struct request_sock *req)\n \tif (calipso_opt_del(req_inet->ipv6_opt->hopopt, &new))\n \t\treturn; /* Nothing to do */\n \n-\ttxopts = ipv6_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);\n+\ttxopts = ipeh_renew_options(sk, req_inet->ipv6_opt, IPV6_HOPOPTS, new);\n \n \tif (!IS_ERR(txopts)) {\n \t\ttxopts = xchg(&req_inet->ipv6_opt, txopts);\ndiff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c\nindex 664491e..e12d3a5 100644\n--- a/net/ipv6/exthdrs.c\n+++ b/net/ipv6/exthdrs.c\n@@ -784,144 +784,6 @@ void ipv6_push_frag_opts(struct sk_buff *skb, struct ipv6_txoptions *opt, u8 *pr\n }\n EXPORT_SYMBOL(ipv6_push_frag_opts);\n \n-struct ipv6_txoptions *\n-ipv6_dup_options(struct sock *sk, struct ipv6_txoptions *opt)\n-{\n-\tstruct ipv6_txoptions *opt2;\n-\n-\topt2 = sock_kmalloc(sk, opt->tot_len, GFP_ATOMIC);\n-\tif (opt2) {\n-\t\tlong dif = (char *)opt2 - (char *)opt;\n-\t\tmemcpy(opt2, opt, opt->tot_len);\n-\t\tif (opt2->hopopt)\n-\t\t\t*((char **)&opt2->hopopt) += dif;\n-\t\tif (opt2->dst0opt)\n-\t\t\t*((char **)&opt2->dst0opt) += dif;\n-\t\tif (opt2->dst1opt)\n-\t\t\t*((char **)&opt2->dst1opt) += dif;\n-\t\tif (opt2->srcrt)\n-\t\t\t*((char **)&opt2->srcrt) += dif;\n-\t\trefcount_set(&opt2->refcnt, 1);\n-\t}\n-\treturn opt2;\n-}\n-EXPORT_SYMBOL_GPL(ipv6_dup_options);\n-\n-static void ipv6_renew_option(int renewtype,\n-\t\t\t      struct ipv6_opt_hdr **dest,\n-\t\t\t      struct ipv6_opt_hdr *old,\n-\t\t\t      struct ipv6_opt_hdr *new,\n-\t\t\t      int newtype, char **p)\n-{\n-\tstruct ipv6_opt_hdr *src;\n-\n-\tsrc = (renewtype == newtype ? new : old);\n-\tif (!src)\n-\t\treturn;\n-\n-\tmemcpy(*p, src, ipv6_optlen(src));\n-\t*dest = (struct ipv6_opt_hdr *)*p;\n-\t*p += CMSG_ALIGN(ipv6_optlen(*dest));\n-}\n-\n-/**\n- * ipv6_renew_options - replace a specific ext hdr with a new one.\n- *\n- * @sk: sock from which to allocate memory\n- * @opt: original options\n- * @newtype: option type to replace in @opt\n- * @newopt: new option of type @newtype to replace (user-mem)\n- * @newoptlen: length of @newopt\n- *\n- * Returns a new set of options which is a copy of @opt with the\n- * option type @newtype replaced with @newopt.\n- *\n- * @opt may be NULL, in which case a new set of options is returned\n- * containing just @newopt.\n- *\n- * @newopt may be NULL, in which case the specified option type is\n- * not copied into the new set of options.\n- *\n- * The new set of options is allocated from the socket option memory\n- * buffer of @sk.\n- */\n-struct ipv6_txoptions *\n-ipv6_renew_options(struct sock *sk, struct ipv6_txoptions *opt,\n-\t\t   int newtype, struct ipv6_opt_hdr *newopt)\n-{\n-\tint tot_len = 0;\n-\tchar *p;\n-\tstruct ipv6_txoptions *opt2;\n-\n-\tif (opt) {\n-\t\tif (newtype != IPV6_HOPOPTS && opt->hopopt)\n-\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->hopopt));\n-\t\tif (newtype != IPV6_RTHDRDSTOPTS && opt->dst0opt)\n-\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->dst0opt));\n-\t\tif (newtype != IPV6_RTHDR && opt->srcrt)\n-\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->srcrt));\n-\t\tif (newtype != IPV6_DSTOPTS && opt->dst1opt)\n-\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));\n-\t}\n-\n-\tif (newopt)\n-\t\ttot_len += CMSG_ALIGN(ipv6_optlen(newopt));\n-\n-\tif (!tot_len)\n-\t\treturn NULL;\n-\n-\ttot_len += sizeof(*opt2);\n-\topt2 = sock_kmalloc(sk, tot_len, GFP_ATOMIC);\n-\tif (!opt2)\n-\t\treturn ERR_PTR(-ENOBUFS);\n-\n-\tmemset(opt2, 0, tot_len);\n-\trefcount_set(&opt2->refcnt, 1);\n-\topt2->tot_len = tot_len;\n-\tp = (char *)(opt2 + 1);\n-\n-\tipv6_renew_option(IPV6_HOPOPTS, &opt2->hopopt,\n-\t\t\t  (opt ? opt->hopopt : NULL),\n-\t\t\t  newopt, newtype, &p);\n-\tipv6_renew_option(IPV6_RTHDRDSTOPTS, &opt2->dst0opt,\n-\t\t\t  (opt ? opt->dst0opt : NULL),\n-\t\t\t  newopt, newtype, &p);\n-\tipv6_renew_option(IPV6_RTHDR,\n-\t\t\t  (struct ipv6_opt_hdr **)&opt2->srcrt,\n-\t\t\t  (opt ? (struct ipv6_opt_hdr *)opt->srcrt : NULL),\n-\t\t\t  newopt, newtype, &p);\n-\tipv6_renew_option(IPV6_DSTOPTS, &opt2->dst1opt,\n-\t\t\t  (opt ? opt->dst1opt : NULL),\n-\t\t\t  newopt, newtype, &p);\n-\n-\topt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +\n-\t\t\t  (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +\n-\t\t\t  (opt2->srcrt ? ipv6_optlen(opt2->srcrt) : 0);\n-\topt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);\n-\n-\treturn opt2;\n-}\n-\n-struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,\n-\t\t\t\t\t  struct ipv6_txoptions *opt)\n-{\n-\t/*\n-\t * ignore the dest before srcrt unless srcrt is being included.\n-\t * --yoshfuji\n-\t */\n-\tif (opt && opt->dst0opt && !opt->srcrt) {\n-\t\tif (opt_space != opt) {\n-\t\t\tmemcpy(opt_space, opt, sizeof(*opt_space));\n-\t\t\topt = opt_space;\n-\t\t}\n-\t\topt->opt_nflen -= ipv6_optlen(opt->dst0opt);\n-\t\topt->dst0opt = NULL;\n-\t}\n-\n-\treturn opt;\n-}\n-EXPORT_SYMBOL_GPL(ipv6_fixup_options);\n-\n /**\n  * fl6_update_dst - update flowi destination address with info given\n  *                  by srcrt option, if any.\ndiff --git a/net/ipv6/exthdrs_common.c b/net/ipv6/exthdrs_common.c\nnew file mode 100644\nindex 0000000..2c68184\n--- /dev/null\n+++ b/net/ipv6/exthdrs_common.c\n@@ -0,0 +1,144 @@\n+// SPDX-License-Identifier: GPL-2.0\n+\n+/* Extension header and TLV library code that is not specific to IPv6. */\n+#include <linux/export.h>\n+#include <net/ipv6.h>\n+\n+struct ipv6_txoptions *\n+ipeh_dup_options(struct sock *sk, struct ipv6_txoptions *opt)\n+{\n+\tstruct ipv6_txoptions *opt2;\n+\n+\topt2 = sock_kmalloc(sk, opt->tot_len, GFP_ATOMIC);\n+\tif (opt2) {\n+\t\tlong dif = (char *)opt2 - (char *)opt;\n+\n+\t\tmemcpy(opt2, opt, opt->tot_len);\n+\t\tif (opt2->hopopt)\n+\t\t\t*((char **)&opt2->hopopt) += dif;\n+\t\tif (opt2->dst0opt)\n+\t\t\t*((char **)&opt2->dst0opt) += dif;\n+\t\tif (opt2->dst1opt)\n+\t\t\t*((char **)&opt2->dst1opt) += dif;\n+\t\tif (opt2->srcrt)\n+\t\t\t*((char **)&opt2->srcrt) += dif;\n+\t\trefcount_set(&opt2->refcnt, 1);\n+\t}\n+\treturn opt2;\n+}\n+EXPORT_SYMBOL_GPL(ipeh_dup_options);\n+\n+static void ipeh_renew_option(int renewtype,\n+\t\t\t      struct ipv6_opt_hdr **dest,\n+\t\t\t      struct ipv6_opt_hdr *old,\n+\t\t\t      struct ipv6_opt_hdr *new,\n+\t\t\t      int newtype, char **p)\n+{\n+\tstruct ipv6_opt_hdr *src;\n+\n+\tsrc = (renewtype == newtype ? new : old);\n+\tif (!src)\n+\t\treturn;\n+\n+\tmemcpy(*p, src, ipv6_optlen(src));\n+\t*dest = (struct ipv6_opt_hdr *)*p;\n+\t*p += CMSG_ALIGN(ipv6_optlen(*dest));\n+}\n+\n+/**\n+ * ipeh_renew_options - replace a specific ext hdr with a new one.\n+ *\n+ * @sk: sock from which to allocate memory\n+ * @opt: original options\n+ * @newtype: option type to replace in @opt\n+ * @newopt: new option of type @newtype to replace (user-mem)\n+ * @newoptlen: length of @newopt\n+ *\n+ * Returns a new set of options which is a copy of @opt with the\n+ * option type @newtype replaced with @newopt.\n+ *\n+ * @opt may be NULL, in which case a new set of options is returned\n+ * containing just @newopt.\n+ *\n+ * @newopt may be NULL, in which case the specified option type is\n+ * not copied into the new set of options.\n+ *\n+ * The new set of options is allocated from the socket option memory\n+ * buffer of @sk.\n+ */\n+struct ipv6_txoptions *\n+ipeh_renew_options(struct sock *sk, struct ipv6_txoptions *opt,\n+\t\t   int newtype, struct ipv6_opt_hdr *newopt)\n+{\n+\tint tot_len = 0;\n+\tchar *p;\n+\tstruct ipv6_txoptions *opt2;\n+\n+\tif (opt) {\n+\t\tif (newtype != IPV6_HOPOPTS && opt->hopopt)\n+\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->hopopt));\n+\t\tif (newtype != IPV6_RTHDRDSTOPTS && opt->dst0opt)\n+\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->dst0opt));\n+\t\tif (newtype != IPV6_RTHDR && opt->srcrt)\n+\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->srcrt));\n+\t\tif (newtype != IPV6_DSTOPTS && opt->dst1opt)\n+\t\t\ttot_len += CMSG_ALIGN(ipv6_optlen(opt->dst1opt));\n+\t}\n+\n+\tif (newopt)\n+\t\ttot_len += CMSG_ALIGN(ipv6_optlen(newopt));\n+\n+\tif (!tot_len)\n+\t\treturn NULL;\n+\n+\ttot_len += sizeof(*opt2);\n+\topt2 = sock_kmalloc(sk, tot_len, GFP_ATOMIC);\n+\tif (!opt2)\n+\t\treturn ERR_PTR(-ENOBUFS);\n+\n+\tmemset(opt2, 0, tot_len);\n+\trefcount_set(&opt2->refcnt, 1);\n+\topt2->tot_len = tot_len;\n+\tp = (char *)(opt2 + 1);\n+\n+\tipeh_renew_option(IPV6_HOPOPTS, &opt2->hopopt,\n+\t\t\t  (opt ? opt->hopopt : NULL),\n+\t\t\t  newopt, newtype, &p);\n+\tipeh_renew_option(IPV6_RTHDRDSTOPTS, &opt2->dst0opt,\n+\t\t\t  (opt ? opt->dst0opt : NULL),\n+\t\t\t  newopt, newtype, &p);\n+\tipeh_renew_option(IPV6_RTHDR,\n+\t\t\t  (struct ipv6_opt_hdr **)&opt2->srcrt,\n+\t\t\t  (opt ? (struct ipv6_opt_hdr *)opt->srcrt : NULL),\n+\t\t\t  newopt, newtype, &p);\n+\tipeh_renew_option(IPV6_DSTOPTS, &opt2->dst1opt,\n+\t\t\t  (opt ? opt->dst1opt : NULL),\n+\t\t\t  newopt, newtype, &p);\n+\n+\topt2->opt_nflen = (opt2->hopopt ? ipv6_optlen(opt2->hopopt) : 0) +\n+\t\t\t  (opt2->dst0opt ? ipv6_optlen(opt2->dst0opt) : 0) +\n+\t\t\t  (opt2->srcrt ? ipv6_optlen(opt2->srcrt) : 0);\n+\topt2->opt_flen = (opt2->dst1opt ? ipv6_optlen(opt2->dst1opt) : 0);\n+\n+\treturn opt2;\n+}\n+EXPORT_SYMBOL(ipeh_renew_options);\n+\n+struct ipv6_txoptions *ipeh_fixup_options(struct ipv6_txoptions *opt_space,\n+\t\t\t\t\t  struct ipv6_txoptions *opt)\n+{\n+\t/* ignore the dest before srcrt unless srcrt is being included.\n+\t * --yoshfuji\n+\t */\n+\tif (opt && opt->dst0opt && !opt->srcrt) {\n+\t\tif (opt_space != opt) {\n+\t\t\tmemcpy(opt_space, opt, sizeof(*opt_space));\n+\t\t\topt = opt_space;\n+\t\t}\n+\t\topt->opt_nflen -= ipv6_optlen(opt->dst0opt);\n+\t\topt->dst0opt = NULL;\n+\t}\n+\n+\treturn opt;\n+}\n+EXPORT_SYMBOL_GPL(ipeh_fixup_options);\ndiff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c\nindex 264c292..8755ecc 100644\n--- a/net/ipv6/ipv6_sockglue.c\n+++ b/net/ipv6/ipv6_sockglue.c\n@@ -427,7 +427,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,\n \n \t\topt = rcu_dereference_protected(np->opt,\n \t\t\t\t\t\tlockdep_sock_is_held(sk));\n-\t\topt = ipv6_renew_options(sk, opt, optname, new);\n+\t\topt = ipeh_renew_options(sk, opt, optname, new);\n \t\tkfree(new);\n \t\tif (IS_ERR(opt)) {\n \t\t\tretv = PTR_ERR(opt);\ndiff --git a/net/ipv6/raw.c b/net/ipv6/raw.c\nindex 8a61319..5834ca4 100644\n--- a/net/ipv6/raw.c\n+++ b/net/ipv6/raw.c\n@@ -888,7 +888,7 @@ static int rawv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)\n \t}\n \tif (flowlabel)\n \t\topt = fl6_merge_options(&opt_space, flowlabel, opt);\n-\topt = ipv6_fixup_options(&opt_space, opt);\n+\topt = ipeh_fixup_options(&opt_space, opt);\n \n \tfl6.flowi6_proto = proto;\n \ndiff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c\nindex 5da069e..009b0ec 100644\n--- a/net/ipv6/tcp_ipv6.c\n+++ b/net/ipv6/tcp_ipv6.c\n@@ -1228,7 +1228,7 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff *\n \tif (!opt)\n \t\topt = rcu_dereference(np->opt);\n \tif (opt) {\n-\t\topt = ipv6_dup_options(newsk, opt);\n+\t\topt = ipeh_dup_options(newsk, opt);\n \t\tRCU_INIT_POINTER(newnp->opt, opt);\n \t}\n \tinet_csk(newsk)->icsk_ext_hdr_len = 0;\ndiff --git a/net/ipv6/udp.c b/net/ipv6/udp.c\nindex 827fe73..02ab20e 100644\n--- a/net/ipv6/udp.c\n+++ b/net/ipv6/udp.c\n@@ -1384,7 +1384,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)\n \t}\n \tif (flowlabel)\n \t\topt = fl6_merge_options(&opt_space, flowlabel, opt);\n-\topt = ipv6_fixup_options(&opt_space, opt);\n+\topt = ipeh_fixup_options(&opt_space, opt);\n \tipc6.opt = opt;\n \n \tfl6.flowi6_proto = sk->sk_protocol;\ndiff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c\nindex 687e23a..bc4925c 100644\n--- a/net/l2tp/l2tp_ip6.c\n+++ b/net/l2tp/l2tp_ip6.c\n@@ -590,7 +590,7 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)\n \t}\n \tif (flowlabel)\n \t\topt = fl6_merge_options(&opt_space, flowlabel, opt);\n-\topt = ipv6_fixup_options(&opt_space, opt);\n+\topt = ipeh_fixup_options(&opt_space, opt);\n \tipc6.opt = opt;\n \n \tfl6.flowi6_proto = sk->sk_protocol;\ndiff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c\nindex e5f2fc7..b5b1349 100644\n--- a/net/sctp/ipv6.c\n+++ b/net/sctp/ipv6.c\n@@ -441,7 +441,7 @@ static void sctp_v6_copy_ip_options(struct sock *sk, struct sock *newsk)\n \trcu_read_lock();\n \topt = rcu_dereference(np->opt);\n \tif (opt) {\n-\t\topt = ipv6_dup_options(newsk, opt);\n+\t\topt = ipeh_dup_options(newsk, opt);\n \t\tif (!opt)\n \t\t\tpr_err(\"%s: Failed to copy ip options\\n\", __func__);\n \t}\n",
    "prefixes": [
        "net-next",
        "2/7"
    ]
}