Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1145970/?format=api
{ "id": 1145970, "url": "http://patchwork.ozlabs.org/api/patches/1145970/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1565657261-15979-2-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-2-git-send-email-tom@quantonium.net>", "list_archive_url": null, "date": "2019-08-13T00:47:35", "name": "[net-next,1/7] ipeh: Create exthdrs_options.c and ipeh.h", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "34b8173e9c5d31c3d0b30035304af005e8e02f17", "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-2-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/1145970/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1145970/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=\"N0hAYKsV\"; 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 466vQ95VsJz9sND\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 13 Aug 2019 10:55:13 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 26A21869D7;\n\tTue, 13 Aug 2019 00:55:12 +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 JIpJOG5lUtHd; Tue, 13 Aug 2019 00:55:09 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 76F9B86970;\n\tTue, 13 Aug 2019 00:55:09 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 8245B1BF989\n\tfor <Intel-wired-lan@lists.osuosl.org>;\n\tTue, 13 Aug 2019 00:55:08 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 7F5BE2264A\n\tfor <Intel-wired-lan@lists.osuosl.org>;\n\tTue, 13 Aug 2019 00:55:08 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id xHeNqulN8BYZ for <Intel-wired-lan@lists.osuosl.org>;\n\tTue, 13 Aug 2019 00:55:06 +0000 (UTC)", "from mail-pf1-f195.google.com (mail-pf1-f195.google.com\n\t[209.85.210.195])\n\tby silver.osuosl.org (Postfix) with ESMTPS id DADC5204E8\n\tfor <Intel-wired-lan@lists.osuosl.org>;\n\tTue, 13 Aug 2019 00:55:06 +0000 (UTC)", "by mail-pf1-f195.google.com with SMTP id f17so46584735pfn.6\n\tfor <Intel-wired-lan@lists.osuosl.org>;\n\tMon, 12 Aug 2019 17:55:06 -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.01\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tMon, 12 Aug 2019 17:48:01 -0700 (PDT)" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "delayed 00:07:10 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=d5mTyufCZRlIsRD5WBhIGzFskYe8+bWcLNwJybgOLRk=;\n\tb=N0hAYKsV9c0qIUhT2yT1q4iK0o+8RSBVmFJoxPOo8BqtxmOyrVg+l2qI+MSxhv0ZVQ\n\t0jROGSL5ifFevMvJXRLqY4IYCX5gUhEAW7V9DdgZ6s/VieOo3bljsBMkcqHx1hgyQbEw\n\thy2hrrqfTWZt/g0TuxEaO7UHEg1QsQb6/PkTAvCnD6HjgnjCJGJWe7a3MkkH9qSt+FeB\n\tY60rlsXktunON3r/MuoH/c0ZtIi/IA5K4jLfNleH1F8zU+pQogJZoZRlpz7SL+f07l1L\n\tGVsFaT1Q57iLiAmocKebexNqOlaHs5vJOo8kPUzP2ns+Fq3JMM0VmdJJGBdvjyrhBkgQ\n\tWKWA==", "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=d5mTyufCZRlIsRD5WBhIGzFskYe8+bWcLNwJybgOLRk=;\n\tb=WDwLngFEd/rAPhukkO54Sc8+fWnV4kgAwSXz5gLWrq9WR5xt4CwoUyU7XXZIYPpOCz\n\tEY6mQHm7YgWShv/LYDNGckq+41ACbsZ4+wmllarpntNIPk5JHifnq0SXwn1wqmOec0kS\n\tdUWFcPM5Ing4CK8iSHMEb7x+cdf7TeVMbxmuKN0X2CgdceYPuHc0DqVYOmxbECqowR+A\n\tlNEVvtndUa09IJbjf2oUqJIDbr+kAdBB+PxUTVaEJTVROAf/2pQ4ZZV7/L4/A3PhXt4C\n\tnUXh3s+8Diqfi9eBZZi6lG/rIkIdbHEyTA0TaMWM+rrCDT6A2G53fQipRCngZpdOhxWV\n\t93Iw==", "X-Gm-Message-State": "APjAAAVWDAhk4AH7xuNucxFXT8J0FRBA9ecR5WAmGUCO4a3Rw0BI1MD8\n\tHah8r+Y3bRj6DKYH4PahefDIxDkmOD0=", "X-Google-Smtp-Source": "APXvYqwu1Vr9Yu6IBQGrgutooeu3rGoPjHP/Q3RA5o1mj26DdFQ+TanBn/iNFH0SRvzvV8x7TjvNmQ==", "X-Received": "by 2002:aa7:97aa:: with SMTP id\n\td10mr38386618pfq.176.1565657282225; \n\tMon, 12 Aug 2019 17:48:02 -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:35 -0700", "Message-Id": "<1565657261-15979-2-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 1/7] ipeh: Create\n\texthdrs_options.c and ipeh.h", "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": "Create exthdrs_options.c to hold code related to specific Hop-by-Hop\nand Destination extension header options. Move related functions in\nexthdrs.c to the new file.\n\nCreate include net/ipeh.h to contain common definitions for IP extension\nheaders.\n\nSigned-off-by: Tom Herbert <tom@quantonium.net>\n---\n include/net/ipeh.h | 20 +++++\n include/net/ipv6.h | 1 +\n net/ipv6/Makefile | 2 +-\n net/ipv6/exthdrs.c | 204 ---------------------------------------------\n net/ipv6/exthdrs_options.c | 201 ++++++++++++++++++++++++++++++++++++++++++++\n 5 files changed, 223 insertions(+), 205 deletions(-)\n create mode 100644 include/net/ipeh.h\n create mode 100644 net/ipv6/exthdrs_options.c", "diff": "diff --git a/include/net/ipeh.h b/include/net/ipeh.h\nnew file mode 100644\nindex 0000000..0e775e1\n--- /dev/null\n+++ b/include/net/ipeh.h\n@@ -0,0 +1,20 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+#ifndef _NET_IPEH_H\n+#define _NET_IPEH_H\n+\n+/*\n+ * Parsing tlv encoded headers.\n+ *\n+ * Parsing function \"func\" returns true, if parsing succeed\n+ * and false, if it failed.\n+ * It MUST NOT touch skb->h.\n+ */\n+struct tlvtype_proc {\n+\tint\ttype;\n+\tbool\t(*func)(struct sk_buff *skb, int offset);\n+};\n+\n+extern const struct tlvtype_proc tlvprocdestopt_lst[];\n+extern const struct tlvtype_proc tlvprochopopt_lst[];\n+\n+#endif /* _NET_IPEH_H */\ndiff --git a/include/net/ipv6.h b/include/net/ipv6.h\nindex 8dfc656..ec10fca 100644\n--- a/include/net/ipv6.h\n+++ b/include/net/ipv6.h\n@@ -20,6 +20,7 @@\n #include <net/flow_dissector.h>\n #include <net/snmp.h>\n #include <net/netns/hash.h>\n+#include <net/ipeh.h>\n \n #define SIN6_LEN_RFC2133\t24\n \ndiff --git a/net/ipv6/Makefile b/net/ipv6/Makefile\nindex 8ccf355..df3919b 100644\n--- a/net/ipv6/Makefile\n+++ b/net/ipv6/Makefile\n@@ -10,7 +10,7 @@ ipv6-objs :=\taf_inet6.o anycast.o ip6_output.o ip6_input.o addrconf.o \\\n \t\troute.o ip6_fib.o ipv6_sockglue.o ndisc.o udp.o udplite.o \\\n \t\traw.o icmp.o mcast.o reassembly.o tcp_ipv6.o ping.o \\\n \t\texthdrs.o datagram.o ip6_flowlabel.o inet6_connection_sock.o \\\n-\t\tudp_offload.o seg6.o fib6_notifier.o\n+\t\tudp_offload.o seg6.o fib6_notifier.o exthdrs_options.o\n \n ipv6-offload :=\tip6_offload.o tcpv6_offload.o exthdrs_offload.o\n \ndiff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c\nindex ab5add0..664491e 100644\n--- a/net/ipv6/exthdrs.c\n+++ b/net/ipv6/exthdrs.c\n@@ -39,7 +39,6 @@\n #include <net/ndisc.h>\n #include <net/ip6_route.h>\n #include <net/addrconf.h>\n-#include <net/calipso.h>\n #if IS_ENABLED(CONFIG_IPV6_MIP6)\n #include <net/xfrm.h>\n #endif\n@@ -51,19 +50,6 @@\n \n #include <linux/uaccess.h>\n \n-/*\n- *\tParsing tlv encoded headers.\n- *\n- *\tParsing function \"func\" returns true, if parsing succeed\n- *\tand false, if it failed.\n- *\tIt MUST NOT touch skb->h.\n- */\n-\n-struct tlvtype_proc {\n-\tint\ttype;\n-\tbool\t(*func)(struct sk_buff *skb, int offset);\n-};\n-\n /*********************\n Generic functions\n *********************/\n@@ -200,80 +186,6 @@ static bool ip6_parse_tlv(const struct tlvtype_proc *procs,\n \treturn false;\n }\n \n-/*****************************\n- Destination options header.\n- *****************************/\n-\n-#if IS_ENABLED(CONFIG_IPV6_MIP6)\n-static bool ipv6_dest_hao(struct sk_buff *skb, int optoff)\n-{\n-\tstruct ipv6_destopt_hao *hao;\n-\tstruct inet6_skb_parm *opt = IP6CB(skb);\n-\tstruct ipv6hdr *ipv6h = ipv6_hdr(skb);\n-\tint ret;\n-\n-\tif (opt->dsthao) {\n-\t\tnet_dbg_ratelimited(\"hao duplicated\\n\");\n-\t\tgoto discard;\n-\t}\n-\topt->dsthao = opt->dst1;\n-\topt->dst1 = 0;\n-\n-\thao = (struct ipv6_destopt_hao *)(skb_network_header(skb) + optoff);\n-\n-\tif (hao->length != 16) {\n-\t\tnet_dbg_ratelimited(\"hao invalid option length = %d\\n\",\n-\t\t\t\t hao->length);\n-\t\tgoto discard;\n-\t}\n-\n-\tif (!(ipv6_addr_type(&hao->addr) & IPV6_ADDR_UNICAST)) {\n-\t\tnet_dbg_ratelimited(\"hao is not an unicast addr: %pI6\\n\",\n-\t\t\t\t &hao->addr);\n-\t\tgoto discard;\n-\t}\n-\n-\tret = xfrm6_input_addr(skb, (xfrm_address_t *)&ipv6h->daddr,\n-\t\t\t (xfrm_address_t *)&hao->addr, IPPROTO_DSTOPTS);\n-\tif (unlikely(ret < 0))\n-\t\tgoto discard;\n-\n-\tif (skb_cloned(skb)) {\n-\t\tif (pskb_expand_head(skb, 0, 0, GFP_ATOMIC))\n-\t\t\tgoto discard;\n-\n-\t\t/* update all variable using below by copied skbuff */\n-\t\thao = (struct ipv6_destopt_hao *)(skb_network_header(skb) +\n-\t\t\t\t\t\t optoff);\n-\t\tipv6h = ipv6_hdr(skb);\n-\t}\n-\n-\tif (skb->ip_summed == CHECKSUM_COMPLETE)\n-\t\tskb->ip_summed = CHECKSUM_NONE;\n-\n-\tswap(ipv6h->saddr, hao->addr);\n-\n-\tif (skb->tstamp == 0)\n-\t\t__net_timestamp(skb);\n-\n-\treturn true;\n-\n- discard:\n-\tkfree_skb(skb);\n-\treturn false;\n-}\n-#endif\n-\n-static const struct tlvtype_proc tlvprocdestopt_lst[] = {\n-#if IS_ENABLED(CONFIG_IPV6_MIP6)\n-\t{\n-\t\t.type\t= IPV6_TLV_HAO,\n-\t\t.func\t= ipv6_dest_hao,\n-\t},\n-#endif\n-\t{-1,\t\t\tNULL}\n-};\n-\n static int ipv6_destopt_rcv(struct sk_buff *skb)\n {\n \tstruct inet6_dev *idev = __in6_dev_get(skb->dev);\n@@ -702,122 +614,6 @@ void ipv6_exthdrs_exit(void)\n \tinet6_del_protocol(&rthdr_protocol, IPPROTO_ROUTING);\n }\n \n-/**********************************\n- Hop-by-hop options.\n- **********************************/\n-\n-/*\n- * Note: we cannot rely on skb_dst(skb) before we assign it in ip6_route_input().\n- */\n-static inline struct inet6_dev *ipv6_skb_idev(struct sk_buff *skb)\n-{\n-\treturn skb_dst(skb) ? ip6_dst_idev(skb_dst(skb)) : __in6_dev_get(skb->dev);\n-}\n-\n-static inline struct net *ipv6_skb_net(struct sk_buff *skb)\n-{\n-\treturn skb_dst(skb) ? dev_net(skb_dst(skb)->dev) : dev_net(skb->dev);\n-}\n-\n-/* Router Alert as of RFC 2711 */\n-\n-static bool ipv6_hop_ra(struct sk_buff *skb, int optoff)\n-{\n-\tconst unsigned char *nh = skb_network_header(skb);\n-\n-\tif (nh[optoff + 1] == 2) {\n-\t\tIP6CB(skb)->flags |= IP6SKB_ROUTERALERT;\n-\t\tmemcpy(&IP6CB(skb)->ra, nh + optoff + 2, sizeof(IP6CB(skb)->ra));\n-\t\treturn true;\n-\t}\n-\tnet_dbg_ratelimited(\"ipv6_hop_ra: wrong RA length %d\\n\",\n-\t\t\t nh[optoff + 1]);\n-\tkfree_skb(skb);\n-\treturn false;\n-}\n-\n-/* Jumbo payload */\n-\n-static bool ipv6_hop_jumbo(struct sk_buff *skb, int optoff)\n-{\n-\tconst unsigned char *nh = skb_network_header(skb);\n-\tstruct inet6_dev *idev = __in6_dev_get_safely(skb->dev);\n-\tstruct net *net = ipv6_skb_net(skb);\n-\tu32 pkt_len;\n-\n-\tif (nh[optoff + 1] != 4 || (optoff & 3) != 2) {\n-\t\tnet_dbg_ratelimited(\"ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\\n\",\n-\t\t\t\t nh[optoff+1]);\n-\t\t__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);\n-\t\tgoto drop;\n-\t}\n-\n-\tpkt_len = ntohl(*(__be32 *)(nh + optoff + 2));\n-\tif (pkt_len <= IPV6_MAXPLEN) {\n-\t\t__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);\n-\t\ticmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2);\n-\t\treturn false;\n-\t}\n-\tif (ipv6_hdr(skb)->payload_len) {\n-\t\t__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);\n-\t\ticmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff);\n-\t\treturn false;\n-\t}\n-\n-\tif (pkt_len > skb->len - sizeof(struct ipv6hdr)) {\n-\t\t__IP6_INC_STATS(net, idev, IPSTATS_MIB_INTRUNCATEDPKTS);\n-\t\tgoto drop;\n-\t}\n-\n-\tif (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))\n-\t\tgoto drop;\n-\n-\tIP6CB(skb)->flags |= IP6SKB_JUMBOGRAM;\n-\treturn true;\n-\n-drop:\n-\tkfree_skb(skb);\n-\treturn false;\n-}\n-\n-/* CALIPSO RFC 5570 */\n-\n-static bool ipv6_hop_calipso(struct sk_buff *skb, int optoff)\n-{\n-\tconst unsigned char *nh = skb_network_header(skb);\n-\n-\tif (nh[optoff + 1] < 8)\n-\t\tgoto drop;\n-\n-\tif (nh[optoff + 6] * 4 + 8 > nh[optoff + 1])\n-\t\tgoto drop;\n-\n-\tif (!calipso_validate(skb, nh + optoff))\n-\t\tgoto drop;\n-\n-\treturn true;\n-\n-drop:\n-\tkfree_skb(skb);\n-\treturn false;\n-}\n-\n-static const struct tlvtype_proc tlvprochopopt_lst[] = {\n-\t{\n-\t\t.type\t= IPV6_TLV_ROUTERALERT,\n-\t\t.func\t= ipv6_hop_ra,\n-\t},\n-\t{\n-\t\t.type\t= IPV6_TLV_JUMBO,\n-\t\t.func\t= ipv6_hop_jumbo,\n-\t},\n-\t{\n-\t\t.type\t= IPV6_TLV_CALIPSO,\n-\t\t.func\t= ipv6_hop_calipso,\n-\t},\n-\t{ -1, }\n-};\n-\n int ipv6_parse_hopopts(struct sk_buff *skb)\n {\n \tstruct inet6_skb_parm *opt = IP6CB(skb);\ndiff --git a/net/ipv6/exthdrs_options.c b/net/ipv6/exthdrs_options.c\nnew file mode 100644\nindex 0000000..032e072\n--- /dev/null\n+++ b/net/ipv6/exthdrs_options.c\n@@ -0,0 +1,201 @@\n+// SPDX-License-Identifier: GPL-2.0\n+#include <linux/errno.h>\n+#include <linux/in6.h>\n+#include <linux/net.h>\n+#include <linux/netdevice.h>\n+#include <linux/socket.h>\n+#include <linux/types.h>\n+#include <net/calipso.h>\n+#include <net/ipv6.h>\n+#include <net/ip6_route.h>\n+#if IS_ENABLED(CONFIG_IPV6_MIP6)\n+#include <net/xfrm.h>\n+#endif\n+\n+/* Destination options header */\n+\n+#if IS_ENABLED(CONFIG_IPV6_MIP6)\n+static bool ipv6_dest_hao(struct sk_buff *skb, int optoff)\n+{\n+\tstruct ipv6_destopt_hao *hao;\n+\tstruct inet6_skb_parm *opt = IP6CB(skb);\n+\tstruct ipv6hdr *ipv6h = ipv6_hdr(skb);\n+\tint ret;\n+\n+\tif (opt->dsthao) {\n+\t\tnet_dbg_ratelimited(\"hao duplicated\\n\");\n+\t\tgoto discard;\n+\t}\n+\topt->dsthao = opt->dst1;\n+\topt->dst1 = 0;\n+\n+\thao = (struct ipv6_destopt_hao *)(skb_network_header(skb) + optoff);\n+\n+\tif (hao->length != 16) {\n+\t\tnet_dbg_ratelimited(\"hao invalid option length = %d\\n\",\n+\t\t\t\t hao->length);\n+\t\tgoto discard;\n+\t}\n+\n+\tif (!(ipv6_addr_type(&hao->addr) & IPV6_ADDR_UNICAST)) {\n+\t\tnet_dbg_ratelimited(\"hao is not an unicast addr: %pI6\\n\",\n+\t\t\t\t &hao->addr);\n+\t\tgoto discard;\n+\t}\n+\n+\tret = xfrm6_input_addr(skb, (xfrm_address_t *)&ipv6h->daddr,\n+\t\t\t (xfrm_address_t *)&hao->addr, IPPROTO_DSTOPTS);\n+\tif (unlikely(ret < 0))\n+\t\tgoto discard;\n+\n+\tif (skb_cloned(skb)) {\n+\t\tif (pskb_expand_head(skb, 0, 0, GFP_ATOMIC))\n+\t\t\tgoto discard;\n+\n+\t\t/* update all variable using below by copied skbuff */\n+\t\thao = (struct ipv6_destopt_hao *)(skb_network_header(skb) +\n+\t\t\t\t\t\t optoff);\n+\t\tipv6h = ipv6_hdr(skb);\n+\t}\n+\n+\tif (skb->ip_summed == CHECKSUM_COMPLETE)\n+\t\tskb->ip_summed = CHECKSUM_NONE;\n+\n+\tswap(ipv6h->saddr, hao->addr);\n+\n+\tif (skb->tstamp == 0)\n+\t\t__net_timestamp(skb);\n+\n+\treturn true;\n+\n+ discard:\n+\tkfree_skb(skb);\n+\treturn false;\n+}\n+#endif\n+\n+const struct tlvtype_proc tlvprocdestopt_lst[] = {\n+#if IS_ENABLED(CONFIG_IPV6_MIP6)\n+\t{\n+\t\t.type\t= IPV6_TLV_HAO,\n+\t\t.func\t= ipv6_dest_hao,\n+\t},\n+#endif\n+\t{-1,\t\t\tNULL}\n+};\n+\n+/* Hop-by-hop options */\n+\n+/* Note: we cannot rely on skb_dst(skb) before we assign it in\n+ * ip6_route_input().\n+ */\n+static inline struct inet6_dev *ipv6_skb_idev(struct sk_buff *skb)\n+{\n+\treturn skb_dst(skb) ? ip6_dst_idev(skb_dst(skb)) :\n+\t __in6_dev_get(skb->dev);\n+}\n+\n+static inline struct net *ipv6_skb_net(struct sk_buff *skb)\n+{\n+\treturn skb_dst(skb) ? dev_net(skb_dst(skb)->dev) : dev_net(skb->dev);\n+}\n+\n+/* Router Alert as of RFC 2711 */\n+\n+static bool ipv6_hop_ra(struct sk_buff *skb, int optoff)\n+{\n+\tconst unsigned char *nh = skb_network_header(skb);\n+\n+\tif (nh[optoff + 1] == 2) {\n+\t\tIP6CB(skb)->flags |= IP6SKB_ROUTERALERT;\n+\t\tmemcpy(&IP6CB(skb)->ra, nh + optoff + 2,\n+\t\t sizeof(IP6CB(skb)->ra));\n+\t\treturn true;\n+\t}\n+\tnet_dbg_ratelimited(\"%s: wrong RA length %d\\n\",\n+\t\t\t __func__, nh[optoff + 1]);\n+\tkfree_skb(skb);\n+\treturn false;\n+}\n+\n+/* Jumbo payload */\n+\n+static bool ipv6_hop_jumbo(struct sk_buff *skb, int optoff)\n+{\n+\tconst unsigned char *nh = skb_network_header(skb);\n+\tstruct inet6_dev *idev = __in6_dev_get_safely(skb->dev);\n+\tstruct net *net = ipv6_skb_net(skb);\n+\tu32 pkt_len;\n+\n+\tif (nh[optoff + 1] != 4 || (optoff & 3) != 2) {\n+\t\tnet_dbg_ratelimited(\"%s: wrong jumbo opt length/alignment %d\\n\",\n+\t\t\t\t __func__, nh[optoff + 1]);\n+\t\t__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);\n+\t\tgoto drop;\n+\t}\n+\n+\tpkt_len = ntohl(*(__be32 *)(nh + optoff + 2));\n+\tif (pkt_len <= IPV6_MAXPLEN) {\n+\t\t__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);\n+\t\ticmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff + 2);\n+\t\treturn false;\n+\t}\n+\tif (ipv6_hdr(skb)->payload_len) {\n+\t\t__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);\n+\t\ticmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff);\n+\t\treturn false;\n+\t}\n+\n+\tif (pkt_len > skb->len - sizeof(struct ipv6hdr)) {\n+\t\t__IP6_INC_STATS(net, idev, IPSTATS_MIB_INTRUNCATEDPKTS);\n+\t\tgoto drop;\n+\t}\n+\n+\tif (pskb_trim_rcsum(skb, pkt_len + sizeof(struct ipv6hdr)))\n+\t\tgoto drop;\n+\n+\tIP6CB(skb)->flags |= IP6SKB_JUMBOGRAM;\n+\treturn true;\n+\n+drop:\n+\tkfree_skb(skb);\n+\treturn false;\n+}\n+\n+/* CALIPSO RFC 5570 */\n+\n+static bool ipv6_hop_calipso(struct sk_buff *skb, int optoff)\n+{\n+\tconst unsigned char *nh = skb_network_header(skb);\n+\n+\tif (nh[optoff + 1] < 8)\n+\t\tgoto drop;\n+\n+\tif (nh[optoff + 6] * 4 + 8 > nh[optoff + 1])\n+\t\tgoto drop;\n+\n+\tif (!calipso_validate(skb, nh + optoff))\n+\t\tgoto drop;\n+\n+\treturn true;\n+\n+drop:\n+\tkfree_skb(skb);\n+\treturn false;\n+}\n+\n+const struct tlvtype_proc tlvprochopopt_lst[] = {\n+\t{\n+\t\t.type\t= IPV6_TLV_ROUTERALERT,\n+\t\t.func\t= ipv6_hop_ra,\n+\t},\n+\t{\n+\t\t.type\t= IPV6_TLV_JUMBO,\n+\t\t.func\t= ipv6_hop_jumbo,\n+\t},\n+\t{\n+\t\t.type\t= IPV6_TLV_CALIPSO,\n+\t\t.func\t= ipv6_hop_calipso,\n+\t},\n+\t{ -1, }\n+};\n", "prefixes": [ "net-next", "1/7" ] }