| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/09/25 05:00 | flow | patch-triage |
2mArgs:null Results: {
"EnableConfigs": [
"NET_IPGRE",
"NET_IPGRE_DEMUX",
"NET_IP_TUNNEL",
"IPV6",
"IPV6_TUNNEL",
"IPV6_GRE"
],
"FocusSymbols": [
"gre_parse_header",
"ip_tunnel_rcv",
"ip_tunnel_xmit",
"ip_md_tunnel_xmit",
"__iptunnel_pull_header_reason",
"ip6_tnl_xmit",
"ip6_tnl_rcv",
"ip6_tnl_start_xmit",
"ipgre_xmit",
"ip6gre_tunnel_xmit",
"ip6erspan_tunnel_xmit",
"erspan_xmit"
],
"KMSANReasoning": "The patch series refactors packet drop handling across GRE, ERSPAN, and IPv4/IPv6 tunnel code (in net/ipv4 and net/ipv6) to supply specific drop reasons to kfree_skb_reason() instead of using generic kfree_skb() calls and negative errno codes. Several new SKB_DROP_REASON_* enum values are introduced.\n\nKMSAN vs KASAN evaluation:\n1. No uninitialized data exposure to userspace: No new kernel structures or fields are copied to userspace via copy_to_user, netlink, or socket options. Drop reasons are consumed internally by kernel tracing/drop monitoring.\n2. Variable initialization: All introduced or modified local 'enum skb_drop_reason' variables are either initialized at declaration (e.g., SKB_DROP_REASON_NOT_SPECIFIED) or unconditionally assigned prior to branch conditions and consumption.\n3. Buffer and length validation: Replacing !pskb_may_pull(...) with pskb_may_pull_reason(...) preserves identical bounds checks and length handling; no changes allow uninitialized buffer segments to be read.\n4. Struct handling: Structures such as struct tnl_ptk_info populated by gre_parse_header() are only accessed upon successful parsing, and its fields are fully assigned as in the preexisting code.\n\nSince the changes do not introduce or expose uninitialized memory reads or information leaks, a dedicated KMSAN fuzzing session is not warranted. Standard KASAN builds are sufficient to catch any buffer bounds or lifetime issues.",
"NeedsKMSAN": false,
"Reasoning": "The patch introduces multiple new skb drop reasons and refactors packet parsing, encapsulation, transmission, and reception error paths across IPv4/IPv6 GRE and IP tunneling drivers (gre_demux, ip_gre, ip6_gre, ip_tunnel, and ip6_tunnel). These virtual tunnel devices and protocols are fully reachable in virtualized QEMU environments via netlink and packet/socket interfaces, so fuzzing is warranted to test the altered control flow and error paths.",
"WorthFuzzing": true
} |
| 1/1 | 2026/09/25 05:00 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 8528ffb1c7e241220d9880e821afa233d80a376c\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Fri Sep 25 05:00:45 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h\nindex 12f9096515912..a72b84b07daa2 100644\n--- a/include/net/dropreason-core.h\n+++ b/include/net/dropreason-core.h\n@@ -129,6 +129,12 @@\n \tFN(PSP_INPUT)\t\t\t\\\n \tFN(PSP_OUTPUT)\t\t\t\\\n \tFN(RECURSION_LIMIT)\t\t\\\n+\tFN(TNL_OPT_MISMATCH)\t\t\\\n+\tFN(TNL_OLD_SEQ)\t\t\t\\\n+\tFN(GRE_INVALID_HDR)\t\t\\\n+\tFN(GRE_CSUM)\t\t\t\\\n+\tFN(GRE_TUNNEL_NOT_FOUND)\t\\\n+\tFN(TNL_ENCAP)\t\t\t\\\n \tFNe(MAX)\n \n /**\n@@ -612,6 +618,39 @@ enum skb_drop_reason {\n \tSKB_DROP_REASON_PSP_OUTPUT,\n \t/** @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device. */\n \tSKB_DROP_REASON_RECURSION_LIMIT,\n+\t/**\n+\t * @SKB_DROP_REASON_TNL_OPT_MISMATCH: the tunnel options\n+\t * carried by the packet do not match the tunnel configuration, e.g.\n+\t * a GRE tunnel configured with 'icsum' or 'iseq' received a packet\n+\t * with no checksum or no sequence number, or a GRE tunnel without\n+\t * 'icsum' received a packet with a checksum.\n+\t */\n+\tSKB_DROP_REASON_TNL_OPT_MISMATCH,\n+\t/**\n+\t * @SKB_DROP_REASON_TNL_OLD_SEQ: the sequence number carried\n+\t * by the packet is older than the one expected by the tunnel, e.g.\n+\t * after the remote endpoint restarted and reset its sequence\n+\t * numbering.\n+\t */\n+\tSKB_DROP_REASON_TNL_OLD_SEQ,\n+\t/**\n+\t * @SKB_DROP_REASON_GRE_INVALID_HDR: the GRE header is invalid, e.g.\n+\t * an unsupported version or the routing bit is set.\n+\t */\n+\tSKB_DROP_REASON_GRE_INVALID_HDR,\n+\t/** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */\n+\tSKB_DROP_REASON_GRE_CSUM,\n+\t/**\n+\t * @SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND: no GRE tunnel found for the\n+\t * endpoints and the key the packet carries.\n+\t */\n+\tSKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND,\n+\t/**\n+\t * @SKB_DROP_REASON_TNL_ENCAP: failed to build the\n+\t * encapsulation header of a tunnel, e.g. an unknown or\n+\t * unregistered encapsulation type.\n+\t */\n+\tSKB_DROP_REASON_TNL_ENCAP,\n \t/**\n \t * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which\n \t * shouldn't be used as a real 'reason' - only for tracing code gen\ndiff --git a/include/net/gre.h b/include/net/gre.h\nindex b55f67ecd2fc4..4cb19abea90de 100644\n--- a/include/net/gre.h\n+++ b/include/net/gre.h\n@@ -32,8 +32,9 @@ struct gre_protocol {\n int gre_add_protocol(const struct gre_protocol *proto, u8 version);\n int gre_del_protocol(const struct gre_protocol *proto, u8 version);\n \n-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n-\t\t bool *csum_err, __be16 proto, int nhs);\n+enum skb_drop_reason\n+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n+\t\t bool icmp_err, __be16 proto, int nhs);\n \n static inline bool netif_is_gretap(const struct net_device *dev)\n {\ndiff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h\nindex d1f0a427e9c82..363eed61b296a 100644\n--- a/include/net/ip6_tunnel.h\n+++ b/include/net/ip6_tunnel.h\n@@ -143,8 +143,9 @@ int ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \t\tbool log_ecn_error);\n int ip6_tnl_xmit_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,\n \t\t const struct in6_addr *raddr);\n-int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n-\t\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);\n+enum skb_drop_reason\n+ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n+\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);\n __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);\n __u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,\n \t\t\t const struct in6_addr *raddr);\ndiff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h\nindex 7102aa11fae29..27a9e097996b6 100644\n--- a/include/net/ip_tunnels.h\n+++ b/include/net/ip_tunnels.h\n@@ -207,10 +207,6 @@ struct tnl_ptk_info {\n \tint hdr_len;\n };\n \n-#define PACKET_RCVD\t0\n-#define PACKET_REJECT\t1\n-#define PACKET_NEXT\t2\n-\n #define IP_TNL_HASH_BITS 7\n #define IP_TNL_HASH_SIZE (1 \u003c\u003c IP_TNL_HASH_BITS)\n \n@@ -614,8 +610,17 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph,\n \treturn INET_ECN_encapsulate(tos, inner);\n }\n \n-int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n-\t\t\t __be16 inner_proto, bool raw_proto, bool xnet);\n+enum skb_drop_reason\n+__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,\n+\t\t\t __be16 inner_proto, bool raw_proto, bool xnet);\n+\n+static inline int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n+\t\t\t\t\t __be16 inner_proto, bool raw_proto,\n+\t\t\t\t\t bool xnet)\n+{\n+\treturn __iptunnel_pull_header_reason(skb, hdr_len, inner_proto,\n+\t\t\t\t\t raw_proto, xnet) ? -ENOMEM : 0;\n+}\n \n static inline int iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n \t\t\t\t __be16 inner_proto, bool xnet)\ndiff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c\nindex 96fd7dc6d82dd..e117056525f06 100644\n--- a/net/ipv4/gre_demux.c\n+++ b/net/ipv4/gre_demux.c\n@@ -56,28 +56,35 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)\n }\n EXPORT_SYMBOL_GPL(gre_del_protocol);\n \n-/* Fills in tpi and returns header length to be pulled.\n+/* Fills in tpi, including the header length to be pulled in tpi-\u003ehdr_len,\n+ * and returns SKB_NOT_DROPPED_YET, or the reason to drop the packet if the\n+ * header is rejected.\n * Note that caller must use pskb_may_pull() before pulling GRE header.\n+ *\n+ * @icmp_err is set by the ICMP error handlers, which only get a part of\n+ * the original packet: a checksum failure does not reject the header then,\n+ * the checksum is still computed and the rest of the header is parsed.\n */\n-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n-\t\t bool *csum_err, __be16 proto, int nhs)\n+enum skb_drop_reason\n+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n+\t\t bool icmp_err, __be16 proto, int nhs)\n {\n \tconst struct gre_base_hdr *greh;\n \t__be32 *options;\n \tint hdr_len;\n \n \tif (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))\n-\t\treturn -EINVAL;\n+\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n \n \tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n \tif (unlikely(greh-\u003eflags \u0026 (GRE_VERSION | GRE_ROUTING)))\n-\t\treturn -EINVAL;\n+\t\treturn SKB_DROP_REASON_GRE_INVALID_HDR;\n \n \tgre_flags_to_tnl_flags(tpi-\u003eflags, greh-\u003eflags);\n \thdr_len = gre_calc_hlen(tpi-\u003eflags);\n \n \tif (!pskb_may_pull(skb, nhs + hdr_len))\n-\t\treturn -EINVAL;\n+\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n \n \tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n \ttpi-\u003eproto = greh-\u003eprotocol;\n@@ -87,9 +94,8 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\tif (!skb_checksum_simple_validate(skb)) {\n \t\t\tskb_checksum_try_convert(skb, IPPROTO_GRE,\n \t\t\t\t\t\t null_compute_pseudo);\n-\t\t} else if (csum_err) {\n-\t\t\t*csum_err = true;\n-\t\t\treturn -EINVAL;\n+\t\t} else if (!icmp_err) {\n+\t\t\treturn SKB_DROP_REASON_GRE_CSUM;\n \t\t}\n \n \t\toptions++;\n@@ -117,7 +123,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\tval = skb_header_pointer(skb, nhs + hdr_len,\n \t\t\t\t\t sizeof(_val), \u0026_val);\n \t\tif (!val)\n-\t\t\treturn -EINVAL;\n+\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n \t\ttpi-\u003eproto = proto;\n \t\tif ((*val \u0026 0xF0) != 0x40)\n \t\t\thdr_len += 4;\n@@ -133,28 +139,32 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\tstruct erspan_base_hdr *ershdr;\n \n \t\tif (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))\n-\t\t\treturn -EINVAL;\n+\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n \n \t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + nhs + hdr_len);\n \t\ttpi-\u003ekey = cpu_to_be32(get_session_id(ershdr));\n \t}\n \n-\treturn hdr_len;\n+\treturn SKB_NOT_DROPPED_YET;\n }\n EXPORT_SYMBOL(gre_parse_header);\n \n static int gre_rcv(struct sk_buff *skb)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tconst struct gre_protocol *proto;\n \tu8 ver;\n \tint ret;\n \n-\tif (!pskb_may_pull(skb, 12))\n+\treason = pskb_may_pull_reason(skb, 12);\n+\tif (reason)\n \t\tgoto drop;\n \n \tver = skb-\u003edata[1]\u00260x7f;\n-\tif (ver \u003e= GREPROTO_MAX)\n+\tif (ver \u003e= GREPROTO_MAX) {\n+\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\tgoto drop;\n+\t}\n \n \trcu_read_lock();\n \tproto = rcu_dereference(gre_proto[ver]);\n@@ -167,11 +177,11 @@ static int gre_rcv(struct sk_buff *skb)\n drop_nohandler:\n \trcu_read_unlock();\n \tdev_core_stats_rx_nohandler_inc(skb-\u003edev);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);\n \treturn NET_RX_DROP;\n drop:\n \tdev_core_stats_rx_dropped_inc(skb-\u003edev);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn NET_RX_DROP;\n }\n \ndiff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c\nindex 5e877018e006c..ad669b3f87570 100644\n--- a/net/ipv4/ip_gre.c\n+++ b/net/ipv4/ip_gre.c\n@@ -237,8 +237,8 @@ static void gre_err(struct sk_buff *skb, u32 info)\n \tconst int code = icmp_hdr(skb)-\u003ecode;\n \tstruct tnl_ptk_info tpi;\n \n-\tif (gre_parse_header(skb, \u0026tpi, NULL, htons(ETH_P_IP),\n-\t\t\t iph-\u003eihl * 4) \u003c 0)\n+\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IP),\n+\t\t\t iph-\u003eihl * 4))\n \t\treturn;\n \n \tif (type == ICMP_DEST_UNREACH \u0026\u0026 code == ICMP_FRAG_NEEDED) {\n@@ -264,13 +264,15 @@ static bool is_erspan_type1(int gre_hdr_len)\n \treturn gre_hdr_len == 4;\n }\n \n-static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n-\t\t int gre_hdr_len)\n+static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,\n+\t\t\t\t struct tnl_ptk_info *tpi,\n+\t\t\t\t int gre_hdr_len)\n {\n \tstruct net *net = dev_net(skb-\u003edev);\n \tstruct metadata_dst *tun_dst = NULL;\n \tstruct erspan_base_hdr *ershdr;\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n+\tenum skb_drop_reason reason;\n \tstruct ip_tunnel_net *itn;\n \tstruct ip_tunnel *tunnel;\n \tconst struct iphdr *iph;\n@@ -290,7 +292,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t} else {\n \t\tif (unlikely(!pskb_may_pull(skb,\n \t\t\t\t\t gre_hdr_len + sizeof(*ershdr))))\n-\t\t\treturn PACKET_REJECT;\n+\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n \n \t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + gre_hdr_len);\n \t\tver = ershdr-\u003ever;\n@@ -307,12 +309,12 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\t\tlen = gre_hdr_len + erspan_hdr_len(ver);\n \n \t\tif (unlikely(!pskb_may_pull(skb, len)))\n-\t\t\treturn PACKET_REJECT;\n+\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n \n-\t\tif (__iptunnel_pull_header(skb,\n-\t\t\t\t\t len,\n-\t\t\t\t\t htons(ETH_P_TEB),\n-\t\t\t\t\t false, false) \u003c 0)\n+\t\treason = __iptunnel_pull_header_reason(skb, len,\n+\t\t\t\t\t\t htons(ETH_P_TEB),\n+\t\t\t\t\t\t false, false);\n+\t\tif (reason)\n \t\t\tgoto drop;\n \n \t\tif (tunnel-\u003ecollect_md) {\n@@ -328,7 +330,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\t\ttun_dst = ip_tun_rx_dst(skb, flags,\n \t\t\t\t\t\ttun_id, sizeof(*md));\n \t\t\tif (!tun_dst)\n-\t\t\t\treturn PACKET_REJECT;\n+\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n \n \t\t\t/* MUST set options_len before referencing options */\n \t\t\tinfo = \u0026tun_dst-\u003eu.tun_info;\n@@ -354,19 +356,22 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \n \t\tskb_reset_mac_header(skb);\n \t\tip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\n-\t\treturn PACKET_RCVD;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \t}\n-\treturn PACKET_REJECT;\n+\treturn SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;\n \n drop:\n-\tkfree_skb(skb);\n-\treturn PACKET_RCVD;\n+\tkfree_skb_reason(skb, reason);\n+\treturn SKB_NOT_DROPPED_YET;\n }\n \n-static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n-\t\t struct ip_tunnel_net *itn, int hdr_len, bool raw_proto)\n+static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\n+\t\t\t\t\tconst struct tnl_ptk_info *tpi,\n+\t\t\t\t\tstruct ip_tunnel_net *itn,\n+\t\t\t\t\tint hdr_len, bool raw_proto)\n {\n \tstruct metadata_dst *tun_dst = NULL;\n+\tenum skb_drop_reason reason;\n \tconst struct iphdr *iph;\n \tstruct ip_tunnel *tunnel;\n \n@@ -377,8 +382,10 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n \tif (tunnel) {\n \t\tconst struct iphdr *tnl_params;\n \n-\t\tif (__iptunnel_pull_header(skb, hdr_len, tpi-\u003eproto,\n-\t\t\t\t\t raw_proto, false) \u003c 0)\n+\t\treason = __iptunnel_pull_header_reason(skb, hdr_len,\n+\t\t\t\t\t\t tpi-\u003eproto, raw_proto,\n+\t\t\t\t\t\t false);\n+\t\tif (reason)\n \t\t\tgoto drop;\n \n \t\t/* Special case for ipgre_header_parse(), which expects the\n@@ -401,47 +408,48 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n \t\t\ttun_id = key32_to_tunnel_id(tpi-\u003ekey);\n \t\t\ttun_dst = ip_tun_rx_dst(skb, flags, tun_id, 0);\n \t\t\tif (!tun_dst)\n-\t\t\t\treturn PACKET_REJECT;\n+\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n \t\t}\n \n \t\tip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\n-\t\treturn PACKET_RCVD;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \t}\n-\treturn PACKET_NEXT;\n+\treturn SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;\n \n drop:\n-\tkfree_skb(skb);\n-\treturn PACKET_RCVD;\n+\tkfree_skb_reason(skb, reason);\n+\treturn SKB_NOT_DROPPED_YET;\n }\n \n-static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n-\t\t int hdr_len)\n+static enum skb_drop_reason ipgre_rcv(struct sk_buff *skb,\n+\t\t\t\t const struct tnl_ptk_info *tpi,\n+\t\t\t\t int hdr_len)\n {\n \tstruct net *net = dev_net(skb-\u003edev);\n+\tenum skb_drop_reason reason;\n \tstruct ip_tunnel_net *itn;\n-\tint res;\n \n \tif (tpi-\u003eproto == htons(ETH_P_TEB))\n \t\titn = net_generic(net, gre_tap_net_id);\n \telse\n \t\titn = net_generic(net, ipgre_net_id);\n \n-\tres = __ipgre_rcv(skb, tpi, itn, hdr_len, false);\n-\tif (res == PACKET_NEXT \u0026\u0026 tpi-\u003eproto == htons(ETH_P_TEB)) {\n+\treason = __ipgre_rcv(skb, tpi, itn, hdr_len, false);\n+\tif (reason == SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND \u0026\u0026\n+\t tpi-\u003eproto == htons(ETH_P_TEB)) {\n \t\t/* ipgre tunnels in collect metadata mode should receive\n \t\t * also ETH_P_TEB traffic.\n \t\t */\n \t\titn = net_generic(net, ipgre_net_id);\n-\t\tres = __ipgre_rcv(skb, tpi, itn, hdr_len, true);\n+\t\treason = __ipgre_rcv(skb, tpi, itn, hdr_len, true);\n \t}\n-\treturn res;\n+\treturn reason;\n }\n \n static int gre_rcv(struct sk_buff *skb)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct tnl_ptk_info tpi;\n-\tbool csum_err = false;\n-\tint hdr_len;\n \n #ifdef CONFIG_NET_IPGRE_BROADCAST\n \tif (ipv4_is_multicast(ip_hdr(skb)-\u003edaddr)) {\n@@ -451,25 +459,27 @@ static int gre_rcv(struct sk_buff *skb)\n \t}\n #endif\n \n-\thdr_len = gre_parse_header(skb, \u0026tpi, \u0026csum_err, htons(ETH_P_IP), 0);\n-\tif (hdr_len \u003c 0)\n+\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IP), 0);\n+\tif (reason)\n \t\tgoto drop;\n \n \tif (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||\n \t\t tpi.proto == htons(ETH_P_ERSPAN2))) {\n-\t\tif (erspan_rcv(skb, \u0026tpi, hdr_len) == PACKET_RCVD)\n+\t\treason = erspan_rcv(skb, \u0026tpi, tpi.hdr_len);\n+\t\tif (!reason)\n \t\t\treturn 0;\n \t\tgoto out;\n \t}\n \n-\tif (ipgre_rcv(skb, \u0026tpi, hdr_len) == PACKET_RCVD)\n+\treason = ipgre_rcv(skb, \u0026tpi, tpi.hdr_len);\n+\tif (!reason)\n \t\treturn 0;\n \n out:\n \ticmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);\n drop:\n \tdev_core_stats_rx_dropped_inc(skb-\u003edev);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n \n@@ -496,6 +506,7 @@ static int gre_handle_offloads(struct sk_buff *skb, bool csum)\n static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t\t__be16 proto)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags) = { };\n \tstruct ip_tunnel_info *tun_info;\n@@ -504,19 +515,25 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \ttun_info = skb_tunnel_info(skb);\n \tif (unlikely(!tun_info || !(tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) ||\n-\t\t ip_tunnel_info_af(tun_info) != AF_INET))\n+\t\t ip_tunnel_info_af(tun_info) != AF_INET)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto err_free_skb;\n+\t}\n \n \tkey = \u0026tun_info-\u003ekey;\n \ttunnel_hlen = gre_calc_hlen(key-\u003etun_flags);\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto err_free_skb;\n+\t}\n \n \t/* Push Tunnel header. */\n \tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,\n-\t\t\t\t\t tunnel-\u003eparms.o_flags)))\n+\t\t\t\t\t tunnel-\u003eparms.o_flags))) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto err_free_skb;\n+\t}\n \n \t__set_bit(IP_TUNNEL_CSUM_BIT, flags);\n \t__set_bit(IP_TUNNEL_KEY_BIT, flags);\n@@ -533,12 +550,13 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,\n \treturn;\n \n err_free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n }\n \n static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags) = { };\n \tstruct ip_tunnel_info *tun_info;\n@@ -552,29 +570,41 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)\n \n \ttun_info = skb_tunnel_info(skb);\n \tif (unlikely(!tun_info || !(tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) ||\n-\t\t ip_tunnel_info_af(tun_info) != AF_INET))\n+\t\t ip_tunnel_info_af(tun_info) != AF_INET)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto err_free_skb;\n+\t}\n \n \tkey = \u0026tun_info-\u003ekey;\n-\tif (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info-\u003ekey.tun_flags))\n+\tif (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info-\u003ekey.tun_flags)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto err_free_skb;\n-\tif (tun_info-\u003eoptions_len \u003c sizeof(*md))\n+\t}\n+\tif (tun_info-\u003eoptions_len \u003c sizeof(*md)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto err_free_skb;\n+\t}\n \tmd = ip_tunnel_info_opts(tun_info);\n \n \t/* ERSPAN has fixed 8 byte GRE header */\n \tversion = md-\u003eversion;\n \ttunnel_hlen = 8 + erspan_hdr_len(version);\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto err_free_skb;\n+\t}\n \n-\tif (gre_handle_offloads(skb, false))\n+\tif (gre_handle_offloads(skb, false)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto err_free_skb;\n+\t}\n \n \tif (skb-\u003elen \u003e dev-\u003emtu + dev-\u003ehard_header_len) {\n-\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len))\n+\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto err_free_skb;\n+\t\t}\n \t\ttruncate = true;\n \t}\n \n@@ -606,6 +636,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)\n \t\t\t\t truncate, true);\n \t\tproto = htons(ETH_P_ERSPAN2);\n \t} else {\n+\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\tgoto err_free_skb;\n \t}\n \n@@ -618,7 +649,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)\n \treturn;\n \n err_free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n }\n \n@@ -649,11 +680,13 @@ static int gre_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)\n static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n \t\t\t struct net_device *dev)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n \tconst struct iphdr *tnl_params;\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto free_skb;\n \n \tif (tunnel-\u003ecollect_md) {\n@@ -664,10 +697,13 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n \tif (dev-\u003eheader_ops) {\n \t\tint pull_len = tunnel-\u003ehlen + sizeof(struct iphdr);\n \n-\t\tif (skb_cow_head(skb, 0))\n+\t\tif (skb_cow_head(skb, 0)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto free_skb;\n+\t\t}\n \n-\t\tif (!pskb_may_pull(skb, pull_len))\n+\t\treason = pskb_may_pull_reason(skb, pull_len);\n+\t\tif (reason)\n \t\t\tgoto free_skb;\n \n \t\ttnl_params = (const struct iphdr *)skb-\u003edata;\n@@ -677,25 +713,31 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n \t\tskb_reset_mac_header(skb);\n \n \t\tif (skb-\u003eip_summed == CHECKSUM_PARTIAL \u0026\u0026\n-\t\t skb_checksum_start(skb) \u003c skb-\u003edata)\n+\t\t skb_checksum_start(skb) \u003c skb-\u003edata) {\n+\t\t\treason = SKB_DROP_REASON_SKB_CSUM;\n \t\t\tgoto free_skb;\n+\t\t}\n \t} else {\n-\t\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\t\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto free_skb;\n+\t\t}\n \n \t\ttnl_params = \u0026tunnel-\u003eparms.iph;\n \t}\n \n \tip_tunnel_flags_copy(flags, tunnel-\u003eparms.o_flags);\n \n-\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))\n+\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n \t__gre_xmit(skb, dev, tnl_params, skb-\u003eprotocol, flags);\n \treturn NETDEV_TX_OK;\n \n free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n \treturn NETDEV_TX_OK;\n }\n@@ -703,12 +745,14 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n \t\t\t struct net_device *dev)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n \tbool truncate = false;\n \t__be16 proto;\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto free_skb;\n \n \tif (tunnel-\u003ecollect_md) {\n@@ -716,15 +760,21 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n \t\treturn NETDEV_TX_OK;\n \t}\n \n-\tif (gre_handle_offloads(skb, false))\n+\tif (gre_handle_offloads(skb, false)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n \tif (skb-\u003elen \u003e dev-\u003emtu + dev-\u003ehard_header_len) {\n-\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len))\n+\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto free_skb;\n+\t\t}\n \t\ttruncate = true;\n \t}\n \n@@ -745,6 +795,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n \t\t\t\t truncate, true);\n \t\tproto = htons(ETH_P_ERSPAN2);\n \t} else {\n+\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\tgoto free_skb;\n \t}\n \n@@ -753,7 +804,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n \treturn NETDEV_TX_OK;\n \n free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n \treturn NETDEV_TX_OK;\n }\n@@ -761,10 +812,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,\n \t\t\t\tstruct net_device *dev)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto free_skb;\n \n \tif (tunnel-\u003ecollect_md) {\n@@ -774,17 +827,21 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,\n \n \tip_tunnel_flags_copy(flags, tunnel-\u003eparms.o_flags);\n \n-\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))\n+\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n \t__gre_xmit(skb, dev, \u0026tunnel-\u003eparms.iph, htons(ETH_P_TEB), flags);\n \treturn NETDEV_TX_OK;\n \n free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n \treturn NETDEV_TX_OK;\n }\ndiff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c\nindex 0875474a578a4..66cb0b86fa79a 100644\n--- a/net/ipv4/ip_tunnel.c\n+++ b/net/ipv4/ip_tunnel.c\n@@ -384,6 +384,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \t\t const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,\n \t\t bool log_ecn_error)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tconst struct iphdr *iph = ip_hdr(skb);\n \tint nh, err;\n \n@@ -398,14 +399,22 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \t test_bit(IP_TUNNEL_CSUM_BIT, tpi-\u003eflags)) {\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_crc_errors);\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\treason = SKB_DROP_REASON_TNL_OPT_MISMATCH;\n \t\tgoto drop;\n \t}\n \n \tif (test_bit(IP_TUNNEL_SEQ_BIT, tunnel-\u003eparms.i_flags)) {\n-\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags) ||\n-\t\t (tunnel-\u003ei_seqno \u0026\u0026 (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0)) {\n+\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags)) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_TNL_OPT_MISMATCH;\n+\t\t\tgoto drop;\n+\t\t}\n+\t\tif (tunnel-\u003ei_seqno \u0026\u0026\n+\t\t (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0) {\n+\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n+\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_TNL_OLD_SEQ;\n \t\t\tgoto drop;\n \t\t}\n \t\ttunnel-\u003ei_seqno = ntohl(tpi-\u003eseq) + 1;\n@@ -419,7 +428,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \n \tskb_set_network_header(skb, (tunnel-\u003edev-\u003etype == ARPHRD_ETHER) ? ETH_HLEN : 0);\n \n-\tif (!pskb_inet_may_pull(skb)) {\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason) {\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n \t\tgoto drop;\n@@ -434,6 +444,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \t\tif (err \u003e 1) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_frame_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_IP_TUNNEL_ECN;\n \t\t\tgoto drop;\n \t\t}\n \t}\n@@ -457,7 +468,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n drop:\n \tif (tun_dst)\n \t\tdst_release((struct dst_entry *)tun_dst);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n EXPORT_SYMBOL_GPL(ip_tunnel_rcv);\n@@ -575,6 +586,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,\n void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t u8 proto, int tunnel_hlen)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tu32 headroom = sizeof(struct iphdr);\n \tstruct ip_tunnel_info *tun_info;\n@@ -588,8 +600,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \ttun_info = skb_tunnel_info(skb);\n \tif (unlikely(!tun_info || !(tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) ||\n-\t\t ip_tunnel_info_af(tun_info) != AF_INET))\n+\t\t ip_tunnel_info_af(tun_info) != AF_INET)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto tx_error;\n+\t}\n \tkey = \u0026tun_info-\u003ekey;\n \tmemset(\u0026(IPCB(skb)-\u003eopt), 0, sizeof(IPCB(skb)-\u003eopt));\n \tinner_iph = (const struct iphdr *)skb_inner_network_header(skb);\n@@ -608,8 +622,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (!tunnel_hlen)\n \t\ttunnel_hlen = ip_encap_hlen(\u0026tun_info-\u003eencap);\n \n-\tif (ip_tunnel_encap(skb, \u0026tun_info-\u003eencap, \u0026proto, \u0026fl4) \u003c 0)\n+\tif (ip_tunnel_encap(skb, \u0026tun_info-\u003eencap, \u0026proto, \u0026fl4) \u003c 0) {\n+\t\treason = SKB_DROP_REASON_TNL_ENCAP;\n \t\tgoto tx_error;\n+\t}\n \n \tuse_cache = ip_tunnel_dst_cache_usable(skb, tun_info);\n \tif (use_cache)\n@@ -618,6 +634,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\trt = ip_route_output_key(tunnel-\u003enet, \u0026fl4);\n \t\tif (IS_ERR(rt)) {\n \t\t\tDEV_STATS_INC(dev, tx_carrier_errors);\n+\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_error;\n \t\t}\n \t\tif (use_cache)\n@@ -627,6 +644,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (rt-\u003edst.dev == dev) {\n \t\tip_rt_put(rt);\n \t\tDEV_STATS_INC(dev, collisions);\n+\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n \t\tgoto tx_error;\n \t}\n \n@@ -635,6 +653,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (tnl_update_pmtu(dev, skb, rt, df, inner_iph, tunnel_hlen,\n \t\t\t key-\u003eu.ipv4.dst, true)) {\n \t\tip_rt_put(rt);\n+\t\treason = SKB_DROP_REASON_PKT_TOO_BIG;\n \t\tgoto tx_error;\n \t}\n \n@@ -652,6 +671,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \theadroom += LL_RESERVED_SPACE(rt-\u003edst.dev) + rt-\u003edst.header_len;\n \tif (skb_cow_head(skb, headroom)) {\n \t\tip_rt_put(rt);\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto tx_dropped;\n \t}\n \n@@ -666,13 +686,14 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n tx_dropped:\n \tDEV_STATS_INC(dev, tx_dropped);\n kfree:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n }\n EXPORT_SYMBOL_GPL(ip_md_tunnel_xmit);\n \n void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t const struct iphdr *tnl_params, u8 protocol)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tstruct ip_tunnel_info *tun_info = NULL;\n \tconst struct iphdr *inner_iph;\n@@ -700,9 +721,15 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \t\tif (!skb_dst(skb)) {\n \t\t\tDEV_STATS_INC(dev, tx_fifo_errors);\n+\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\t\tgoto tx_error;\n \t\t}\n \n+\t\t/* Only the branches below can derive a destination. If\n+\t\t * none of them matches, the payload protocol is not one\n+\t\t * this tunnel can carry.\n+\t\t */\n+\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\ttun_info = skb_tunnel_info(skb);\n \t\tif (tun_info \u0026\u0026 (tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) \u0026\u0026\n \t\t ip_tunnel_info_af(tun_info) == AF_INET \u0026\u0026\n@@ -723,8 +750,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \t\t\tneigh = dst_neigh_lookup(skb_dst(skb),\n \t\t\t\t\t\t \u0026ipv6_hdr(skb)-\u003edaddr);\n-\t\t\tif (!neigh)\n+\t\t\tif (!neigh) {\n+\t\t\t\treason = SKB_DROP_REASON_NEIGH_CREATEFAIL;\n \t\t\t\tgoto tx_error;\n+\t\t\t}\n \n \t\t\taddr6 = (const struct in6_addr *)\u0026neigh-\u003eprimary_key;\n \t\t\taddr_type = ipv6_addr_type(addr6);\n@@ -741,8 +770,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t\t\tdst = addr6-\u003es6_addr32[3];\n \t\t\t}\n \t\t\tneigh_release(neigh);\n-\t\t\tif (do_tx_error_icmp)\n+\t\t\tif (do_tx_error_icmp) {\n+\t\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\t\t\tgoto tx_error_icmp;\n+\t\t\t}\n \t\t}\n #endif\n \t\telse\n@@ -769,8 +800,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t\t tunnel-\u003enet, READ_ONCE(tunnel-\u003eparms.link),\n \t\t\t tunnel-\u003efwmark, skb_get_hash(skb), 0);\n \n-\tif (ip_tunnel_encap(skb, \u0026tunnel-\u003eencap, \u0026protocol, \u0026fl4) \u003c 0)\n+\tif (ip_tunnel_encap(skb, \u0026tunnel-\u003eencap, \u0026protocol, \u0026fl4) \u003c 0) {\n+\t\treason = SKB_DROP_REASON_TNL_ENCAP;\n \t\tgoto tx_error;\n+\t}\n \n \tif (connected \u0026\u0026 md) {\n \t\tuse_cache = ip_tunnel_dst_cache_usable(skb, tun_info);\n@@ -787,6 +820,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \t\tif (IS_ERR(rt)) {\n \t\t\tDEV_STATS_INC(dev, tx_carrier_errors);\n+\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_error;\n \t\t}\n \t\tif (use_cache)\n@@ -800,6 +834,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (rt-\u003edst.dev == dev) {\n \t\tip_rt_put(rt);\n \t\tDEV_STATS_INC(dev, collisions);\n+\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n \t\tgoto tx_error;\n \t}\n \n@@ -809,6 +844,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \tif (tnl_update_pmtu(dev, skb, rt, df, inner_iph, 0, 0, false)) {\n \t\tip_rt_put(rt);\n+\t\treason = SKB_DROP_REASON_PKT_TOO_BIG;\n \t\tgoto tx_error;\n \t}\n \n@@ -843,7 +879,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (skb_cow_head(skb, max_headroom)) {\n \t\tip_rt_put(rt);\n \t\tDEV_STATS_INC(dev, tx_dropped);\n-\t\tkfree_skb(skb);\n+\t\tkfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);\n \t\treturn;\n \t}\n \n@@ -859,7 +895,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n #endif\n tx_error:\n \tDEV_STATS_INC(dev, tx_errors);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n }\n EXPORT_SYMBOL_GPL(ip_tunnel_xmit);\n \ndiff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c\nindex bab42b9e277f7..51f1537ce6c1f 100644\n--- a/net/ipv4/ip_tunnel_core.c\n+++ b/net/ipv4/ip_tunnel_core.c\n@@ -106,19 +106,24 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,\n }\n EXPORT_SYMBOL_GPL(iptunnel_xmit);\n \n-int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n-\t\t\t __be16 inner_proto, bool raw_proto, bool xnet)\n+enum skb_drop_reason\n+__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,\n+\t\t\t __be16 inner_proto, bool raw_proto, bool xnet)\n {\n-\tif (unlikely(!pskb_may_pull(skb, hdr_len)))\n-\t\treturn -ENOMEM;\n+\tenum skb_drop_reason reason;\n+\n+\treason = pskb_may_pull_reason(skb, hdr_len);\n+\tif (unlikely(reason))\n+\t\treturn reason;\n \n \tskb_pull_rcsum(skb, hdr_len);\n \n \tif (!raw_proto \u0026\u0026 inner_proto == htons(ETH_P_TEB)) {\n \t\tstruct ethhdr *eh;\n \n-\t\tif (unlikely(!pskb_may_pull(skb, ETH_HLEN)))\n-\t\t\treturn -ENOMEM;\n+\t\treason = pskb_may_pull_reason(skb, ETH_HLEN);\n+\t\tif (unlikely(reason))\n+\t\t\treturn reason;\n \n \t\teh = (struct ethhdr *)skb-\u003edata;\n \t\tif (likely(eth_proto_is_802_3(eh-\u003eh_proto)))\n@@ -135,9 +140,12 @@ int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n \tskb_set_queue_mapping(skb, 0);\n \tskb_scrub_packet(skb, xnet);\n \n-\treturn iptunnel_pull_offloads(skb);\n+\tif (unlikely(iptunnel_pull_offloads(skb)))\n+\t\treturn SKB_DROP_REASON_NOMEM;\n+\n+\treturn SKB_NOT_DROPPED_YET;\n }\n-EXPORT_SYMBOL_GPL(__iptunnel_pull_header);\n+EXPORT_SYMBOL_GPL(__iptunnel_pull_header_reason);\n \n struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md,\n \t\t\t\t\t gfp_t flags)\ndiff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c\nindex c851af22b9fe5..31930ff813dd2 100644\n--- a/net/ipv6/ip6_gre.c\n+++ b/net/ipv6/ip6_gre.c\n@@ -389,8 +389,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n \tstruct tnl_ptk_info tpi;\n \tstruct ip6_tnl *t;\n \n-\tif (gre_parse_header(skb, \u0026tpi, NULL, htons(ETH_P_IPV6),\n-\t\t\t offset) \u003c 0)\n+\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IPV6),\n+\t\t\t offset))\n \t\treturn -EINVAL;\n \n \tipv6h = (const struct ipv6hdr *)skb-\u003edata;\n@@ -451,7 +451,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n \treturn 0;\n }\n \n-static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)\n+static enum skb_drop_reason ip6gre_rcv(struct sk_buff *skb,\n+\t\t\t\t const struct tnl_ptk_info *tpi)\n {\n \tconst struct ipv6hdr *ipv6h;\n \tstruct ip6_tnl *tunnel;\n@@ -471,22 +472,22 @@ static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)\n \n \t\t\ttun_dst = ipv6_tun_rx_dst(skb, flags, tun_id, 0);\n \t\t\tif (!tun_dst)\n-\t\t\t\treturn PACKET_REJECT;\n+\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n \n \t\t\tip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\n \t\t} else {\n \t\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);\n \t\t}\n \n-\t\treturn PACKET_RCVD;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \t}\n \n-\treturn PACKET_REJECT;\n+\treturn SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;\n }\n \n-static int ip6erspan_rcv(struct sk_buff *skb,\n-\t\t\t struct tnl_ptk_info *tpi,\n-\t\t\t int gre_hdr_len)\n+static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n+\t\t\t\t\t struct tnl_ptk_info *tpi,\n+\t\t\t\t\t int gre_hdr_len)\n {\n \tstruct erspan_base_hdr *ershdr;\n \tconst struct ipv6hdr *ipv6h;\n@@ -495,7 +496,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,\n \tu8 ver;\n \n \tif (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))\n-\t\treturn PACKET_REJECT;\n+\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n \n \tipv6h = ipv6_hdr(skb);\n \tershdr = (struct erspan_base_hdr *)skb-\u003edata;\n@@ -506,14 +507,16 @@ static int ip6erspan_rcv(struct sk_buff *skb,\n \t\t\t\t tpi-\u003eproto);\n \tif (tunnel) {\n \t\tint len = erspan_hdr_len(ver);\n+\t\tenum skb_drop_reason reason;\n \n \t\tif (unlikely(!pskb_may_pull(skb, len)))\n-\t\t\treturn PACKET_REJECT;\n+\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n \n-\t\tif (__iptunnel_pull_header(skb, len,\n-\t\t\t\t\t htons(ETH_P_TEB),\n-\t\t\t\t\t false, false) \u003c 0)\n-\t\t\treturn PACKET_REJECT;\n+\t\treason = __iptunnel_pull_header_reason(skb, len,\n+\t\t\t\t\t\t htons(ETH_P_TEB),\n+\t\t\t\t\t\t false, false);\n+\t\tif (reason)\n+\t\t\treturn reason;\n \n \t\tif (tunnel-\u003eparms.collect_md) {\n \t\t\tstruct erspan_metadata *pkt_md, *md;\n@@ -530,7 +533,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,\n \t\t\ttun_dst = ipv6_tun_rx_dst(skb, flags, tun_id,\n \t\t\t\t\t\t sizeof(*md));\n \t\t\tif (!tun_dst)\n-\t\t\t\treturn PACKET_REJECT;\n+\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n \n \t\t\t/* MUST set options_len before referencing options */\n \t\t\tinfo = \u0026tun_dst-\u003eu.tun_info;\n@@ -558,40 +561,43 @@ static int ip6erspan_rcv(struct sk_buff *skb,\n \t\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);\n \t\t}\n \n-\t\treturn PACKET_RCVD;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \t}\n \n-\treturn PACKET_REJECT;\n+\treturn SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;\n }\n \n static int gre_rcv(struct sk_buff *skb)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct tnl_ptk_info tpi;\n-\tbool csum_err = false;\n-\tint hdr_len;\n \n-\thdr_len = gre_parse_header(skb, \u0026tpi, \u0026csum_err, htons(ETH_P_IPV6), 0);\n-\tif (hdr_len \u003c 0)\n+\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\n+\tif (reason)\n \t\tgoto drop;\n \n-\tif (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))\n+\treason = __iptunnel_pull_header_reason(skb, tpi.hdr_len, tpi.proto,\n+\t\t\t\t\t false, false);\n+\tif (reason)\n \t\tgoto drop;\n \n \tif (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||\n \t\t tpi.proto == htons(ETH_P_ERSPAN2))) {\n-\t\tif (ip6erspan_rcv(skb, \u0026tpi, hdr_len) == PACKET_RCVD)\n+\t\treason = ip6erspan_rcv(skb, \u0026tpi, tpi.hdr_len);\n+\t\tif (!reason)\n \t\t\treturn 0;\n \t\tgoto out;\n \t}\n \n-\tif (ip6gre_rcv(skb, \u0026tpi) == PACKET_RCVD)\n+\treason = ip6gre_rcv(skb, \u0026tpi);\n+\tif (!reason)\n \t\treturn 0;\n \n out:\n \ticmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);\n drop:\n \tdev_core_stats_rx_dropped_inc(skb-\u003edev);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n \n@@ -674,10 +680,10 @@ static int prepare_ip6gre_xmit_ipv6(struct sk_buff *skb,\n \treturn 0;\n }\n \n-static int prepare_ip6gre_xmit_other(struct sk_buff *skb,\n-\t\t\t\t struct net_device *dev,\n-\t\t\t\t struct flowi6 *fl6, __u8 *dsfield,\n-\t\t\t\t int *encap_limit)\n+static void prepare_ip6gre_xmit_other(struct sk_buff *skb,\n+\t\t\t\t struct net_device *dev,\n+\t\t\t\t struct flowi6 *fl6, __u8 *dsfield,\n+\t\t\t\t int *encap_limit)\n {\n \tstruct ip6_tnl *t = netdev_priv(dev);\n \n@@ -697,8 +703,6 @@ static int prepare_ip6gre_xmit_other(struct sk_buff *skb,\n \t\tfl6-\u003eflowi6_mark = t-\u003eparms.fwmark;\n \n \tfl6-\u003eflowi6_uid = sock_net_uid(dev_net(dev), NULL);\n-\n-\treturn 0;\n }\n \n static struct ip_tunnel_info *skb_tunnel_info_txcheck(struct sk_buff *skb)\n@@ -712,10 +716,10 @@ static struct ip_tunnel_info *skb_tunnel_info_txcheck(struct sk_buff *skb)\n \treturn tun_info;\n }\n \n-static netdev_tx_t __gre6_xmit(struct sk_buff *skb,\n-\t\t\t struct net_device *dev, __u8 dsfield,\n-\t\t\t struct flowi6 *fl6, int encap_limit,\n-\t\t\t __u32 *pmtu, __be16 proto)\n+static enum skb_drop_reason __gre6_xmit(struct sk_buff *skb,\n+\t\t\t\t\tstruct net_device *dev, __u8 dsfield,\n+\t\t\t\t\tstruct flowi6 *fl6, int encap_limit,\n+\t\t\t\t\t__u32 *pmtu, __be16 proto)\n {\n \tstruct ip6_tnl *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n@@ -740,7 +744,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,\n \t\ttun_info = skb_tunnel_info_txcheck(skb);\n \t\tif (IS_ERR(tun_info) ||\n \t\t unlikely(ip_tunnel_info_af(tun_info) != AF_INET6))\n-\t\t\treturn -EINVAL;\n+\t\t\treturn SKB_DROP_REASON_TUNNEL_TXINFO;\n \n \t\tkey = \u0026tun_info-\u003ekey;\n \t\tmemset(fl6, 0, sizeof(*fl6));\n@@ -759,7 +763,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,\n \t\ttun_hlen = gre_calc_hlen(flags);\n \n \t\tif (skb_cow_head(skb, dev-\u003eneeded_headroom ?: tun_hlen + tunnel-\u003eencap_hlen))\n-\t\t\treturn -ENOMEM;\n+\t\t\treturn SKB_DROP_REASON_NOMEM;\n \n \t\tgre_build_header(skb, tun_hlen,\n \t\t\t\t flags, protocol,\n@@ -770,7 +774,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,\n \n \t} else {\n \t\tif (skb_cow_head(skb, dev-\u003eneeded_headroom ?: tunnel-\u003ehlen))\n-\t\t\treturn -ENOMEM;\n+\t\t\treturn SKB_DROP_REASON_NOMEM;\n \n \t\tip_tunnel_flags_copy(flags, tunnel-\u003eparms.o_flags);\n \n@@ -785,9 +789,11 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,\n \t\t\t NEXTHDR_GRE);\n }\n \n-static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)\n+static inline enum skb_drop_reason ip6gre_xmit_ipv4(struct sk_buff *skb,\n+\t\t\t\t\t\t struct net_device *dev)\n {\n \tstruct ip6_tnl *t = netdev_priv(dev);\n+\tenum skb_drop_reason reason;\n \tint encap_limit = -1;\n \tstruct flowi6 fl6;\n \t__u8 dsfield = 0;\n@@ -803,54 +809,56 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)\n \terr = gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,\n \t\t\t\t\t\tt-\u003eparms.o_flags));\n \tif (err)\n-\t\treturn -1;\n+\t\treturn SKB_DROP_REASON_NOMEM;\n \n-\terr = __gre6_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\n-\t\t\t skb-\u003eprotocol);\n-\tif (err != 0) {\n+\treason = __gre6_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\n+\t\t\t skb-\u003eprotocol);\n+\tif (reason) {\n \t\t/* XXX: send ICMP error even if DF is not set. */\n-\t\tif (err == -EMSGSIZE)\n+\t\tif (reason == SKB_DROP_REASON_PKT_TOO_BIG)\n \t\t\ticmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,\n \t\t\t\t htonl(mtu));\n-\t\treturn -1;\n+\t\treturn reason;\n \t}\n \n-\treturn 0;\n+\treturn SKB_NOT_DROPPED_YET;\n }\n \n-static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)\n+static inline enum skb_drop_reason ip6gre_xmit_ipv6(struct sk_buff *skb,\n+\t\t\t\t\t\t struct net_device *dev)\n {\n \tstruct ip6_tnl *t = netdev_priv(dev);\n \tstruct ipv6hdr *ipv6h = ipv6_hdr(skb);\n+\tenum skb_drop_reason reason;\n \tint encap_limit = -1;\n \tstruct flowi6 fl6;\n \t__u8 dsfield = 0;\n \t__u32 mtu;\n-\tint err;\n \n \tif (ipv6_addr_equal(\u0026t-\u003eparms.raddr, \u0026ipv6h-\u003esaddr))\n-\t\treturn -1;\n+\t\treturn SKB_DROP_REASON_RECURSION_LIMIT;\n \n \tif (!t-\u003eparms.collect_md \u0026\u0026\n \t prepare_ip6gre_xmit_ipv6(skb, dev, \u0026fl6, \u0026dsfield, \u0026encap_limit))\n-\t\treturn -1;\n+\t\treturn SKB_DROP_REASON_IPV6_BAD_EXTHDR;\n \n \tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,\n \t\t\t\t\t t-\u003eparms.o_flags)))\n-\t\treturn -1;\n+\t\treturn SKB_DROP_REASON_NOMEM;\n \n-\terr = __gre6_xmit(skb, dev, dsfield, \u0026fl6, encap_limit,\n-\t\t\t \u0026mtu, skb-\u003eprotocol);\n-\tif (err != 0) {\n-\t\tif (err == -EMSGSIZE)\n+\treason = __gre6_xmit(skb, dev, dsfield, \u0026fl6, encap_limit,\n+\t\t\t \u0026mtu, skb-\u003eprotocol);\n+\tif (reason) {\n+\t\tif (reason == SKB_DROP_REASON_PKT_TOO_BIG)\n \t\t\ticmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);\n-\t\treturn -1;\n+\t\treturn reason;\n \t}\n \n-\treturn 0;\n+\treturn SKB_NOT_DROPPED_YET;\n }\n \n-static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)\n+static enum skb_drop_reason ip6gre_xmit_other(struct sk_buff *skb,\n+\t\t\t\t\t struct net_device *dev)\n {\n \tstruct ip6_tnl *t = netdev_priv(dev);\n \tint encap_limit = -1;\n@@ -859,32 +867,35 @@ static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)\n \t__u32 mtu;\n \tint err;\n \n-\tif (!t-\u003eparms.collect_md \u0026\u0026\n-\t prepare_ip6gre_xmit_other(skb, dev, \u0026fl6, \u0026dsfield, \u0026encap_limit))\n-\t\treturn -1;\n+\tif (!t-\u003eparms.collect_md)\n+\t\tprepare_ip6gre_xmit_other(skb, dev, \u0026fl6,\n+\t\t\t\t\t \u0026dsfield, \u0026encap_limit);\n \n \terr = gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,\n \t\t\t\t\t\tt-\u003eparms.o_flags));\n \tif (err)\n-\t\treturn err;\n-\terr = __gre6_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu, skb-\u003eprotocol);\n+\t\treturn SKB_DROP_REASON_NOMEM;\n \n-\treturn err;\n+\treturn __gre6_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\n+\t\t\t skb-\u003eprotocol);\n }\n \n static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,\n \tstruct net_device *dev)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel_info *tun_info = NULL;\n \tstruct ip6_tnl *t = netdev_priv(dev);\n \t__be16 payload_protocol;\n-\tint ret;\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto tx_err;\n \n-\tif (!ip6_tnl_xmit_ctl(t, \u0026t-\u003eparms.laddr, \u0026t-\u003eparms.raddr))\n+\tif (!ip6_tnl_xmit_ctl(t, \u0026t-\u003eparms.laddr, \u0026t-\u003eparms.raddr)) {\n+\t\treason = SKB_DROP_REASON_DEV_READY;\n \t\tgoto tx_err;\n+\t}\n \n \tif (t-\u003eparms.collect_md)\n \t\ttun_info = skb_tunnel_info_txcheck(skb);\n@@ -892,17 +903,17 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,\n \tpayload_protocol = skb_protocol(skb, true);\n \tswitch (payload_protocol) {\n \tcase htons(ETH_P_IP):\n-\t\tret = ip6gre_xmit_ipv4(skb, dev);\n+\t\treason = ip6gre_xmit_ipv4(skb, dev);\n \t\tbreak;\n \tcase htons(ETH_P_IPV6):\n-\t\tret = ip6gre_xmit_ipv6(skb, dev);\n+\t\treason = ip6gre_xmit_ipv6(skb, dev);\n \t\tbreak;\n \tdefault:\n-\t\tret = ip6gre_xmit_other(skb, dev);\n+\t\treason = ip6gre_xmit_other(skb, dev);\n \t\tbreak;\n \t}\n \n-\tif (ret \u003c 0)\n+\tif (reason)\n \t\tgoto tx_err;\n \n \treturn NETDEV_TX_OK;\n@@ -911,13 +922,14 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,\n \tif (!IS_ERR(tun_info))\n \t\tDEV_STATS_INC(dev, tx_errors);\n \tDEV_STATS_INC(dev, tx_dropped);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn NETDEV_TX_OK;\n }\n \n static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \t\t\t\t\t struct net_device *dev)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel_info *tun_info = NULL;\n \tstruct ip6_tnl *t = netdev_priv(dev);\n \tstruct dst_entry *dst = skb_dst(skb);\n@@ -926,23 +938,29 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \tint encap_limit = -1;\n \t__u8 dsfield = false;\n \tstruct flowi6 fl6;\n-\tint err = -EINVAL;\n \t__be16 proto;\n \t__u32 mtu;\n \tint nhoff;\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto tx_err;\n \n-\tif (!ip6_tnl_xmit_ctl(t, \u0026t-\u003eparms.laddr, \u0026t-\u003eparms.raddr))\n+\tif (!ip6_tnl_xmit_ctl(t, \u0026t-\u003eparms.laddr, \u0026t-\u003eparms.raddr)) {\n+\t\treason = SKB_DROP_REASON_DEV_READY;\n \t\tgoto tx_err;\n+\t}\n \n-\tif (gre_handle_offloads(skb, false))\n+\tif (gre_handle_offloads(skb, false)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto tx_err;\n+\t}\n \n \tif (skb-\u003elen \u003e dev-\u003emtu + dev-\u003ehard_header_len) {\n-\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len))\n+\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto tx_err;\n+\t\t}\n \t\ttruncate = true;\n \t}\n \n@@ -962,8 +980,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \t\t\ttruncate = true;\n \t}\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom ?: t-\u003ehlen))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom ?: t-\u003ehlen)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto tx_err;\n+\t}\n \n \tIPCB(skb)-\u003eflags = 0;\n \n@@ -977,8 +997,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \n \t\ttun_info = skb_tunnel_info_txcheck(skb);\n \t\tif (IS_ERR(tun_info) ||\n-\t\t unlikely(ip_tunnel_info_af(tun_info) != AF_INET6))\n+\t\t unlikely(ip_tunnel_info_af(tun_info) != AF_INET6)) {\n+\t\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\t\tgoto tx_err;\n+\t\t}\n \n \t\tkey = \u0026tun_info-\u003ekey;\n \t\tmemset(\u0026fl6, 0, sizeof(fl6));\n@@ -990,10 +1012,14 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \n \t\tdsfield = key-\u003etos;\n \t\tif (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT,\n-\t\t\t tun_info-\u003ekey.tun_flags))\n+\t\t\t tun_info-\u003ekey.tun_flags)) {\n+\t\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\t\tgoto tx_err;\n-\t\tif (tun_info-\u003eoptions_len \u003c sizeof(*md))\n+\t\t}\n+\t\tif (tun_info-\u003eoptions_len \u003c sizeof(*md)) {\n+\t\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\t\tgoto tx_err;\n+\t\t}\n \t\tmd = ip_tunnel_info_opts(tun_info);\n \n \t\ttun_id = tunnel_id_to_key32(key-\u003etun_id);\n@@ -1011,6 +1037,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \t\t\t\t\t truncate, false);\n \t\t\tproto = htons(ETH_P_ERSPAN2);\n \t\t} else {\n+\t\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\t\tgoto tx_err;\n \t\t}\n \t} else {\n@@ -1021,11 +1048,16 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \t\t\t\t\t\t \u0026dsfield, \u0026encap_limit);\n \t\t\tbreak;\n \t\tcase htons(ETH_P_IPV6):\n-\t\t\tif (ipv6_addr_equal(\u0026t-\u003eparms.raddr, \u0026ipv6_hdr(skb)-\u003esaddr))\n+\t\t\tif (ipv6_addr_equal(\u0026t-\u003eparms.raddr,\n+\t\t\t\t\t \u0026ipv6_hdr(skb)-\u003esaddr)) {\n+\t\t\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n \t\t\t\tgoto tx_err;\n+\t\t\t}\n \t\t\tif (prepare_ip6gre_xmit_ipv6(skb, dev, \u0026fl6,\n-\t\t\t\t\t\t \u0026dsfield, \u0026encap_limit))\n+\t\t\t\t\t\t \u0026dsfield, \u0026encap_limit)) {\n+\t\t\t\treason = SKB_DROP_REASON_IPV6_BAD_EXTHDR;\n \t\t\t\tgoto tx_err;\n+\t\t\t}\n \t\t\tbreak;\n \t\tdefault:\n \t\t\tmemcpy(\u0026fl6, \u0026t-\u003efl.u.ip6, sizeof(fl6));\n@@ -1044,6 +1076,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \t\t\t\t\t truncate, false);\n \t\t\tproto = htons(ETH_P_ERSPAN2);\n \t\t} else {\n+\t\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\t\tgoto tx_err;\n \t\t}\n \n@@ -1061,11 +1094,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \t\tif (dst_mtu(dst) \u003e mtu)\n \t\t\tdst-\u003eops-\u003eupdate_pmtu(dst, NULL, skb, mtu, false);\n \t}\n-\terr = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\n-\t\t\t NEXTHDR_GRE);\n-\tif (err != 0) {\n+\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\n+\t\t\t NEXTHDR_GRE);\n+\tif (reason) {\n \t\t/* XXX: send ICMP error even if DF is not set. */\n-\t\tif (err == -EMSGSIZE) {\n+\t\tif (reason == SKB_DROP_REASON_PKT_TOO_BIG) {\n \t\t\tif (skb-\u003eprotocol == htons(ETH_P_IP))\n \t\t\t\ticmp_ndo_send(skb, ICMP_DEST_UNREACH,\n \t\t\t\t\t ICMP_FRAG_NEEDED, htonl(mtu));\n@@ -1081,7 +1114,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \tif (!IS_ERR(tun_info))\n \t\tDEV_STATS_INC(dev, tx_errors);\n \tDEV_STATS_INC(dev, tx_dropped);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn NETDEV_TX_OK;\n }\n \ndiff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c\nindex d5ff50a2ac017..77400a1087af5 100644\n--- a/net/ipv6/ip6_tunnel.c\n+++ b/net/ipv6/ip6_tunnel.c\n@@ -813,6 +813,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \t\t\t\t\t\tstruct sk_buff *skb),\n \t\t\t bool log_ecn_err)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tconst struct ipv6hdr *ipv6h;\n \tint nh, err;\n \n@@ -820,15 +821,22 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \t test_bit(IP_TUNNEL_CSUM_BIT, tpi-\u003eflags)) {\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_crc_errors);\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\treason = SKB_DROP_REASON_TNL_OPT_MISMATCH;\n \t\tgoto drop;\n \t}\n \n \tif (test_bit(IP_TUNNEL_SEQ_BIT, tunnel-\u003eparms.i_flags)) {\n-\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags) ||\n-\t\t (tunnel-\u003ei_seqno \u0026\u0026\n-\t\t (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0)) {\n+\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags)) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_TNL_OPT_MISMATCH;\n+\t\t\tgoto drop;\n+\t\t}\n+\t\tif (tunnel-\u003ei_seqno \u0026\u0026\n+\t\t (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0) {\n+\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n+\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_TNL_OLD_SEQ;\n \t\t\tgoto drop;\n \t\t}\n \t\ttunnel-\u003ei_seqno = ntohl(tpi-\u003eseq) + 1;\n@@ -838,7 +846,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \n \t/* Warning: All skb pointers will be invalidated! */\n \tif (tunnel-\u003edev-\u003etype == ARPHRD_ETHER) {\n-\t\tif (!pskb_may_pull(skb, ETH_HLEN)) {\n+\t\treason = pskb_may_pull_reason(skb, ETH_HLEN);\n+\t\tif (reason) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n \t\t\tgoto drop;\n@@ -859,7 +868,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \n \tskb_reset_network_header(skb);\n \n-\tif (skb_vlan_inet_prepare(skb, true)) {\n+\treason = skb_vlan_inet_prepare(skb, true);\n+\tif (reason) {\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n \t\tgoto drop;\n@@ -881,6 +891,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \t\tif (err \u003e 1) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_frame_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_IP_TUNNEL_ECN;\n \t\t\tgoto drop;\n \t\t}\n \t}\n@@ -898,7 +909,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n drop:\n \tif (tun_dst)\n \t\tdst_release((struct dst_entry *)tun_dst);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n \n@@ -1092,14 +1103,14 @@ EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);\n * it.\n *\n * Return:\n- * 0 on success\n- * -1 fail\n- * %-EMSGSIZE message too big. return mtu in this case.\n+ * %SKB_NOT_DROPPED_YET on success, otherwise the drop reason.\n+ * %SKB_DROP_REASON_PKT_TOO_BIG means the message is too big, the path MTU\n+ * is stored in @pmtu in this case.\n **/\n \n-int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n-\t\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu,\n-\t\t __u8 proto)\n+enum skb_drop_reason\n+ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n+\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)\n {\n \tstruct ip6_tnl *t = netdev_priv(dev);\n \tstruct net *net = t-\u003enet;\n@@ -1110,11 +1121,11 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \tint err_count, mtu;\n \tunsigned int eth_hlen = t-\u003edev-\u003etype == ARPHRD_ETHER ? ETH_HLEN : 0;\n \tunsigned int psh_hlen = sizeof(struct ipv6hdr) + t-\u003eencap_hlen;\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tunsigned int max_headroom = psh_hlen;\n \t__be16 payload_protocol;\n \tbool use_cache = false;\n \tu8 hop_limit;\n-\tint err = -1;\n \n \tpayload_protocol = skb_protocol(skb, true);\n \n@@ -1132,13 +1143,17 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \t\t\tstruct neighbour *neigh;\n \t\t\tint addr_type;\n \n-\t\t\tif (!skb_dst(skb))\n+\t\t\tif (!skb_dst(skb)) {\n+\t\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\t\t\tgoto tx_err_link_failure;\n+\t\t\t}\n \n \t\t\tneigh = dst_neigh_lookup(skb_dst(skb),\n \t\t\t\t\t\t \u0026ipv6_hdr(skb)-\u003edaddr);\n-\t\t\tif (!neigh)\n+\t\t\tif (!neigh) {\n+\t\t\t\treason = SKB_DROP_REASON_NEIGH_CREATEFAIL;\n \t\t\t\tgoto tx_err_link_failure;\n+\t\t\t}\n \n \t\t\taddr6 = (struct in6_addr *)\u0026neigh-\u003eprimary_key;\n \t\t\taddr_type = ipv6_addr_type(addr6);\n@@ -1151,8 +1166,10 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \t\t} else if (payload_protocol == htons(ETH_P_IP)) {\n \t\t\tconst struct rtable *rt = skb_rtable(skb);\n \n-\t\t\tif (!rt)\n+\t\t\tif (!rt) {\n+\t\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\t\t\tgoto tx_err_link_failure;\n+\t\t\t}\n \n \t\t\tif (rt-\u003ert_gw_family == AF_INET6)\n \t\t\t\tmemcpy(\u0026fl6-\u003edaddr, \u0026rt-\u003ert_gw6, sizeof(fl6-\u003edaddr));\n@@ -1169,8 +1186,10 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \tif (use_cache)\n \t\tdst = dst_cache_get(\u0026t-\u003edst_cache);\n \n-\tif (!ip6_tnl_xmit_ctl(t, \u0026fl6-\u003esaddr, \u0026fl6-\u003edaddr))\n+\tif (!ip6_tnl_xmit_ctl(t, \u0026fl6-\u003esaddr, \u0026fl6-\u003edaddr)) {\n+\t\treason = SKB_DROP_REASON_DEV_READY;\n \t\tgoto tx_err_link_failure;\n+\t}\n \n \tif (!dst) {\n route_lookup:\n@@ -1179,18 +1198,22 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \n \t\tdst = ip6_route_output(net, NULL, fl6);\n \n-\t\tif (dst-\u003eerror)\n+\t\tif (dst-\u003eerror) {\n+\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_err_link_failure;\n+\t\t}\n \t\tdst = xfrm_lookup(net, dst, flowi6_to_flowi(fl6), NULL, 0);\n \t\tif (IS_ERR(dst)) {\n-\t\t\terr = PTR_ERR(dst);\n \t\t\tdst = NULL;\n+\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_err_link_failure;\n \t\t}\n \t\tif (t-\u003eparms.collect_md \u0026\u0026 ipv6_addr_any(\u0026fl6-\u003esaddr) \u0026\u0026\n \t\t ipv6_dev_get_saddr(net, ip6_dst_idev(dst)-\u003edev,\n-\t\t\t\t \u0026fl6-\u003edaddr, 0, \u0026fl6-\u003esaddr))\n+\t\t\t\t \u0026fl6-\u003edaddr, 0, \u0026fl6-\u003esaddr)) {\n+\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_err_link_failure;\n+\t\t}\n \t\tndst = dst;\n \t}\n \n@@ -1200,6 +1223,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \t\tDEV_STATS_INC(dev, collisions);\n \t\tnet_warn_ratelimited(\"%s: Local routing loop detected!\\n\",\n \t\t\t\t t-\u003eparms.name);\n+\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n \t\tgoto tx_err_dst_release;\n \t}\n \tmtu = dst6_mtu(dst) - eth_hlen - psh_hlen - t-\u003etun_hlen;\n@@ -1213,7 +1237,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \tskb_dst_update_pmtu_no_confirm(skb, mtu);\n \tif (skb-\u003elen - t-\u003etun_hlen - eth_hlen \u003e mtu \u0026\u0026 !skb_is_gso(skb)) {\n \t\t*pmtu = mtu;\n-\t\terr = -EMSGSIZE;\n+\t\treason = SKB_DROP_REASON_PKT_TOO_BIG;\n \t\tgoto tx_err_dst_release;\n \t}\n \n@@ -1236,12 +1260,16 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \t */\n \tmax_headroom += LL_RESERVED_SPACE(tdev);\n \n-\tif (skb_cow_head(skb, max_headroom))\n+\tif (skb_cow_head(skb, max_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto tx_err_dst_release;\n+\t}\n \n \tif (t-\u003eparms.collect_md) {\n-\t\tif (t-\u003eencap.type != TUNNEL_ENCAP_NONE)\n+\t\tif (t-\u003eencap.type != TUNNEL_ENCAP_NONE) {\n+\t\t\treason = SKB_DROP_REASON_TNL_ENCAP;\n \t\t\tgoto tx_err_dst_release;\n+\t\t}\n \t} else {\n \t\tif (use_cache \u0026\u0026 ndst)\n \t\t\tdst_cache_set_ip6(\u0026t-\u003edst_cache, ndst, \u0026fl6-\u003esaddr);\n@@ -1264,9 +1292,8 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \t\t\t+ dst-\u003eheader_len + t-\u003ehlen;\n \tip_tunnel_adj_headroom(dev, max_headroom);\n \n-\terr = ip6_tnl_encap(skb, t, \u0026proto, fl6);\n-\tif (err)\n-\t\treturn err;\n+\tif (ip6_tnl_encap(skb, t, \u0026proto, fl6))\n+\t\treturn SKB_DROP_REASON_TNL_ENCAP;\n \n \tif (encap_limit \u003e= 0) {\n \t\tinit_tel_txopt(\u0026opt, encap_limit);\n@@ -1283,21 +1310,22 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n \tipv6h-\u003esaddr = fl6-\u003esaddr;\n \tipv6h-\u003edaddr = fl6-\u003edaddr;\n \tip6tunnel_xmit(NULL, skb, dev, 0);\n-\treturn 0;\n+\treturn SKB_NOT_DROPPED_YET;\n tx_err_link_failure:\n \tDEV_STATS_INC(dev, tx_carrier_errors);\n \tdst_link_failure(skb);\n tx_err_dst_release:\n \tdst_release(dst);\n-\treturn err;\n+\treturn reason;\n }\n EXPORT_SYMBOL(ip6_tnl_xmit);\n \n-static inline int\n+static inline enum skb_drop_reason\n ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\tu8 protocol)\n {\n \tstruct ip6_tnl *t = netdev_priv(dev);\n+\tenum skb_drop_reason reason;\n \tstruct ipv6hdr *ipv6h;\n \tconst struct iphdr *iph;\n \tint encap_limit = -1;\n@@ -1306,11 +1334,10 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n \t__u8 dsfield, orig_dsfield;\n \t__u32 mtu;\n \tu8 tproto;\n-\tint err;\n \n \ttproto = READ_ONCE(t-\u003eparms.proto);\n \tif (tproto != protocol \u0026\u0026 tproto != 0)\n-\t\treturn -1;\n+\t\treturn SKB_DROP_REASON_UNHANDLED_PROTO;\n \n \tif (t-\u003eparms.collect_md) {\n \t\tstruct ip_tunnel_info *tun_info;\n@@ -1319,7 +1346,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\ttun_info = skb_tunnel_info(skb);\n \t\tif (unlikely(!tun_info || !(tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) ||\n \t\t\t ip_tunnel_info_af(tun_info) != AF_INET6))\n-\t\t\treturn -1;\n+\t\t\treturn SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tkey = \u0026tun_info-\u003ekey;\n \t\tmemset(\u0026fl6, 0, sizeof(fl6));\n \t\tfl6.flowi6_proto = protocol;\n@@ -1356,7 +1383,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t\t\tif (tel-\u003eencap_limit == 0) {\n \t\t\t\t\ticmpv6_ndo_send(skb, ICMPV6_PARAMPROB,\n \t\t\t\t\t\t\tICMPV6_HDR_FIELD, offset + 2);\n-\t\t\t\t\treturn -1;\n+\t\t\t\t\treturn SKB_DROP_REASON_IPV6_BAD_EXTHDR;\n \t\t\t\t}\n \t\t\t\tencap_limit = tel-\u003eencap_limit - 1;\n \t\t\t}\n@@ -1398,15 +1425,15 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n \tdsfield = INET_ECN_encapsulate(dsfield, orig_dsfield);\n \n \tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))\n-\t\treturn -1;\n+\t\treturn SKB_DROP_REASON_NOMEM;\n \n \tskb_set_inner_ipproto(skb, protocol);\n \n-\terr = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\n-\t\t\t protocol);\n-\tif (err != 0) {\n+\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\n+\t\t\t protocol);\n+\tif (reason) {\n \t\t/* XXX: send ICMP error even if DF is not set. */\n-\t\tif (err == -EMSGSIZE)\n+\t\tif (reason == SKB_DROP_REASON_PKT_TOO_BIG)\n \t\t\tswitch (protocol) {\n \t\t\tcase IPPROTO_IPIP:\n \t\t\t\ticmp_ndo_send(skb, ICMP_DEST_UNREACH,\n@@ -1418,20 +1445,21 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t\tdefault:\n \t\t\t\tbreak;\n \t\t\t}\n-\t\treturn -1;\n+\t\treturn reason;\n \t}\n \n-\treturn 0;\n+\treturn SKB_NOT_DROPPED_YET;\n }\n \n static netdev_tx_t\n ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip6_tnl *t = netdev_priv(dev);\n \tu8 ipproto;\n-\tint ret;\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto tx_err;\n \n \tswitch (skb-\u003eprotocol) {\n@@ -1439,19 +1467,22 @@ ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n \t\tipproto = IPPROTO_IPIP;\n \t\tbreak;\n \tcase htons(ETH_P_IPV6):\n-\t\tif (ip6_tnl_addr_conflict(t, ipv6_hdr(skb)))\n+\t\tif (ip6_tnl_addr_conflict(t, ipv6_hdr(skb))) {\n+\t\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n \t\t\tgoto tx_err;\n+\t\t}\n \t\tipproto = IPPROTO_IPV6;\n \t\tbreak;\n \tcase htons(ETH_P_MPLS_UC):\n \t\tipproto = IPPROTO_MPLS;\n \t\tbreak;\n \tdefault:\n+\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\tgoto tx_err;\n \t}\n \n-\tret = ipxip6_tnl_xmit(skb, dev, ipproto);\n-\tif (ret \u003c 0)\n+\treason = ipxip6_tnl_xmit(skb, dev, ipproto);\n+\tif (reason)\n \t\tgoto tx_err;\n \n \treturn NETDEV_TX_OK;\n@@ -1459,7 +1490,7 @@ ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n tx_err:\n \tDEV_STATS_INC(dev, tx_errors);\n \tDEV_STATS_INC(dev, tx_dropped);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn NETDEV_TX_OK;\n }\n \n"
} |
| 2/1 | 2026/09/25 05:00 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": [
"NET_IPGRE",
"NET_IPGRE_DEMUX",
"NET_IP_TUNNEL",
"IPV6",
"IPV6_TUNNEL",
"IPV6_GRE"
],
"FocusSymbols": [
"gre_parse_header",
"ip_tunnel_rcv",
"ip_tunnel_xmit",
"ip_md_tunnel_xmit",
"__iptunnel_pull_header_reason",
"ip6_tnl_xmit",
"ip6_tnl_rcv",
"ip6_tnl_start_xmit",
"ipgre_xmit",
"ip6gre_tunnel_xmit",
"ip6erspan_tunnel_xmit",
"erspan_xmit"
],
"Reasoning": "The patch introduces multiple new skb drop reasons and refactors packet parsing, encapsulation, transmission, and reception error paths across IPv4/IPv6 GRE and IP tunneling drivers (gre_demux, ip_gre, ip6_gre, ip_tunnel, and ip6_tunnel). These virtual tunnel devices and protocols are fully reachable in virtualized QEMU environments via netlink and packet/socket interfaces, so fuzzing is warranted to test the altered control flow and error paths.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 8528ffb1c7e241220d9880e821afa233d80a376c
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Sep 25 05:00:45 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 12f9096515912..a72b84b07daa2 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -129,6 +129,12 @@
FN(PSP_INPUT) \
FN(PSP_OUTPUT) \
FN(RECURSION_LIMIT) \
+ FN(TNL_OPT_MISMATCH) \
+ FN(TNL_OLD_SEQ) \
+ FN(GRE_INVALID_HDR) \
+ FN(GRE_CSUM) \
+ FN(GRE_TUNNEL_NOT_FOUND) \
+ FN(TNL_ENCAP) \
FNe(MAX)
/**
@@ -612,6 +618,39 @@ enum skb_drop_reason {
SKB_DROP_REASON_PSP_OUTPUT,
/** @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device. */
SKB_DROP_REASON_RECURSION_LIMIT,
+ /**
+ * @SKB_DROP_REASON_TNL_OPT_MISMATCH: the tunnel options
+ * carried by the packet do not match the tunnel configuration, e.g.
+ * a GRE tunnel configured with 'icsum' or 'iseq' received a packet
+ * with no checksum or no sequence number, or a GRE tunnel without
+ * 'icsum' received a packet with a checksum.
+ */
+ SKB_DROP_REASON_TNL_OPT_MISMATCH,
+ /**
+ * @SKB_DROP_REASON_TNL_OLD_SEQ: the sequence number carried
+ * by the packet is older than the one expected by the tunnel, e.g.
+ * after the remote endpoint restarted and reset its sequence
+ * numbering.
+ */
+ SKB_DROP_REASON_TNL_OLD_SEQ,
+ /**
+ * @SKB_DROP_REASON_GRE_INVALID_HDR: the GRE header is invalid, e.g.
+ * an unsupported version or the routing bit is set.
+ */
+ SKB_DROP_REASON_GRE_INVALID_HDR,
+ /** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */
+ SKB_DROP_REASON_GRE_CSUM,
+ /**
+ * @SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND: no GRE tunnel found for the
+ * endpoints and the key the packet carries.
+ */
+ SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND,
+ /**
+ * @SKB_DROP_REASON_TNL_ENCAP: failed to build the
+ * encapsulation header of a tunnel, e.g. an unknown or
+ * unregistered encapsulation type.
+ */
+ SKB_DROP_REASON_TNL_ENCAP,
/**
* @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
* shouldn't be used as a real 'reason' - only for tracing code gen
diff --git a/include/net/gre.h b/include/net/gre.h
index b55f67ecd2fc4..4cb19abea90de 100644
--- a/include/net/gre.h
+++ b/include/net/gre.h
@@ -32,8 +32,9 @@ struct gre_protocol {
int gre_add_protocol(const struct gre_protocol *proto, u8 version);
int gre_del_protocol(const struct gre_protocol *proto, u8 version);
-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
- bool *csum_err, __be16 proto, int nhs);
+enum skb_drop_reason
+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
+ bool icmp_err, __be16 proto, int nhs);
static inline bool netif_is_gretap(const struct net_device *dev)
{
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index d1f0a427e9c82..363eed61b296a 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -143,8 +143,9 @@ int ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
bool log_ecn_error);
int ip6_tnl_xmit_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
const struct in6_addr *raddr);
-int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
- struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);
+enum skb_drop_reason
+ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
+ struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);
__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
const struct in6_addr *raddr);
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 7102aa11fae29..27a9e097996b6 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -207,10 +207,6 @@ struct tnl_ptk_info {
int hdr_len;
};
-#define PACKET_RCVD 0
-#define PACKET_REJECT 1
-#define PACKET_NEXT 2
-
#define IP_TNL_HASH_BITS 7
#define IP_TNL_HASH_SIZE (1 << IP_TNL_HASH_BITS)
@@ -614,8 +610,17 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph,
return INET_ECN_encapsulate(tos, inner);
}
-int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
- __be16 inner_proto, bool raw_proto, bool xnet);
+enum skb_drop_reason
+__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,
+ __be16 inner_proto, bool raw_proto, bool xnet);
+
+static inline int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
+ __be16 inner_proto, bool raw_proto,
+ bool xnet)
+{
+ return __iptunnel_pull_header_reason(skb, hdr_len, inner_proto,
+ raw_proto, xnet) ? -ENOMEM : 0;
+}
static inline int iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
__be16 inner_proto, bool xnet)
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 96fd7dc6d82dd..e117056525f06 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -56,28 +56,35 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)
}
EXPORT_SYMBOL_GPL(gre_del_protocol);
-/* Fills in tpi and returns header length to be pulled.
+/* Fills in tpi, including the header length to be pulled in tpi->hdr_len,
+ * and returns SKB_NOT_DROPPED_YET, or the reason to drop the packet if the
+ * header is rejected.
* Note that caller must use pskb_may_pull() before pulling GRE header.
+ *
+ * @icmp_err is set by the ICMP error handlers, which only get a part of
+ * the original packet: a checksum failure does not reject the header then,
+ * the checksum is still computed and the rest of the header is parsed.
*/
-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
- bool *csum_err, __be16 proto, int nhs)
+enum skb_drop_reason
+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
+ bool icmp_err, __be16 proto, int nhs)
{
const struct gre_base_hdr *greh;
__be32 *options;
int hdr_len;
if (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))
- return -EINVAL;
+ return SKB_DROP_REASON_HDR_TRUNC;
greh = (struct gre_base_hdr *)(skb->data + nhs);
if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
- return -EINVAL;
+ return SKB_DROP_REASON_GRE_INVALID_HDR;
gre_flags_to_tnl_flags(tpi->flags, greh->flags);
hdr_len = gre_calc_hlen(tpi->flags);
if (!pskb_may_pull(skb, nhs + hdr_len))
- return -EINVAL;
+ return SKB_DROP_REASON_HDR_TRUNC;
greh = (struct gre_base_hdr *)(skb->data + nhs);
tpi->proto = greh->protocol;
@@ -87,9 +94,8 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
if (!skb_checksum_simple_validate(skb)) {
skb_checksum_try_convert(skb, IPPROTO_GRE,
null_compute_pseudo);
- } else if (csum_err) {
- *csum_err = true;
- return -EINVAL;
+ } else if (!icmp_err) {
+ return SKB_DROP_REASON_GRE_CSUM;
}
options++;
@@ -117,7 +123,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
val = skb_header_pointer(skb, nhs + hdr_len,
sizeof(_val), &_val);
if (!val)
- return -EINVAL;
+ return SKB_DROP_REASON_HDR_TRUNC;
tpi->proto = proto;
if ((*val & 0xF0) != 0x40)
hdr_len += 4;
@@ -133,28 +139,32 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
struct erspan_base_hdr *ershdr;
if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
- return -EINVAL;
+ return SKB_DROP_REASON_HDR_TRUNC;
ershdr = (struct erspan_base_hdr *)(skb->data + nhs + hdr_len);
tpi->key = cpu_to_be32(get_session_id(ershdr));
}
- return hdr_len;
+ return SKB_NOT_DROPPED_YET;
}
EXPORT_SYMBOL(gre_parse_header);
static int gre_rcv(struct sk_buff *skb)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
const struct gre_protocol *proto;
u8 ver;
int ret;
- if (!pskb_may_pull(skb, 12))
+ reason = pskb_may_pull_reason(skb, 12);
+ if (reason)
goto drop;
ver = skb->data[1]&0x7f;
- if (ver >= GREPROTO_MAX)
+ if (ver >= GREPROTO_MAX) {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto drop;
+ }
rcu_read_lock();
proto = rcu_dereference(gre_proto[ver]);
@@ -167,11 +177,11 @@ static int gre_rcv(struct sk_buff *skb)
drop_nohandler:
rcu_read_unlock();
dev_core_stats_rx_nohandler_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);
return NET_RX_DROP;
drop:
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NET_RX_DROP;
}
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 5e877018e006c..ad669b3f87570 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -237,8 +237,8 @@ static void gre_err(struct sk_buff *skb, u32 info)
const int code = icmp_hdr(skb)->code;
struct tnl_ptk_info tpi;
- if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IP),
- iph->ihl * 4) < 0)
+ if (gre_parse_header(skb, &tpi, true, htons(ETH_P_IP),
+ iph->ihl * 4))
return;
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
@@ -264,13 +264,15 @@ static bool is_erspan_type1(int gre_hdr_len)
return gre_hdr_len == 4;
}
-static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
- int gre_hdr_len)
+static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,
+ struct tnl_ptk_info *tpi,
+ int gre_hdr_len)
{
struct net *net = dev_net(skb->dev);
struct metadata_dst *tun_dst = NULL;
struct erspan_base_hdr *ershdr;
IP_TUNNEL_DECLARE_FLAGS(flags);
+ enum skb_drop_reason reason;
struct ip_tunnel_net *itn;
struct ip_tunnel *tunnel;
const struct iphdr *iph;
@@ -290,7 +292,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
} else {
if (unlikely(!pskb_may_pull(skb,
gre_hdr_len + sizeof(*ershdr))))
- return PACKET_REJECT;
+ return SKB_DROP_REASON_HDR_TRUNC;
ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len);
ver = ershdr->ver;
@@ -307,12 +309,12 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
len = gre_hdr_len + erspan_hdr_len(ver);
if (unlikely(!pskb_may_pull(skb, len)))
- return PACKET_REJECT;
+ return SKB_DROP_REASON_HDR_TRUNC;
- if (__iptunnel_pull_header(skb,
- len,
- htons(ETH_P_TEB),
- false, false) < 0)
+ reason = __iptunnel_pull_header_reason(skb, len,
+ htons(ETH_P_TEB),
+ false, false);
+ if (reason)
goto drop;
if (tunnel->collect_md) {
@@ -328,7 +330,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
tun_dst = ip_tun_rx_dst(skb, flags,
tun_id, sizeof(*md));
if (!tun_dst)
- return PACKET_REJECT;
+ return SKB_DROP_REASON_NOMEM;
/* MUST set options_len before referencing options */
info = &tun_dst->u.tun_info;
@@ -354,19 +356,22 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
skb_reset_mac_header(skb);
ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
- return PACKET_RCVD;
+ return SKB_NOT_DROPPED_YET;
}
- return PACKET_REJECT;
+ return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
drop:
- kfree_skb(skb);
- return PACKET_RCVD;
+ kfree_skb_reason(skb, reason);
+ return SKB_NOT_DROPPED_YET;
}
-static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
- struct ip_tunnel_net *itn, int hdr_len, bool raw_proto)
+static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,
+ const struct tnl_ptk_info *tpi,
+ struct ip_tunnel_net *itn,
+ int hdr_len, bool raw_proto)
{
struct metadata_dst *tun_dst = NULL;
+ enum skb_drop_reason reason;
const struct iphdr *iph;
struct ip_tunnel *tunnel;
@@ -377,8 +382,10 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
if (tunnel) {
const struct iphdr *tnl_params;
- if (__iptunnel_pull_header(skb, hdr_len, tpi->proto,
- raw_proto, false) < 0)
+ reason = __iptunnel_pull_header_reason(skb, hdr_len,
+ tpi->proto, raw_proto,
+ false);
+ if (reason)
goto drop;
/* Special case for ipgre_header_parse(), which expects the
@@ -401,47 +408,48 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
tun_id = key32_to_tunnel_id(tpi->key);
tun_dst = ip_tun_rx_dst(skb, flags, tun_id, 0);
if (!tun_dst)
- return PACKET_REJECT;
+ return SKB_DROP_REASON_NOMEM;
}
ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
- return PACKET_RCVD;
+ return SKB_NOT_DROPPED_YET;
}
- return PACKET_NEXT;
+ return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
drop:
- kfree_skb(skb);
- return PACKET_RCVD;
+ kfree_skb_reason(skb, reason);
+ return SKB_NOT_DROPPED_YET;
}
-static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
- int hdr_len)
+static enum skb_drop_reason ipgre_rcv(struct sk_buff *skb,
+ const struct tnl_ptk_info *tpi,
+ int hdr_len)
{
struct net *net = dev_net(skb->dev);
+ enum skb_drop_reason reason;
struct ip_tunnel_net *itn;
- int res;
if (tpi->proto == htons(ETH_P_TEB))
itn = net_generic(net, gre_tap_net_id);
else
itn = net_generic(net, ipgre_net_id);
- res = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
- if (res == PACKET_NEXT && tpi->proto == htons(ETH_P_TEB)) {
+ reason = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
+ if (reason == SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND &&
+ tpi->proto == htons(ETH_P_TEB)) {
/* ipgre tunnels in collect metadata mode should receive
* also ETH_P_TEB traffic.
*/
itn = net_generic(net, ipgre_net_id);
- res = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
+ reason = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
}
- return res;
+ return reason;
}
static int gre_rcv(struct sk_buff *skb)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct tnl_ptk_info tpi;
- bool csum_err = false;
- int hdr_len;
#ifdef CONFIG_NET_IPGRE_BROADCAST
if (ipv4_is_multicast(ip_hdr(skb)->daddr)) {
@@ -451,25 +459,27 @@ static int gre_rcv(struct sk_buff *skb)
}
#endif
- hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP), 0);
- if (hdr_len < 0)
+ reason = gre_parse_header(skb, &tpi, false, htons(ETH_P_IP), 0);
+ if (reason)
goto drop;
if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
tpi.proto == htons(ETH_P_ERSPAN2))) {
- if (erspan_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+ reason = erspan_rcv(skb, &tpi, tpi.hdr_len);
+ if (!reason)
return 0;
goto out;
}
- if (ipgre_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+ reason = ipgre_rcv(skb, &tpi, tpi.hdr_len);
+ if (!reason)
return 0;
out:
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
drop:
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -496,6 +506,7 @@ static int gre_handle_offloads(struct sk_buff *skb, bool csum)
static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
__be16 proto)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
struct ip_tunnel_info *tun_info;
@@ -504,19 +515,25 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
- ip_tunnel_info_af(tun_info) != AF_INET))
+ ip_tunnel_info_af(tun_info) != AF_INET)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto err_free_skb;
+ }
key = &tun_info->key;
tunnel_hlen = gre_calc_hlen(key->tun_flags);
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
/* Push Tunnel header. */
if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
- tunnel->parms.o_flags)))
+ tunnel->parms.o_flags))) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
__set_bit(IP_TUNNEL_CSUM_BIT, flags);
__set_bit(IP_TUNNEL_KEY_BIT, flags);
@@ -533,12 +550,13 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
return;
err_free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
}
static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
struct ip_tunnel_info *tun_info;
@@ -552,29 +570,41 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
- ip_tunnel_info_af(tun_info) != AF_INET))
+ ip_tunnel_info_af(tun_info) != AF_INET)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto err_free_skb;
+ }
key = &tun_info->key;
- if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info->key.tun_flags))
+ if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info->key.tun_flags)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto err_free_skb;
- if (tun_info->options_len < sizeof(*md))
+ }
+ if (tun_info->options_len < sizeof(*md)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto err_free_skb;
+ }
md = ip_tunnel_info_opts(tun_info);
/* ERSPAN has fixed 8 byte GRE header */
version = md->version;
tunnel_hlen = 8 + erspan_hdr_len(version);
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
- if (gre_handle_offloads(skb, false))
+ if (gre_handle_offloads(skb, false)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
if (skb->len > dev->mtu + dev->hard_header_len) {
- if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+ if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
truncate = true;
}
@@ -606,6 +636,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
truncate, true);
proto = htons(ETH_P_ERSPAN2);
} else {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto err_free_skb;
}
@@ -618,7 +649,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
return;
err_free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
}
@@ -649,11 +680,13 @@ static int gre_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
const struct iphdr *tnl_params;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -664,10 +697,13 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
if (dev->header_ops) {
int pull_len = tunnel->hlen + sizeof(struct iphdr);
- if (skb_cow_head(skb, 0))
+ if (skb_cow_head(skb, 0)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
- if (!pskb_may_pull(skb, pull_len))
+ reason = pskb_may_pull_reason(skb, pull_len);
+ if (reason)
goto free_skb;
tnl_params = (const struct iphdr *)skb->data;
@@ -677,25 +713,31 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
skb_reset_mac_header(skb);
if (skb->ip_summed == CHECKSUM_PARTIAL &&
- skb_checksum_start(skb) < skb->data)
+ skb_checksum_start(skb) < skb->data) {
+ reason = SKB_DROP_REASON_SKB_CSUM;
goto free_skb;
+ }
} else {
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
tnl_params = &tunnel->parms.iph;
}
ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
- if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))
+ if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
__gre_xmit(skb, dev, tnl_params, skb->protocol, flags);
return NETDEV_TX_OK;
free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
@@ -703,12 +745,14 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
static netdev_tx_t erspan_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
bool truncate = false;
__be16 proto;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -716,15 +760,21 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
- if (gre_handle_offloads(skb, false))
+ if (gre_handle_offloads(skb, false)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
if (skb->len > dev->mtu + dev->hard_header_len) {
- if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+ if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
truncate = true;
}
@@ -745,6 +795,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
truncate, true);
proto = htons(ETH_P_ERSPAN2);
} else {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto free_skb;
}
@@ -753,7 +804,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
@@ -761,10 +812,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -774,17 +827,21 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
- if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))
+ if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
__gre_xmit(skb, dev, &tunnel->parms.iph, htons(ETH_P_TEB), flags);
return NETDEV_TX_OK;
free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 0875474a578a4..66cb0b86fa79a 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -384,6 +384,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,
bool log_ecn_error)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
const struct iphdr *iph = ip_hdr(skb);
int nh, err;
@@ -398,14 +399,22 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
test_bit(IP_TUNNEL_CSUM_BIT, tpi->flags)) {
DEV_STATS_INC(tunnel->dev, rx_crc_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OPT_MISMATCH;
goto drop;
}
if (test_bit(IP_TUNNEL_SEQ_BIT, tunnel->parms.i_flags)) {
- if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags) ||
- (tunnel->i_seqno && (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0)) {
+ if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags)) {
DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OPT_MISMATCH;
+ goto drop;
+ }
+ if (tunnel->i_seqno &&
+ (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0) {
+ DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
+ DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OLD_SEQ;
goto drop;
}
tunnel->i_seqno = ntohl(tpi->seq) + 1;
@@ -419,7 +428,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
skb_set_network_header(skb, (tunnel->dev->type == ARPHRD_ETHER) ? ETH_HLEN : 0);
- if (!pskb_inet_may_pull(skb)) {
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason) {
DEV_STATS_INC(tunnel->dev, rx_length_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
goto drop;
@@ -434,6 +444,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
if (err > 1) {
DEV_STATS_INC(tunnel->dev, rx_frame_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
goto drop;
}
}
@@ -457,7 +468,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
drop:
if (tun_dst)
dst_release((struct dst_entry *)tun_dst);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
EXPORT_SYMBOL_GPL(ip_tunnel_rcv);
@@ -575,6 +586,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
u8 proto, int tunnel_hlen)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
u32 headroom = sizeof(struct iphdr);
struct ip_tunnel_info *tun_info;
@@ -588,8 +600,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
- ip_tunnel_info_af(tun_info) != AF_INET))
+ ip_tunnel_info_af(tun_info) != AF_INET)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto tx_error;
+ }
key = &tun_info->key;
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
inner_iph = (const struct iphdr *)skb_inner_network_header(skb);
@@ -608,8 +622,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (!tunnel_hlen)
tunnel_hlen = ip_encap_hlen(&tun_info->encap);
- if (ip_tunnel_encap(skb, &tun_info->encap, &proto, &fl4) < 0)
+ if (ip_tunnel_encap(skb, &tun_info->encap, &proto, &fl4) < 0) {
+ reason = SKB_DROP_REASON_TNL_ENCAP;
goto tx_error;
+ }
use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
if (use_cache)
@@ -618,6 +634,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
rt = ip_route_output_key(tunnel->net, &fl4);
if (IS_ERR(rt)) {
DEV_STATS_INC(dev, tx_carrier_errors);
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
if (use_cache)
@@ -627,6 +644,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (rt->dst.dev == dev) {
ip_rt_put(rt);
DEV_STATS_INC(dev, collisions);
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_error;
}
@@ -635,6 +653,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, tunnel_hlen,
key->u.ipv4.dst, true)) {
ip_rt_put(rt);
+ reason = SKB_DROP_REASON_PKT_TOO_BIG;
goto tx_error;
}
@@ -652,6 +671,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
headroom += LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len;
if (skb_cow_head(skb, headroom)) {
ip_rt_put(rt);
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_dropped;
}
@@ -666,13 +686,14 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
tx_dropped:
DEV_STATS_INC(dev, tx_dropped);
kfree:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
}
EXPORT_SYMBOL_GPL(ip_md_tunnel_xmit);
void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
const struct iphdr *tnl_params, u8 protocol)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
struct ip_tunnel_info *tun_info = NULL;
const struct iphdr *inner_iph;
@@ -700,9 +721,15 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (!skb_dst(skb)) {
DEV_STATS_INC(dev, tx_fifo_errors);
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_error;
}
+ /* Only the branches below can derive a destination. If
+ * none of them matches, the payload protocol is not one
+ * this tunnel can carry.
+ */
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
tun_info = skb_tunnel_info(skb);
if (tun_info && (tun_info->mode & IP_TUNNEL_INFO_TX) &&
ip_tunnel_info_af(tun_info) == AF_INET &&
@@ -723,8 +750,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
neigh = dst_neigh_lookup(skb_dst(skb),
&ipv6_hdr(skb)->daddr);
- if (!neigh)
+ if (!neigh) {
+ reason = SKB_DROP_REASON_NEIGH_CREATEFAIL;
goto tx_error;
+ }
addr6 = (const struct in6_addr *)&neigh->primary_key;
addr_type = ipv6_addr_type(addr6);
@@ -741,8 +770,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
dst = addr6->s6_addr32[3];
}
neigh_release(neigh);
- if (do_tx_error_icmp)
+ if (do_tx_error_icmp) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_error_icmp;
+ }
}
#endif
else
@@ -769,8 +800,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
tunnel->net, READ_ONCE(tunnel->parms.link),
tunnel->fwmark, skb_get_hash(skb), 0);
- if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0)
+ if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0) {
+ reason = SKB_DROP_REASON_TNL_ENCAP;
goto tx_error;
+ }
if (connected && md) {
use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
@@ -787,6 +820,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (IS_ERR(rt)) {
DEV_STATS_INC(dev, tx_carrier_errors);
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
if (use_cache)
@@ -800,6 +834,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (rt->dst.dev == dev) {
ip_rt_put(rt);
DEV_STATS_INC(dev, collisions);
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_error;
}
@@ -809,6 +844,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, 0, 0, false)) {
ip_rt_put(rt);
+ reason = SKB_DROP_REASON_PKT_TOO_BIG;
goto tx_error;
}
@@ -843,7 +879,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (skb_cow_head(skb, max_headroom)) {
ip_rt_put(rt);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);
return;
}
@@ -859,7 +895,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
#endif
tx_error:
DEV_STATS_INC(dev, tx_errors);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
}
EXPORT_SYMBOL_GPL(ip_tunnel_xmit);
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index bab42b9e277f7..51f1537ce6c1f 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -106,19 +106,24 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
}
EXPORT_SYMBOL_GPL(iptunnel_xmit);
-int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
- __be16 inner_proto, bool raw_proto, bool xnet)
+enum skb_drop_reason
+__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,
+ __be16 inner_proto, bool raw_proto, bool xnet)
{
- if (unlikely(!pskb_may_pull(skb, hdr_len)))
- return -ENOMEM;
+ enum skb_drop_reason reason;
+
+ reason = pskb_may_pull_reason(skb, hdr_len);
+ if (unlikely(reason))
+ return reason;
skb_pull_rcsum(skb, hdr_len);
if (!raw_proto && inner_proto == htons(ETH_P_TEB)) {
struct ethhdr *eh;
- if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
- return -ENOMEM;
+ reason = pskb_may_pull_reason(skb, ETH_HLEN);
+ if (unlikely(reason))
+ return reason;
eh = (struct ethhdr *)skb->data;
if (likely(eth_proto_is_802_3(eh->h_proto)))
@@ -135,9 +140,12 @@ int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
skb_set_queue_mapping(skb, 0);
skb_scrub_packet(skb, xnet);
- return iptunnel_pull_offloads(skb);
+ if (unlikely(iptunnel_pull_offloads(skb)))
+ return SKB_DROP_REASON_NOMEM;
+
+ return SKB_NOT_DROPPED_YET;
}
-EXPORT_SYMBOL_GPL(__iptunnel_pull_header);
+EXPORT_SYMBOL_GPL(__iptunnel_pull_header_reason);
struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md,
gfp_t flags)
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index c851af22b9fe5..31930ff813dd2 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -389,8 +389,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
struct tnl_ptk_info tpi;
struct ip6_tnl *t;
- if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IPV6),
- offset) < 0)
+ if (gre_parse_header(skb, &tpi, true, htons(ETH_P_IPV6),
+ offset))
return -EINVAL;
ipv6h = (const struct ipv6hdr *)skb->data;
@@ -451,7 +451,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
return 0;
}
-static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
+static enum skb_drop_reason ip6gre_rcv(struct sk_buff *skb,
+ const struct tnl_ptk_info *tpi)
{
const struct ipv6hdr *ipv6h;
struct ip6_tnl *tunnel;
@@ -471,22 +472,22 @@ static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
tun_dst = ipv6_tun_rx_dst(skb, flags, tun_id, 0);
if (!tun_dst)
- return PACKET_REJECT;
+ return SKB_DROP_REASON_NOMEM;
ip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
} else {
ip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
}
- return PACKET_RCVD;
+ return SKB_NOT_DROPPED_YET;
}
- return PACKET_REJECT;
+ return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
}
-static int ip6erspan_rcv(struct sk_buff *skb,
- struct tnl_ptk_info *tpi,
- int gre_hdr_len)
+static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,
+ struct tnl_ptk_info *tpi,
+ int gre_hdr_len)
{
struct erspan_base_hdr *ershdr;
const struct ipv6hdr *ipv6h;
@@ -495,7 +496,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,
u8 ver;
if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))
- return PACKET_REJECT;
+ return SKB_DROP_REASON_HDR_TRUNC;
ipv6h = ipv6_hdr(skb);
ershdr = (struct erspan_base_hdr *)skb->data;
@@ -506,14 +507,16 @@ static int ip6erspan_rcv(struct sk_buff *skb,
tpi->proto);
if (tunnel) {
int len = erspan_hdr_len(ver);
+ enum skb_drop_reason reason;
if (unlikely(!pskb_may_pull(skb, len)))
- return PACKET_REJECT;
+ return SKB_DROP_REASON_HDR_TRUNC;
- if (__iptunnel_pull_header(skb, len,
- htons(ETH_P_TEB),
- false, false) < 0)
- return PACKET_REJECT;
+ reason = __iptunnel_pull_header_reason(skb, len,
+ htons(ETH_P_TEB),
+ false, false);
+ if (reason)
+ return reason;
if (tunnel->parms.collect_md) {
struct erspan_metadata *pkt_md, *md;
@@ -530,7 +533,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,
tun_dst = ipv6_tun_rx_dst(skb, flags, tun_id,
sizeof(*md));
if (!tun_dst)
- return PACKET_REJECT;
+ return SKB_DROP_REASON_NOMEM;
/* MUST set options_len before referencing options */
info = &tun_dst->u.tun_info;
@@ -558,40 +561,43 @@ static int ip6erspan_rcv(struct sk_buff *skb,
ip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
}
- return PACKET_RCVD;
+ return SKB_NOT_DROPPED_YET;
}
- return PACKET_REJECT;
+ return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
}
static int gre_rcv(struct sk_buff *skb)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct tnl_ptk_info tpi;
- bool csum_err = false;
- int hdr_len;
- hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6), 0);
- if (hdr_len < 0)
+ reason = gre_parse_header(skb, &tpi, false, htons(ETH_P_IPV6), 0);
+ if (reason)
goto drop;
- if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
+ reason = __iptunnel_pull_header_reason(skb, tpi.hdr_len, tpi.proto,
+ false, false);
+ if (reason)
goto drop;
if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
tpi.proto == htons(ETH_P_ERSPAN2))) {
- if (ip6erspan_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+ reason = ip6erspan_rcv(skb, &tpi, tpi.hdr_len);
+ if (!reason)
return 0;
goto out;
}
- if (ip6gre_rcv(skb, &tpi) == PACKET_RCVD)
+ reason = ip6gre_rcv(skb, &tpi);
+ if (!reason)
return 0;
out:
icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
drop:
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -674,10 +680,10 @@ static int prepare_ip6gre_xmit_ipv6(struct sk_buff *skb,
return 0;
}
-static int prepare_ip6gre_xmit_other(struct sk_buff *skb,
- struct net_device *dev,
- struct flowi6 *fl6, __u8 *dsfield,
- int *encap_limit)
+static void prepare_ip6gre_xmit_other(struct sk_buff *skb,
+ struct net_device *dev,
+ struct flowi6 *fl6, __u8 *dsfield,
+ int *encap_limit)
{
struct ip6_tnl *t = netdev_priv(dev);
@@ -697,8 +703,6 @@ static int prepare_ip6gre_xmit_other(struct sk_buff *skb,
fl6->flowi6_mark = t->parms.fwmark;
fl6->flowi6_uid = sock_net_uid(dev_net(dev), NULL);
-
- return 0;
}
static struct ip_tunnel_info *skb_tunnel_info_txcheck(struct sk_buff *skb)
@@ -712,10 +716,10 @@ static struct ip_tunnel_info *skb_tunnel_info_txcheck(struct sk_buff *skb)
return tun_info;
}
-static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
- struct net_device *dev, __u8 dsfield,
- struct flowi6 *fl6, int encap_limit,
- __u32 *pmtu, __be16 proto)
+static enum skb_drop_reason __gre6_xmit(struct sk_buff *skb,
+ struct net_device *dev, __u8 dsfield,
+ struct flowi6 *fl6, int encap_limit,
+ __u32 *pmtu, __be16 proto)
{
struct ip6_tnl *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
@@ -740,7 +744,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
tun_info = skb_tunnel_info_txcheck(skb);
if (IS_ERR(tun_info) ||
unlikely(ip_tunnel_info_af(tun_info) != AF_INET6))
- return -EINVAL;
+ return SKB_DROP_REASON_TUNNEL_TXINFO;
key = &tun_info->key;
memset(fl6, 0, sizeof(*fl6));
@@ -759,7 +763,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
tun_hlen = gre_calc_hlen(flags);
if (skb_cow_head(skb, dev->needed_headroom ?: tun_hlen + tunnel->encap_hlen))
- return -ENOMEM;
+ return SKB_DROP_REASON_NOMEM;
gre_build_header(skb, tun_hlen,
flags, protocol,
@@ -770,7 +774,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
} else {
if (skb_cow_head(skb, dev->needed_headroom ?: tunnel->hlen))
- return -ENOMEM;
+ return SKB_DROP_REASON_NOMEM;
ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
@@ -785,9 +789,11 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
NEXTHDR_GRE);
}
-static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
+static inline enum skb_drop_reason ip6gre_xmit_ipv4(struct sk_buff *skb,
+ struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
+ enum skb_drop_reason reason;
int encap_limit = -1;
struct flowi6 fl6;
__u8 dsfield = 0;
@@ -803,54 +809,56 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
err = gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
t->parms.o_flags));
if (err)
- return -1;
+ return SKB_DROP_REASON_NOMEM;
- err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- skb->protocol);
- if (err != 0) {
+ reason = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ skb->protocol);
+ if (reason) {
/* XXX: send ICMP error even if DF is not set. */
- if (err == -EMSGSIZE)
+ if (reason == SKB_DROP_REASON_PKT_TOO_BIG)
icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
htonl(mtu));
- return -1;
+ return reason;
}
- return 0;
+ return SKB_NOT_DROPPED_YET;
}
-static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
+static inline enum skb_drop_reason ip6gre_xmit_ipv6(struct sk_buff *skb,
+ struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
struct ipv6hdr *ipv6h = ipv6_hdr(skb);
+ enum skb_drop_reason reason;
int encap_limit = -1;
struct flowi6 fl6;
__u8 dsfield = 0;
__u32 mtu;
- int err;
if (ipv6_addr_equal(&t->parms.raddr, &ipv6h->saddr))
- return -1;
+ return SKB_DROP_REASON_RECURSION_LIMIT;
if (!t->parms.collect_md &&
prepare_ip6gre_xmit_ipv6(skb, dev, &fl6, &dsfield, &encap_limit))
- return -1;
+ return SKB_DROP_REASON_IPV6_BAD_EXTHDR;
if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
t->parms.o_flags)))
- return -1;
+ return SKB_DROP_REASON_NOMEM;
- err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit,
- &mtu, skb->protocol);
- if (err != 0) {
- if (err == -EMSGSIZE)
+ reason = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit,
+ &mtu, skb->protocol);
+ if (reason) {
+ if (reason == SKB_DROP_REASON_PKT_TOO_BIG)
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
- return -1;
+ return reason;
}
- return 0;
+ return SKB_NOT_DROPPED_YET;
}
-static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)
+static enum skb_drop_reason ip6gre_xmit_other(struct sk_buff *skb,
+ struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
int encap_limit = -1;
@@ -859,32 +867,35 @@ static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)
__u32 mtu;
int err;
- if (!t->parms.collect_md &&
- prepare_ip6gre_xmit_other(skb, dev, &fl6, &dsfield, &encap_limit))
- return -1;
+ if (!t->parms.collect_md)
+ prepare_ip6gre_xmit_other(skb, dev, &fl6,
+ &dsfield, &encap_limit);
err = gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
t->parms.o_flags));
if (err)
- return err;
- err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu, skb->protocol);
+ return SKB_DROP_REASON_NOMEM;
- return err;
+ return __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ skb->protocol);
}
static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel_info *tun_info = NULL;
struct ip6_tnl *t = netdev_priv(dev);
__be16 payload_protocol;
- int ret;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto tx_err;
- if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
+ if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr)) {
+ reason = SKB_DROP_REASON_DEV_READY;
goto tx_err;
+ }
if (t->parms.collect_md)
tun_info = skb_tunnel_info_txcheck(skb);
@@ -892,17 +903,17 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
payload_protocol = skb_protocol(skb, true);
switch (payload_protocol) {
case htons(ETH_P_IP):
- ret = ip6gre_xmit_ipv4(skb, dev);
+ reason = ip6gre_xmit_ipv4(skb, dev);
break;
case htons(ETH_P_IPV6):
- ret = ip6gre_xmit_ipv6(skb, dev);
+ reason = ip6gre_xmit_ipv6(skb, dev);
break;
default:
- ret = ip6gre_xmit_other(skb, dev);
+ reason = ip6gre_xmit_other(skb, dev);
break;
}
- if (ret < 0)
+ if (reason)
goto tx_err;
return NETDEV_TX_OK;
@@ -911,13 +922,14 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
if (!IS_ERR(tun_info))
DEV_STATS_INC(dev, tx_errors);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NETDEV_TX_OK;
}
static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel_info *tun_info = NULL;
struct ip6_tnl *t = netdev_priv(dev);
struct dst_entry *dst = skb_dst(skb);
@@ -926,23 +938,29 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
int encap_limit = -1;
__u8 dsfield = false;
struct flowi6 fl6;
- int err = -EINVAL;
__be16 proto;
__u32 mtu;
int nhoff;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto tx_err;
- if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
+ if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr)) {
+ reason = SKB_DROP_REASON_DEV_READY;
goto tx_err;
+ }
- if (gre_handle_offloads(skb, false))
+ if (gre_handle_offloads(skb, false)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_err;
+ }
if (skb->len > dev->mtu + dev->hard_header_len) {
- if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+ if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_err;
+ }
truncate = true;
}
@@ -962,8 +980,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
truncate = true;
}
- if (skb_cow_head(skb, dev->needed_headroom ?: t->hlen))
+ if (skb_cow_head(skb, dev->needed_headroom ?: t->hlen)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_err;
+ }
IPCB(skb)->flags = 0;
@@ -977,8 +997,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
tun_info = skb_tunnel_info_txcheck(skb);
if (IS_ERR(tun_info) ||
- unlikely(ip_tunnel_info_af(tun_info) != AF_INET6))
+ unlikely(ip_tunnel_info_af(tun_info) != AF_INET6)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto tx_err;
+ }
key = &tun_info->key;
memset(&fl6, 0, sizeof(fl6));
@@ -990,10 +1012,14 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
dsfield = key->tos;
if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT,
- tun_info->key.tun_flags))
+ tun_info->key.tun_flags)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto tx_err;
- if (tun_info->options_len < sizeof(*md))
+ }
+ if (tun_info->options_len < sizeof(*md)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto tx_err;
+ }
md = ip_tunnel_info_opts(tun_info);
tun_id = tunnel_id_to_key32(key->tun_id);
@@ -1011,6 +1037,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
truncate, false);
proto = htons(ETH_P_ERSPAN2);
} else {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto tx_err;
}
} else {
@@ -1021,11 +1048,16 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
&dsfield, &encap_limit);
break;
case htons(ETH_P_IPV6):
- if (ipv6_addr_equal(&t->parms.raddr, &ipv6_hdr(skb)->saddr))
+ if (ipv6_addr_equal(&t->parms.raddr,
+ &ipv6_hdr(skb)->saddr)) {
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_err;
+ }
if (prepare_ip6gre_xmit_ipv6(skb, dev, &fl6,
- &dsfield, &encap_limit))
+ &dsfield, &encap_limit)) {
+ reason = SKB_DROP_REASON_IPV6_BAD_EXTHDR;
goto tx_err;
+ }
break;
default:
memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
@@ -1044,6 +1076,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
truncate, false);
proto = htons(ETH_P_ERSPAN2);
} else {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto tx_err;
}
@@ -1061,11 +1094,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
if (dst_mtu(dst) > mtu)
dst->ops->update_pmtu(dst, NULL, skb, mtu, false);
}
- err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- NEXTHDR_GRE);
- if (err != 0) {
+ reason = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ NEXTHDR_GRE);
+ if (reason) {
/* XXX: send ICMP error even if DF is not set. */
- if (err == -EMSGSIZE) {
+ if (reason == SKB_DROP_REASON_PKT_TOO_BIG) {
if (skb->protocol == htons(ETH_P_IP))
icmp_ndo_send(skb, ICMP_DEST_UNREACH,
ICMP_FRAG_NEEDED, htonl(mtu));
@@ -1081,7 +1114,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
if (!IS_ERR(tun_info))
DEV_STATS_INC(dev, tx_errors);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NETDEV_TX_OK;
}
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index d5ff50a2ac017..77400a1087af5 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -813,6 +813,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
struct sk_buff *skb),
bool log_ecn_err)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
const struct ipv6hdr *ipv6h;
int nh, err;
@@ -820,15 +821,22 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
test_bit(IP_TUNNEL_CSUM_BIT, tpi->flags)) {
DEV_STATS_INC(tunnel->dev, rx_crc_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OPT_MISMATCH;
goto drop;
}
if (test_bit(IP_TUNNEL_SEQ_BIT, tunnel->parms.i_flags)) {
- if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags) ||
- (tunnel->i_seqno &&
- (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0)) {
+ if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags)) {
DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OPT_MISMATCH;
+ goto drop;
+ }
+ if (tunnel->i_seqno &&
+ (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0) {
+ DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
+ DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OLD_SEQ;
goto drop;
}
tunnel->i_seqno = ntohl(tpi->seq) + 1;
@@ -838,7 +846,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
/* Warning: All skb pointers will be invalidated! */
if (tunnel->dev->type == ARPHRD_ETHER) {
- if (!pskb_may_pull(skb, ETH_HLEN)) {
+ reason = pskb_may_pull_reason(skb, ETH_HLEN);
+ if (reason) {
DEV_STATS_INC(tunnel->dev, rx_length_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
goto drop;
@@ -859,7 +868,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
skb_reset_network_header(skb);
- if (skb_vlan_inet_prepare(skb, true)) {
+ reason = skb_vlan_inet_prepare(skb, true);
+ if (reason) {
DEV_STATS_INC(tunnel->dev, rx_length_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
goto drop;
@@ -881,6 +891,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
if (err > 1) {
DEV_STATS_INC(tunnel->dev, rx_frame_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
goto drop;
}
}
@@ -898,7 +909,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
drop:
if (tun_dst)
dst_release((struct dst_entry *)tun_dst);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -1092,14 +1103,14 @@ EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);
* it.
*
* Return:
- * 0 on success
- * -1 fail
- * %-EMSGSIZE message too big. return mtu in this case.
+ * %SKB_NOT_DROPPED_YET on success, otherwise the drop reason.
+ * %SKB_DROP_REASON_PKT_TOO_BIG means the message is too big, the path MTU
+ * is stored in @pmtu in this case.
**/
-int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
- struct flowi6 *fl6, int encap_limit, __u32 *pmtu,
- __u8 proto)
+enum skb_drop_reason
+ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
+ struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)
{
struct ip6_tnl *t = netdev_priv(dev);
struct net *net = t->net;
@@ -1110,11 +1121,11 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
int err_count, mtu;
unsigned int eth_hlen = t->dev->type == ARPHRD_ETHER ? ETH_HLEN : 0;
unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen;
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
unsigned int max_headroom = psh_hlen;
__be16 payload_protocol;
bool use_cache = false;
u8 hop_limit;
- int err = -1;
payload_protocol = skb_protocol(skb, true);
@@ -1132,13 +1143,17 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
struct neighbour *neigh;
int addr_type;
- if (!skb_dst(skb))
+ if (!skb_dst(skb)) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_err_link_failure;
+ }
neigh = dst_neigh_lookup(skb_dst(skb),
&ipv6_hdr(skb)->daddr);
- if (!neigh)
+ if (!neigh) {
+ reason = SKB_DROP_REASON_NEIGH_CREATEFAIL;
goto tx_err_link_failure;
+ }
addr6 = (struct in6_addr *)&neigh->primary_key;
addr_type = ipv6_addr_type(addr6);
@@ -1151,8 +1166,10 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
} else if (payload_protocol == htons(ETH_P_IP)) {
const struct rtable *rt = skb_rtable(skb);
- if (!rt)
+ if (!rt) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_err_link_failure;
+ }
if (rt->rt_gw_family == AF_INET6)
memcpy(&fl6->daddr, &rt->rt_gw6, sizeof(fl6->daddr));
@@ -1169,8 +1186,10 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
if (use_cache)
dst = dst_cache_get(&t->dst_cache);
- if (!ip6_tnl_xmit_ctl(t, &fl6->saddr, &fl6->daddr))
+ if (!ip6_tnl_xmit_ctl(t, &fl6->saddr, &fl6->daddr)) {
+ reason = SKB_DROP_REASON_DEV_READY;
goto tx_err_link_failure;
+ }
if (!dst) {
route_lookup:
@@ -1179,18 +1198,22 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
dst = ip6_route_output(net, NULL, fl6);
- if (dst->error)
+ if (dst->error) {
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_err_link_failure;
+ }
dst = xfrm_lookup(net, dst, flowi6_to_flowi(fl6), NULL, 0);
if (IS_ERR(dst)) {
- err = PTR_ERR(dst);
dst = NULL;
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_err_link_failure;
}
if (t->parms.collect_md && ipv6_addr_any(&fl6->saddr) &&
ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
- &fl6->daddr, 0, &fl6->saddr))
+ &fl6->daddr, 0, &fl6->saddr)) {
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_err_link_failure;
+ }
ndst = dst;
}
@@ -1200,6 +1223,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
DEV_STATS_INC(dev, collisions);
net_warn_ratelimited("%s: Local routing loop detected!\n",
t->parms.name);
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_err_dst_release;
}
mtu = dst6_mtu(dst) - eth_hlen - psh_hlen - t->tun_hlen;
@@ -1213,7 +1237,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
skb_dst_update_pmtu_no_confirm(skb, mtu);
if (skb->len - t->tun_hlen - eth_hlen > mtu && !skb_is_gso(skb)) {
*pmtu = mtu;
- err = -EMSGSIZE;
+ reason = SKB_DROP_REASON_PKT_TOO_BIG;
goto tx_err_dst_release;
}
@@ -1236,12 +1260,16 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
*/
max_headroom += LL_RESERVED_SPACE(tdev);
- if (skb_cow_head(skb, max_headroom))
+ if (skb_cow_head(skb, max_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_err_dst_release;
+ }
if (t->parms.collect_md) {
- if (t->encap.type != TUNNEL_ENCAP_NONE)
+ if (t->encap.type != TUNNEL_ENCAP_NONE) {
+ reason = SKB_DROP_REASON_TNL_ENCAP;
goto tx_err_dst_release;
+ }
} else {
if (use_cache && ndst)
dst_cache_set_ip6(&t->dst_cache, ndst, &fl6->saddr);
@@ -1264,9 +1292,8 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
+ dst->header_len + t->hlen;
ip_tunnel_adj_headroom(dev, max_headroom);
- err = ip6_tnl_encap(skb, t, &proto, fl6);
- if (err)
- return err;
+ if (ip6_tnl_encap(skb, t, &proto, fl6))
+ return SKB_DROP_REASON_TNL_ENCAP;
if (encap_limit >= 0) {
init_tel_txopt(&opt, encap_limit);
@@ -1283,21 +1310,22 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
ipv6h->saddr = fl6->saddr;
ipv6h->daddr = fl6->daddr;
ip6tunnel_xmit(NULL, skb, dev, 0);
- return 0;
+ return SKB_NOT_DROPPED_YET;
tx_err_link_failure:
DEV_STATS_INC(dev, tx_carrier_errors);
dst_link_failure(skb);
tx_err_dst_release:
dst_release(dst);
- return err;
+ return reason;
}
EXPORT_SYMBOL(ip6_tnl_xmit);
-static inline int
+static inline enum skb_drop_reason
ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
u8 protocol)
{
struct ip6_tnl *t = netdev_priv(dev);
+ enum skb_drop_reason reason;
struct ipv6hdr *ipv6h;
const struct iphdr *iph;
int encap_limit = -1;
@@ -1306,11 +1334,10 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
__u8 dsfield, orig_dsfield;
__u32 mtu;
u8 tproto;
- int err;
tproto = READ_ONCE(t->parms.proto);
if (tproto != protocol && tproto != 0)
- return -1;
+ return SKB_DROP_REASON_UNHANDLED_PROTO;
if (t->parms.collect_md) {
struct ip_tunnel_info *tun_info;
@@ -1319,7 +1346,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
ip_tunnel_info_af(tun_info) != AF_INET6))
- return -1;
+ return SKB_DROP_REASON_TUNNEL_TXINFO;
key = &tun_info->key;
memset(&fl6, 0, sizeof(fl6));
fl6.flowi6_proto = protocol;
@@ -1356,7 +1383,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
if (tel->encap_limit == 0) {
icmpv6_ndo_send(skb, ICMPV6_PARAMPROB,
ICMPV6_HDR_FIELD, offset + 2);
- return -1;
+ return SKB_DROP_REASON_IPV6_BAD_EXTHDR;
}
encap_limit = tel->encap_limit - 1;
}
@@ -1398,15 +1425,15 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
dsfield = INET_ECN_encapsulate(dsfield, orig_dsfield);
if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))
- return -1;
+ return SKB_DROP_REASON_NOMEM;
skb_set_inner_ipproto(skb, protocol);
- err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- protocol);
- if (err != 0) {
+ reason = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ protocol);
+ if (reason) {
/* XXX: send ICMP error even if DF is not set. */
- if (err == -EMSGSIZE)
+ if (reason == SKB_DROP_REASON_PKT_TOO_BIG)
switch (protocol) {
case IPPROTO_IPIP:
icmp_ndo_send(skb, ICMP_DEST_UNREACH,
@@ -1418,20 +1445,21 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
default:
break;
}
- return -1;
+ return reason;
}
- return 0;
+ return SKB_NOT_DROPPED_YET;
}
static netdev_tx_t
ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip6_tnl *t = netdev_priv(dev);
u8 ipproto;
- int ret;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto tx_err;
switch (skb->protocol) {
@@ -1439,19 +1467,22 @@ ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)
ipproto = IPPROTO_IPIP;
break;
case htons(ETH_P_IPV6):
- if (ip6_tnl_addr_conflict(t, ipv6_hdr(skb)))
+ if (ip6_tnl_addr_conflict(t, ipv6_hdr(skb))) {
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_err;
+ }
ipproto = IPPROTO_IPV6;
break;
case htons(ETH_P_MPLS_UC):
ipproto = IPPROTO_MPLS;
break;
default:
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto tx_err;
}
- ret = ipxip6_tnl_xmit(skb, dev, ipproto);
- if (ret < 0)
+ reason = ipxip6_tnl_xmit(skb, dev, ipproto);
+ if (reason)
goto tx_err;
return NETDEV_TX_OK;
@@ -1459,7 +1490,7 @@ ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)
tx_err:
DEV_STATS_INC(dev, tx_errors);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NETDEV_TX_OK;
}
|
| 3/2 | 2026/09/25 05:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30270 output: 46 thoughts: 714 Thoughts: **Analyzing the Networking Code Patch** Okay, so this patch is clearly digging into the networking core. I see it's touching a bunch of files related to GRE and IP tunnels for both IPv4 and IPv6: `dropreason-core.h`, `gre.h`, `ip6_tunnel.h`, `ip_tunnels.h`, and a handful of C files in `net/ipv4` and `net/ipv6`. Right away, my expert spidey-sense is tingling – anytime we're messing with tunnel code, especially around packet handling, error conditions, and flow control, it's worth a very close look. The core of the change seems to be around introducing new drop reasons and updating the receive and transmit paths to utilize `kfree_skb_reason()` and switch return types to the `enum skb_drop_reason`. But wait, I'm not going to just take that at face value. I need to dig deeper. I need to scrutinize these changes for *any* logic changes, potential alterations to error handling, control flow, even subtle changes to return values. This isn't just a refactoring; it's a structural adjustment, and with the drop reasons being changed, there are some implications for how packets are handled when dropped or rejected. And then I remember the crucial guiding principles: Reachability is key. Can this code actually *execute* in a standard virtualized environment like QEMU, or even GCE, using software-emulated devices? Absolutely, we have virtual network devices like GRE, ip6gre, ipip, ip6tnl, and erspan that can be readily created and tested via rtnetlink, sockets, packet sockets, tun/tap, even in syzkaller! This is directly applicable to fuzzing. My brain kicks into high gear. This isn't just a refactoring. Reachable executable code *is* being modified, and that is a core networking component. This patch touches the core of GRE, IPv4/IPv6 tunnels, which are fundamental virtual network devices! With my knowledge of the kernel code, I know this is ripe for fuzzing. According to those principles, I'm thinking this is definitely `WorthFuzzing = true`. Next step: let's go check what Kconfig options are required to enable this functionality. I need to be sure I can actually build and test this stuff properly. |
| 4/2 | 2026/09/25 05:00 | tool | grepper |
0mArgs:{
"Expression": "(NET_IPGRE|IPV6_TUNNEL|NET_FOU|NET_IP_TUNNEL)",
"PathPrefix": "net/"
}Results: {
"Output": "net/ipv4/Kconfig=162=config NET_IPIP\n--\nnet/ipv4/Kconfig-164-\tselect INET_TUNNEL\nnet/ipv4/Kconfig:165:\tselect NET_IP_TUNNEL\nnet/ipv4/Kconfig-166-\thelp\n--\nnet/ipv4/Kconfig-179-\nnet/ipv4/Kconfig:180:config NET_IPGRE_DEMUX\nnet/ipv4/Kconfig-181-\ttristate \"IP: GRE demultiplexer\"\n--\nnet/ipv4/Kconfig-185-\nnet/ipv4/Kconfig:186:config NET_IP_TUNNEL\nnet/ipv4/Kconfig-187-\ttristate\n--\nnet/ipv4/Kconfig-191-\nnet/ipv4/Kconfig:192:config NET_IPGRE\nnet/ipv4/Kconfig-193-\ttristate \"IP: GRE tunnels over IP\"\nnet/ipv4/Kconfig:194:\tdepends on NET_IPGRE_DEMUX\nnet/ipv4/Kconfig:195:\tselect NET_IP_TUNNEL\nnet/ipv4/Kconfig-196-\thelp\n--\nnet/ipv4/Kconfig-206-\nnet/ipv4/Kconfig:207:config NET_IPGRE_BROADCAST\nnet/ipv4/Kconfig-208-\tbool \"IP: broadcast GRE over IP\"\nnet/ipv4/Kconfig:209:\tdepends on IP_MULTICAST \u0026\u0026 NET_IPGRE\nnet/ipv4/Kconfig-210-\thelp\n--\nnet/ipv4/Kconfig=304=config NET_IPVTI\n--\nnet/ipv4/Kconfig-306-\tselect INET_TUNNEL\nnet/ipv4/Kconfig:307:\tselect NET_IP_TUNNEL\nnet/ipv4/Kconfig-308-\tselect XFRM\n--\nnet/ipv4/Kconfig=316=config NET_UDP_TUNNEL\nnet/ipv4/Kconfig-317-\ttristate\nnet/ipv4/Kconfig:318:\tselect NET_IP_TUNNEL\nnet/ipv4/Kconfig-319-\tdefault n\nnet/ipv4/Kconfig-320-\nnet/ipv4/Kconfig:321:config NET_FOU\nnet/ipv4/Kconfig-322-\ttristate \"IP: Foo (IP protocols) over UDP\"\n--\nnet/ipv4/Kconfig-329-\nnet/ipv4/Kconfig:330:config NET_FOU_IP_TUNNELS\nnet/ipv4/Kconfig-331-\tbool \"IP: FOU encapsulation of IP tunnels\"\nnet/ipv4/Kconfig:332:\tdepends on NET_IPIP || NET_IPGRE || IPV6_SIT\nnet/ipv4/Kconfig:333:\tselect NET_FOU\nnet/ipv4/Kconfig-334-\thelp\n--\nnet/ipv4/Makefile=6=obj-y := route.o inetpeer.o protocol.o \\\n--\nnet/ipv4/Makefile-18-\nnet/ipv4/Makefile:19:obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o\nnet/ipv4/Makefile-20-obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o\n--\nnet/ipv4/Makefile=27=fou-y := fou_core.o fou_nl.o fou_bpf.o\nnet/ipv4/Makefile:28:obj-$(CONFIG_NET_FOU) += fou.o\nnet/ipv4/Makefile:29:obj-$(CONFIG_NET_IPGRE_DEMUX) += gre.o\nnet/ipv4/Makefile:30:obj-$(CONFIG_NET_IPGRE) += ip_gre.o\nnet/ipv4/Makefile-31-udp_tunnel-y := udp_tunnel_core.o udp_tunnel_nic.o\n--\nnet/ipv4/fou_core.c=1027=EXPORT_SYMBOL(__gue_build_header);\nnet/ipv4/fou_core.c-1028-\nnet/ipv4/fou_core.c:1029:#ifdef CONFIG_NET_FOU_IP_TUNNELS\nnet/ipv4/fou_core.c-1030-\n--\nnet/ipv4/ip_gre.c=449=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv4/ip_gre.c-453-\nnet/ipv4/ip_gre.c:454:#ifdef CONFIG_NET_IPGRE_BROADCAST\nnet/ipv4/ip_gre.c-455-\tif (ipv4_is_multicast(ip_hdr(skb)-\u003edaddr)) {\n--\nnet/ipv4/ip_gre.c=992=static const struct header_ops ipgre_header_ops = {\n--\nnet/ipv4/ip_gre.c-996-\nnet/ipv4/ip_gre.c:997:#ifdef CONFIG_NET_IPGRE_BROADCAST\nnet/ipv4/ip_gre.c-998-static int ipgre_open(struct net_device *dev)\n--\nnet/ipv4/ip_gre.c=1041=static const struct net_device_ops ipgre_netdev_ops = {\n--\nnet/ipv4/ip_gre.c-1043-\t.ndo_uninit\t\t= ip_tunnel_uninit,\nnet/ipv4/ip_gre.c:1044:#ifdef CONFIG_NET_IPGRE_BROADCAST\nnet/ipv4/ip_gre.c-1045-\t.ndo_open\t\t= ipgre_open,\n--\nnet/ipv4/ip_gre.c=1097=static int ipgre_tunnel_init(struct net_device *dev)\n--\nnet/ipv4/ip_gre.c-1111-\tif (iph-\u003edaddr \u0026\u0026 !tunnel-\u003ecollect_md) {\nnet/ipv4/ip_gre.c:1112:#ifdef CONFIG_NET_IPGRE_BROADCAST\nnet/ipv4/ip_gre.c-1113-\t\tif (ipv4_is_multicast(iph-\u003edaddr)) {\n--\nnet/ipv4/ip_tunnel.c=383=int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n--\nnet/ipv4/ip_tunnel.c-390-\nnet/ipv4/ip_tunnel.c:391:#ifdef CONFIG_NET_IPGRE_BROADCAST\nnet/ipv4/ip_tunnel.c-392-\tif (ipv4_is_multicast(iph-\u003edaddr)) {\n--\nnet/ipv4/udp_offload.c=35=struct udp_tunnel_type_entry {\n--\nnet/ipv4/udp_offload.c-41-\t\t\t IS_ENABLED(CONFIG_VXLAN) * 2 + \\\nnet/ipv4/udp_offload.c:42:\t\t\t IS_ENABLED(CONFIG_NET_FOU) * 2 + \\\nnet/ipv4/udp_offload.c-43-\t\t\t IS_ENABLED(CONFIG_XFRM) * 2)\n--\nnet/ipv6/Kconfig=150=config IPV6_VTI\nnet/ipv6/Kconfig-151-\ttristate \"Virtual (secure) IPv6: tunneling\"\nnet/ipv6/Kconfig:152:\tselect IPV6_TUNNEL\nnet/ipv6/Kconfig:153:\tselect NET_IP_TUNNEL\nnet/ipv6/Kconfig-154-\tselect XFRM\n--\nnet/ipv6/Kconfig=162=config IPV6_SIT\n--\nnet/ipv6/Kconfig-164-\tselect INET_TUNNEL\nnet/ipv6/Kconfig:165:\tselect NET_IP_TUNNEL\nnet/ipv6/Kconfig-166-\tselect IPV6_NDISC_NODETYPE\n--\nnet/ipv6/Kconfig=196=config IPV6_NDISC_NODETYPE\n--\nnet/ipv6/Kconfig-198-\nnet/ipv6/Kconfig:199:config IPV6_TUNNEL\nnet/ipv6/Kconfig-200-\ttristate \"IPv6: IP-in-IPv6 tunnel (RFC2473)\"\n--\nnet/ipv6/Kconfig=210=config IPV6_GRE\nnet/ipv6/Kconfig-211-\ttristate \"IPv6: GRE tunnel\"\nnet/ipv6/Kconfig:212:\tselect IPV6_TUNNEL\nnet/ipv6/Kconfig:213:\tselect NET_IP_TUNNEL\nnet/ipv6/Kconfig:214:\tdepends on NET_IPGRE_DEMUX\nnet/ipv6/Kconfig-215-\thelp\n--\nnet/ipv6/Kconfig=228=config IPV6_FOU\nnet/ipv6/Kconfig-229-\ttristate\nnet/ipv6/Kconfig:230:\tdefault NET_FOU \u0026\u0026 IPV6\nnet/ipv6/Kconfig-231-\nnet/ipv6/Kconfig=232=config IPV6_FOU_TUNNEL\nnet/ipv6/Kconfig-233-\ttristate\nnet/ipv6/Kconfig:234:\tdefault NET_FOU_IP_TUNNELS \u0026\u0026 IPV6_FOU\nnet/ipv6/Kconfig:235:\tselect IPV6_TUNNEL\nnet/ipv6/Kconfig-236-\n--\nnet/ipv6/Makefile=41=obj-$(CONFIG_IPV6_SIT) += sit.o\nnet/ipv6/Makefile:42:obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o\nnet/ipv6/Makefile-43-obj-$(CONFIG_IPV6_GRE) += ip6_gre.o\n--\nnet/ipv6/addrconf.c=3214=static void add_addr(struct inet6_dev *idev, const struct in6_addr *addr,\n--\nnet/ipv6/addrconf.c-3238-\nnet/ipv6/addrconf.c:3239:#if IS_ENABLED(CONFIG_IPV6_SIT) || IS_ENABLED(CONFIG_NET_IPGRE)\nnet/ipv6/addrconf.c-3240-static void add_v4_addrs(struct inet6_dev *idev)\n--\nnet/ipv6/addrconf.c=3525=static void addrconf_sit_config(struct net_device *dev)\n--\nnet/ipv6/addrconf.c-3554-\nnet/ipv6/addrconf.c:3555:#if IS_ENABLED(CONFIG_NET_IPGRE)\nnet/ipv6/addrconf.c-3556-static void addrconf_gre_config(struct net_device *dev)\n--\nnet/ipv6/addrconf.c=3581=static void addrconf_init_auto_addrs(struct net_device *dev)\n--\nnet/ipv6/addrconf.c-3588-#endif\nnet/ipv6/addrconf.c:3589:#if IS_ENABLED(CONFIG_NET_IPGRE)\nnet/ipv6/addrconf.c-3590-\tcase ARPHRD_IPGRE:\n--\nnet/ipv6/af_inet6.c-53-#include \u003cnet/ndisc.h\u003e\nnet/ipv6/af_inet6.c:54:#ifdef CONFIG_IPV6_TUNNEL\nnet/ipv6/af_inet6.c-55-#include \u003cnet/ip6_tunnel.h\u003e\n--\nnet/mpls/Kconfig=26=config MPLS_ROUTING\nnet/mpls/Kconfig-27-\ttristate \"MPLS: routing support\"\nnet/mpls/Kconfig:28:\tdepends on NET_IP_TUNNEL || NET_IP_TUNNEL=n\nnet/mpls/Kconfig-29-\tdepends on SYSCTL\n--\nnet/mpls/af_mpls.c=41=static int ttl_max = 255;\nnet/mpls/af_mpls.c-42-\nnet/mpls/af_mpls.c:43:#if IS_ENABLED(CONFIG_NET_IP_TUNNEL)\nnet/mpls/af_mpls.c-44-static size_t ipgre_mpls_encap_hlen(struct ip_tunnel_encap *e)\n"
} |
| 5/2 | 2026/09/25 05:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34694 output: 29 thoughts: 188 Thoughts: Okay, let's break this down. **Analyzing the Tunneling Code Changes** Alright, so I need to understand what's been touched in this patch. My immediate focus is on the modified files. I see the core header files are updated: `include/net/dropreason-core.h`, `include/net/gre.h`, `include/net/ip6_tunnel.h`, and `include/net/ip_tunnels.h`. These are the foundational bits, so I'll need to pay close attention to those. Then, there are the implementation files. I see `net/ipv4/gre_demux.c`, `net/ipv4/ip_gre.c`, `net/ipv4/ip_tunnel.c`, and `net/ipv4/ip_tunnel_core.c` are updated. My next thought is the conditional compilation. Ah, yes, `gre_demux.c` relies on `CONFIG_NET_IPGRE_DEMUX`, `ip_gre.c` on `CONFIG_NET_IPGRE`, and `ip_tunnel.c` on `CONFIG_NET_IP_TUNNEL`. These configurations are important, as they tell me exactly what scenarios this code path will be active in. I'm especially interested in `ip_tunnel_core.c`, I'll probably spend a bit of time checking how this module is compiled. This will help understand how these changes fit into the broader tunneling architecture and impact different configurations. |
| 6/2 | 2026/09/25 05:00 | tool | grepper |
0mArgs:{
"Expression": "ip_tunnel_core\\.o",
"PathPrefix": "net/"
}Results: {
"Output": "net/ipv4/Makefile=6=obj-y := route.o inetpeer.o protocol.o \\\n--\nnet/ipv4/Makefile-15-\t fib_frontend.o fib_semantics.o fib_trie.o fib_notifier.o \\\nnet/ipv4/Makefile:16:\t inet_fragment.o ping.o ip_tunnel_core.o gre_offload.o \\\nnet/ipv4/Makefile-17-\t metrics.o netlink.o nexthop.o udp_tunnel_stub.o\n"
} |
| 7/2 | 2026/09/25 05:00 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35375 output: 32 thoughts: 217 Thoughts: **Analyzing IP Tunneling Configuration** Okay, so I'm looking at the kernel source and mapping out the IP tunneling components. `net/ipv4/ip_tunnel_core.c` is being built as part of the `obj-y` directives in `net/ipv4/Makefile`. That's expected, but a good starting point. I see `net/ipv6/ip6_gre.c` is compiled conditionally with `CONFIG_IPV6_GRE`, and `net/ipv6/ip6_tunnel.c` relies on `CONFIG_IPV6_TUNNEL`. Time to dig deeper and establish the dependencies and relationships here. Let's break down the dependencies of these configurations and see how they chain together. I'll need to know: * `CONFIG_NET_IPGRE_DEMUX` * `CONFIG_NET_IPGRE` (which depends on `NET_IPGRE_DEMUX` and selects `NET_IP_TUNNEL`) * `CONFIG_IPV6_TUNNEL` (depends on `IPV6`) * `CONFIG_IPV6_GRE` (depends on `NET_IPGRE_DEMUX` and selects `IPV6_TUNNEL` and `NET_IP_TUNNEL`). I need to confirm all of this, especially regarding `IPV6_TUNNEL`, so I'll verify the dependencies listed in `net/ipv6/Kconfig` to ensure my understanding is correct. |
| 8/2 | 2026/09/25 05:01 | tool | grepper |
0mArgs:{
"Expression": "config IPV6_TUNNEL",
"PathPrefix": "net/ipv6/"
}Results: {
"Output": "net/ipv6/Kconfig=196=config IPV6_NDISC_NODETYPE\n--\nnet/ipv6/Kconfig-198-\nnet/ipv6/Kconfig:199:config IPV6_TUNNEL\nnet/ipv6/Kconfig-200-\ttristate \"IPv6: IP-in-IPv6 tunnel (RFC2473)\"\n"
} |
| 9/2 | 2026/09/25 05:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36045 output: 35 thoughts: 23 Thoughts: Okay, here's my take on those lines in `net/ipv6/Kconfig`, summarized as if they're my own thoughts: **Analyzing IPv6 Configuration Options** Alright, time to dive back into the IPv6 configuration options. Let me pinpoint lines 190 through 220 in `net/ipv6/Kconfig`. I'm curious to see what key aspects are defined there, and how they relate to the broader network stack. Based on prior experience, I anticipate this section might touch upon critical features, perhaps those that relate to address configuration, neighbor discovery, or potentially even some of the more advanced security-related items, or aspects around the interaction of IPv6 with other protocols, like MPLS. I know this is a core file so I'm expecting some key configuration elements. Let's see what gems are there, and I need to keep in mind possible areas of interest to update or change. |
| 10/2 | 2026/09/25 05:01 | tool | read-file |
0mArgs:{
"File": "net/ipv6/Kconfig",
"FirstLine": 195,
"LineCount": 30
}Results: {
"Contents": " 195:\t\n 196:\tconfig IPV6_NDISC_NODETYPE\n 197:\t\tbool\n 198:\t\n 199:\tconfig IPV6_TUNNEL\n 200:\t\ttristate \"IPv6: IP-in-IPv6 tunnel (RFC2473)\"\n 201:\t\tselect INET6_TUNNEL\n 202:\t\tselect DST_CACHE\n 203:\t\tselect GRO_CELLS\n 204:\t\thelp\n 205:\t\t Support for IPv6-in-IPv6 and IPv4-in-IPv6 tunnels described in\n 206:\t\t RFC 2473.\n 207:\t\n 208:\t\t If unsure, say N.\n 209:\t\n 210:\tconfig IPV6_GRE\n 211:\t\ttristate \"IPv6: GRE tunnel\"\n 212:\t\tselect IPV6_TUNNEL\n 213:\t\tselect NET_IP_TUNNEL\n 214:\t\tdepends on NET_IPGRE_DEMUX\n 215:\t\thelp\n 216:\t\t Tunneling means encapsulating data of one protocol type within\n 217:\t\t another protocol and sending it over a channel that understands the\n 218:\t\t encapsulating protocol. This particular tunneling driver implements\n 219:\t\t GRE (Generic Routing Encapsulation) and at this time allows\n 220:\t\t encapsulating of IPv4 or IPv6 over existing IPv6 infrastructure.\n 221:\t\t This driver is useful if the other endpoint is a Cisco router: Cisco\n 222:\t\t likes GRE much better than the other Linux tunneling driver (\"IP\n 223:\t\t tunneling\" above). In addition, GRE allows multicast redistribution\n 224:\t\t through the tunnel.\n"
} |
| 11/2 | 2026/09/25 05:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36766 output: 37 thoughts: 1394 Thoughts: **Analyzing the Impact of IPV6 Integration** Okay, let's get down to brass tacks. First, I need to confirm the scope, so I'll quickly check `net/ipv6/Kconfig`. Yup, `menuconfig IPV6` is right at the top, confirming `IPV6` and related configurations like `NET_IPGRE`, `IPV6_GRE`, `IPV6_TUNNEL`, and `NET_IP_TUNNEL` are all under consideration. Excellent, that's the baseline. Now, the real work begins. I need a granular understanding of these changes to pinpoint the relevant FocusSymbols. I'll meticulously go through each modified function in the impacted files. * `net/ipv4/gre_demux.c`: `gre_parse_header`, and `gre_rcv`. Noted. * `net/ipv4/ip_gre.c`: `gre_err`, `erspan_rcv`, `__ipgre_rcv`, `ipgre_rcv`, `gre_rcv`, `gre_fb_xmit`, `erspan_fb_xmit`, `ipgre_xmit`, `erspan_xmit`, `gre_tap_xmit`. A lot of IPV4-related functions here, I'll need to pay extra attention to these. * `net/ipv4/ip_tunnel.c`: `ip_tunnel_rcv`, `ip_md_tunnel_xmit`, `ip_tunnel_xmit`. Seems straightforward. * `net/ipv4/ip_tunnel_core.c`: `__iptunnel_pull_header_reason`. Noted. * `net/ipv6/ip6_gre.c`: `ip6gre_err`, `ip6gre_rcv`, `ip6erspan_rcv`, `gre_rcv`, `prepare_ip6gre_xmit_other`, `__gre6_xmit`, `ip6gre_xmit_ipv4`, `ip6gre_xmit_ipv6`, `ip6gre_xmit_other`, `ip6gre_tunnel_xmit`, `ip6erspan_tunnel_xmit`. Several ipv6 functions here, and some overlap, I need to keep the contexts separate for comparison's sake. * `net/ipv6/ip6_tunnel.c`: `__ip6_tnl_rcv`, `ip6_tnl_xmit`, `ipxip6_tnl_xmit`, `ip6_tnl_start_xmit`. Straightforward. Right, next step is to examine their visibility; are these static or exported symbols? This will shape how they're used and potential downstream impacts. * `gre_parse_header` is exported. * `__iptunnel_pull_header_reason` is exported. * `ip_tunnel_rcv`, `ip_md_tunnel_xmit`, and `ip_tunnel_xmit` are exported. * `ip6_tnl_xmit` is exported. * `ip6gre_tunnel_xmit` is static, used as ndo_start_xmit for ip6gre. * `ip6erspan_tunnel_xmit` is static, used as ndo_start_xmit for ip6erspan. * `ipgre_xmit` is static, used as ndo_start_xmit for ipgre. * `erspan_xmit` is static, used as ndo_start_xmit for erspan. * `gre_tap_xmit` is static, used as ndo_start_xmit for gretap. * `ip6_tnl_start_xmit` is static, used as ndo_start_xmit for ip6_tunnel. Okay, now for the nitty-gritty. Let's dig into the code itself. I'm going to look for subtle behavior changes and potential bugs. I'll start with `net/ipv4/ip_gre.c`. Ah, here we go! It looks like there's a modification in how `gre_parse_header` is used, and the subsequent error handling in the receiver function. Instead of directly checking the returned `hdr_len`, the patch now checks the return value of `gre_parse_header` to catch errors. The return is now interpreted as a `reason`, and errors are dropped appropriately. Now, this piques my interest: `gre_parse_header`'s signature has a boolean argument added, and the code now directly uses the return value |
| 12/2 | 2026/09/25 05:01 | tool | grepper |
0mArgs:{
"Expression": "tpi-\u003ehdr_len",
"PathPrefix": "net/ipv4/gre_demux.c"
}Results: {
"Output": "net/ipv4/gre_demux.c=57=EXPORT_SYMBOL_GPL(gre_del_protocol);\nnet/ipv4/gre_demux.c-58-\nnet/ipv4/gre_demux.c:59:/* Fills in tpi, including the header length to be pulled in tpi-\u003ehdr_len,\nnet/ipv4/gre_demux.c-60- * and returns SKB_NOT_DROPPED_YET, or the reason to drop the packet if the\n--\nnet/ipv4/gre_demux.c=69=gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n--\nnet/ipv4/gre_demux.c-130-\t}\nnet/ipv4/gre_demux.c:131:\ttpi-\u003ehdr_len = hdr_len;\nnet/ipv4/gre_demux.c-132-\n"
} |
| 13/2 | 2026/09/25 05:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39468 output: 39 thoughts: 27 Thoughts: Okay, here's my attempt at summarizing the thought process, as requested, geared toward an expert audience, and in the first person: **Diving into gre_demux.c** Alright, time to get to the heart of this. Let's pull up `net/ipv4/gre_demux.c` and focus on lines 120-155. I know this area deals with GRE demultiplexing, but I need to quickly refresh my understanding of *precisely* how it handles the ingress path. My intuition is that this section likely contains the primary logic for identifying and dispatching incoming GRE packets to the appropriate network namespace or device. I expect to see checks for GRE key, source and destination IP addresses, and potentially some kind of tunnel ID lookup. I'm looking for the core of the decision-making process here. This probably involves a hash table lookup or a more sophisticated forwarding table traversal. I'm mentally parsing this code for any red flags related to potential performance bottlenecks or subtle security vulnerabilities – especially related to resource exhaustion or crafted packets that could bypass these checks. I'll be looking for efficient use of memory and computational resources, as well as a robust error-handling strategy that prevents DoS attacks. I want to see how it manages the various encapsulation and decapsulation options, and I need to figure out how it handles any type of fragmenting or reassembly in the mix. |
| 14/2 | 2026/09/25 05:01 | tool | read-file |
0mArgs:{
"File": "net/ipv4/gre_demux.c",
"FirstLine": 120,
"LineCount": 35
}Results: {
"Contents": " 120:\t\tif (greh-\u003eflags == 0 \u0026\u0026 tpi-\u003eproto == htons(ETH_P_WCCP)) {\n 121:\t\t\tu8 _val, *val;\n 122:\t\n 123:\t\t\tval = skb_header_pointer(skb, nhs + hdr_len,\n 124:\t\t\t\t\t\t sizeof(_val), \u0026_val);\n 125:\t\t\tif (!val)\n 126:\t\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n 127:\t\t\ttpi-\u003eproto = proto;\n 128:\t\t\tif ((*val \u0026 0xF0) != 0x40)\n 129:\t\t\t\thdr_len += 4;\n 130:\t\t}\n 131:\t\ttpi-\u003ehdr_len = hdr_len;\n 132:\t\n 133:\t\t/* ERSPAN ver 1 and 2 protocol sets GRE key field\n 134:\t\t * to 0 and sets the configured key in the\n 135:\t\t * inner erspan header field\n 136:\t\t */\n 137:\t\tif ((greh-\u003eprotocol == htons(ETH_P_ERSPAN) \u0026\u0026 hdr_len != 4) ||\n 138:\t\t greh-\u003eprotocol == htons(ETH_P_ERSPAN2)) {\n 139:\t\t\tstruct erspan_base_hdr *ershdr;\n 140:\t\n 141:\t\t\tif (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))\n 142:\t\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n 143:\t\n 144:\t\t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + nhs + hdr_len);\n 145:\t\t\ttpi-\u003ekey = cpu_to_be32(get_session_id(ershdr));\n 146:\t\t}\n 147:\t\n 148:\t\treturn SKB_NOT_DROPPED_YET;\n 149:\t}\n 150:\tEXPORT_SYMBOL(gre_parse_header);\n 151:\t\n 152:\tstatic int gre_rcv(struct sk_buff *skb)\n 153:\t{\n 154:\t\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n"
} |
| 15/2 | 2026/09/25 05:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40442 output: 19 thoughts: 3266 Thoughts: **Analysis of GRE Receive Path and Potential Double-Free Vulnerability** Okay, let's break this down systematically. I'm focusing on the `gre_rcv` function and the potential for a double-free issue, and the interaction between the IPv4 and IPv6 implementations. My initial concern was centered around the handling of ERSPAN packets and the use of `__iptunnel_pull_header_reason` and `kfree_skb_reason`. First, I examined the IPv6 path in `net/ipv6/ip6_gre.c`. In `gre_rcv`, `gre_parse_header` is called. Critically, it returns an `enum skb_drop_reason` now. If this initial parse fails, the `skb` is dropped. Then, if the protocol is ERSPAN, the code calls `ip6erspan_rcv`. Here's where it got interesting. `__iptunnel_pull_header_reason` is *already* called prior to `ip6erspan_rcv` in `gre_rcv`, but `ip6erspan_rcv` itself *also* checks for and attempts to pull a header. This initially seemed redundant, but in the IPv6 case the `ip6erspan_rcv` does not call `kfree_skb_reason` directly when it fails. Then I shifted my focus to `net/ipv4/ip_gre.c`, specifically `erspan_rcv` in the IPv4 implementation. This is where I found the key difference. The IPv4 version of `erspan_rcv` *does* call `__iptunnel_pull_header_reason` and, on failure, returns `SKB_NOT_DROPPED_YET`, which is 0. However, `kfree_skb_reason` is performed in that same branch. This is significant because the original code *did not* call `kfree_skb`. This meant the `skb` *could* have been dropped or freed in `erspan_rcv`, and then potentially freed again later, for example in `gre_rcv`, in the `drop:` path. I then followed the path. I verified that if the `reason` is non-zero (indicating a failure in `__iptunnel_pull_header_reason` in `erspan_rcv`), the `skb` is freed with `kfree_skb_reason` and then `0` is returned. So, the original vulnerability that I was concerned about *was* avoided because the `skb` is freed in the failure path of `erspan_rcv`, before `gre_rcv` can act on it. Then I verified the path for `ipgre_rcv`. If `ipgre_rcv` returns `SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND` and it is an ERSPAN tunnel, it tries a second time with another tunnel context. I then revisited the IPv6 implementation. The failure paths in `ip6erspan_rcv` do *not* call `kfree_skb_reason` directly, but rather return a reason code. This means that if `ip6erspan_rcv` returns a failure, the control flow goes back to `gre_rcv`, which then jumps to the `drop` label. From `drop`, the `skb` will finally be cleaned up, preventing the double free. Also, `icmpv6_send` would be called if the `pskb_may_pull` fails or the tunnel is not found. Finally, I checked cases where `tun_dst` is NULL (no tunnel) and confirmed that the correct `SKB_DROP_REASON` is returned, leading to a single free, and not a double free. Overall, my analysis showed that the current code avoids double frees, although there is considerable branching in the control paths. |
| 16/2 | 2026/09/25 05:01 | tool | grepper |
0mArgs:{
"Expression": "gre_parse_header"
}Results: {
"Output": "include/net/gre.h=35=enum skb_drop_reason\ninclude/net/gre.h:36:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\ninclude/net/gre.h-37-\t\t bool icmp_err, __be16 proto, int nhs);\n--\nnet/ipv4/gre_demux.c=68=enum skb_drop_reason\nnet/ipv4/gre_demux.c:69:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\nnet/ipv4/gre_demux.c-70-\t\t bool icmp_err, __be16 proto, int nhs)\n--\nnet/ipv4/gre_demux.c-149-}\nnet/ipv4/gre_demux.c:150:EXPORT_SYMBOL(gre_parse_header);\nnet/ipv4/gre_demux.c-151-\n--\nnet/ipv4/ip_gre.c=219=static void gre_err(struct sk_buff *skb, u32 info)\n--\nnet/ipv4/ip_gre.c-239-\nnet/ipv4/ip_gre.c:240:\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IP),\nnet/ipv4/ip_gre.c-241-\t\t\t iph-\u003eihl * 4))\n--\nnet/ipv4/ip_gre.c=449=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv4/ip_gre.c-461-\nnet/ipv4/ip_gre.c:462:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IP), 0);\nnet/ipv4/ip_gre.c-463-\tif (reason)\n--\nnet/ipv6/ip6_gre.c=384=static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n--\nnet/ipv6/ip6_gre.c-391-\nnet/ipv6/ip6_gre.c:392:\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IPV6),\nnet/ipv6/ip6_gre.c-393-\t\t\t offset))\n--\nnet/ipv6/ip6_gre.c=570=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-574-\nnet/ipv6/ip6_gre.c:575:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\nnet/ipv6/ip6_gre.c-576-\tif (reason)\n"
} |
| 17/2 | 2026/09/25 05:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 45326 output: 21 thoughts: 63 Thoughts: Here's my thought process, as if I were reviewing this code: **Checking Header Parsing Consistency** Okay, so I've updated all the callers of `gre_parse_header`. Good. But wait a minute... We're dealing with tunnel headers here, and these are likely interrelated. Before I move on, I *need* to be absolutely sure that the changes I've made don't introduce any regressions or inconsistencies. Let's see... I should also verify the use of the lower level header pulling functions. I'll need to check the other callers of `__iptunnel_pull_header` and, importantly, `__iptunnel_pull_header_reason`. These are critical, and I need to confirm that any changes I introduced are correctly reflected downstream, and that nothing was missed. I'll pull out the big guns: a quick grep of the entire codebase for `__iptunnel_pull_header`. That should give me a comprehensive view of *every* instance, ensuring I haven't overlooked any integration points. No stone left unturned here! |
| 18/2 | 2026/09/25 05:01 | tool | grepper |
0mArgs:{
"Expression": "__iptunnel_pull_header"
}Results: {
"Output": "drivers/net/vxlan/vxlan_core.c=1657=static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/vxlan/vxlan_core.c-1722-\ndrivers/net/vxlan/vxlan_core.c:1723:\tif (__iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,\ndrivers/net/vxlan/vxlan_core.c-1724-\t\t\t\t !net_eq(vxlan-\u003enet, dev_net(vxlan-\u003edev)))) {\n--\ninclude/net/ip_tunnels.h=613=enum skb_drop_reason\ninclude/net/ip_tunnels.h:614:__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-615-\t\t\t __be16 inner_proto, bool raw_proto, bool xnet);\ninclude/net/ip_tunnels.h-616-\ninclude/net/ip_tunnels.h:617:static inline int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-618-\t\t\t\t\t __be16 inner_proto, bool raw_proto,\n--\ninclude/net/ip_tunnels.h-620-{\ninclude/net/ip_tunnels.h:621:\treturn __iptunnel_pull_header_reason(skb, hdr_len, inner_proto,\ninclude/net/ip_tunnels.h-622-\t\t\t\t\t raw_proto, xnet) ? -ENOMEM : 0;\n--\ninclude/net/ip_tunnels.h=625=static inline int iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n--\ninclude/net/ip_tunnels.h-627-{\ninclude/net/ip_tunnels.h:628:\treturn __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);\ninclude/net/ip_tunnels.h-629-}\n--\ninclude/net/udp.h=632=static inline void udp_post_segment_fix_csum(struct sk_buff *skb)\n--\ninclude/net/udp.h-638-\t * can reach an UDP socket with CHECKSUM_NONE, because\ninclude/net/udp.h:639:\t * __iptunnel_pull_header() converts CHECKSUM_PARTIAL into NONE.\ninclude/net/udp.h-640-\t * SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST packets with no UDP tunnel will\n--\nnet/ipv4/ip_gre.c=267=static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-313-\nnet/ipv4/ip_gre.c:314:\t\treason = __iptunnel_pull_header_reason(skb, len,\nnet/ipv4/ip_gre.c-315-\t\t\t\t\t\t htons(ETH_P_TEB),\n--\nnet/ipv4/ip_gre.c-338-\nnet/ipv4/ip_gre.c:339:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv4/ip_gre.c-340-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv4/ip_gre.c=368=static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-384-\nnet/ipv4/ip_gre.c:385:\t\treason = __iptunnel_pull_header_reason(skb, hdr_len,\nnet/ipv4/ip_gre.c-386-\t\t\t\t\t\t tpi-\u003eproto, raw_proto,\n--\nnet/ipv4/ip_tunnel_core.c=109=enum skb_drop_reason\nnet/ipv4/ip_tunnel_core.c:110:__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,\nnet/ipv4/ip_tunnel_core.c-111-\t\t\t __be16 inner_proto, bool raw_proto, bool xnet)\n--\nnet/ipv4/ip_tunnel_core.c-147-}\nnet/ipv4/ip_tunnel_core.c:148:EXPORT_SYMBOL_GPL(__iptunnel_pull_header_reason);\nnet/ipv4/ip_tunnel_core.c-149-\n--\nnet/ipv6/ip6_gre.c=488=static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-514-\nnet/ipv6/ip6_gre.c:515:\t\treason = __iptunnel_pull_header_reason(skb, len,\nnet/ipv6/ip6_gre.c-516-\t\t\t\t\t\t htons(ETH_P_TEB),\n--\nnet/ipv6/ip6_gre.c-541-\nnet/ipv6/ip6_gre.c:542:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv6/ip6_gre.c-543-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv6/ip6_gre.c=570=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-578-\nnet/ipv6/ip6_gre.c:579:\treason = __iptunnel_pull_header_reason(skb, tpi.hdr_len, tpi.proto,\nnet/ipv6/ip6_gre.c-580-\t\t\t\t\t false, false);\n"
} |
| 19/2 | 2026/09/25 05:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 47170 output: 22 thoughts: 36 Thoughts: Here's my take on the thought process, as requested: **Diving into `ip6_tnl_xmit`** Okay, time to get my hands dirty. Let's see what's happening with `ip6_tnl_xmit`. I need a clear picture of its role and how it's being used. The best way to understand this is to trace its usage. I'll need to identify all the callers of `ip6_tnl_xmit` throughout the codebase. Understanding where it's being *called* will give me invaluable insight into its function and how it fits into the larger architecture. Let's get to work and map out those dependencies. |
| 20/2 | 2026/09/25 05:01 | tool | grepper |
0mArgs:{
"Expression": "ip6_tnl_xmit"
}Results: {
"Output": "drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c=524=mlxsw_sp_span_gretap6_route(const struct net_device *to_dev,\n--\ndrivers/net/ethernet/mellanox/mlxsw/spectrum_span.c-537-\tfl6.flowi6_mark = t-\u003eparms.fwmark;\ndrivers/net/ethernet/mellanox/mlxsw/spectrum_span.c:538:\tif (!ip6_tnl_xmit_ctl(t, \u0026fl6.saddr, \u0026fl6.daddr))\ndrivers/net/ethernet/mellanox/mlxsw/spectrum_span.c-539-\t\treturn NULL;\n--\ninclude/net/ip6_tunnel.h=141=int ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n--\ninclude/net/ip6_tunnel.h-143-\t\tbool log_ecn_error);\ninclude/net/ip6_tunnel.h:144:int ip6_tnl_xmit_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,\ninclude/net/ip6_tunnel.h-145-\t\t const struct in6_addr *raddr);\ninclude/net/ip6_tunnel.h=146=enum skb_drop_reason\ninclude/net/ip6_tunnel.h:147:ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\ninclude/net/ip6_tunnel.h-148-\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);\n--\nnet/ipv6/ip6_gre.c=719=static enum skb_drop_reason __gre6_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-787-\nnet/ipv6/ip6_gre.c:788:\treturn ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,\nnet/ipv6/ip6_gre.c-789-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_gre.c=883=static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-894-\nnet/ipv6/ip6_gre.c:895:\tif (!ip6_tnl_xmit_ctl(t, \u0026t-\u003eparms.laddr, \u0026t-\u003eparms.raddr)) {\nnet/ipv6/ip6_gre.c-896-\t\treason = SKB_DROP_REASON_DEV_READY;\n--\nnet/ipv6/ip6_gre.c=929=static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-948-\nnet/ipv6/ip6_gre.c:949:\tif (!ip6_tnl_xmit_ctl(t, \u0026t-\u003eparms.laddr, \u0026t-\u003eparms.raddr)) {\nnet/ipv6/ip6_gre.c-950-\t\treason = SKB_DROP_REASON_DEV_READY;\n--\nnet/ipv6/ip6_gre.c-1096-\t}\nnet/ipv6/ip6_gre.c:1097:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_gre.c-1098-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_tunnel.c=1048=ip6_tnl_addr_conflict(const struct ip6_tnl *t, const struct ipv6hdr *hdr)\n--\nnet/ipv6/ip6_tunnel.c-1052-\nnet/ipv6/ip6_tunnel.c:1053:int ip6_tnl_xmit_ctl(struct ip6_tnl *t,\nnet/ipv6/ip6_tunnel.c-1054-\t\t const struct in6_addr *laddr,\n--\nnet/ipv6/ip6_tunnel.c-1088-}\nnet/ipv6/ip6_tunnel.c:1089:EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);\nnet/ipv6/ip6_tunnel.c-1090-\nnet/ipv6/ip6_tunnel.c-1091-/**\nnet/ipv6/ip6_tunnel.c:1092: * ip6_tnl_xmit - encapsulate packet and send\nnet/ipv6/ip6_tunnel.c-1093- * @skb: the outgoing socket buffer\n--\nnet/ipv6/ip6_tunnel.c=1111=enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1112:ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\nnet/ipv6/ip6_tunnel.c-1113-\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)\n--\nnet/ipv6/ip6_tunnel.c-1188-\nnet/ipv6/ip6_tunnel.c:1189:\tif (!ip6_tnl_xmit_ctl(t, \u0026fl6-\u003esaddr, \u0026fl6-\u003edaddr)) {\nnet/ipv6/ip6_tunnel.c-1190-\t\treason = SKB_DROP_REASON_DEV_READY;\n--\nnet/ipv6/ip6_tunnel.c-1320-}\nnet/ipv6/ip6_tunnel.c:1321:EXPORT_SYMBOL(ip6_tnl_xmit);\nnet/ipv6/ip6_tunnel.c-1322-\nnet/ipv6/ip6_tunnel.c=1323=static inline enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1324:ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\nnet/ipv6/ip6_tunnel.c-1325-\t\tu8 protocol)\n--\nnet/ipv6/ip6_tunnel.c-1431-\nnet/ipv6/ip6_tunnel.c:1432:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_tunnel.c-1433-\t\t\t protocol);\n--\nnet/ipv6/ip6_tunnel.c=1455=ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n--\nnet/ipv6/ip6_tunnel.c-1483-\nnet/ipv6/ip6_tunnel.c:1484:\treason = ipxip6_tnl_xmit(skb, dev, ipproto);\nnet/ipv6/ip6_tunnel.c-1485-\tif (reason)\n--\nnet/ipv6/ip6_vti.c=443=vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)\n--\nnet/ipv6/ip6_vti.c-497-\nnet/ipv6/ip6_vti.c:498:\tif (!ip6_tnl_xmit_ctl(t, (const struct in6_addr *)\u0026x-\u003eprops.saddr,\nnet/ipv6/ip6_vti.c-499-\t\t\t (const struct in6_addr *)\u0026x-\u003eid.daddr))\n"
} |
| 21/2 | 2026/09/25 05:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49404 output: 39 thoughts: 363 Thoughts: **My Analysis of the Code Changes** Okay, everything compiled and linked without issues, so we're good there. Now, let's see about WorthFuzzing; is this actually a good candidate for fuzzing? Absolutely, yes. The changes hit core network tunnel code, specifically GRE, IPv4 tunnel, and IPv6 tunnel implementations. Crucially, it's restructuring return values, error handling, and skb dropping logic in reachable networking paths. This sounds perfect. The real win here is that these virtual network devices – GRE, gretap, ip6gre, ip6gretap, ip6tnl, erspan – are createable through both netlink (RTM_NEWLINK) and ioctl, even within unprivileged namespaces. That's a huge accessibility win for fuzzing. We can create the devices, send/receive packets. Easy. Now, let's focus in on which specific symbols have been altered or are implementing this new logic. Looking for non-ubiquitous, specific feature logic: We have `gre_parse_header`, `ip_tunnel_rcv`, `ip_tunnel_xmit`, `ip_md_tunnel_xmit`, `__iptunnel_pull_header_reason`, `ip6_tnl_rcv`, `ip6_tnl_xmit`, `ip6_tnl_start_xmit`, `ipgre_xmit`, `ip6gre_tunnel_xmit`, `ip6erspan_tunnel_xmit`, and `erspan_xmit`. Wait a second, is `ip6_tnl_rcv` actually modified? Let me double-check. I'll need to confirm if it's explicitly altered, or if it is being called from another function that has been changed, like `__ip6_tnl_rcv`... Let me just check if `ip6_tnl_rcv` is static or exported... |
| 22/2 | 2026/09/25 05:01 | tool | grepper |
0mArgs:{
"Expression": "ip6_tnl_rcv",
"PathPrefix": "net/ipv6/ip6_tunnel.c"
}Results: {
"Output": "net/ipv6/ip6_tunnel.c=777=EXPORT_SYMBOL(ip6_tnl_get_cap);\n--\nnet/ipv6/ip6_tunnel.c-779-/* called with rcu_read_lock() */\nnet/ipv6/ip6_tunnel.c:780:int ip6_tnl_rcv_ctl(struct ip6_tnl *t,\nnet/ipv6/ip6_tunnel.c-781-\t\t\t\t const struct in6_addr *laddr,\n--\nnet/ipv6/ip6_tunnel.c-805-}\nnet/ipv6/ip6_tunnel.c:806:EXPORT_SYMBOL_GPL(ip6_tnl_rcv_ctl);\nnet/ipv6/ip6_tunnel.c-807-\nnet/ipv6/ip6_tunnel.c:808:static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\nnet/ipv6/ip6_tunnel.c-809-\t\t\t const struct tnl_ptk_info *tpi,\n--\nnet/ipv6/ip6_tunnel.c-915-\nnet/ipv6/ip6_tunnel.c:916:int ip6_tnl_rcv(struct ip6_tnl *t, struct sk_buff *skb,\nnet/ipv6/ip6_tunnel.c-917-\t\tconst struct tnl_ptk_info *tpi,\n--\nnet/ipv6/ip6_tunnel.c-928-\nnet/ipv6/ip6_tunnel.c:929:\treturn __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,\nnet/ipv6/ip6_tunnel.c-930-\t\t\t log_ecn_err);\nnet/ipv6/ip6_tunnel.c-931-}\nnet/ipv6/ip6_tunnel.c:932:EXPORT_SYMBOL(ip6_tnl_rcv);\nnet/ipv6/ip6_tunnel.c-933-\n--\nnet/ipv6/ip6_tunnel.c=949=static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n--\nnet/ipv6/ip6_tunnel.c-970-\t\tipv6h = ipv6_hdr(skb);\nnet/ipv6/ip6_tunnel.c:971:\t\tif (!ip6_tnl_rcv_ctl(t, \u0026ipv6h-\u003edaddr, \u0026ipv6h-\u003esaddr))\nnet/ipv6/ip6_tunnel.c-972-\t\t\tgoto drop;\n--\nnet/ipv6/ip6_tunnel.c-981-\t\t}\nnet/ipv6/ip6_tunnel.c:982:\t\tret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,\nnet/ipv6/ip6_tunnel.c-983-\t\t\t\t log_ecn_error);\n"
} |
| 23/2 | 2026/09/25 05:01 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51009 output: 297 thoughts: 867 Thoughts: **Analyzing Tunneling Code for Fuzzing Scope** Alright, let's break this down. First, I need to identify the key functions involved in the IPv4 and IPv6 GRE/IP tunnel implementations. I see them spread across several files: `ip_gre.c`, `ip6_gre.c`, `gre_demux.c`, `ip_tunnel.c`, `ip_tunnel_core.c`, and `ip6_tunnel.c`. The core functions are the `xmit` and `rcv` paths, along with header parsing and tunnel start functions. Specifically, I'm noting functions like `ipgre_xmit`, `gre_rcv`, `ip6gre_tunnel_xmit`, `gre_parse_header`, `ip_tunnel_rcv`, and others like `ip6_tnl_xmit`. The full list of focused symbols seems comprehensive, hitting both the IPv4 and IPv6 transmit, receive, and processing logic. Now, let's confirm the necessary kernel configuration options. To enable these features, I need to ensure that `NET_IPGRE_DEMUX`, `NET_IP_TUNNEL`, `NET_IPGRE`, `IPV6`, `IPV6_TUNNEL`, and `IPV6_GRE` are all enabled. A quick check of dependencies confirms the relationships: `NET_IPGRE` requires `NET_IPGRE_DEMUX`, and selects `NET_IP_TUNNEL`. `IPV6_GRE` depends on `NET_IPGRE_DEMUX`, and selects `IPV6_TUNNEL` and `NET_IP_TUNNEL`. `IPV6_TUNNEL` depends on `IPV6`. This is important because any fuzzing campaign needs to be able to exercise these paths. The reasoning here is straightforward: this patch is updating critical tunnel path code, adding explicit `skb_drop_reason` codes for packet handling during encapsulation and de-capsulation. This code touches core network protocol logic as well as virtual network device functionality. Given the configuration options, this could very well be exercised in virtualized and cloud environments. It's a prime target for fuzzing because errors here can result in dropped packets and potential vulnerabilities. These are all non-ubiquitous, directly altered functions in core networking tunnel code. Time to call `set-results`. |
| 24/2 | 2026/09/25 05:01 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"NET_IPGRE",
"NET_IPGRE_DEMUX",
"NET_IP_TUNNEL",
"IPV6",
"IPV6_TUNNEL",
"IPV6_GRE"
],
"FocusSymbols": [
"gre_parse_header",
"ip_tunnel_rcv",
"ip_tunnel_xmit",
"ip_md_tunnel_xmit",
"__iptunnel_pull_header_reason",
"ip6_tnl_xmit",
"ip6_tnl_rcv",
"ip6_tnl_start_xmit",
"ipgre_xmit",
"ip6gre_tunnel_xmit",
"ip6erspan_tunnel_xmit",
"erspan_xmit"
],
"Reasoning": "The patch introduces multiple new skb drop reasons and refactors packet parsing, encapsulation, transmission, and reception error paths across IPv4/IPv6 GRE and IP tunneling drivers (gre_demux, ip_gre, ip6_gre, ip_tunnel, and ip6_tunnel). These virtual tunnel devices and protocols are fully reachable in virtualized QEMU environments via netlink and packet/socket interfaces, so fuzzing is warranted to test the altered control flow and error paths.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"NET_IPGRE",
"NET_IPGRE_DEMUX",
"NET_IP_TUNNEL",
"IPV6",
"IPV6_TUNNEL",
"IPV6_GRE"
],
"FocusSymbols": [
"gre_parse_header",
"ip_tunnel_rcv",
"ip_tunnel_xmit",
"ip_md_tunnel_xmit",
"__iptunnel_pull_header_reason",
"ip6_tnl_xmit",
"ip6_tnl_rcv",
"ip6_tnl_start_xmit",
"ipgre_xmit",
"ip6gre_tunnel_xmit",
"ip6erspan_tunnel_xmit",
"erspan_xmit"
],
"Reasoning": "The patch introduces multiple new skb drop reasons and refactors packet parsing, encapsulation, transmission, and reception error paths across IPv4/IPv6 GRE and IP tunneling drivers (gre_demux, ip_gre, ip6_gre, ip_tunnel, and ip6_tunnel). These virtual tunnel devices and protocols are fully reachable in virtualized QEMU environments via netlink and packet/socket interfaces, so fuzzing is warranted to test the altered control flow and error paths.",
"WorthFuzzing": true
} |
| 25/1 | 2026/09/25 05:01 | action | If |
1mArgs:{
"WorthFuzzing": true
}Results: null |
| 26/2 | 2026/09/25 05:01 | agent | kmsan-evaluator |
1mModel:core Args: null Results: {
"KMSANReasoning": "The patch series refactors packet drop handling across GRE, ERSPAN, and IPv4/IPv6 tunnel code (in net/ipv4 and net/ipv6) to supply specific drop reasons to kfree_skb_reason() instead of using generic kfree_skb() calls and negative errno codes. Several new SKB_DROP_REASON_* enum values are introduced.\n\nKMSAN vs KASAN evaluation:\n1. No uninitialized data exposure to userspace: No new kernel structures or fields are copied to userspace via copy_to_user, netlink, or socket options. Drop reasons are consumed internally by kernel tracing/drop monitoring.\n2. Variable initialization: All introduced or modified local 'enum skb_drop_reason' variables are either initialized at declaration (e.g., SKB_DROP_REASON_NOT_SPECIFIED) or unconditionally assigned prior to branch conditions and consumption.\n3. Buffer and length validation: Replacing !pskb_may_pull(...) with pskb_may_pull_reason(...) preserves identical bounds checks and length handling; no changes allow uninitialized buffer segments to be read.\n4. Struct handling: Structures such as struct tnl_ptk_info populated by gre_parse_header() are only accessed upon successful parsing, and its fields are fully assigned as in the preexisting code.\n\nSince the changes do not introduce or expose uninitialized memory reads or information leaks, a dedicated KMSAN fuzzing session is not warranted. Standard KASAN builds are sufficient to catch any buffer bounds or lifetime issues.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 8528ffb1c7e241220d9880e821afa233d80a376c
Author: syz-cluster <triage@syzkaller.com>
Date: Fri Sep 25 05:00:45 2026 +0000
syz-cluster: applied patch under review
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 12f9096515912..a72b84b07daa2 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -129,6 +129,12 @@
FN(PSP_INPUT) \
FN(PSP_OUTPUT) \
FN(RECURSION_LIMIT) \
+ FN(TNL_OPT_MISMATCH) \
+ FN(TNL_OLD_SEQ) \
+ FN(GRE_INVALID_HDR) \
+ FN(GRE_CSUM) \
+ FN(GRE_TUNNEL_NOT_FOUND) \
+ FN(TNL_ENCAP) \
FNe(MAX)
/**
@@ -612,6 +618,39 @@ enum skb_drop_reason {
SKB_DROP_REASON_PSP_OUTPUT,
/** @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device. */
SKB_DROP_REASON_RECURSION_LIMIT,
+ /**
+ * @SKB_DROP_REASON_TNL_OPT_MISMATCH: the tunnel options
+ * carried by the packet do not match the tunnel configuration, e.g.
+ * a GRE tunnel configured with 'icsum' or 'iseq' received a packet
+ * with no checksum or no sequence number, or a GRE tunnel without
+ * 'icsum' received a packet with a checksum.
+ */
+ SKB_DROP_REASON_TNL_OPT_MISMATCH,
+ /**
+ * @SKB_DROP_REASON_TNL_OLD_SEQ: the sequence number carried
+ * by the packet is older than the one expected by the tunnel, e.g.
+ * after the remote endpoint restarted and reset its sequence
+ * numbering.
+ */
+ SKB_DROP_REASON_TNL_OLD_SEQ,
+ /**
+ * @SKB_DROP_REASON_GRE_INVALID_HDR: the GRE header is invalid, e.g.
+ * an unsupported version or the routing bit is set.
+ */
+ SKB_DROP_REASON_GRE_INVALID_HDR,
+ /** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */
+ SKB_DROP_REASON_GRE_CSUM,
+ /**
+ * @SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND: no GRE tunnel found for the
+ * endpoints and the key the packet carries.
+ */
+ SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND,
+ /**
+ * @SKB_DROP_REASON_TNL_ENCAP: failed to build the
+ * encapsulation header of a tunnel, e.g. an unknown or
+ * unregistered encapsulation type.
+ */
+ SKB_DROP_REASON_TNL_ENCAP,
/**
* @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
* shouldn't be used as a real 'reason' - only for tracing code gen
diff --git a/include/net/gre.h b/include/net/gre.h
index b55f67ecd2fc4..4cb19abea90de 100644
--- a/include/net/gre.h
+++ b/include/net/gre.h
@@ -32,8 +32,9 @@ struct gre_protocol {
int gre_add_protocol(const struct gre_protocol *proto, u8 version);
int gre_del_protocol(const struct gre_protocol *proto, u8 version);
-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
- bool *csum_err, __be16 proto, int nhs);
+enum skb_drop_reason
+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
+ bool icmp_err, __be16 proto, int nhs);
static inline bool netif_is_gretap(const struct net_device *dev)
{
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index d1f0a427e9c82..363eed61b296a 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -143,8 +143,9 @@ int ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
bool log_ecn_error);
int ip6_tnl_xmit_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,
const struct in6_addr *raddr);
-int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
- struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);
+enum skb_drop_reason
+ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
+ struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);
__u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw);
__u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr,
const struct in6_addr *raddr);
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 7102aa11fae29..27a9e097996b6 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -207,10 +207,6 @@ struct tnl_ptk_info {
int hdr_len;
};
-#define PACKET_RCVD 0
-#define PACKET_REJECT 1
-#define PACKET_NEXT 2
-
#define IP_TNL_HASH_BITS 7
#define IP_TNL_HASH_SIZE (1 << IP_TNL_HASH_BITS)
@@ -614,8 +610,17 @@ static inline u8 ip_tunnel_ecn_encap(u8 tos, const struct iphdr *iph,
return INET_ECN_encapsulate(tos, inner);
}
-int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
- __be16 inner_proto, bool raw_proto, bool xnet);
+enum skb_drop_reason
+__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,
+ __be16 inner_proto, bool raw_proto, bool xnet);
+
+static inline int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
+ __be16 inner_proto, bool raw_proto,
+ bool xnet)
+{
+ return __iptunnel_pull_header_reason(skb, hdr_len, inner_proto,
+ raw_proto, xnet) ? -ENOMEM : 0;
+}
static inline int iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
__be16 inner_proto, bool xnet)
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 96fd7dc6d82dd..e117056525f06 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -56,28 +56,35 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)
}
EXPORT_SYMBOL_GPL(gre_del_protocol);
-/* Fills in tpi and returns header length to be pulled.
+/* Fills in tpi, including the header length to be pulled in tpi->hdr_len,
+ * and returns SKB_NOT_DROPPED_YET, or the reason to drop the packet if the
+ * header is rejected.
* Note that caller must use pskb_may_pull() before pulling GRE header.
+ *
+ * @icmp_err is set by the ICMP error handlers, which only get a part of
+ * the original packet: a checksum failure does not reject the header then,
+ * the checksum is still computed and the rest of the header is parsed.
*/
-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
- bool *csum_err, __be16 proto, int nhs)
+enum skb_drop_reason
+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
+ bool icmp_err, __be16 proto, int nhs)
{
const struct gre_base_hdr *greh;
__be32 *options;
int hdr_len;
if (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))
- return -EINVAL;
+ return SKB_DROP_REASON_HDR_TRUNC;
greh = (struct gre_base_hdr *)(skb->data + nhs);
if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
- return -EINVAL;
+ return SKB_DROP_REASON_GRE_INVALID_HDR;
gre_flags_to_tnl_flags(tpi->flags, greh->flags);
hdr_len = gre_calc_hlen(tpi->flags);
if (!pskb_may_pull(skb, nhs + hdr_len))
- return -EINVAL;
+ return SKB_DROP_REASON_HDR_TRUNC;
greh = (struct gre_base_hdr *)(skb->data + nhs);
tpi->proto = greh->protocol;
@@ -87,9 +94,8 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
if (!skb_checksum_simple_validate(skb)) {
skb_checksum_try_convert(skb, IPPROTO_GRE,
null_compute_pseudo);
- } else if (csum_err) {
- *csum_err = true;
- return -EINVAL;
+ } else if (!icmp_err) {
+ return SKB_DROP_REASON_GRE_CSUM;
}
options++;
@@ -117,7 +123,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
val = skb_header_pointer(skb, nhs + hdr_len,
sizeof(_val), &_val);
if (!val)
- return -EINVAL;
+ return SKB_DROP_REASON_HDR_TRUNC;
tpi->proto = proto;
if ((*val & 0xF0) != 0x40)
hdr_len += 4;
@@ -133,28 +139,32 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
struct erspan_base_hdr *ershdr;
if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
- return -EINVAL;
+ return SKB_DROP_REASON_HDR_TRUNC;
ershdr = (struct erspan_base_hdr *)(skb->data + nhs + hdr_len);
tpi->key = cpu_to_be32(get_session_id(ershdr));
}
- return hdr_len;
+ return SKB_NOT_DROPPED_YET;
}
EXPORT_SYMBOL(gre_parse_header);
static int gre_rcv(struct sk_buff *skb)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
const struct gre_protocol *proto;
u8 ver;
int ret;
- if (!pskb_may_pull(skb, 12))
+ reason = pskb_may_pull_reason(skb, 12);
+ if (reason)
goto drop;
ver = skb->data[1]&0x7f;
- if (ver >= GREPROTO_MAX)
+ if (ver >= GREPROTO_MAX) {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto drop;
+ }
rcu_read_lock();
proto = rcu_dereference(gre_proto[ver]);
@@ -167,11 +177,11 @@ static int gre_rcv(struct sk_buff *skb)
drop_nohandler:
rcu_read_unlock();
dev_core_stats_rx_nohandler_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);
return NET_RX_DROP;
drop:
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NET_RX_DROP;
}
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 5e877018e006c..ad669b3f87570 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -237,8 +237,8 @@ static void gre_err(struct sk_buff *skb, u32 info)
const int code = icmp_hdr(skb)->code;
struct tnl_ptk_info tpi;
- if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IP),
- iph->ihl * 4) < 0)
+ if (gre_parse_header(skb, &tpi, true, htons(ETH_P_IP),
+ iph->ihl * 4))
return;
if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
@@ -264,13 +264,15 @@ static bool is_erspan_type1(int gre_hdr_len)
return gre_hdr_len == 4;
}
-static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
- int gre_hdr_len)
+static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,
+ struct tnl_ptk_info *tpi,
+ int gre_hdr_len)
{
struct net *net = dev_net(skb->dev);
struct metadata_dst *tun_dst = NULL;
struct erspan_base_hdr *ershdr;
IP_TUNNEL_DECLARE_FLAGS(flags);
+ enum skb_drop_reason reason;
struct ip_tunnel_net *itn;
struct ip_tunnel *tunnel;
const struct iphdr *iph;
@@ -290,7 +292,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
} else {
if (unlikely(!pskb_may_pull(skb,
gre_hdr_len + sizeof(*ershdr))))
- return PACKET_REJECT;
+ return SKB_DROP_REASON_HDR_TRUNC;
ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len);
ver = ershdr->ver;
@@ -307,12 +309,12 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
len = gre_hdr_len + erspan_hdr_len(ver);
if (unlikely(!pskb_may_pull(skb, len)))
- return PACKET_REJECT;
+ return SKB_DROP_REASON_HDR_TRUNC;
- if (__iptunnel_pull_header(skb,
- len,
- htons(ETH_P_TEB),
- false, false) < 0)
+ reason = __iptunnel_pull_header_reason(skb, len,
+ htons(ETH_P_TEB),
+ false, false);
+ if (reason)
goto drop;
if (tunnel->collect_md) {
@@ -328,7 +330,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
tun_dst = ip_tun_rx_dst(skb, flags,
tun_id, sizeof(*md));
if (!tun_dst)
- return PACKET_REJECT;
+ return SKB_DROP_REASON_NOMEM;
/* MUST set options_len before referencing options */
info = &tun_dst->u.tun_info;
@@ -354,19 +356,22 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
skb_reset_mac_header(skb);
ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
- return PACKET_RCVD;
+ return SKB_NOT_DROPPED_YET;
}
- return PACKET_REJECT;
+ return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
drop:
- kfree_skb(skb);
- return PACKET_RCVD;
+ kfree_skb_reason(skb, reason);
+ return SKB_NOT_DROPPED_YET;
}
-static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
- struct ip_tunnel_net *itn, int hdr_len, bool raw_proto)
+static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,
+ const struct tnl_ptk_info *tpi,
+ struct ip_tunnel_net *itn,
+ int hdr_len, bool raw_proto)
{
struct metadata_dst *tun_dst = NULL;
+ enum skb_drop_reason reason;
const struct iphdr *iph;
struct ip_tunnel *tunnel;
@@ -377,8 +382,10 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
if (tunnel) {
const struct iphdr *tnl_params;
- if (__iptunnel_pull_header(skb, hdr_len, tpi->proto,
- raw_proto, false) < 0)
+ reason = __iptunnel_pull_header_reason(skb, hdr_len,
+ tpi->proto, raw_proto,
+ false);
+ if (reason)
goto drop;
/* Special case for ipgre_header_parse(), which expects the
@@ -401,47 +408,48 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
tun_id = key32_to_tunnel_id(tpi->key);
tun_dst = ip_tun_rx_dst(skb, flags, tun_id, 0);
if (!tun_dst)
- return PACKET_REJECT;
+ return SKB_DROP_REASON_NOMEM;
}
ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
- return PACKET_RCVD;
+ return SKB_NOT_DROPPED_YET;
}
- return PACKET_NEXT;
+ return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
drop:
- kfree_skb(skb);
- return PACKET_RCVD;
+ kfree_skb_reason(skb, reason);
+ return SKB_NOT_DROPPED_YET;
}
-static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
- int hdr_len)
+static enum skb_drop_reason ipgre_rcv(struct sk_buff *skb,
+ const struct tnl_ptk_info *tpi,
+ int hdr_len)
{
struct net *net = dev_net(skb->dev);
+ enum skb_drop_reason reason;
struct ip_tunnel_net *itn;
- int res;
if (tpi->proto == htons(ETH_P_TEB))
itn = net_generic(net, gre_tap_net_id);
else
itn = net_generic(net, ipgre_net_id);
- res = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
- if (res == PACKET_NEXT && tpi->proto == htons(ETH_P_TEB)) {
+ reason = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
+ if (reason == SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND &&
+ tpi->proto == htons(ETH_P_TEB)) {
/* ipgre tunnels in collect metadata mode should receive
* also ETH_P_TEB traffic.
*/
itn = net_generic(net, ipgre_net_id);
- res = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
+ reason = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
}
- return res;
+ return reason;
}
static int gre_rcv(struct sk_buff *skb)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct tnl_ptk_info tpi;
- bool csum_err = false;
- int hdr_len;
#ifdef CONFIG_NET_IPGRE_BROADCAST
if (ipv4_is_multicast(ip_hdr(skb)->daddr)) {
@@ -451,25 +459,27 @@ static int gre_rcv(struct sk_buff *skb)
}
#endif
- hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP), 0);
- if (hdr_len < 0)
+ reason = gre_parse_header(skb, &tpi, false, htons(ETH_P_IP), 0);
+ if (reason)
goto drop;
if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
tpi.proto == htons(ETH_P_ERSPAN2))) {
- if (erspan_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+ reason = erspan_rcv(skb, &tpi, tpi.hdr_len);
+ if (!reason)
return 0;
goto out;
}
- if (ipgre_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+ reason = ipgre_rcv(skb, &tpi, tpi.hdr_len);
+ if (!reason)
return 0;
out:
icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
drop:
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -496,6 +506,7 @@ static int gre_handle_offloads(struct sk_buff *skb, bool csum)
static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
__be16 proto)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
struct ip_tunnel_info *tun_info;
@@ -504,19 +515,25 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
- ip_tunnel_info_af(tun_info) != AF_INET))
+ ip_tunnel_info_af(tun_info) != AF_INET)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto err_free_skb;
+ }
key = &tun_info->key;
tunnel_hlen = gre_calc_hlen(key->tun_flags);
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
/* Push Tunnel header. */
if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
- tunnel->parms.o_flags)))
+ tunnel->parms.o_flags))) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
__set_bit(IP_TUNNEL_CSUM_BIT, flags);
__set_bit(IP_TUNNEL_KEY_BIT, flags);
@@ -533,12 +550,13 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
return;
err_free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
}
static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
struct ip_tunnel_info *tun_info;
@@ -552,29 +570,41 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
- ip_tunnel_info_af(tun_info) != AF_INET))
+ ip_tunnel_info_af(tun_info) != AF_INET)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto err_free_skb;
+ }
key = &tun_info->key;
- if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info->key.tun_flags))
+ if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info->key.tun_flags)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto err_free_skb;
- if (tun_info->options_len < sizeof(*md))
+ }
+ if (tun_info->options_len < sizeof(*md)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto err_free_skb;
+ }
md = ip_tunnel_info_opts(tun_info);
/* ERSPAN has fixed 8 byte GRE header */
version = md->version;
tunnel_hlen = 8 + erspan_hdr_len(version);
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
- if (gre_handle_offloads(skb, false))
+ if (gre_handle_offloads(skb, false)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
if (skb->len > dev->mtu + dev->hard_header_len) {
- if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+ if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto err_free_skb;
+ }
truncate = true;
}
@@ -606,6 +636,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
truncate, true);
proto = htons(ETH_P_ERSPAN2);
} else {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto err_free_skb;
}
@@ -618,7 +649,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
return;
err_free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
}
@@ -649,11 +680,13 @@ static int gre_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)
static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
const struct iphdr *tnl_params;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -664,10 +697,13 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
if (dev->header_ops) {
int pull_len = tunnel->hlen + sizeof(struct iphdr);
- if (skb_cow_head(skb, 0))
+ if (skb_cow_head(skb, 0)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
- if (!pskb_may_pull(skb, pull_len))
+ reason = pskb_may_pull_reason(skb, pull_len);
+ if (reason)
goto free_skb;
tnl_params = (const struct iphdr *)skb->data;
@@ -677,25 +713,31 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
skb_reset_mac_header(skb);
if (skb->ip_summed == CHECKSUM_PARTIAL &&
- skb_checksum_start(skb) < skb->data)
+ skb_checksum_start(skb) < skb->data) {
+ reason = SKB_DROP_REASON_SKB_CSUM;
goto free_skb;
+ }
} else {
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
tnl_params = &tunnel->parms.iph;
}
ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
- if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))
+ if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
__gre_xmit(skb, dev, tnl_params, skb->protocol, flags);
return NETDEV_TX_OK;
free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
@@ -703,12 +745,14 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
static netdev_tx_t erspan_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
bool truncate = false;
__be16 proto;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -716,15 +760,21 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
- if (gre_handle_offloads(skb, false))
+ if (gre_handle_offloads(skb, false)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
if (skb->len > dev->mtu + dev->hard_header_len) {
- if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+ if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
truncate = true;
}
@@ -745,6 +795,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
truncate, true);
proto = htons(ETH_P_ERSPAN2);
} else {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto free_skb;
}
@@ -753,7 +804,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
@@ -761,10 +812,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -774,17 +827,21 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
- if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))
+ if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
- if (skb_cow_head(skb, dev->needed_headroom))
+ if (skb_cow_head(skb, dev->needed_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto free_skb;
+ }
__gre_xmit(skb, dev, &tunnel->parms.iph, htons(ETH_P_TEB), flags);
return NETDEV_TX_OK;
free_skb:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 0875474a578a4..66cb0b86fa79a 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -384,6 +384,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,
bool log_ecn_error)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
const struct iphdr *iph = ip_hdr(skb);
int nh, err;
@@ -398,14 +399,22 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
test_bit(IP_TUNNEL_CSUM_BIT, tpi->flags)) {
DEV_STATS_INC(tunnel->dev, rx_crc_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OPT_MISMATCH;
goto drop;
}
if (test_bit(IP_TUNNEL_SEQ_BIT, tunnel->parms.i_flags)) {
- if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags) ||
- (tunnel->i_seqno && (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0)) {
+ if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags)) {
DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OPT_MISMATCH;
+ goto drop;
+ }
+ if (tunnel->i_seqno &&
+ (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0) {
+ DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
+ DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OLD_SEQ;
goto drop;
}
tunnel->i_seqno = ntohl(tpi->seq) + 1;
@@ -419,7 +428,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
skb_set_network_header(skb, (tunnel->dev->type == ARPHRD_ETHER) ? ETH_HLEN : 0);
- if (!pskb_inet_may_pull(skb)) {
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason) {
DEV_STATS_INC(tunnel->dev, rx_length_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
goto drop;
@@ -434,6 +444,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
if (err > 1) {
DEV_STATS_INC(tunnel->dev, rx_frame_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
goto drop;
}
}
@@ -457,7 +468,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
drop:
if (tun_dst)
dst_release((struct dst_entry *)tun_dst);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
EXPORT_SYMBOL_GPL(ip_tunnel_rcv);
@@ -575,6 +586,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
u8 proto, int tunnel_hlen)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
u32 headroom = sizeof(struct iphdr);
struct ip_tunnel_info *tun_info;
@@ -588,8 +600,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
- ip_tunnel_info_af(tun_info) != AF_INET))
+ ip_tunnel_info_af(tun_info) != AF_INET)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto tx_error;
+ }
key = &tun_info->key;
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
inner_iph = (const struct iphdr *)skb_inner_network_header(skb);
@@ -608,8 +622,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (!tunnel_hlen)
tunnel_hlen = ip_encap_hlen(&tun_info->encap);
- if (ip_tunnel_encap(skb, &tun_info->encap, &proto, &fl4) < 0)
+ if (ip_tunnel_encap(skb, &tun_info->encap, &proto, &fl4) < 0) {
+ reason = SKB_DROP_REASON_TNL_ENCAP;
goto tx_error;
+ }
use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
if (use_cache)
@@ -618,6 +634,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
rt = ip_route_output_key(tunnel->net, &fl4);
if (IS_ERR(rt)) {
DEV_STATS_INC(dev, tx_carrier_errors);
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
if (use_cache)
@@ -627,6 +644,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (rt->dst.dev == dev) {
ip_rt_put(rt);
DEV_STATS_INC(dev, collisions);
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_error;
}
@@ -635,6 +653,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, tunnel_hlen,
key->u.ipv4.dst, true)) {
ip_rt_put(rt);
+ reason = SKB_DROP_REASON_PKT_TOO_BIG;
goto tx_error;
}
@@ -652,6 +671,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
headroom += LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len;
if (skb_cow_head(skb, headroom)) {
ip_rt_put(rt);
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_dropped;
}
@@ -666,13 +686,14 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
tx_dropped:
DEV_STATS_INC(dev, tx_dropped);
kfree:
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
}
EXPORT_SYMBOL_GPL(ip_md_tunnel_xmit);
void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
const struct iphdr *tnl_params, u8 protocol)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel *tunnel = netdev_priv(dev);
struct ip_tunnel_info *tun_info = NULL;
const struct iphdr *inner_iph;
@@ -700,9 +721,15 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (!skb_dst(skb)) {
DEV_STATS_INC(dev, tx_fifo_errors);
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_error;
}
+ /* Only the branches below can derive a destination. If
+ * none of them matches, the payload protocol is not one
+ * this tunnel can carry.
+ */
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
tun_info = skb_tunnel_info(skb);
if (tun_info && (tun_info->mode & IP_TUNNEL_INFO_TX) &&
ip_tunnel_info_af(tun_info) == AF_INET &&
@@ -723,8 +750,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
neigh = dst_neigh_lookup(skb_dst(skb),
&ipv6_hdr(skb)->daddr);
- if (!neigh)
+ if (!neigh) {
+ reason = SKB_DROP_REASON_NEIGH_CREATEFAIL;
goto tx_error;
+ }
addr6 = (const struct in6_addr *)&neigh->primary_key;
addr_type = ipv6_addr_type(addr6);
@@ -741,8 +770,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
dst = addr6->s6_addr32[3];
}
neigh_release(neigh);
- if (do_tx_error_icmp)
+ if (do_tx_error_icmp) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_error_icmp;
+ }
}
#endif
else
@@ -769,8 +800,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
tunnel->net, READ_ONCE(tunnel->parms.link),
tunnel->fwmark, skb_get_hash(skb), 0);
- if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0)
+ if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0) {
+ reason = SKB_DROP_REASON_TNL_ENCAP;
goto tx_error;
+ }
if (connected && md) {
use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
@@ -787,6 +820,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (IS_ERR(rt)) {
DEV_STATS_INC(dev, tx_carrier_errors);
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
if (use_cache)
@@ -800,6 +834,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (rt->dst.dev == dev) {
ip_rt_put(rt);
DEV_STATS_INC(dev, collisions);
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_error;
}
@@ -809,6 +844,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, 0, 0, false)) {
ip_rt_put(rt);
+ reason = SKB_DROP_REASON_PKT_TOO_BIG;
goto tx_error;
}
@@ -843,7 +879,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
if (skb_cow_head(skb, max_headroom)) {
ip_rt_put(rt);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);
return;
}
@@ -859,7 +895,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
#endif
tx_error:
DEV_STATS_INC(dev, tx_errors);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
}
EXPORT_SYMBOL_GPL(ip_tunnel_xmit);
diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c
index bab42b9e277f7..51f1537ce6c1f 100644
--- a/net/ipv4/ip_tunnel_core.c
+++ b/net/ipv4/ip_tunnel_core.c
@@ -106,19 +106,24 @@ void iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
}
EXPORT_SYMBOL_GPL(iptunnel_xmit);
-int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
- __be16 inner_proto, bool raw_proto, bool xnet)
+enum skb_drop_reason
+__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,
+ __be16 inner_proto, bool raw_proto, bool xnet)
{
- if (unlikely(!pskb_may_pull(skb, hdr_len)))
- return -ENOMEM;
+ enum skb_drop_reason reason;
+
+ reason = pskb_may_pull_reason(skb, hdr_len);
+ if (unlikely(reason))
+ return reason;
skb_pull_rcsum(skb, hdr_len);
if (!raw_proto && inner_proto == htons(ETH_P_TEB)) {
struct ethhdr *eh;
- if (unlikely(!pskb_may_pull(skb, ETH_HLEN)))
- return -ENOMEM;
+ reason = pskb_may_pull_reason(skb, ETH_HLEN);
+ if (unlikely(reason))
+ return reason;
eh = (struct ethhdr *)skb->data;
if (likely(eth_proto_is_802_3(eh->h_proto)))
@@ -135,9 +140,12 @@ int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
skb_set_queue_mapping(skb, 0);
skb_scrub_packet(skb, xnet);
- return iptunnel_pull_offloads(skb);
+ if (unlikely(iptunnel_pull_offloads(skb)))
+ return SKB_DROP_REASON_NOMEM;
+
+ return SKB_NOT_DROPPED_YET;
}
-EXPORT_SYMBOL_GPL(__iptunnel_pull_header);
+EXPORT_SYMBOL_GPL(__iptunnel_pull_header_reason);
struct metadata_dst *iptunnel_metadata_reply(struct metadata_dst *md,
gfp_t flags)
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index c851af22b9fe5..31930ff813dd2 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -389,8 +389,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
struct tnl_ptk_info tpi;
struct ip6_tnl *t;
- if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IPV6),
- offset) < 0)
+ if (gre_parse_header(skb, &tpi, true, htons(ETH_P_IPV6),
+ offset))
return -EINVAL;
ipv6h = (const struct ipv6hdr *)skb->data;
@@ -451,7 +451,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
return 0;
}
-static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
+static enum skb_drop_reason ip6gre_rcv(struct sk_buff *skb,
+ const struct tnl_ptk_info *tpi)
{
const struct ipv6hdr *ipv6h;
struct ip6_tnl *tunnel;
@@ -471,22 +472,22 @@ static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
tun_dst = ipv6_tun_rx_dst(skb, flags, tun_id, 0);
if (!tun_dst)
- return PACKET_REJECT;
+ return SKB_DROP_REASON_NOMEM;
ip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
} else {
ip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
}
- return PACKET_RCVD;
+ return SKB_NOT_DROPPED_YET;
}
- return PACKET_REJECT;
+ return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
}
-static int ip6erspan_rcv(struct sk_buff *skb,
- struct tnl_ptk_info *tpi,
- int gre_hdr_len)
+static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,
+ struct tnl_ptk_info *tpi,
+ int gre_hdr_len)
{
struct erspan_base_hdr *ershdr;
const struct ipv6hdr *ipv6h;
@@ -495,7 +496,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,
u8 ver;
if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))
- return PACKET_REJECT;
+ return SKB_DROP_REASON_HDR_TRUNC;
ipv6h = ipv6_hdr(skb);
ershdr = (struct erspan_base_hdr *)skb->data;
@@ -506,14 +507,16 @@ static int ip6erspan_rcv(struct sk_buff *skb,
tpi->proto);
if (tunnel) {
int len = erspan_hdr_len(ver);
+ enum skb_drop_reason reason;
if (unlikely(!pskb_may_pull(skb, len)))
- return PACKET_REJECT;
+ return SKB_DROP_REASON_HDR_TRUNC;
- if (__iptunnel_pull_header(skb, len,
- htons(ETH_P_TEB),
- false, false) < 0)
- return PACKET_REJECT;
+ reason = __iptunnel_pull_header_reason(skb, len,
+ htons(ETH_P_TEB),
+ false, false);
+ if (reason)
+ return reason;
if (tunnel->parms.collect_md) {
struct erspan_metadata *pkt_md, *md;
@@ -530,7 +533,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,
tun_dst = ipv6_tun_rx_dst(skb, flags, tun_id,
sizeof(*md));
if (!tun_dst)
- return PACKET_REJECT;
+ return SKB_DROP_REASON_NOMEM;
/* MUST set options_len before referencing options */
info = &tun_dst->u.tun_info;
@@ -558,40 +561,43 @@ static int ip6erspan_rcv(struct sk_buff *skb,
ip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
}
- return PACKET_RCVD;
+ return SKB_NOT_DROPPED_YET;
}
- return PACKET_REJECT;
+ return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
}
static int gre_rcv(struct sk_buff *skb)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct tnl_ptk_info tpi;
- bool csum_err = false;
- int hdr_len;
- hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6), 0);
- if (hdr_len < 0)
+ reason = gre_parse_header(skb, &tpi, false, htons(ETH_P_IPV6), 0);
+ if (reason)
goto drop;
- if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
+ reason = __iptunnel_pull_header_reason(skb, tpi.hdr_len, tpi.proto,
+ false, false);
+ if (reason)
goto drop;
if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
tpi.proto == htons(ETH_P_ERSPAN2))) {
- if (ip6erspan_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+ reason = ip6erspan_rcv(skb, &tpi, tpi.hdr_len);
+ if (!reason)
return 0;
goto out;
}
- if (ip6gre_rcv(skb, &tpi) == PACKET_RCVD)
+ reason = ip6gre_rcv(skb, &tpi);
+ if (!reason)
return 0;
out:
icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
drop:
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -674,10 +680,10 @@ static int prepare_ip6gre_xmit_ipv6(struct sk_buff *skb,
return 0;
}
-static int prepare_ip6gre_xmit_other(struct sk_buff *skb,
- struct net_device *dev,
- struct flowi6 *fl6, __u8 *dsfield,
- int *encap_limit)
+static void prepare_ip6gre_xmit_other(struct sk_buff *skb,
+ struct net_device *dev,
+ struct flowi6 *fl6, __u8 *dsfield,
+ int *encap_limit)
{
struct ip6_tnl *t = netdev_priv(dev);
@@ -697,8 +703,6 @@ static int prepare_ip6gre_xmit_other(struct sk_buff *skb,
fl6->flowi6_mark = t->parms.fwmark;
fl6->flowi6_uid = sock_net_uid(dev_net(dev), NULL);
-
- return 0;
}
static struct ip_tunnel_info *skb_tunnel_info_txcheck(struct sk_buff *skb)
@@ -712,10 +716,10 @@ static struct ip_tunnel_info *skb_tunnel_info_txcheck(struct sk_buff *skb)
return tun_info;
}
-static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
- struct net_device *dev, __u8 dsfield,
- struct flowi6 *fl6, int encap_limit,
- __u32 *pmtu, __be16 proto)
+static enum skb_drop_reason __gre6_xmit(struct sk_buff *skb,
+ struct net_device *dev, __u8 dsfield,
+ struct flowi6 *fl6, int encap_limit,
+ __u32 *pmtu, __be16 proto)
{
struct ip6_tnl *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
@@ -740,7 +744,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
tun_info = skb_tunnel_info_txcheck(skb);
if (IS_ERR(tun_info) ||
unlikely(ip_tunnel_info_af(tun_info) != AF_INET6))
- return -EINVAL;
+ return SKB_DROP_REASON_TUNNEL_TXINFO;
key = &tun_info->key;
memset(fl6, 0, sizeof(*fl6));
@@ -759,7 +763,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
tun_hlen = gre_calc_hlen(flags);
if (skb_cow_head(skb, dev->needed_headroom ?: tun_hlen + tunnel->encap_hlen))
- return -ENOMEM;
+ return SKB_DROP_REASON_NOMEM;
gre_build_header(skb, tun_hlen,
flags, protocol,
@@ -770,7 +774,7 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
} else {
if (skb_cow_head(skb, dev->needed_headroom ?: tunnel->hlen))
- return -ENOMEM;
+ return SKB_DROP_REASON_NOMEM;
ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
@@ -785,9 +789,11 @@ static netdev_tx_t __gre6_xmit(struct sk_buff *skb,
NEXTHDR_GRE);
}
-static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
+static inline enum skb_drop_reason ip6gre_xmit_ipv4(struct sk_buff *skb,
+ struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
+ enum skb_drop_reason reason;
int encap_limit = -1;
struct flowi6 fl6;
__u8 dsfield = 0;
@@ -803,54 +809,56 @@ static inline int ip6gre_xmit_ipv4(struct sk_buff *skb, struct net_device *dev)
err = gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
t->parms.o_flags));
if (err)
- return -1;
+ return SKB_DROP_REASON_NOMEM;
- err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- skb->protocol);
- if (err != 0) {
+ reason = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ skb->protocol);
+ if (reason) {
/* XXX: send ICMP error even if DF is not set. */
- if (err == -EMSGSIZE)
+ if (reason == SKB_DROP_REASON_PKT_TOO_BIG)
icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
htonl(mtu));
- return -1;
+ return reason;
}
- return 0;
+ return SKB_NOT_DROPPED_YET;
}
-static inline int ip6gre_xmit_ipv6(struct sk_buff *skb, struct net_device *dev)
+static inline enum skb_drop_reason ip6gre_xmit_ipv6(struct sk_buff *skb,
+ struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
struct ipv6hdr *ipv6h = ipv6_hdr(skb);
+ enum skb_drop_reason reason;
int encap_limit = -1;
struct flowi6 fl6;
__u8 dsfield = 0;
__u32 mtu;
- int err;
if (ipv6_addr_equal(&t->parms.raddr, &ipv6h->saddr))
- return -1;
+ return SKB_DROP_REASON_RECURSION_LIMIT;
if (!t->parms.collect_md &&
prepare_ip6gre_xmit_ipv6(skb, dev, &fl6, &dsfield, &encap_limit))
- return -1;
+ return SKB_DROP_REASON_IPV6_BAD_EXTHDR;
if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
t->parms.o_flags)))
- return -1;
+ return SKB_DROP_REASON_NOMEM;
- err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit,
- &mtu, skb->protocol);
- if (err != 0) {
- if (err == -EMSGSIZE)
+ reason = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit,
+ &mtu, skb->protocol);
+ if (reason) {
+ if (reason == SKB_DROP_REASON_PKT_TOO_BIG)
icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
- return -1;
+ return reason;
}
- return 0;
+ return SKB_NOT_DROPPED_YET;
}
-static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)
+static enum skb_drop_reason ip6gre_xmit_other(struct sk_buff *skb,
+ struct net_device *dev)
{
struct ip6_tnl *t = netdev_priv(dev);
int encap_limit = -1;
@@ -859,32 +867,35 @@ static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)
__u32 mtu;
int err;
- if (!t->parms.collect_md &&
- prepare_ip6gre_xmit_other(skb, dev, &fl6, &dsfield, &encap_limit))
- return -1;
+ if (!t->parms.collect_md)
+ prepare_ip6gre_xmit_other(skb, dev, &fl6,
+ &dsfield, &encap_limit);
err = gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
t->parms.o_flags));
if (err)
- return err;
- err = __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu, skb->protocol);
+ return SKB_DROP_REASON_NOMEM;
- return err;
+ return __gre6_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ skb->protocol);
}
static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel_info *tun_info = NULL;
struct ip6_tnl *t = netdev_priv(dev);
__be16 payload_protocol;
- int ret;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto tx_err;
- if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
+ if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr)) {
+ reason = SKB_DROP_REASON_DEV_READY;
goto tx_err;
+ }
if (t->parms.collect_md)
tun_info = skb_tunnel_info_txcheck(skb);
@@ -892,17 +903,17 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
payload_protocol = skb_protocol(skb, true);
switch (payload_protocol) {
case htons(ETH_P_IP):
- ret = ip6gre_xmit_ipv4(skb, dev);
+ reason = ip6gre_xmit_ipv4(skb, dev);
break;
case htons(ETH_P_IPV6):
- ret = ip6gre_xmit_ipv6(skb, dev);
+ reason = ip6gre_xmit_ipv6(skb, dev);
break;
default:
- ret = ip6gre_xmit_other(skb, dev);
+ reason = ip6gre_xmit_other(skb, dev);
break;
}
- if (ret < 0)
+ if (reason)
goto tx_err;
return NETDEV_TX_OK;
@@ -911,13 +922,14 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
if (!IS_ERR(tun_info))
DEV_STATS_INC(dev, tx_errors);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NETDEV_TX_OK;
}
static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip_tunnel_info *tun_info = NULL;
struct ip6_tnl *t = netdev_priv(dev);
struct dst_entry *dst = skb_dst(skb);
@@ -926,23 +938,29 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
int encap_limit = -1;
__u8 dsfield = false;
struct flowi6 fl6;
- int err = -EINVAL;
__be16 proto;
__u32 mtu;
int nhoff;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto tx_err;
- if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
+ if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr)) {
+ reason = SKB_DROP_REASON_DEV_READY;
goto tx_err;
+ }
- if (gre_handle_offloads(skb, false))
+ if (gre_handle_offloads(skb, false)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_err;
+ }
if (skb->len > dev->mtu + dev->hard_header_len) {
- if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+ if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_err;
+ }
truncate = true;
}
@@ -962,8 +980,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
truncate = true;
}
- if (skb_cow_head(skb, dev->needed_headroom ?: t->hlen))
+ if (skb_cow_head(skb, dev->needed_headroom ?: t->hlen)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_err;
+ }
IPCB(skb)->flags = 0;
@@ -977,8 +997,10 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
tun_info = skb_tunnel_info_txcheck(skb);
if (IS_ERR(tun_info) ||
- unlikely(ip_tunnel_info_af(tun_info) != AF_INET6))
+ unlikely(ip_tunnel_info_af(tun_info) != AF_INET6)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto tx_err;
+ }
key = &tun_info->key;
memset(&fl6, 0, sizeof(fl6));
@@ -990,10 +1012,14 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
dsfield = key->tos;
if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT,
- tun_info->key.tun_flags))
+ tun_info->key.tun_flags)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto tx_err;
- if (tun_info->options_len < sizeof(*md))
+ }
+ if (tun_info->options_len < sizeof(*md)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
goto tx_err;
+ }
md = ip_tunnel_info_opts(tun_info);
tun_id = tunnel_id_to_key32(key->tun_id);
@@ -1011,6 +1037,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
truncate, false);
proto = htons(ETH_P_ERSPAN2);
} else {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto tx_err;
}
} else {
@@ -1021,11 +1048,16 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
&dsfield, &encap_limit);
break;
case htons(ETH_P_IPV6):
- if (ipv6_addr_equal(&t->parms.raddr, &ipv6_hdr(skb)->saddr))
+ if (ipv6_addr_equal(&t->parms.raddr,
+ &ipv6_hdr(skb)->saddr)) {
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_err;
+ }
if (prepare_ip6gre_xmit_ipv6(skb, dev, &fl6,
- &dsfield, &encap_limit))
+ &dsfield, &encap_limit)) {
+ reason = SKB_DROP_REASON_IPV6_BAD_EXTHDR;
goto tx_err;
+ }
break;
default:
memcpy(&fl6, &t->fl.u.ip6, sizeof(fl6));
@@ -1044,6 +1076,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
truncate, false);
proto = htons(ETH_P_ERSPAN2);
} else {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto tx_err;
}
@@ -1061,11 +1094,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
if (dst_mtu(dst) > mtu)
dst->ops->update_pmtu(dst, NULL, skb, mtu, false);
}
- err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- NEXTHDR_GRE);
- if (err != 0) {
+ reason = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ NEXTHDR_GRE);
+ if (reason) {
/* XXX: send ICMP error even if DF is not set. */
- if (err == -EMSGSIZE) {
+ if (reason == SKB_DROP_REASON_PKT_TOO_BIG) {
if (skb->protocol == htons(ETH_P_IP))
icmp_ndo_send(skb, ICMP_DEST_UNREACH,
ICMP_FRAG_NEEDED, htonl(mtu));
@@ -1081,7 +1114,7 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
if (!IS_ERR(tun_info))
DEV_STATS_INC(dev, tx_errors);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NETDEV_TX_OK;
}
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index d5ff50a2ac017..77400a1087af5 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -813,6 +813,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
struct sk_buff *skb),
bool log_ecn_err)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
const struct ipv6hdr *ipv6h;
int nh, err;
@@ -820,15 +821,22 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
test_bit(IP_TUNNEL_CSUM_BIT, tpi->flags)) {
DEV_STATS_INC(tunnel->dev, rx_crc_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OPT_MISMATCH;
goto drop;
}
if (test_bit(IP_TUNNEL_SEQ_BIT, tunnel->parms.i_flags)) {
- if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags) ||
- (tunnel->i_seqno &&
- (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0)) {
+ if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags)) {
DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OPT_MISMATCH;
+ goto drop;
+ }
+ if (tunnel->i_seqno &&
+ (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0) {
+ DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
+ DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_TNL_OLD_SEQ;
goto drop;
}
tunnel->i_seqno = ntohl(tpi->seq) + 1;
@@ -838,7 +846,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
/* Warning: All skb pointers will be invalidated! */
if (tunnel->dev->type == ARPHRD_ETHER) {
- if (!pskb_may_pull(skb, ETH_HLEN)) {
+ reason = pskb_may_pull_reason(skb, ETH_HLEN);
+ if (reason) {
DEV_STATS_INC(tunnel->dev, rx_length_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
goto drop;
@@ -859,7 +868,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
skb_reset_network_header(skb);
- if (skb_vlan_inet_prepare(skb, true)) {
+ reason = skb_vlan_inet_prepare(skb, true);
+ if (reason) {
DEV_STATS_INC(tunnel->dev, rx_length_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
goto drop;
@@ -881,6 +891,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
if (err > 1) {
DEV_STATS_INC(tunnel->dev, rx_frame_errors);
DEV_STATS_INC(tunnel->dev, rx_errors);
+ reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
goto drop;
}
}
@@ -898,7 +909,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
drop:
if (tun_dst)
dst_release((struct dst_entry *)tun_dst);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -1092,14 +1103,14 @@ EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);
* it.
*
* Return:
- * 0 on success
- * -1 fail
- * %-EMSGSIZE message too big. return mtu in this case.
+ * %SKB_NOT_DROPPED_YET on success, otherwise the drop reason.
+ * %SKB_DROP_REASON_PKT_TOO_BIG means the message is too big, the path MTU
+ * is stored in @pmtu in this case.
**/
-int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
- struct flowi6 *fl6, int encap_limit, __u32 *pmtu,
- __u8 proto)
+enum skb_drop_reason
+ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
+ struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)
{
struct ip6_tnl *t = netdev_priv(dev);
struct net *net = t->net;
@@ -1110,11 +1121,11 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
int err_count, mtu;
unsigned int eth_hlen = t->dev->type == ARPHRD_ETHER ? ETH_HLEN : 0;
unsigned int psh_hlen = sizeof(struct ipv6hdr) + t->encap_hlen;
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
unsigned int max_headroom = psh_hlen;
__be16 payload_protocol;
bool use_cache = false;
u8 hop_limit;
- int err = -1;
payload_protocol = skb_protocol(skb, true);
@@ -1132,13 +1143,17 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
struct neighbour *neigh;
int addr_type;
- if (!skb_dst(skb))
+ if (!skb_dst(skb)) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_err_link_failure;
+ }
neigh = dst_neigh_lookup(skb_dst(skb),
&ipv6_hdr(skb)->daddr);
- if (!neigh)
+ if (!neigh) {
+ reason = SKB_DROP_REASON_NEIGH_CREATEFAIL;
goto tx_err_link_failure;
+ }
addr6 = (struct in6_addr *)&neigh->primary_key;
addr_type = ipv6_addr_type(addr6);
@@ -1151,8 +1166,10 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
} else if (payload_protocol == htons(ETH_P_IP)) {
const struct rtable *rt = skb_rtable(skb);
- if (!rt)
+ if (!rt) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_err_link_failure;
+ }
if (rt->rt_gw_family == AF_INET6)
memcpy(&fl6->daddr, &rt->rt_gw6, sizeof(fl6->daddr));
@@ -1169,8 +1186,10 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
if (use_cache)
dst = dst_cache_get(&t->dst_cache);
- if (!ip6_tnl_xmit_ctl(t, &fl6->saddr, &fl6->daddr))
+ if (!ip6_tnl_xmit_ctl(t, &fl6->saddr, &fl6->daddr)) {
+ reason = SKB_DROP_REASON_DEV_READY;
goto tx_err_link_failure;
+ }
if (!dst) {
route_lookup:
@@ -1179,18 +1198,22 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
dst = ip6_route_output(net, NULL, fl6);
- if (dst->error)
+ if (dst->error) {
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_err_link_failure;
+ }
dst = xfrm_lookup(net, dst, flowi6_to_flowi(fl6), NULL, 0);
if (IS_ERR(dst)) {
- err = PTR_ERR(dst);
dst = NULL;
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_err_link_failure;
}
if (t->parms.collect_md && ipv6_addr_any(&fl6->saddr) &&
ipv6_dev_get_saddr(net, ip6_dst_idev(dst)->dev,
- &fl6->daddr, 0, &fl6->saddr))
+ &fl6->daddr, 0, &fl6->saddr)) {
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_err_link_failure;
+ }
ndst = dst;
}
@@ -1200,6 +1223,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
DEV_STATS_INC(dev, collisions);
net_warn_ratelimited("%s: Local routing loop detected!\n",
t->parms.name);
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_err_dst_release;
}
mtu = dst6_mtu(dst) - eth_hlen - psh_hlen - t->tun_hlen;
@@ -1213,7 +1237,7 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
skb_dst_update_pmtu_no_confirm(skb, mtu);
if (skb->len - t->tun_hlen - eth_hlen > mtu && !skb_is_gso(skb)) {
*pmtu = mtu;
- err = -EMSGSIZE;
+ reason = SKB_DROP_REASON_PKT_TOO_BIG;
goto tx_err_dst_release;
}
@@ -1236,12 +1260,16 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
*/
max_headroom += LL_RESERVED_SPACE(tdev);
- if (skb_cow_head(skb, max_headroom))
+ if (skb_cow_head(skb, max_headroom)) {
+ reason = SKB_DROP_REASON_NOMEM;
goto tx_err_dst_release;
+ }
if (t->parms.collect_md) {
- if (t->encap.type != TUNNEL_ENCAP_NONE)
+ if (t->encap.type != TUNNEL_ENCAP_NONE) {
+ reason = SKB_DROP_REASON_TNL_ENCAP;
goto tx_err_dst_release;
+ }
} else {
if (use_cache && ndst)
dst_cache_set_ip6(&t->dst_cache, ndst, &fl6->saddr);
@@ -1264,9 +1292,8 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
+ dst->header_len + t->hlen;
ip_tunnel_adj_headroom(dev, max_headroom);
- err = ip6_tnl_encap(skb, t, &proto, fl6);
- if (err)
- return err;
+ if (ip6_tnl_encap(skb, t, &proto, fl6))
+ return SKB_DROP_REASON_TNL_ENCAP;
if (encap_limit >= 0) {
init_tel_txopt(&opt, encap_limit);
@@ -1283,21 +1310,22 @@ int ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,
ipv6h->saddr = fl6->saddr;
ipv6h->daddr = fl6->daddr;
ip6tunnel_xmit(NULL, skb, dev, 0);
- return 0;
+ return SKB_NOT_DROPPED_YET;
tx_err_link_failure:
DEV_STATS_INC(dev, tx_carrier_errors);
dst_link_failure(skb);
tx_err_dst_release:
dst_release(dst);
- return err;
+ return reason;
}
EXPORT_SYMBOL(ip6_tnl_xmit);
-static inline int
+static inline enum skb_drop_reason
ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
u8 protocol)
{
struct ip6_tnl *t = netdev_priv(dev);
+ enum skb_drop_reason reason;
struct ipv6hdr *ipv6h;
const struct iphdr *iph;
int encap_limit = -1;
@@ -1306,11 +1334,10 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
__u8 dsfield, orig_dsfield;
__u32 mtu;
u8 tproto;
- int err;
tproto = READ_ONCE(t->parms.proto);
if (tproto != protocol && tproto != 0)
- return -1;
+ return SKB_DROP_REASON_UNHANDLED_PROTO;
if (t->parms.collect_md) {
struct ip_tunnel_info *tun_info;
@@ -1319,7 +1346,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
tun_info = skb_tunnel_info(skb);
if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
ip_tunnel_info_af(tun_info) != AF_INET6))
- return -1;
+ return SKB_DROP_REASON_TUNNEL_TXINFO;
key = &tun_info->key;
memset(&fl6, 0, sizeof(fl6));
fl6.flowi6_proto = protocol;
@@ -1356,7 +1383,7 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
if (tel->encap_limit == 0) {
icmpv6_ndo_send(skb, ICMPV6_PARAMPROB,
ICMPV6_HDR_FIELD, offset + 2);
- return -1;
+ return SKB_DROP_REASON_IPV6_BAD_EXTHDR;
}
encap_limit = tel->encap_limit - 1;
}
@@ -1398,15 +1425,15 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
dsfield = INET_ECN_encapsulate(dsfield, orig_dsfield);
if (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))
- return -1;
+ return SKB_DROP_REASON_NOMEM;
skb_set_inner_ipproto(skb, protocol);
- err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
- protocol);
- if (err != 0) {
+ reason = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu,
+ protocol);
+ if (reason) {
/* XXX: send ICMP error even if DF is not set. */
- if (err == -EMSGSIZE)
+ if (reason == SKB_DROP_REASON_PKT_TOO_BIG)
switch (protocol) {
case IPPROTO_IPIP:
icmp_ndo_send(skb, ICMP_DEST_UNREACH,
@@ -1418,20 +1445,21 @@ ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,
default:
break;
}
- return -1;
+ return reason;
}
- return 0;
+ return SKB_NOT_DROPPED_YET;
}
static netdev_tx_t
ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip6_tnl *t = netdev_priv(dev);
u8 ipproto;
- int ret;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto tx_err;
switch (skb->protocol) {
@@ -1439,19 +1467,22 @@ ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)
ipproto = IPPROTO_IPIP;
break;
case htons(ETH_P_IPV6):
- if (ip6_tnl_addr_conflict(t, ipv6_hdr(skb)))
+ if (ip6_tnl_addr_conflict(t, ipv6_hdr(skb))) {
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
goto tx_err;
+ }
ipproto = IPPROTO_IPV6;
break;
case htons(ETH_P_MPLS_UC):
ipproto = IPPROTO_MPLS;
break;
default:
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto tx_err;
}
- ret = ipxip6_tnl_xmit(skb, dev, ipproto);
- if (ret < 0)
+ reason = ipxip6_tnl_xmit(skb, dev, ipproto);
+ if (reason)
goto tx_err;
return NETDEV_TX_OK;
@@ -1459,7 +1490,7 @@ ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)
tx_err:
DEV_STATS_INC(dev, tx_errors);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NETDEV_TX_OK;
}
|
| 27/3 | 2026/09/25 05:01 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29482 output: 38 thoughts: 1744 Thoughts: **KMSAN Fuzzing Session Justification**
Okay, so I'm looking at this patch series and trying to figure out if it warrants firing up a dedicated KMSAN fuzzing session, in addition to our usual KASAN coverage. Let's break this down.
This series seems to be a focused instrumentation and conversion effort. It's about adding `kfree_skb_reason` to the GRE and IP tunnel networking paths. It's replacing the old `kfree_skb()` calls and error codes with proper `enum skb_drop_reason` values. This is good; it gives us more granular information about *why* packets are being dropped, which is useful for debugging and, potentially, for fuzzing.
My primary concern, though, is whether this introduces any new memory safety vulnerabilities that KASAN might miss. I need to be *sure* this patch doesn't:
1. Introduce new kernel structures that are sent to user space with uninitialized fields.
2. Have conditional logic or branches that depend on uninitialized variables or struct fields.
3. Allocate or initialize complex data structures where uninitialized fields could be read later.
4. Introduce bounds checking, lengths, or logic that allows surrounding code to access uninitialized bytes of existing buffers.
So, I'm going through the changes meticulously. The code touched is: `include/net/dropreason-core.h`, `include/net/gre.h`, `include/net/ip6_tunnel.h`, `include/net/ip_tunnels.h`, `net/ipv4/gre_demux.c`, `net/ipv4/ip_gre.c`, `net/ipv4/ip_tunnel.c`, `net/ipv4/ip_tunnel_core.c`, `net/ipv6/ip6_gre.c`, and `net/ipv6/ip6_tunnel.c`. Essentially, it's touching a lot of tunnel code.
I'm starting with `gre_parse_header`. Originally, it returned an `int` for header length or an error. Now, it returns an `enum skb_drop_reason`. But, where does the code set `tpi->hdr_len`? This is critical. I *need* to be sure that the header length is set *correctly* before being used.
Looking at `net/ipv4/gre_demux.c`, in the new code, I see:
```c
enum skb_drop_reason
gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
bool icmp_err, __be16 proto, int nhs)
{
const struct gre_base_hdr *greh;
__be32 *options;
int hdr_len;
if (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))
return SKB_DROP_REASON_HDR_TRUNC;
greh = (struct gre_base_hdr *)(skb->data + nhs);
if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
return SKB_DROP_REASON_GRE_INVALID_HDR;
gre_flags_to_tnl_flags(tpi->flags, greh->flags);
hdr_len = gre_calc_hlen(tpi->flags);
if (!pskb_may_pull(skb, nhs + hdr_len))
return SKB_DROP_REASON_HDR_TRUNC;
greh = (struct gre_base_hdr *)(skb->data + nhs);
tpi->proto = greh->protocol;
...
if (tpi->flags[0] & TUNNEL_ERSPAN_OPT) {
...
}
return SKB_NOT_DROPPED_YET;
}
```
Wait! Is `hdr_len` ever assigned to `tpi->hdr_len`? **No!** That could be a problem! Now I need to see who calls this function. `net/ipv4/ip_gre.c` calls `gre_parse_header`. And it *uses* `tpi.hdr_len`. This is a *major* red flag! Without setting that value, there will be uninitialized memory. We must check how the value is initialized. I need to make sure this is initialized. Now I must check the header length function to confirm.
|
| 28/3 | 2026/09/25 05:02 | tool | read-file |
0mArgs:{
"File": "net/ipv4/gre_demux.c",
"FirstLine": 55,
"LineCount": 95
}Results: {
"Contents": " 55:\t\treturn 0;\n 56:\t}\n 57:\tEXPORT_SYMBOL_GPL(gre_del_protocol);\n 58:\t\n 59:\t/* Fills in tpi, including the header length to be pulled in tpi-\u003ehdr_len,\n 60:\t * and returns SKB_NOT_DROPPED_YET, or the reason to drop the packet if the\n 61:\t * header is rejected.\n 62:\t * Note that caller must use pskb_may_pull() before pulling GRE header.\n 63:\t *\n 64:\t * @icmp_err is set by the ICMP error handlers, which only get a part of\n 65:\t * the original packet: a checksum failure does not reject the header then,\n 66:\t * the checksum is still computed and the rest of the header is parsed.\n 67:\t */\n 68:\tenum skb_drop_reason\n 69:\tgre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n 70:\t\t\t bool icmp_err, __be16 proto, int nhs)\n 71:\t{\n 72:\t\tconst struct gre_base_hdr *greh;\n 73:\t\t__be32 *options;\n 74:\t\tint hdr_len;\n 75:\t\n 76:\t\tif (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))\n 77:\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n 78:\t\n 79:\t\tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n 80:\t\tif (unlikely(greh-\u003eflags \u0026 (GRE_VERSION | GRE_ROUTING)))\n 81:\t\t\treturn SKB_DROP_REASON_GRE_INVALID_HDR;\n 82:\t\n 83:\t\tgre_flags_to_tnl_flags(tpi-\u003eflags, greh-\u003eflags);\n 84:\t\thdr_len = gre_calc_hlen(tpi-\u003eflags);\n 85:\t\n 86:\t\tif (!pskb_may_pull(skb, nhs + hdr_len))\n 87:\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n 88:\t\n 89:\t\tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n 90:\t\ttpi-\u003eproto = greh-\u003eprotocol;\n 91:\t\n 92:\t\toptions = (__be32 *)(greh + 1);\n 93:\t\tif (greh-\u003eflags \u0026 GRE_CSUM) {\n 94:\t\t\tif (!skb_checksum_simple_validate(skb)) {\n 95:\t\t\t\tskb_checksum_try_convert(skb, IPPROTO_GRE,\n 96:\t\t\t\t\t\t\t null_compute_pseudo);\n 97:\t\t\t} else if (!icmp_err) {\n 98:\t\t\t\treturn SKB_DROP_REASON_GRE_CSUM;\n 99:\t\t\t}\n 100:\t\n 101:\t\t\toptions++;\n 102:\t\t}\n 103:\t\n 104:\t\tif (greh-\u003eflags \u0026 GRE_KEY) {\n 105:\t\t\ttpi-\u003ekey = *options;\n 106:\t\t\toptions++;\n 107:\t\t} else {\n 108:\t\t\ttpi-\u003ekey = 0;\n 109:\t\t}\n 110:\t\tif (unlikely(greh-\u003eflags \u0026 GRE_SEQ)) {\n 111:\t\t\ttpi-\u003eseq = *options;\n 112:\t\t\toptions++;\n 113:\t\t} else {\n 114:\t\t\ttpi-\u003eseq = 0;\n 115:\t\t}\n 116:\t\t/* WCCP version 1 and 2 protocol decoding.\n 117:\t\t * - Change protocol to IPv4/IPv6\n 118:\t\t * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header\n 119:\t\t */\n 120:\t\tif (greh-\u003eflags == 0 \u0026\u0026 tpi-\u003eproto == htons(ETH_P_WCCP)) {\n 121:\t\t\tu8 _val, *val;\n 122:\t\n 123:\t\t\tval = skb_header_pointer(skb, nhs + hdr_len,\n 124:\t\t\t\t\t\t sizeof(_val), \u0026_val);\n 125:\t\t\tif (!val)\n 126:\t\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n 127:\t\t\ttpi-\u003eproto = proto;\n 128:\t\t\tif ((*val \u0026 0xF0) != 0x40)\n 129:\t\t\t\thdr_len += 4;\n 130:\t\t}\n 131:\t\ttpi-\u003ehdr_len = hdr_len;\n 132:\t\n 133:\t\t/* ERSPAN ver 1 and 2 protocol sets GRE key field\n 134:\t\t * to 0 and sets the configured key in the\n 135:\t\t * inner erspan header field\n 136:\t\t */\n 137:\t\tif ((greh-\u003eprotocol == htons(ETH_P_ERSPAN) \u0026\u0026 hdr_len != 4) ||\n 138:\t\t greh-\u003eprotocol == htons(ETH_P_ERSPAN2)) {\n 139:\t\t\tstruct erspan_base_hdr *ershdr;\n 140:\t\n 141:\t\t\tif (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))\n 142:\t\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n 143:\t\n 144:\t\t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + nhs + hdr_len);\n 145:\t\t\ttpi-\u003ekey = cpu_to_be32(get_session_id(ershdr));\n 146:\t\t}\n 147:\t\n 148:\t\treturn SKB_NOT_DROPPED_YET;\n 149:\t}\n"
} |
| 29/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33818 output: 38 thoughts: 466 Thoughts: **Analyzing a Code Modification** Okay, hold on a second. I need to understand this patch more deeply. My initial focus was on line 131: `tpi->hdr_len = hdr_len;`. I need to determine if this line was introduced by this patch or if it was present in the original code. It's crucial to understand the context of the change. Let's look at the diff. Okay, the change seems to involve replacing `-EINVAL` with `SKB_DROP_REASON_HDR_TRUNC`, but the `tpi->hdr_len = hdr_len;` line appears untouched. Now to verify that, I need to check the history of this part of the code. Let's start with a git log search or a `git blame` command. Failing that, I can run a `grepper` search for the specific line `tpi->hdr_len = hdr_len` across the codebase to confirm its original presence. This is basic, but important, defensive programming. Understanding this context helps to determine if the issue is a bug or if there is something else going on. |
| 30/3 | 2026/09/25 05:02 | tool | grepper |
0mArgs:{
"Expression": "hdr_len = hdr_len",
"PathPrefix": "net/ipv4/gre_demux.c"
}Results: {
"Output": "net/ipv4/gre_demux.c=69=gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n--\nnet/ipv4/gre_demux.c-130-\t}\nnet/ipv4/gre_demux.c:131:\ttpi-\u003ehdr_len = hdr_len;\nnet/ipv4/gre_demux.c-132-\n"
} |
| 31/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34684 output: 20 thoughts: 505 Thoughts: **Analyzing the Usage of `tpi->hdr_len` in `gre_parse_header` and its Callers** Okay, so I'm digging into how `tpi->hdr_len` is used and particularly, the potential for it to be uninitialized in certain scenarios within the GRE parsing logic. My first thought was, "Aha! It's assigned at line 131 in `gre_parse_header`." However, the critical question popped into my mind: What happens if `gre_parse_header` fails *before* line 131? I then recalled the error handling. If `gre_parse_header` fails prematurely, it returns a drop reason (like `SKB_DROP_REASON_HDR_TRUNC`, `SKB_DROP_REASON_GRE_INVALID_HDR`, or `SKB_DROP_REASON_GRE_CSUM`). These drop reasons are non-zero, essentially evaluating to `true`. This means the calling function will jump to `drop` and I can see this in the code from `net/ipv4/ip_gre.c`. In this scenario, if the return value of `gre_parse_header` is not zero and does not equal `SKB_NOT_DROPPED_YET` then it will jump to drop, and will not use the value of `tpi` at all, including `tpi->hdr_len`. However, if the return value is zero, then this means that the parsing completed and line 131 *was* reached, so `tpi->hdr_len` would have been set. Now, I considered another edge case. What if `gre_parse_header` fails *after* line 131, specifically at line 142 where it checks for buffer length? `if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr))) return SKB_DROP_REASON_HDR_TRUNC;` Even though `tpi->hdr_len` would have been set by then, the function still returns a non-zero drop reason, and the caller will still jump to `drop` without any subsequent use of the potentially incorrect `tpi` state. Next, I looked at the error-handling calls to `gre_parse_header`. Both `gre_err` and `ip6gre_err` call `gre_parse_header`. In both of these cases, a non-zero return results in an immediate return from the function, so any issue within `gre_parse_header` is quickly handled and doesn't propagate a potential uninitialized value. Finally, I'm thinking, "Let's broaden the scope. Are there any other callers of `gre_parse_header` in the kernel? Are they all correctly handling the return value?" A quick `grepper` search should reveal all the other calls, and I'll need to review those to ensure the same robust error handling is in place everywhere. This will ensure that `tpi->hdr_len` is always used safely or not at all. |
| 32/3 | 2026/09/25 05:02 | tool | grepper |
0mArgs:{
"Expression": "gre_parse_header\\("
}Results: {
"Output": "include/net/gre.h=35=enum skb_drop_reason\ninclude/net/gre.h:36:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\ninclude/net/gre.h-37-\t\t bool icmp_err, __be16 proto, int nhs);\n--\nnet/ipv4/gre_demux.c=68=enum skb_drop_reason\nnet/ipv4/gre_demux.c:69:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\nnet/ipv4/gre_demux.c-70-\t\t bool icmp_err, __be16 proto, int nhs)\n--\nnet/ipv4/ip_gre.c=219=static void gre_err(struct sk_buff *skb, u32 info)\n--\nnet/ipv4/ip_gre.c-239-\nnet/ipv4/ip_gre.c:240:\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IP),\nnet/ipv4/ip_gre.c-241-\t\t\t iph-\u003eihl * 4))\n--\nnet/ipv4/ip_gre.c=449=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv4/ip_gre.c-461-\nnet/ipv4/ip_gre.c:462:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IP), 0);\nnet/ipv4/ip_gre.c-463-\tif (reason)\n--\nnet/ipv6/ip6_gre.c=384=static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n--\nnet/ipv6/ip6_gre.c-391-\nnet/ipv6/ip6_gre.c:392:\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IPV6),\nnet/ipv6/ip6_gre.c-393-\t\t\t offset))\n--\nnet/ipv6/ip6_gre.c=570=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-574-\nnet/ipv6/ip6_gre.c:575:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\nnet/ipv6/ip6_gre.c-576-\tif (reason)\n"
} |
| 33/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36567 output: 21 thoughts: 57 Thoughts: Here's my analysis of the provided text, rendered as though I'm thinking it: **Digging into the GRE Header Parsing** Okay, so I've confirmed that I've accounted for every call to `gre_parse_header`. Now, I need to see what's happening internally. My next step is to examine `__iptunnel_pull_header`. I'm going to track down every instance where this function, and potentially its related function `__iptunnel_pull_header_reason` is used. Understanding *how* and *why* these functions are called will be crucial to my broader understanding of this GRE header parsing logic. I need to trace the control flow to identify all the call sites. |
| 34/3 | 2026/09/25 05:02 | tool | grepper |
0mArgs:{
"Expression": "__iptunnel_pull_header"
}Results: {
"Output": "drivers/net/vxlan/vxlan_core.c=1657=static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/vxlan/vxlan_core.c-1722-\ndrivers/net/vxlan/vxlan_core.c:1723:\tif (__iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,\ndrivers/net/vxlan/vxlan_core.c-1724-\t\t\t\t !net_eq(vxlan-\u003enet, dev_net(vxlan-\u003edev)))) {\n--\ninclude/net/ip_tunnels.h=613=enum skb_drop_reason\ninclude/net/ip_tunnels.h:614:__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-615-\t\t\t __be16 inner_proto, bool raw_proto, bool xnet);\ninclude/net/ip_tunnels.h-616-\ninclude/net/ip_tunnels.h:617:static inline int __iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-618-\t\t\t\t\t __be16 inner_proto, bool raw_proto,\n--\ninclude/net/ip_tunnels.h-620-{\ninclude/net/ip_tunnels.h:621:\treturn __iptunnel_pull_header_reason(skb, hdr_len, inner_proto,\ninclude/net/ip_tunnels.h-622-\t\t\t\t\t raw_proto, xnet) ? -ENOMEM : 0;\n--\ninclude/net/ip_tunnels.h=625=static inline int iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n--\ninclude/net/ip_tunnels.h-627-{\ninclude/net/ip_tunnels.h:628:\treturn __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);\ninclude/net/ip_tunnels.h-629-}\n--\ninclude/net/udp.h=632=static inline void udp_post_segment_fix_csum(struct sk_buff *skb)\n--\ninclude/net/udp.h-638-\t * can reach an UDP socket with CHECKSUM_NONE, because\ninclude/net/udp.h:639:\t * __iptunnel_pull_header() converts CHECKSUM_PARTIAL into NONE.\ninclude/net/udp.h-640-\t * SKB_GSO_UDP_L4 or SKB_GSO_FRAGLIST packets with no UDP tunnel will\n--\nnet/ipv4/ip_gre.c=267=static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-313-\nnet/ipv4/ip_gre.c:314:\t\treason = __iptunnel_pull_header_reason(skb, len,\nnet/ipv4/ip_gre.c-315-\t\t\t\t\t\t htons(ETH_P_TEB),\n--\nnet/ipv4/ip_gre.c-338-\nnet/ipv4/ip_gre.c:339:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv4/ip_gre.c-340-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv4/ip_gre.c=368=static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-384-\nnet/ipv4/ip_gre.c:385:\t\treason = __iptunnel_pull_header_reason(skb, hdr_len,\nnet/ipv4/ip_gre.c-386-\t\t\t\t\t\t tpi-\u003eproto, raw_proto,\n--\nnet/ipv4/ip_tunnel_core.c=109=enum skb_drop_reason\nnet/ipv4/ip_tunnel_core.c:110:__iptunnel_pull_header_reason(struct sk_buff *skb, int hdr_len,\nnet/ipv4/ip_tunnel_core.c-111-\t\t\t __be16 inner_proto, bool raw_proto, bool xnet)\n--\nnet/ipv4/ip_tunnel_core.c-147-}\nnet/ipv4/ip_tunnel_core.c:148:EXPORT_SYMBOL_GPL(__iptunnel_pull_header_reason);\nnet/ipv4/ip_tunnel_core.c-149-\n--\nnet/ipv6/ip6_gre.c=488=static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-514-\nnet/ipv6/ip6_gre.c:515:\t\treason = __iptunnel_pull_header_reason(skb, len,\nnet/ipv6/ip6_gre.c-516-\t\t\t\t\t\t htons(ETH_P_TEB),\n--\nnet/ipv6/ip6_gre.c-541-\nnet/ipv6/ip6_gre.c:542:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv6/ip6_gre.c-543-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv6/ip6_gre.c=570=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-578-\nnet/ipv6/ip6_gre.c:579:\treason = __iptunnel_pull_header_reason(skb, tpi.hdr_len, tpi.proto,\nnet/ipv6/ip6_gre.c-580-\t\t\t\t\t false, false);\n"
} |
| 35/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38331 output: 23 thoughts: 246 Thoughts: **Analyzing IPv6 GRE Header Processing** Okay, let's dive into this `net/ipv6/ip6_gre.c` code. My initial observation is a subtle but potentially significant change in the error handling and header parsing logic. I see that the original code used `hdr_len` directly after calling `gre_parse_header`, but now they are using `tpi.hdr_len`. I'm curious if this change introduces a vulnerability or bug. My expert intuition tells me to drill down further. I've got to ensure the logic and calculations are sound and no information is being lost or mishandled. I see the direct use of the return value in the original, and now a "reason" variable. It looks like the original code had a single return value to indicate success or failure, while the updated code uses an enumeration. The second part of the change relates to `__iptunnel_pull_header_reason`. I should check all the callers of `ip6_tnl_xmit` to understand the implications of this refactoring, making sure the header length is correctly calculated and that the `reason` code is handled correctly across the codebase. I need to understand how the upstream headers are being pulled, and how the changes affect any tunnel-specific processing. |
| 36/3 | 2026/09/25 05:02 | tool | grepper |
0mArgs:{
"Expression": "ip6_tnl_xmit\\("
}Results: {
"Output": "include/net/ip6_tunnel.h=146=enum skb_drop_reason\ninclude/net/ip6_tunnel.h:147:ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\ninclude/net/ip6_tunnel.h-148-\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto);\n--\nnet/ipv6/ip6_gre.c=719=static enum skb_drop_reason __gre6_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-787-\nnet/ipv6/ip6_gre.c:788:\treturn ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,\nnet/ipv6/ip6_gre.c-789-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_gre.c=929=static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-1096-\t}\nnet/ipv6/ip6_gre.c:1097:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_gre.c-1098-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_tunnel.c=1111=enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1112:ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\nnet/ipv6/ip6_tunnel.c-1113-\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)\n--\nnet/ipv6/ip6_tunnel.c=1323=static inline enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1324:ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\nnet/ipv6/ip6_tunnel.c-1325-\t\tu8 protocol)\n--\nnet/ipv6/ip6_tunnel.c-1431-\nnet/ipv6/ip6_tunnel.c:1432:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_tunnel.c-1433-\t\t\t protocol);\n--\nnet/ipv6/ip6_tunnel.c=1455=ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n--\nnet/ipv6/ip6_tunnel.c-1483-\nnet/ipv6/ip6_tunnel.c:1484:\treason = ipxip6_tnl_xmit(skb, dev, ipproto);\nnet/ipv6/ip6_tunnel.c-1485-\tif (reason)\n"
} |
| 37/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39712 output: 40 thoughts: 74 Thoughts: Okay, let's get down to brass tacks. **Investigating a Potential Issue in `ip6_tnl_xmit`** Right, so I've confirmed all the callers of `ip6_tnl_xmit` are accounted for, which is a good starting point. Now, I want to drill down and see if there's any chance this function might be returning an uninitialized `reason` value, a classic source of unpredictable behavior and potential security concerns. To do that, I'm going to focus my attention on the code within `ip6_tnl_xmit` itself. Specifically, I'll be meticulously examining lines 1111 through 1320 in `net/ipv6/ip6_tunnel.c`. I'll be looking for any path that might leave `reason` in an undefined state. This kind of thorough analysis is what's needed to truly understand the code. |
| 38/3 | 2026/09/25 05:02 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 1110,
"LineCount": 90
}Results: {
"Contents": "1110:\t\n1111:\tenum skb_drop_reason\n1112:\tip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\n1113:\t\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)\n1114:\t{\n1115:\t\tstruct ip6_tnl *t = netdev_priv(dev);\n1116:\t\tstruct net *net = t-\u003enet;\n1117:\t\tstruct ipv6hdr *ipv6h;\n1118:\t\tstruct ipv6_tel_txoption opt;\n1119:\t\tstruct dst_entry *dst = NULL, *ndst = NULL;\n1120:\t\tstruct net_device *tdev;\n1121:\t\tint err_count, mtu;\n1122:\t\tunsigned int eth_hlen = t-\u003edev-\u003etype == ARPHRD_ETHER ? ETH_HLEN : 0;\n1123:\t\tunsigned int psh_hlen = sizeof(struct ipv6hdr) + t-\u003eencap_hlen;\n1124:\t\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n1125:\t\tunsigned int max_headroom = psh_hlen;\n1126:\t\t__be16 payload_protocol;\n1127:\t\tbool use_cache = false;\n1128:\t\tu8 hop_limit;\n1129:\t\n1130:\t\tpayload_protocol = skb_protocol(skb, true);\n1131:\t\n1132:\t\tif (t-\u003eparms.collect_md) {\n1133:\t\t\thop_limit = skb_tunnel_info(skb)-\u003ekey.ttl;\n1134:\t\t\tgoto route_lookup;\n1135:\t\t} else {\n1136:\t\t\thop_limit = t-\u003eparms.hop_limit;\n1137:\t\t}\n1138:\t\n1139:\t\t/* NBMA tunnel */\n1140:\t\tif (ipv6_addr_any(\u0026t-\u003eparms.raddr)) {\n1141:\t\t\tif (payload_protocol == htons(ETH_P_IPV6)) {\n1142:\t\t\t\tstruct in6_addr *addr6;\n1143:\t\t\t\tstruct neighbour *neigh;\n1144:\t\t\t\tint addr_type;\n1145:\t\n1146:\t\t\t\tif (!skb_dst(skb)) {\n1147:\t\t\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n1148:\t\t\t\t\tgoto tx_err_link_failure;\n1149:\t\t\t\t}\n1150:\t\n1151:\t\t\t\tneigh = dst_neigh_lookup(skb_dst(skb),\n1152:\t\t\t\t\t\t\t \u0026ipv6_hdr(skb)-\u003edaddr);\n1153:\t\t\t\tif (!neigh) {\n1154:\t\t\t\t\treason = SKB_DROP_REASON_NEIGH_CREATEFAIL;\n1155:\t\t\t\t\tgoto tx_err_link_failure;\n1156:\t\t\t\t}\n1157:\t\n1158:\t\t\t\taddr6 = (struct in6_addr *)\u0026neigh-\u003eprimary_key;\n1159:\t\t\t\taddr_type = ipv6_addr_type(addr6);\n1160:\t\n1161:\t\t\t\tif (addr_type == IPV6_ADDR_ANY)\n1162:\t\t\t\t\taddr6 = \u0026ipv6_hdr(skb)-\u003edaddr;\n1163:\t\n1164:\t\t\t\tmemcpy(\u0026fl6-\u003edaddr, addr6, sizeof(fl6-\u003edaddr));\n1165:\t\t\t\tneigh_release(neigh);\n1166:\t\t\t} else if (payload_protocol == htons(ETH_P_IP)) {\n1167:\t\t\t\tconst struct rtable *rt = skb_rtable(skb);\n1168:\t\n1169:\t\t\t\tif (!rt) {\n1170:\t\t\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n1171:\t\t\t\t\tgoto tx_err_link_failure;\n1172:\t\t\t\t}\n1173:\t\n1174:\t\t\t\tif (rt-\u003ert_gw_family == AF_INET6)\n1175:\t\t\t\t\tmemcpy(\u0026fl6-\u003edaddr, \u0026rt-\u003ert_gw6, sizeof(fl6-\u003edaddr));\n1176:\t\t\t}\n1177:\t\t} else if (t-\u003eparms.proto != 0 \u0026\u0026 !(t-\u003eparms.flags \u0026\n1178:\t\t\t\t\t\t (IP6_TNL_F_USE_ORIG_TCLASS |\n1179:\t\t\t\t\t\t IP6_TNL_F_USE_ORIG_FWMARK))) {\n1180:\t\t\t/* enable the cache only if neither the outer protocol nor the\n1181:\t\t\t * routing decision depends on the current inner header value\n1182:\t\t\t */\n1183:\t\t\tuse_cache = true;\n1184:\t\t}\n1185:\t\n1186:\t\tif (use_cache)\n1187:\t\t\tdst = dst_cache_get(\u0026t-\u003edst_cache);\n1188:\t\n1189:\t\tif (!ip6_tnl_xmit_ctl(t, \u0026fl6-\u003esaddr, \u0026fl6-\u003edaddr)) {\n1190:\t\t\treason = SKB_DROP_REASON_DEV_READY;\n1191:\t\t\tgoto tx_err_link_failure;\n1192:\t\t}\n1193:\t\n1194:\t\tif (!dst) {\n1195:\troute_lookup:\n1196:\t\t\t/* add dsfield to flowlabel for route lookup */\n1197:\t\t\tfl6-\u003eflowlabel = ip6_make_flowinfo(dsfield, fl6-\u003eflowlabel);\n1198:\t\n1199:\t\t\tdst = ip6_route_output(net, NULL, fl6);\n"
} |
| 39/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41540 output: 40 thoughts: 17 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person: **Diving into `ip6_tnl_xmit`** Alright, so the task at hand is to understand the flow of logic within `ip6_tnl_xmit`. Let's assume I'm already familiar with the broader IPv6 tunneling context, and understand its role in encapsulating IPv6 traffic within another protocol. The immediate goal is to get a handle on the key steps involved in *transmitting* this encapsulated data. I need to figure out what data is being pulled from where, how it’s being packaged, and crucially, how the underlying network stack is being interacted with to send the packet out the door. The function's name is a good starting point, now let's analyze its actual implementation and see how it works. |
| 40/3 | 2026/09/25 05:02 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 1200,
"LineCount": 80
}Results: {
"Contents": "1200:\t\n1201:\t\t\tif (dst-\u003eerror) {\n1202:\t\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n1203:\t\t\t\tgoto tx_err_link_failure;\n1204:\t\t\t}\n1205:\t\t\tdst = xfrm_lookup(net, dst, flowi6_to_flowi(fl6), NULL, 0);\n1206:\t\t\tif (IS_ERR(dst)) {\n1207:\t\t\t\tdst = NULL;\n1208:\t\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n1209:\t\t\t\tgoto tx_err_link_failure;\n1210:\t\t\t}\n1211:\t\t\tif (t-\u003eparms.collect_md \u0026\u0026 ipv6_addr_any(\u0026fl6-\u003esaddr) \u0026\u0026\n1212:\t\t\t ipv6_dev_get_saddr(net, ip6_dst_idev(dst)-\u003edev,\n1213:\t\t\t\t\t \u0026fl6-\u003edaddr, 0, \u0026fl6-\u003esaddr)) {\n1214:\t\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n1215:\t\t\t\tgoto tx_err_link_failure;\n1216:\t\t\t}\n1217:\t\t\tndst = dst;\n1218:\t\t}\n1219:\t\n1220:\t\ttdev = dst_dev(dst);\n1221:\t\n1222:\t\tif (tdev == dev) {\n1223:\t\t\tDEV_STATS_INC(dev, collisions);\n1224:\t\t\tnet_warn_ratelimited(\"%s: Local routing loop detected!\\n\",\n1225:\t\t\t\t\t t-\u003eparms.name);\n1226:\t\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n1227:\t\t\tgoto tx_err_dst_release;\n1228:\t\t}\n1229:\t\tmtu = dst6_mtu(dst) - eth_hlen - psh_hlen - t-\u003etun_hlen;\n1230:\t\tif (encap_limit \u003e= 0) {\n1231:\t\t\tmax_headroom += 8;\n1232:\t\t\tmtu -= 8;\n1233:\t\t}\n1234:\t\tmtu = max(mtu, skb-\u003eprotocol == htons(ETH_P_IPV6) ?\n1235:\t\t\t IPV6_MIN_MTU : IPV4_MIN_MTU);\n1236:\t\n1237:\t\tskb_dst_update_pmtu_no_confirm(skb, mtu);\n1238:\t\tif (skb-\u003elen - t-\u003etun_hlen - eth_hlen \u003e mtu \u0026\u0026 !skb_is_gso(skb)) {\n1239:\t\t\t*pmtu = mtu;\n1240:\t\t\treason = SKB_DROP_REASON_PKT_TOO_BIG;\n1241:\t\t\tgoto tx_err_dst_release;\n1242:\t\t}\n1243:\t\n1244:\t\terr_count = READ_ONCE(t-\u003eerr_count);\n1245:\t\tif (err_count \u003e 0) {\n1246:\t\t\tif (time_before(jiffies,\n1247:\t\t\t\t\tREAD_ONCE(t-\u003eerr_time) + IP6TUNNEL_ERR_TIMEO)) {\n1248:\t\t\t\tWRITE_ONCE(t-\u003eerr_count, err_count - 1);\n1249:\t\n1250:\t\t\t\tdst_link_failure(skb);\n1251:\t\t\t} else {\n1252:\t\t\t\tWRITE_ONCE(t-\u003eerr_count, 0);\n1253:\t\t\t}\n1254:\t\t}\n1255:\t\n1256:\t\tskb_scrub_packet(skb, !net_eq(t-\u003enet, dev_net(dev)));\n1257:\t\n1258:\t\t/*\n1259:\t\t * Okay, now see if we can stuff it in the buffer as-is.\n1260:\t\t */\n1261:\t\tmax_headroom += LL_RESERVED_SPACE(tdev);\n1262:\t\n1263:\t\tif (skb_cow_head(skb, max_headroom)) {\n1264:\t\t\treason = SKB_DROP_REASON_NOMEM;\n1265:\t\t\tgoto tx_err_dst_release;\n1266:\t\t}\n1267:\t\n1268:\t\tif (t-\u003eparms.collect_md) {\n1269:\t\t\tif (t-\u003eencap.type != TUNNEL_ENCAP_NONE) {\n1270:\t\t\t\treason = SKB_DROP_REASON_TNL_ENCAP;\n1271:\t\t\t\tgoto tx_err_dst_release;\n1272:\t\t\t}\n1273:\t\t} else {\n1274:\t\t\tif (use_cache \u0026\u0026 ndst)\n1275:\t\t\t\tdst_cache_set_ip6(\u0026t-\u003edst_cache, ndst, \u0026fl6-\u003esaddr);\n1276:\t\t}\n1277:\t\tskb_dst_set(skb, dst);\n1278:\t\n1279:\t\tif (hop_limit == 0) {\n"
} |
| 41/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43135 output: 40 thoughts: 17 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary: **Peering into `ip6_tnl_xmit`** Alright, let's dive right in. My immediate thought is, "Let's zero in on the tail end of the `ip6_tnl_xmit` function." That's usually where the rubber meets the road, where the actual packet transmission decisions are made, and where subtle performance bottlenecks or error conditions often hide. I want to see precisely how it's finalizing things before handing off the packet. Are there any surprising calls to functions I should know? Are there any obvious areas for optimization, or points of potential failure I should immediately recognize? Specifically, I'm thinking about the low-level details of how it interacts with the NIC or other hardware. Let me trace the final sequence of steps. |
| 42/3 | 2026/09/25 05:02 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 1280,
"LineCount": 45
}Results: {
"Contents": "1280:\t\t\tif (payload_protocol == htons(ETH_P_IP))\n1281:\t\t\t\thop_limit = ip_hdr(skb)-\u003ettl;\n1282:\t\t\telse if (payload_protocol == htons(ETH_P_IPV6))\n1283:\t\t\t\thop_limit = ipv6_hdr(skb)-\u003ehop_limit;\n1284:\t\t\telse\n1285:\t\t\t\thop_limit = ip6_dst_hoplimit(dst);\n1286:\t\t}\n1287:\t\n1288:\t\t/* Calculate max headroom for all the headers and adjust\n1289:\t\t * needed_headroom if necessary.\n1290:\t\t */\n1291:\t\tmax_headroom = LL_RESERVED_SPACE(tdev) + sizeof(struct ipv6hdr)\n1292:\t\t\t\t+ dst-\u003eheader_len + t-\u003ehlen;\n1293:\t\tip_tunnel_adj_headroom(dev, max_headroom);\n1294:\t\n1295:\t\tif (ip6_tnl_encap(skb, t, \u0026proto, fl6))\n1296:\t\t\treturn SKB_DROP_REASON_TNL_ENCAP;\n1297:\t\n1298:\t\tif (encap_limit \u003e= 0) {\n1299:\t\t\tinit_tel_txopt(\u0026opt, encap_limit);\n1300:\t\t\tproto = ipv6_push_frag_opts(skb, \u0026opt.ops, proto);\n1301:\t\t}\n1302:\t\n1303:\t\tskb_push(skb, sizeof(struct ipv6hdr));\n1304:\t\tskb_reset_network_header(skb);\n1305:\t\tipv6h = ipv6_hdr(skb);\n1306:\t\tip6_flow_hdr(ipv6h, dsfield,\n1307:\t\t\t ip6_make_flowlabel(net, skb, fl6-\u003eflowlabel, true, fl6));\n1308:\t\tipv6h-\u003ehop_limit = hop_limit;\n1309:\t\tipv6h-\u003enexthdr = proto;\n1310:\t\tipv6h-\u003esaddr = fl6-\u003esaddr;\n1311:\t\tipv6h-\u003edaddr = fl6-\u003edaddr;\n1312:\t\tip6tunnel_xmit(NULL, skb, dev, 0);\n1313:\t\treturn SKB_NOT_DROPPED_YET;\n1314:\ttx_err_link_failure:\n1315:\t\tDEV_STATS_INC(dev, tx_carrier_errors);\n1316:\t\tdst_link_failure(skb);\n1317:\ttx_err_dst_release:\n1318:\t\tdst_release(dst);\n1319:\t\treturn reason;\n1320:\t}\n1321:\tEXPORT_SYMBOL(ip6_tnl_xmit);\n1322:\t\n1323:\tstatic inline enum skb_drop_reason\n1324:\tipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n"
} |
| 43/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44192 output: 41 thoughts: 49 Thoughts: Okay, here's my take on those thoughts, framed as my own mental processing, and tailored for someone who knows their networking stuff: **Initial Assessment of Packet Dropping in ipxip6_tnl_xmit** Right, so we're talking packet drops here, specifically within the `ipxip6_tnl_xmit` function. My initial impression is that they've taken a solid approach: initializing the `reason` variable to `SKB_DROP_REASON_NOT_SPECIFIED`. This is good practice; it gives us a clear indication of when we've *not* explicitly categorized a drop. It's the starting point. The important thing is that *every* potential error path within that function needs to either assign a specific, descriptive reason to `reason`, or ensure the value is maintained if there's no need to change it. That's absolutely critical for debugging and performance analysis. If any error pathway fails to set it, we'll end up with an ambiguous drop reason. Now, let's dive into the function itself and see how it's implemented. I'll be looking for where those `reason` assignments happen. |
| 44/3 | 2026/09/25 05:02 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 1323,
"LineCount": 100
}Results: {
"Contents": "1323:\tstatic inline enum skb_drop_reason\n1324:\tipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\n1325:\t\t\tu8 protocol)\n1326:\t{\n1327:\t\tstruct ip6_tnl *t = netdev_priv(dev);\n1328:\t\tenum skb_drop_reason reason;\n1329:\t\tstruct ipv6hdr *ipv6h;\n1330:\t\tconst struct iphdr *iph;\n1331:\t\tint encap_limit = -1;\n1332:\t\t__u16 offset;\n1333:\t\tstruct flowi6 fl6;\n1334:\t\t__u8 dsfield, orig_dsfield;\n1335:\t\t__u32 mtu;\n1336:\t\tu8 tproto;\n1337:\t\n1338:\t\ttproto = READ_ONCE(t-\u003eparms.proto);\n1339:\t\tif (tproto != protocol \u0026\u0026 tproto != 0)\n1340:\t\t\treturn SKB_DROP_REASON_UNHANDLED_PROTO;\n1341:\t\n1342:\t\tif (t-\u003eparms.collect_md) {\n1343:\t\t\tstruct ip_tunnel_info *tun_info;\n1344:\t\t\tconst struct ip_tunnel_key *key;\n1345:\t\n1346:\t\t\ttun_info = skb_tunnel_info(skb);\n1347:\t\t\tif (unlikely(!tun_info || !(tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) ||\n1348:\t\t\t\t ip_tunnel_info_af(tun_info) != AF_INET6))\n1349:\t\t\t\treturn SKB_DROP_REASON_TUNNEL_TXINFO;\n1350:\t\t\tkey = \u0026tun_info-\u003ekey;\n1351:\t\t\tmemset(\u0026fl6, 0, sizeof(fl6));\n1352:\t\t\tfl6.flowi6_proto = protocol;\n1353:\t\t\tfl6.saddr = key-\u003eu.ipv6.src;\n1354:\t\t\tfl6.daddr = key-\u003eu.ipv6.dst;\n1355:\t\t\tfl6.flowlabel = key-\u003elabel;\n1356:\t\t\tdsfield = key-\u003etos;\n1357:\t\t\tswitch (protocol) {\n1358:\t\t\tcase IPPROTO_IPIP:\n1359:\t\t\t\tiph = ip_hdr(skb);\n1360:\t\t\t\torig_dsfield = ipv4_get_dsfield(iph);\n1361:\t\t\t\tbreak;\n1362:\t\t\tcase IPPROTO_IPV6:\n1363:\t\t\t\tipv6h = ipv6_hdr(skb);\n1364:\t\t\t\torig_dsfield = ipv6_get_dsfield(ipv6h);\n1365:\t\t\t\tbreak;\n1366:\t\t\tdefault:\n1367:\t\t\t\torig_dsfield = dsfield;\n1368:\t\t\t\tbreak;\n1369:\t\t\t}\n1370:\t\t} else {\n1371:\t\t\tif (!(t-\u003eparms.flags \u0026 IP6_TNL_F_IGN_ENCAP_LIMIT))\n1372:\t\t\t\tencap_limit = t-\u003eparms.encap_limit;\n1373:\t\t\tif (protocol == IPPROTO_IPV6) {\n1374:\t\t\t\toffset = ip6_tnl_parse_tlv_enc_lim(skb,\n1375:\t\t\t\t\t\t\tskb_network_header(skb));\n1376:\t\t\t\t/* ip6_tnl_parse_tlv_enc_lim() might have\n1377:\t\t\t\t * reallocated skb-\u003ehead\n1378:\t\t\t\t */\n1379:\t\t\t\tif (offset \u003e 0) {\n1380:\t\t\t\t\tstruct ipv6_tlv_tnl_enc_lim *tel;\n1381:\t\n1382:\t\t\t\t\ttel = (void *)\u0026skb_network_header(skb)[offset];\n1383:\t\t\t\t\tif (tel-\u003eencap_limit == 0) {\n1384:\t\t\t\t\t\ticmpv6_ndo_send(skb, ICMPV6_PARAMPROB,\n1385:\t\t\t\t\t\t\t\tICMPV6_HDR_FIELD, offset + 2);\n1386:\t\t\t\t\t\treturn SKB_DROP_REASON_IPV6_BAD_EXTHDR;\n1387:\t\t\t\t\t}\n1388:\t\t\t\t\tencap_limit = tel-\u003eencap_limit - 1;\n1389:\t\t\t\t}\n1390:\t\t\t}\n1391:\t\n1392:\t\t\tmemcpy(\u0026fl6, \u0026t-\u003efl.u.ip6, sizeof(fl6));\n1393:\t\t\tfl6.flowi6_proto = protocol;\n1394:\t\n1395:\t\t\tif (t-\u003eparms.flags \u0026 IP6_TNL_F_USE_ORIG_FWMARK)\n1396:\t\t\t\tfl6.flowi6_mark = skb-\u003emark;\n1397:\t\t\telse\n1398:\t\t\t\tfl6.flowi6_mark = t-\u003eparms.fwmark;\n1399:\t\t\tswitch (protocol) {\n1400:\t\t\tcase IPPROTO_IPIP:\n1401:\t\t\t\tiph = ip_hdr(skb);\n1402:\t\t\t\torig_dsfield = ipv4_get_dsfield(iph);\n1403:\t\t\t\tif (t-\u003eparms.flags \u0026 IP6_TNL_F_USE_ORIG_TCLASS)\n1404:\t\t\t\t\tdsfield = orig_dsfield;\n1405:\t\t\t\telse\n1406:\t\t\t\t\tdsfield = ip6_tclass(t-\u003eparms.flowinfo);\n1407:\t\t\t\tbreak;\n1408:\t\t\tcase IPPROTO_IPV6:\n1409:\t\t\t\tipv6h = ipv6_hdr(skb);\n1410:\t\t\t\torig_dsfield = ipv6_get_dsfield(ipv6h);\n1411:\t\t\t\tif (t-\u003eparms.flags \u0026 IP6_TNL_F_USE_ORIG_TCLASS)\n1412:\t\t\t\t\tdsfield = orig_dsfield;\n1413:\t\t\t\telse\n1414:\t\t\t\t\tdsfield = ip6_tclass(t-\u003eparms.flowinfo);\n1415:\t\t\t\tif (t-\u003eparms.flags \u0026 IP6_TNL_F_USE_ORIG_FLOWLABEL)\n1416:\t\t\t\t\tfl6.flowlabel |= ip6_flowlabel(ipv6h);\n1417:\t\t\t\tbreak;\n1418:\t\t\tdefault:\n1419:\t\t\t\torig_dsfield = dsfield = ip6_tclass(t-\u003eparms.flowinfo);\n1420:\t\t\t\tbreak;\n1421:\t\t\t}\n1422:\t\t}\n"
} |
| 45/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46254 output: 40 thoughts: 25 Thoughts: Okay, let's dive into this. Here's how I'd approach summarizing the "thoughts": **Checking Lines After 1422 in ipxip6_tnl_xmit** Right, so the prompt tells me to focus on lines *after* 1422 within the `ipxip6_tnl_xmit` function. Immediately, that tells me we're likely dealing with some core network tunneling logic, specifically related to IPv6 and IPX traffic. Since I’m being directed to a specific line number range, my mind jumps to analyzing the function's flow, probably to understand a bug fix, optimization, or a recent code change. I need to figure out the context of that function and how these lines fit into the larger picture. I’d be thinking: "What's the overall purpose? Is it encapsulation, decapsulation, header manipulation, MTU handling, or something else entirely?" The line number suggests there is a reasonably sized routine, and I would be interested in how the logic is structured in the code as it exists now. I would be considering the control flow and data structures employed. |
| 46/3 | 2026/09/25 05:02 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 1423,
"LineCount": 40
}Results: {
"Contents": "1423:\t\n1424:\t\tfl6.flowi6_uid = sock_net_uid(dev_net(dev), NULL);\n1425:\t\tdsfield = INET_ECN_encapsulate(dsfield, orig_dsfield);\n1426:\t\n1427:\t\tif (iptunnel_handle_offloads(skb, SKB_GSO_IPXIP6))\n1428:\t\t\treturn SKB_DROP_REASON_NOMEM;\n1429:\t\n1430:\t\tskb_set_inner_ipproto(skb, protocol);\n1431:\t\n1432:\t\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\n1433:\t\t\t\t protocol);\n1434:\t\tif (reason) {\n1435:\t\t\t/* XXX: send ICMP error even if DF is not set. */\n1436:\t\t\tif (reason == SKB_DROP_REASON_PKT_TOO_BIG)\n1437:\t\t\t\tswitch (protocol) {\n1438:\t\t\t\tcase IPPROTO_IPIP:\n1439:\t\t\t\t\ticmp_ndo_send(skb, ICMP_DEST_UNREACH,\n1440:\t\t\t\t\t\t ICMP_FRAG_NEEDED, htonl(mtu));\n1441:\t\t\t\t\tbreak;\n1442:\t\t\t\tcase IPPROTO_IPV6:\n1443:\t\t\t\t\ticmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);\n1444:\t\t\t\t\tbreak;\n1445:\t\t\t\tdefault:\n1446:\t\t\t\t\tbreak;\n1447:\t\t\t\t}\n1448:\t\t\treturn reason;\n1449:\t\t}\n1450:\t\n1451:\t\treturn SKB_NOT_DROPPED_YET;\n1452:\t}\n1453:\t\n1454:\tstatic netdev_tx_t\n1455:\tip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n1456:\t{\n1457:\t\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n1458:\t\tstruct ip6_tnl *t = netdev_priv(dev);\n1459:\t\tu8 ipproto;\n1460:\t\n1461:\t\treason = pskb_inet_may_pull_reason(skb);\n1462:\t\tif (reason)\n"
} |
| 47/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 47230 output: 40 thoughts: 29 Thoughts: Okay, let's dive into this code. I need to refresh my memory on the `ip6_tnl_start_xmit` function, specifically lines 1455-1495. I know this is where the core logic for IPv6 tunnel transmission resides. I'm guessing this section handles the crucial aspects of encapsulation, route selection, and perhaps even some fragmentation if the MTU dictates. I'll need to confirm if it's dealing with any specific error handling or rate-limiting considerations here as well. I'll be looking to see if these lines handle the case where the underlying transport protocol might need to be set or reconfigured based on tunnel parameters. Perhaps there is some interaction with the routing subsystem here for optimal path selection. And, of course, I'll need to ensure the packet is being constructed with the correct header structure. Let me see what I can discern! |
| 48/3 | 2026/09/25 05:02 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 1455,
"LineCount": 45
}Results: {
"Contents": "1455:\tip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n1456:\t{\n1457:\t\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n1458:\t\tstruct ip6_tnl *t = netdev_priv(dev);\n1459:\t\tu8 ipproto;\n1460:\t\n1461:\t\treason = pskb_inet_may_pull_reason(skb);\n1462:\t\tif (reason)\n1463:\t\t\tgoto tx_err;\n1464:\t\n1465:\t\tswitch (skb-\u003eprotocol) {\n1466:\t\tcase htons(ETH_P_IP):\n1467:\t\t\tipproto = IPPROTO_IPIP;\n1468:\t\t\tbreak;\n1469:\t\tcase htons(ETH_P_IPV6):\n1470:\t\t\tif (ip6_tnl_addr_conflict(t, ipv6_hdr(skb))) {\n1471:\t\t\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n1472:\t\t\t\tgoto tx_err;\n1473:\t\t\t}\n1474:\t\t\tipproto = IPPROTO_IPV6;\n1475:\t\t\tbreak;\n1476:\t\tcase htons(ETH_P_MPLS_UC):\n1477:\t\t\tipproto = IPPROTO_MPLS;\n1478:\t\t\tbreak;\n1479:\t\tdefault:\n1480:\t\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n1481:\t\t\tgoto tx_err;\n1482:\t\t}\n1483:\t\n1484:\t\treason = ipxip6_tnl_xmit(skb, dev, ipproto);\n1485:\t\tif (reason)\n1486:\t\t\tgoto tx_err;\n1487:\t\n1488:\t\treturn NETDEV_TX_OK;\n1489:\t\n1490:\ttx_err:\n1491:\t\tDEV_STATS_INC(dev, tx_errors);\n1492:\t\tDEV_STATS_INC(dev, tx_dropped);\n1493:\t\tkfree_skb_reason(skb, reason);\n1494:\t\treturn NETDEV_TX_OK;\n1495:\t}\n1496:\t\n1497:\tstatic void ip6_tnl_link_config(struct ip6_tnl *t)\n1498:\t{\n1499:\t\tstruct net_device *dev = t-\u003edev;\n"
} |
| 49/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 48180 output: 40 thoughts: 15 Thoughts: Here's a first-person summary, assuming I'm an expert and this is part of my thought process while debugging/analyzing network code: **Diving into the IPv6 Tunneling Receiver** Okay, so I need to understand what's going on. The log file points to `__ip6_tnl_rcv`. That function name is familiar. It's the core of the IPv6 tunnel receiver. Time to dig in and see what it's doing. What are the key elements to its function? Probably decoding the encapsulated packet, identifying the inner IPv6 header (if it exists) and processing it accordingly. I need to figure out the exact path the data takes to verify if it is as expected. I'll need to watch for any obvious error handling and whether it's dropping packets or forwarding them. I bet there are some relevant statistics to check too, to verify that traffic is being received and processed at the expected rate. Are there any known issues with the tunnel configuration or with fragmentation that might be causing problems? Let's trace through the code. |
| 50/3 | 2026/09/25 05:02 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 810,
"LineCount": 100
}Results: {
"Contents": " 810:\t\t\t\t struct metadata_dst *tun_dst,\n 811:\t\t\t\t int (*dscp_ecn_decapsulate)(const struct ip6_tnl *t,\n 812:\t\t\t\t\t\t\tconst struct ipv6hdr *ipv6h,\n 813:\t\t\t\t\t\t\tstruct sk_buff *skb),\n 814:\t\t\t\t bool log_ecn_err)\n 815:\t{\n 816:\t\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n 817:\t\tconst struct ipv6hdr *ipv6h;\n 818:\t\tint nh, err;\n 819:\t\n 820:\t\tif (test_bit(IP_TUNNEL_CSUM_BIT, tunnel-\u003eparms.i_flags) !=\n 821:\t\t test_bit(IP_TUNNEL_CSUM_BIT, tpi-\u003eflags)) {\n 822:\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_crc_errors);\n 823:\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 824:\t\t\treason = SKB_DROP_REASON_TNL_OPT_MISMATCH;\n 825:\t\t\tgoto drop;\n 826:\t\t}\n 827:\t\n 828:\t\tif (test_bit(IP_TUNNEL_SEQ_BIT, tunnel-\u003eparms.i_flags)) {\n 829:\t\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags)) {\n 830:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n 831:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 832:\t\t\t\treason = SKB_DROP_REASON_TNL_OPT_MISMATCH;\n 833:\t\t\t\tgoto drop;\n 834:\t\t\t}\n 835:\t\t\tif (tunnel-\u003ei_seqno \u0026\u0026\n 836:\t\t\t (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0) {\n 837:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n 838:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 839:\t\t\t\treason = SKB_DROP_REASON_TNL_OLD_SEQ;\n 840:\t\t\t\tgoto drop;\n 841:\t\t\t}\n 842:\t\t\ttunnel-\u003ei_seqno = ntohl(tpi-\u003eseq) + 1;\n 843:\t\t}\n 844:\t\n 845:\t\tskb-\u003eprotocol = tpi-\u003eproto;\n 846:\t\n 847:\t\t/* Warning: All skb pointers will be invalidated! */\n 848:\t\tif (tunnel-\u003edev-\u003etype == ARPHRD_ETHER) {\n 849:\t\t\treason = pskb_may_pull_reason(skb, ETH_HLEN);\n 850:\t\t\tif (reason) {\n 851:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n 852:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 853:\t\t\t\tgoto drop;\n 854:\t\t\t}\n 855:\t\n 856:\t\t\tskb-\u003eprotocol = eth_type_trans(skb, tunnel-\u003edev);\n 857:\t\t\tskb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);\n 858:\t\t} else {\n 859:\t\t\tskb-\u003edev = tunnel-\u003edev;\n 860:\t\t\tskb_reset_mac_header(skb);\n 861:\t\t}\n 862:\t\n 863:\t\t/* Save offset of outer header relative to skb-\u003ehead,\n 864:\t\t * because we are going to reset the network header to the inner header\n 865:\t\t * and might change skb-\u003ehead.\n 866:\t\t */\n 867:\t\tnh = skb_network_header(skb) - skb-\u003ehead;\n 868:\t\n 869:\t\tskb_reset_network_header(skb);\n 870:\t\n 871:\t\treason = skb_vlan_inet_prepare(skb, true);\n 872:\t\tif (reason) {\n 873:\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n 874:\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 875:\t\t\tgoto drop;\n 876:\t\t}\n 877:\t\n 878:\t\t/* Get the outer header. */\n 879:\t\tipv6h = (struct ipv6hdr *)(skb-\u003ehead + nh);\n 880:\t\n 881:\t\tmemset(skb-\u003ecb, 0, sizeof(struct inet6_skb_parm));\n 882:\t\n 883:\t\t__skb_tunnel_rx(skb, tunnel-\u003edev, tunnel-\u003enet);\n 884:\t\n 885:\t\terr = dscp_ecn_decapsulate(tunnel, ipv6h, skb);\n 886:\t\tif (unlikely(err)) {\n 887:\t\t\tif (log_ecn_err)\n 888:\t\t\t\tnet_info_ratelimited(\"non-ECT from %pI6 with DS=%#x\\n\",\n 889:\t\t\t\t\t\t \u0026ipv6h-\u003esaddr,\n 890:\t\t\t\t\t\t ipv6_get_dsfield(ipv6h));\n 891:\t\t\tif (err \u003e 1) {\n 892:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_frame_errors);\n 893:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 894:\t\t\t\treason = SKB_DROP_REASON_IP_TUNNEL_ECN;\n 895:\t\t\t\tgoto drop;\n 896:\t\t\t}\n 897:\t\t}\n 898:\t\n 899:\t\tdev_sw_netstats_rx_add(tunnel-\u003edev, skb-\u003elen);\n 900:\t\n 901:\t\tskb_scrub_packet(skb, !net_eq(tunnel-\u003enet, dev_net(tunnel-\u003edev)));\n 902:\t\n 903:\t\tif (tun_dst)\n 904:\t\t\tskb_dst_set(skb, (struct dst_entry *)tun_dst);\n 905:\t\n 906:\t\tgro_cells_receive(\u0026tunnel-\u003egro_cells, skb);\n 907:\t\treturn 0;\n 908:\t\n 909:\tdrop:\n"
} |
| 51/3 | 2026/09/25 05:02 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 50165 output: 39 thoughts: 1418 Thoughts: **Analyzing Packet Handling in GRE and ERSPAN Tunnels**
Okay, let's break this down. My initial focus is on the packet flow within GRE and ERSPAN tunnels, specifically the `skb` (socket buffer) handling and potential double frees. I'm starting by looking at the core functions: `ip_tunnel_rcv`, `ip_md_tunnel_xmit`, `ip_tunnel_xmit` in `net/ipv4/ip_tunnel.c`. I immediately note the use of `enum skb_drop_reason reason` which is critical for understanding why a packet is dropped.
I then switch to examining the GRE-specific functions in `net/ipv4/ip_gre.c`: `erspan_rcv`, `__ipgre_rcv`, `ipgre_rcv`, and `gre_rcv`. Let's zero in on `gre_rcv`. I observe the standard pattern: a `reason` variable initialized and updated based on error conditions. Crucially, I see that if `gre_rcv` branches to `out:`, an `icmp_send()` call is made, and then the packet is dropped at `drop:` using `kfree_skb_reason(skb, reason);`.
My concern is whether `icmp_send()` consumes the `skb`. If so, calling `kfree_skb_reason` would create a double-free condition. It doesn't. `icmp_send()` doesn't consume `skb`. So then, I focus on the value of `reason`. If `gre_rcv` is called and returns from `out:`, `reason` comes from either `erspan_rcv` or `ipgre_rcv`.
Next, I look at `erspan_rcv`. Specifically, I see:
```c
reason = __iptunnel_pull_header_reason(skb, len,
htons(ETH_P_TEB),
false, false);
if (reason)
goto drop;
...
skb_reset_mac_header(skb);
ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
return SKB_NOT_DROPPED_YET;
}
return SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND;
drop:
kfree_skb_reason(skb, reason);
return SKB_NOT_DROPPED_YET;
```
Here's the critical observation: `erspan_rcv`'s `drop:` path. The function calls `kfree_skb_reason(skb, reason);` and *then* returns `SKB_NOT_DROPPED_YET`. This is highly suspicious. Why return `SKB_NOT_DROPPED_YET` after the `skb` is freed? It is *already freed* by `kfree_skb_reason()`! The return value is misleading. So if `erspan_rcv` returns that, then the caller (`gre_rcv`) *doesn't* touch the `skb` at all.
Now, let's consider the scenario in `gre_rcv`.
```c
if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
tpi.proto == htons(ETH_P_ERSPAN2))) {
reason = erspan_rcv(skb, &tpi, tpi.hdr_len);
if (!reason)
return 0;
goto out;
}
```
If `reason` is `0` (meaning `SKB_NOT_DROPPED_YET` as set by `erspan_rcv` following a free) from `erspan_rcv`, the `gre_rcv` function returns early, and `skb` is not touched. But, if `erspan_rcv` returns an error (like `SKB_DROP_REASON_GRE_TUNNEL_NOT_FOUND`), the packet *wasn't* freed in `erspan_rcv`, so `gre_rcv` continues, sends an ICMP error, and calls `kfree_skb_reason(skb, reason);`, which is the expected behavior.
The same logic of `kfree_skb_reason(skb, reason);` and then `return SKB_NOT_DROPPED_YET` is present in `__ipgre_rcv`.
Finally, to be exhaustive, I need to check the behavior
|
| 52/3 | 2026/09/25 05:03 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_gre.c",
"FirstLine": 505,
"LineCount": 60
}Results: {
"Contents": " 505:\t\ttunnel = ip6gre_tunnel_lookup(skb-\u003edev,\n 506:\t\t\t\t\t \u0026ipv6h-\u003esaddr, \u0026ipv6h-\u003edaddr, tpi-\u003ekey,\n 507:\t\t\t\t\t tpi-\u003eproto);\n 508:\t\tif (tunnel) {\n 509:\t\t\tint len = erspan_hdr_len(ver);\n 510:\t\t\tenum skb_drop_reason reason;\n 511:\t\n 512:\t\t\tif (unlikely(!pskb_may_pull(skb, len)))\n 513:\t\t\t\treturn SKB_DROP_REASON_HDR_TRUNC;\n 514:\t\n 515:\t\t\treason = __iptunnel_pull_header_reason(skb, len,\n 516:\t\t\t\t\t\t\t htons(ETH_P_TEB),\n 517:\t\t\t\t\t\t\t false, false);\n 518:\t\t\tif (reason)\n 519:\t\t\t\treturn reason;\n 520:\t\n 521:\t\t\tif (tunnel-\u003eparms.collect_md) {\n 522:\t\t\t\tstruct erspan_metadata *pkt_md, *md;\n 523:\t\t\t\tIP_TUNNEL_DECLARE_FLAGS(flags);\n 524:\t\t\t\tstruct metadata_dst *tun_dst;\n 525:\t\t\t\tstruct ip_tunnel_info *info;\n 526:\t\t\t\tunsigned char *gh;\n 527:\t\t\t\t__be64 tun_id;\n 528:\t\n 529:\t\t\t\t__set_bit(IP_TUNNEL_KEY_BIT, tpi-\u003eflags);\n 530:\t\t\t\tip_tunnel_flags_copy(flags, tpi-\u003eflags);\n 531:\t\t\t\ttun_id = key32_to_tunnel_id(tpi-\u003ekey);\n 532:\t\n 533:\t\t\t\ttun_dst = ipv6_tun_rx_dst(skb, flags, tun_id,\n 534:\t\t\t\t\t\t\t sizeof(*md));\n 535:\t\t\t\tif (!tun_dst)\n 536:\t\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n 537:\t\n 538:\t\t\t\t/* MUST set options_len before referencing options */\n 539:\t\t\t\tinfo = \u0026tun_dst-\u003eu.tun_info;\n 540:\t\t\t\tinfo-\u003eoptions_len = sizeof(*md);\n 541:\t\n 542:\t\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\n 543:\t\t\t\t * old pkt_md is no longer valid and we need to reset\n 544:\t\t\t\t * it\n 545:\t\t\t\t */\n 546:\t\t\t\tgh = skb_network_header(skb) +\n 547:\t\t\t\t skb_network_header_len(skb);\n 548:\t\t\t\tpkt_md = (struct erspan_metadata *)(gh + gre_hdr_len +\n 549:\t\t\t\t\t\t\t\t sizeof(*ershdr));\n 550:\t\t\t\tmd = ip_tunnel_info_opts(info);\n 551:\t\t\t\tmd-\u003eversion = ver;\n 552:\t\t\t\tmd2 = \u0026md-\u003eu.md2;\n 553:\t\t\t\tmemcpy(md2, pkt_md, ver == 1 ? ERSPAN_V1_MDSIZE :\n 554:\t\t\t\t\t\t\t ERSPAN_V2_MDSIZE);\n 555:\t\t\t\t__set_bit(IP_TUNNEL_ERSPAN_OPT_BIT,\n 556:\t\t\t\t\t info-\u003ekey.tun_flags);\n 557:\t\n 558:\t\t\t\tip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\n 559:\t\n 560:\t\t\t} else {\n 561:\t\t\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);\n 562:\t\t\t}\n 563:\t\n 564:\t\t\treturn SKB_NOT_DROPPED_YET;\n"
} |
| 53/3 | 2026/09/25 05:03 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53662 output: 353 thoughts: 2285 Thoughts: **KMSAN Assessment: NeedsKMSAN = false** Okay, let's break this down. My primary goal here is to determine whether this patch, which introduces detailed `skb` drop reasons across GRE, ERSPAN, and IPv4/IPv6 tunnel code, necessitates the use of KMSAN. My analysis hinges on the KMSAN criteria, specifically whether the patch introduces or exposes uninitialized memory risks that KASAN wouldn't catch. First, I examined the code for any instances of kernel structures being sent to userspace. The patch introduces a new enum, `skb_drop_reason`, which is internal and used for tracepoints and error reporting. This enum and its values are *not* exposed to userspace via `copy_to_user`, `put_user`, netlink, ioctls, or anything of that nature. Therefore, criterion 1 is a non-issue. Next, I meticulously went through the code paths, tracing the usage of local variables declared as `enum skb_drop_reason` and the `tnl_ptk_info tpi` struct to see if there's uninitialized use, particularly in branching or conditional logic. In every single instance where an `enum skb_drop_reason` variable is declared, it is either initialized directly with `SKB_DROP_REASON_NOT_SPECIFIED` or immediately assigned a value via a function. There are no cases where a variable is read before initialization. The `tnl_ptk_info tpi` struct is declared on the stack and initialized by `gre_parse_header`. If there's an error, it returns and the structure is never read. In the successful path, all fields are initialized. This thoroughly eliminates concern number 2. Following this, I looked for new allocations or initializations of complex data structures. The patch doesn't introduce any new allocations that aren't properly initialized. No uninitialized memory leaks or reads were observed. The changes maintain existing validation semantics, and do not introduce new potential risks. Criterion 3 is, therefore, not a concern. Finally, I checked for bounds checks or logic that might allow access to uninitialized bytes of existing buffers. The bounds checking is handled via calls to `pskb_may_pull_reason()`, but performs the same checks as the old implementation. No uninitialized data access is introduced. Criterion 4 also does not apply. In summary, all the code changes introduce detailed error reporting, ensuring that errors are handled robustly. The introduction of these detailed skb drop reasons is *not* exposing any uninitialized memory. KASAN is sufficient for any potential memory safety bugs (out-of-bounds access, use-after-free, etc.). There are no new risks from this patch regarding KMSAN, so there is no need to run KMSAN. Therefore, the correct setting for `NeedsKMSAN` is `false`. The reasoning is clear: the patch refactors error handling and packet dropping, providing detailed `skb` drop reasons with `kfree_skb_reason()`. There are no changes which introduces or utilizes uninitialized memory. |
| 54/3 | 2026/09/25 05:03 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series refactors packet drop handling across GRE, ERSPAN, and IPv4/IPv6 tunnel code (in net/ipv4 and net/ipv6) to supply specific drop reasons to kfree_skb_reason() instead of using generic kfree_skb() calls and negative errno codes. Several new SKB_DROP_REASON_* enum values are introduced.\n\nKMSAN vs KASAN evaluation:\n1. No uninitialized data exposure to userspace: No new kernel structures or fields are copied to userspace via copy_to_user, netlink, or socket options. Drop reasons are consumed internally by kernel tracing/drop monitoring.\n2. Variable initialization: All introduced or modified local 'enum skb_drop_reason' variables are either initialized at declaration (e.g., SKB_DROP_REASON_NOT_SPECIFIED) or unconditionally assigned prior to branch conditions and consumption.\n3. Buffer and length validation: Replacing !pskb_may_pull(...) with pskb_may_pull_reason(...) preserves identical bounds checks and length handling; no changes allow uninitialized buffer segments to be read.\n4. Struct handling: Structures such as struct tnl_ptk_info populated by gre_parse_header() are only accessed upon successful parsing, and its fields are fully assigned as in the preexisting code.\n\nSince the changes do not introduce or expose uninitialized memory reads or information leaks, a dedicated KMSAN fuzzing session is not warranted. Standard KASAN builds are sufficient to catch any buffer bounds or lifetime issues.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series refactors packet drop handling across GRE, ERSPAN, and IPv4/IPv6 tunnel code (in net/ipv4 and net/ipv6) to supply specific drop reasons to kfree_skb_reason() instead of using generic kfree_skb() calls and negative errno codes. Several new SKB_DROP_REASON_* enum values are introduced.\n\nKMSAN vs KASAN evaluation:\n1. No uninitialized data exposure to userspace: No new kernel structures or fields are copied to userspace via copy_to_user, netlink, or socket options. Drop reasons are consumed internally by kernel tracing/drop monitoring.\n2. Variable initialization: All introduced or modified local 'enum skb_drop_reason' variables are either initialized at declaration (e.g., SKB_DROP_REASON_NOT_SPECIFIED) or unconditionally assigned prior to branch conditions and consumption.\n3. Buffer and length validation: Replacing !pskb_may_pull(...) with pskb_may_pull_reason(...) preserves identical bounds checks and length handling; no changes allow uninitialized buffer segments to be read.\n4. Struct handling: Structures such as struct tnl_ptk_info populated by gre_parse_header() are only accessed upon successful parsing, and its fields are fully assigned as in the preexisting code.\n\nSince the changes do not introduce or expose uninitialized memory reads or information leaks, a dedicated KMSAN fuzzing session is not warranted. Standard KASAN builds are sufficient to catch any buffer bounds or lifetime issues.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|