| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/01 19:27 | flow | patch-triage |
5mArgs:null Results: {
"EnableConfigs": [
"VXLAN",
"NET_IPGRE",
"NET_IPGRE_DEMUX",
"NET_IP_TUNNEL",
"IPV6_GRE",
"IPV6_TUNNEL"
],
"FocusSymbols": [
"gre_parse_header",
"__iptunnel_pull_header",
"ip_tunnel_rcv",
"ip_tunnel_xmit",
"ip_md_tunnel_xmit",
"ip6_tnl_rcv",
"ip6_tnl_xmit",
"vxlan_rcv",
"vxlan_xmit_one",
"ipgre_xmit",
"ip6gre_tunnel_xmit"
],
"KMSANReasoning": "The patch series refactors network tunnel implementations (VXLAN, GRE, ERSPAN, and IPv6 tunnels) to propagate specific drop reasons (enum skb_drop_reason) to kfree_skb_reason() instead of using generic drops or negative error codes.\n\nKMSAN is specialized for detecting reads of uninitialized memory (stack, heap, page allocations) and information leaks to user space. The changes in this patch:\n1. Do not copy any kernel data or struct padding to user space.\n2. Do not introduce any new dynamic or stack allocations that could remain uninitialized.\n3. Only introduce and manipulate scalar local variables (`enum skb_drop_reason reason`) which are explicitly initialized or assigned before use on all code paths.\n4. Do not alter buffer bounds, packet length calculations, or offset handling in any way that would expose uninitialized bytes.\n\nBecause there is no risk of uninitialized memory use or kernel-to-user info-leaks, dedicated KMSAN fuzzing is not warranted; standard KASAN and compiler diagnostics are sufficient.",
"NeedsKMSAN": false,
"Reasoning": "The patch converts packet receive, header parsing, and transmission paths across core tunnel subsystems (VXLAN, GRE, IPv4 tunnel, and IPv6 tunnel) to use fine-grained skb drop reasons and updates error return conventions (e.g., in gre_parse_header, __iptunnel_pull_header, and ip6_tnl_xmit). These changes affect reachable virtual network device and packet handling logic, altering drop/error propagation and skb freeing paths that can be exercised via standard network namespaces and virtual netdevices.",
"WorthFuzzing": true
} |
| 1/1 | 2026/10/01 19:27 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 0c8100842fd2b89e6fd886a0c044bc8bdddfbb1d\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Thu Oct 1 19:26:59 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c\nindex 27b0b6567d521..7c94a630d184a 100644\n--- a/drivers/net/vxlan/vxlan_core.c\n+++ b/drivers/net/vxlan/vxlan_core.c\n@@ -1700,7 +1700,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n \tif (!(vh-\u003evx_flags \u0026 VXLAN_HF_VNI)) {\n \t\tnetdev_dbg(skb-\u003edev, \"invalid vxlan flags=%#x vni=%#x\\n\",\n \t\t\t ntohl(vh-\u003evx_flags), ntohl(vh-\u003evx_vni));\n-\t\treason = SKB_DROP_REASON_VXLAN_INVALID_HDR;\n+\t\treason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;\n \t\t/* Return non vxlan pkt */\n \t\tgoto drop;\n \t}\n@@ -1713,7 +1713,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n \n \tvxlan = vxlan_vs_find_vni(vs, skb-\u003edev-\u003eifindex, vni, \u0026vninode);\n \tif (!vxlan) {\n-\t\treason = SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND;\n+\t\treason = SKB_DROP_REASON_TUNNEL_NOT_FOUND;\n \t\tgoto drop;\n \t}\n \n@@ -1729,7 +1729,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n \t\t * previous stack code, and also is more robust and provides a\n \t\t * little more security in adding extensions to VXLAN.\n \t\t */\n-\t\treason = SKB_DROP_REASON_VXLAN_INVALID_HDR;\n+\t\treason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;\n \t\tDEV_STATS_INC(vxlan-\u003edev, rx_frame_errors);\n \t\tDEV_STATS_INC(vxlan-\u003edev, rx_errors);\n \t\tvxlan_vnifilter_count(vxlan, cfg, vni, vninode,\n@@ -1743,11 +1743,11 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n \t\traw_proto = true;\n \t}\n \n-\tif (__iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,\n-\t\t\t\t !net_eq(vxlan-\u003enet, dev_net(vxlan-\u003edev)))) {\n-\t\treason = SKB_DROP_REASON_NOMEM;\n+\treason = __iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,\n+\t\t\t\t\t!net_eq(vxlan-\u003enet,\n+\t\t\t\t\t\tdev_net(vxlan-\u003edev)));\n+\tif (reason)\n \t\tgoto drop;\n-\t}\n \n \tif (cfg-\u003eflags \u0026 VXLAN_F_REMCSUM_RX) {\n \t\treason = vxlan_remcsum(skb, cfg-\u003eflags);\n@@ -2389,7 +2389,7 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,\n \t\t\tDEV_STATS_INC(dev, tx_errors);\n \t\t\tvxlan_vnifilter_count(vxlan, cfg, vni, NULL,\n \t\t\t\t\t VXLAN_VNI_STATS_TX_ERRORS, 0);\n-\t\t\tkfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND);\n+\t\t\tkfree_skb_reason(skb, SKB_DROP_REASON_TUNNEL_NOT_FOUND);\n \n \t\t\treturn -ENOENT;\n \t\t}\n@@ -2547,7 +2547,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,\n \t\t\t\t\t tos, use_cache ? dst_cache : NULL);\n \t\tif (IS_ERR(rt)) {\n \t\t\terr = PTR_ERR(rt);\n-\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n+\t\t\tif (err == -ELOOP)\n+\t\t\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n+\t\t\telse\n+\t\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_error;\n \t\t}\n \n@@ -2633,7 +2636,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,\n \t\tif (IS_ERR(ndst)) {\n \t\t\terr = PTR_ERR(ndst);\n \t\t\tndst = NULL;\n-\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n+\t\t\tif (err == -ELOOP)\n+\t\t\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n+\t\t\telse\n+\t\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_error;\n \t\t}\n \ndiff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h\nindex 12f9096515912..40f23548f6685 100644\n--- a/include/net/dropreason-core.h\n+++ b/include/net/dropreason-core.h\n@@ -111,8 +111,8 @@\n \tFN(PACKET_SOCK_ERROR)\t\t\\\n \tFN(TC_CHAIN_NOTFOUND)\t\t\\\n \tFN(TC_RECLASSIFY_LOOP)\t\t\\\n-\tFN(VXLAN_INVALID_HDR)\t\t\\\n-\tFN(VXLAN_VNI_NOT_FOUND)\t\t\\\n+\tFN(TUNNEL_INVALID_HDR)\t\t\\\n+\tFN(TUNNEL_NOT_FOUND)\t\t\\\n \tFN(MAC_INVALID_SOURCE)\t\t\\\n \tFN(VXLAN_ENTRY_EXISTS)\t\t\\\n \tFN(NO_TX_TARGET)\t\t\\\n@@ -129,6 +129,10 @@\n \tFN(PSP_INPUT)\t\t\t\\\n \tFN(PSP_OUTPUT)\t\t\t\\\n \tFN(RECURSION_LIMIT)\t\t\\\n+\tFN(TUNNEL_OPT_MISMATCH)\t\t\\\n+\tFN(TUNNEL_OLD_SEQ)\t\t\\\n+\tFN(GRE_CSUM)\t\t\t\\\n+\tFN(TUNNEL_ENCAP)\t\t\\\n \tFNe(MAX)\n \n /**\n@@ -539,13 +543,18 @@ enum skb_drop_reason {\n \t */\n \tSKB_DROP_REASON_TC_RECLASSIFY_LOOP,\n \t/**\n-\t * @SKB_DROP_REASON_VXLAN_INVALID_HDR: VXLAN header is invalid. E.g.:\n-\t * 1) reserved fields are not zero\n-\t * 2) \"I\" flag is not set\n+\t * @SKB_DROP_REASON_TUNNEL_INVALID_HDR: tunnel header is invalid. E.g.:\n+\t * 1) VXLAN reserved fields are not zero\n+\t * 2) VXLAN \"I\" flag is not set\n+\t * 3) GRE version is not supported or the routing bit is set\n \t */\n-\tSKB_DROP_REASON_VXLAN_INVALID_HDR,\n-\t/** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */\n-\tSKB_DROP_REASON_VXLAN_VNI_NOT_FOUND,\n+\tSKB_DROP_REASON_TUNNEL_INVALID_HDR,\n+\t/**\n+\t * @SKB_DROP_REASON_TUNNEL_NOT_FOUND: no tunnel device found for the\n+\t * packet, e.g. no VXLAN device for its VNI or no GRE tunnel for its\n+\t * endpoints and key\n+\t */\n+\tSKB_DROP_REASON_TUNNEL_NOT_FOUND,\n \t/** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */\n \tSKB_DROP_REASON_MAC_INVALID_SOURCE,\n \t/**\n@@ -610,8 +619,34 @@ enum skb_drop_reason {\n \tSKB_DROP_REASON_PSP_INPUT,\n \t/** @SKB_DROP_REASON_PSP_OUTPUT: PSP output checks failed */\n \tSKB_DROP_REASON_PSP_OUTPUT,\n-\t/** @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device. */\n+\t/**\n+\t * @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device, e.g. a\n+\t * tunnel whose route to its remote end goes out of the tunnel device\n+\t * itself.\n+\t */\n \tSKB_DROP_REASON_RECURSION_LIMIT,\n+\t/**\n+\t * @SKB_DROP_REASON_TUNNEL_OPT_MISMATCH: the tunnel options carried by\n+\t * the packet do not match the tunnel configuration, e.g. a GRE tunnel\n+\t * configured with 'icsum' or 'iseq' received a packet with no checksum\n+\t * or no sequence number, or a GRE tunnel without 'icsum' received a\n+\t * packet with a checksum.\n+\t */\n+\tSKB_DROP_REASON_TUNNEL_OPT_MISMATCH,\n+\t/**\n+\t * @SKB_DROP_REASON_TUNNEL_OLD_SEQ: the sequence number carried by the\n+\t * packet is older than the one expected by the tunnel, e.g. after the\n+\t * remote endpoint restarted and reset its sequence numbering.\n+\t */\n+\tSKB_DROP_REASON_TUNNEL_OLD_SEQ,\n+\t/** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */\n+\tSKB_DROP_REASON_GRE_CSUM,\n+\t/**\n+\t * @SKB_DROP_REASON_TUNNEL_ENCAP: failed to build the encapsulation\n+\t * header of a tunnel, e.g. an unknown or unregistered encapsulation\n+\t * type.\n+\t */\n+\tSKB_DROP_REASON_TUNNEL_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..b5dbe00ab15ef 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 ignore_csum_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..792690ae4f266 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,11 +610,13 @@ 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(struct sk_buff *skb, int hdr_len,\n+\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 __be16 inner_proto, bool xnet)\n+static inline enum skb_drop_reason\n+iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n+\t\t __be16 inner_proto, bool xnet)\n {\n \treturn __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);\n }\ndiff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c\nindex 96fd7dc6d82dd..fccdaa240f46e 100644\n--- a/net/ipv4/gre_demux.c\n+++ b/net/ipv4/gre_demux.c\n@@ -56,28 +56,47 @@ 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- * Note that caller must use pskb_may_pull() before pulling GRE header.\n+/**\n+ * gre_parse_header() - parse the GRE header of a packet\n+ * @skb: the packet; the GRE header starts @nhs bytes past skb-\u003edata\n+ * @tpi: filled in with the fields of the header, and with the length of\n+ *\tthe header to be pulled in tpi-\u003ehdr_len\n+ * @ignore_csum_err: do not reject the header when its checksum does not\n+ *\tmatch. The ICMP error handlers set it, as they only get a part of the\n+ *\toriginal packet; the checksum is still computed and the rest of the\n+ *\theader is parsed.\n+ * @proto: the protocol to report for a WCCP payload, ETH_P_IP or\n+ *\tETH_P_IPV6\n+ * @nhs: the offset of the GRE header from skb-\u003edata\n+ *\n+ * The caller must use pskb_may_pull() before pulling the GRE header.\n+ *\n+ * Return: SKB_NOT_DROPPED_YET, or the reason to drop the packet if the\n+ * header is rejected.\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 ignore_csum_err, __be16 proto, int nhs)\n {\n \tconst struct gre_base_hdr *greh;\n+\tenum skb_drop_reason reason;\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+\treason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));\n+\tif (unlikely(reason))\n+\t\treturn reason;\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_TUNNEL_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+\treason = pskb_may_pull_reason(skb, nhs + hdr_len);\n+\tif (reason)\n+\t\treturn reason;\n \n \tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n \ttpi-\u003eproto = greh-\u003eprotocol;\n@@ -87,9 +106,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 (!ignore_csum_err) {\n+\t\t\treturn SKB_DROP_REASON_GRE_CSUM;\n \t\t}\n \n \t\toptions++;\n@@ -117,7 +135,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_PKT_TOO_SMALL;\n \t\ttpi-\u003eproto = proto;\n \t\tif ((*val \u0026 0xF0) != 0x40)\n \t\t\thdr_len += 4;\n@@ -132,29 +150,35 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t greh-\u003eprotocol == htons(ETH_P_ERSPAN2)) {\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\treason = pskb_may_pull_reason(skb,\n+\t\t\t\t\t nhs + hdr_len + sizeof(*ershdr));\n+\t\tif (reason)\n+\t\t\treturn reason;\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 \tconst struct gre_protocol *proto;\n+\tenum skb_drop_reason reason;\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_TUNNEL_INVALID_HDR;\n \t\tgoto drop;\n+\t}\n \n \trcu_read_lock();\n \tproto = rcu_dereference(gre_proto[ver]);\n@@ -167,11 +191,12 @@ 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+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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 51fcd603939c5..58234e857d6c2 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,9 +264,11 @@ 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+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct net *net = dev_net(skb-\u003edev);\n \tstruct metadata_dst *tun_dst = NULL;\n \tstruct erspan_base_hdr *ershdr;\n@@ -288,9 +290,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\ttunnel = ip_tunnel_lookup(itn, skb-\u003edev-\u003eifindex, flags,\n \t\t\t\t\t iph-\u003esaddr, iph-\u003edaddr, 0);\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\treason = pskb_may_pull_reason(skb,\n+\t\t\t\t\t gre_hdr_len + sizeof(*ershdr));\n+\t\tif (unlikely(reason))\n+\t\t\treturn reason;\n \n \t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + gre_hdr_len);\n \t\tver = ershdr-\u003ever;\n@@ -306,13 +309,13 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\telse\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\treason = pskb_may_pull_reason(skb, len);\n+\t\tif (unlikely(reason))\n+\t\t\treturn reason;\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(skb, len, htons(ETH_P_TEB),\n+\t\t\t\t\t\tfalse, false);\n+\t\tif (reason)\n \t\t\tgoto drop;\n \n \t\tif (tunnel-\u003ecollect_md) {\n@@ -328,7 +331,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,18 +357,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_TUNNEL_NOT_FOUND;\n \n drop:\n-\tkfree_skb(skb);\n-\treturn PACKET_RCVD;\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct metadata_dst *tun_dst = NULL;\n \tconst struct iphdr *iph;\n \tstruct ip_tunnel *tunnel;\n@@ -377,8 +384,9 @@ 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(skb, hdr_len, tpi-\u003eproto,\n+\t\t\t\t\t\traw_proto, 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 +409,49 @@ 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_TUNNEL_NOT_FOUND;\n \n drop:\n-\tkfree_skb(skb);\n-\treturn PACKET_RCVD;\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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_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 +461,28 @@ 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+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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 +509,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 +518,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 +553,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 +573,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 +639,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 +652,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@@ -652,8 +686,10 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n \tconst struct iphdr *tnl_params;\n+\tenum skb_drop_reason reason;\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 +700,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 +716,32 @@ 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+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n \treturn NETDEV_TX_OK;\n }\n@@ -705,10 +751,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n {\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n+\tenum skb_drop_reason reason;\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 +764,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 +799,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 +808,8 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n \treturn NETDEV_TX_OK;\n \n free_skb:\n-\tkfree_skb(skb);\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n \treturn NETDEV_TX_OK;\n }\n@@ -763,8 +819,10 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,\n {\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n+\tenum skb_drop_reason reason;\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 +832,22 @@ 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+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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..98ebfadbf64b0 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_TUNNEL_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_TUNNEL_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_TUNNEL_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@@ -455,9 +466,10 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \treturn 0;\n \n drop:\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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 +587,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 +601,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 +623,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_TUNNEL_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 +635,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 +645,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 +654,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 +672,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 +687,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,6 +722,7 @@ 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@@ -713,9 +736,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t} else if (payload_protocol == htons(ETH_P_IP)) {\n \t\t\trt = skb_rtable(skb);\n \t\t\tdst = rt_nexthop(rt, inner_iph-\u003edaddr);\n-\t\t}\n #if IS_ENABLED(CONFIG_IPV6)\n-\t\telse if (payload_protocol == htons(ETH_P_IPV6)) {\n+\t\t} else if (payload_protocol == htons(ETH_P_IPV6)) {\n \t\t\tconst struct in6_addr *addr6;\n \t\t\tstruct neighbour *neigh;\n \t\t\tbool do_tx_error_icmp;\n@@ -723,8 +745,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,12 +765,15 @@ 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}\n+\t\t\t}\n #endif\n-\t\telse\n+\t\t} else {\n+\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\t\tgoto tx_error;\n+\t\t}\n \n \t\tif (!md)\n \t\t\tconnected = false;\n@@ -769,8 +796,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_TUNNEL_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 +816,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 +830,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 +840,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 +875,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 +891,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..6c2855adff289 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(struct sk_buff *skb, int hdr_len,\n+\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,7 +140,10 @@ 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 \ndiff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c\nindex 258239a7c53bb..dbca782308158 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,31 +472,33 @@ 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_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+\tenum skb_drop_reason reason;\n \tstruct erspan_md2 *md2;\n \tstruct ip6_tnl *tunnel;\n \tu8 ver;\n \n-\tif (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))\n-\t\treturn PACKET_REJECT;\n+\treason = pskb_may_pull_reason(skb, sizeof(*ershdr));\n+\tif (unlikely(reason))\n+\t\treturn reason;\n \n \tipv6h = ipv6_hdr(skb);\n \tershdr = (struct erspan_base_hdr *)skb-\u003edata;\n@@ -507,13 +510,14 @@ static int ip6erspan_rcv(struct sk_buff *skb,\n \tif (tunnel) {\n \t\tint len = erspan_hdr_len(ver);\n \n-\t\tif (unlikely(!pskb_may_pull(skb, len)))\n-\t\t\treturn PACKET_REJECT;\n+\t\treason = pskb_may_pull_reason(skb, len);\n+\t\tif (unlikely(reason))\n+\t\t\treturn reason;\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(skb, len, htons(ETH_P_TEB),\n+\t\t\t\t\t\tfalse, 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 +534,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 +562,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_TUNNEL_NOT_FOUND;\n }\n \n static int gre_rcv(struct sk_buff *skb)\n {\n+\tenum skb_drop_reason reason;\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(skb, tpi.hdr_len, tpi.proto, 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+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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 +681,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 +704,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 +717,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 +745,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 +764,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 +775,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 +790,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 +810,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,17 +868,17 @@ 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@@ -877,41 +886,56 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,\n {\n \tstruct ip_tunnel_info *tun_info = NULL;\n \tstruct ip6_tnl *t = netdev_priv(dev);\n+\tenum skb_drop_reason reason;\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 (!t-\u003eparms.collect_md \u0026\u0026 ipv6_addr_any(\u0026t-\u003eparms.raddr)) {\n+\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\tgoto tx_err;\n+\t}\n \n-\tif (t-\u003eparms.collect_md)\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+\t\tif (IS_ERR(tun_info) ||\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+\t}\n \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 \n tx_err:\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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@@ -922,27 +946,39 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \tstruct ip6_tnl *t = netdev_priv(dev);\n \tstruct dst_entry *dst = skb_dst(skb);\n \tIP_TUNNEL_DECLARE_FLAGS(flags) = { };\n+\tenum skb_drop_reason reason;\n \tbool truncate = false;\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 (!t-\u003eparms.collect_md \u0026\u0026 ipv6_addr_any(\u0026t-\u003eparms.raddr)) {\n+\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\tgoto tx_err;\n+\t}\n+\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 +998,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 +1015,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 +1030,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 +1055,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 +1066,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 +1094,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 +1112,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@@ -1078,10 +1129,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n \treturn NETDEV_TX_OK;\n \n tx_err:\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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..7e444115f4314 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_TUNNEL_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_TUNNEL_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_TUNNEL_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@@ -896,9 +907,10 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \treturn 0;\n \n drop:\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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@@ -941,6 +953,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n \t\t\t\t\t\t const struct ipv6hdr *ipv6h,\n \t\t\t\t\t\t struct sk_buff *skb))\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip6_tnl *t;\n \tconst struct ipv6hdr *ipv6h = ipv6_hdr(skb);\n \tstruct metadata_dst *tun_dst = NULL;\n@@ -952,21 +965,30 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n \tif (t) {\n \t\tu8 tproto = READ_ONCE(t-\u003eparms.proto);\n \n-\t\tif (tproto != ipproto \u0026\u0026 tproto != 0)\n+\t\tif (tproto != ipproto \u0026\u0026 tproto != 0) {\n+\t\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\t\tgoto drop;\n-\t\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))\n+\t\t}\n+\t\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {\n+\t\t\treason = SKB_DROP_REASON_XFRM_POLICY;\n \t\t\tgoto drop;\n+\t\t}\n \t\tipv6h = ipv6_hdr(skb);\n-\t\tif (!ip6_tnl_rcv_ctl(t, \u0026ipv6h-\u003edaddr, \u0026ipv6h-\u003esaddr))\n+\t\tif (!ip6_tnl_rcv_ctl(t, \u0026ipv6h-\u003edaddr, \u0026ipv6h-\u003esaddr)) {\n+\t\t\treason = SKB_DROP_REASON_DEV_READY;\n \t\t\tgoto drop;\n-\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\n+\t\t}\n+\t\treason = iptunnel_pull_header(skb, 0, tpi-\u003eproto, false);\n+\t\tif (reason)\n \t\t\tgoto drop;\n \t\tif (t-\u003eparms.collect_md) {\n \t\t\tIP_TUNNEL_DECLARE_FLAGS(flags) = { };\n \n \t\t\ttun_dst = ipv6_tun_rx_dst(skb, flags, 0, 0);\n-\t\t\tif (!tun_dst)\n+\t\t\tif (!tun_dst) {\n+\t\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\t\tgoto drop;\n+\t\t\t}\n \t\t}\n \t\tret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,\n \t\t\t\t log_ecn_error);\n@@ -978,7 +1000,8 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n \n drop:\n \trcu_read_unlock();\n-\tkfree_skb(skb);\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n \n@@ -1092,14 +1115,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 +1133,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 +1155,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,12 +1178,19 @@ 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 \t\t}\n+\n+\t\tif (ipv6_addr_any(\u0026fl6-\u003edaddr)) {\n+\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n+\t\t\tgoto tx_err_link_failure;\n+\t\t}\n \t} else if (t-\u003eparms.proto != 0 \u0026\u0026 !(t-\u003eparms.flags \u0026\n \t\t\t\t\t (IP6_TNL_F_USE_ORIG_TCLASS |\n \t\t\t\t\t IP6_TNL_F_USE_ORIG_FWMARK))) {\n@@ -1169,8 +1203,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 +1215,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 +1240,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 +1254,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 +1277,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_TUNNEL_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 +1309,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_TUNNEL_ENCAP;\n \n \tif (encap_limit \u003e= 0) {\n \t\tinit_tel_txopt(\u0026opt, encap_limit);\n@@ -1283,21 +1327,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 +1351,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 +1363,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 +1400,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 +1442,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 +1462,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 \tstruct ip6_tnl *t = netdev_priv(dev);\n+\tenum skb_drop_reason reason;\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,27 +1484,31 @@ 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 \n tx_err:\n+\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\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/10/01 19:27 | agent | patch-evaluator |
2mModel:core Args: null Results: {
"EnableConfigs": [
"VXLAN",
"NET_IPGRE",
"NET_IPGRE_DEMUX",
"NET_IP_TUNNEL",
"IPV6_GRE",
"IPV6_TUNNEL"
],
"FocusSymbols": [
"gre_parse_header",
"__iptunnel_pull_header",
"ip_tunnel_rcv",
"ip_tunnel_xmit",
"ip_md_tunnel_xmit",
"ip6_tnl_rcv",
"ip6_tnl_xmit",
"vxlan_rcv",
"vxlan_xmit_one",
"ipgre_xmit",
"ip6gre_tunnel_xmit"
],
"Reasoning": "The patch converts packet receive, header parsing, and transmission paths across core tunnel subsystems (VXLAN, GRE, IPv4 tunnel, and IPv6 tunnel) to use fine-grained skb drop reasons and updates error return conventions (e.g., in gre_parse_header, __iptunnel_pull_header, and ip6_tnl_xmit). These changes affect reachable virtual network device and packet handling logic, altering drop/error propagation and skb freeing paths that can be exercised via standard network namespaces and virtual netdevices.",
"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 0c8100842fd2b89e6fd886a0c044bc8bdddfbb1d
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Oct 1 19:26:59 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 27b0b6567d521..7c94a630d184a 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1700,7 +1700,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
if (!(vh->vx_flags & VXLAN_HF_VNI)) {
netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n",
ntohl(vh->vx_flags), ntohl(vh->vx_vni));
- reason = SKB_DROP_REASON_VXLAN_INVALID_HDR;
+ reason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;
/* Return non vxlan pkt */
goto drop;
}
@@ -1713,7 +1713,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
vxlan = vxlan_vs_find_vni(vs, skb->dev->ifindex, vni, &vninode);
if (!vxlan) {
- reason = SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND;
+ reason = SKB_DROP_REASON_TUNNEL_NOT_FOUND;
goto drop;
}
@@ -1729,7 +1729,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
* previous stack code, and also is more robust and provides a
* little more security in adding extensions to VXLAN.
*/
- reason = SKB_DROP_REASON_VXLAN_INVALID_HDR;
+ reason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;
DEV_STATS_INC(vxlan->dev, rx_frame_errors);
DEV_STATS_INC(vxlan->dev, rx_errors);
vxlan_vnifilter_count(vxlan, cfg, vni, vninode,
@@ -1743,11 +1743,11 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
raw_proto = true;
}
- if (__iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,
- !net_eq(vxlan->net, dev_net(vxlan->dev)))) {
- reason = SKB_DROP_REASON_NOMEM;
+ reason = __iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,
+ !net_eq(vxlan->net,
+ dev_net(vxlan->dev)));
+ if (reason)
goto drop;
- }
if (cfg->flags & VXLAN_F_REMCSUM_RX) {
reason = vxlan_remcsum(skb, cfg->flags);
@@ -2389,7 +2389,7 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,
DEV_STATS_INC(dev, tx_errors);
vxlan_vnifilter_count(vxlan, cfg, vni, NULL,
VXLAN_VNI_STATS_TX_ERRORS, 0);
- kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND);
+ kfree_skb_reason(skb, SKB_DROP_REASON_TUNNEL_NOT_FOUND);
return -ENOENT;
}
@@ -2547,7 +2547,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
tos, use_cache ? dst_cache : NULL);
if (IS_ERR(rt)) {
err = PTR_ERR(rt);
- reason = SKB_DROP_REASON_IP_OUTNOROUTES;
+ if (err == -ELOOP)
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
+ else
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
@@ -2633,7 +2636,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
if (IS_ERR(ndst)) {
err = PTR_ERR(ndst);
ndst = NULL;
- reason = SKB_DROP_REASON_IP_OUTNOROUTES;
+ if (err == -ELOOP)
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
+ else
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 12f9096515912..40f23548f6685 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -111,8 +111,8 @@
FN(PACKET_SOCK_ERROR) \
FN(TC_CHAIN_NOTFOUND) \
FN(TC_RECLASSIFY_LOOP) \
- FN(VXLAN_INVALID_HDR) \
- FN(VXLAN_VNI_NOT_FOUND) \
+ FN(TUNNEL_INVALID_HDR) \
+ FN(TUNNEL_NOT_FOUND) \
FN(MAC_INVALID_SOURCE) \
FN(VXLAN_ENTRY_EXISTS) \
FN(NO_TX_TARGET) \
@@ -129,6 +129,10 @@
FN(PSP_INPUT) \
FN(PSP_OUTPUT) \
FN(RECURSION_LIMIT) \
+ FN(TUNNEL_OPT_MISMATCH) \
+ FN(TUNNEL_OLD_SEQ) \
+ FN(GRE_CSUM) \
+ FN(TUNNEL_ENCAP) \
FNe(MAX)
/**
@@ -539,13 +543,18 @@ enum skb_drop_reason {
*/
SKB_DROP_REASON_TC_RECLASSIFY_LOOP,
/**
- * @SKB_DROP_REASON_VXLAN_INVALID_HDR: VXLAN header is invalid. E.g.:
- * 1) reserved fields are not zero
- * 2) "I" flag is not set
+ * @SKB_DROP_REASON_TUNNEL_INVALID_HDR: tunnel header is invalid. E.g.:
+ * 1) VXLAN reserved fields are not zero
+ * 2) VXLAN "I" flag is not set
+ * 3) GRE version is not supported or the routing bit is set
*/
- SKB_DROP_REASON_VXLAN_INVALID_HDR,
- /** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */
- SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND,
+ SKB_DROP_REASON_TUNNEL_INVALID_HDR,
+ /**
+ * @SKB_DROP_REASON_TUNNEL_NOT_FOUND: no tunnel device found for the
+ * packet, e.g. no VXLAN device for its VNI or no GRE tunnel for its
+ * endpoints and key
+ */
+ SKB_DROP_REASON_TUNNEL_NOT_FOUND,
/** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */
SKB_DROP_REASON_MAC_INVALID_SOURCE,
/**
@@ -610,8 +619,34 @@ enum skb_drop_reason {
SKB_DROP_REASON_PSP_INPUT,
/** @SKB_DROP_REASON_PSP_OUTPUT: PSP output checks failed */
SKB_DROP_REASON_PSP_OUTPUT,
- /** @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device. */
+ /**
+ * @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device, e.g. a
+ * tunnel whose route to its remote end goes out of the tunnel device
+ * itself.
+ */
SKB_DROP_REASON_RECURSION_LIMIT,
+ /**
+ * @SKB_DROP_REASON_TUNNEL_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_TUNNEL_OPT_MISMATCH,
+ /**
+ * @SKB_DROP_REASON_TUNNEL_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_TUNNEL_OLD_SEQ,
+ /** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */
+ SKB_DROP_REASON_GRE_CSUM,
+ /**
+ * @SKB_DROP_REASON_TUNNEL_ENCAP: failed to build the encapsulation
+ * header of a tunnel, e.g. an unknown or unregistered encapsulation
+ * type.
+ */
+ SKB_DROP_REASON_TUNNEL_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..b5dbe00ab15ef 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 ignore_csum_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..792690ae4f266 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,11 +610,13 @@ 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(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 xnet)
+static inline enum skb_drop_reason
+iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
+ __be16 inner_proto, bool xnet)
{
return __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);
}
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 96fd7dc6d82dd..fccdaa240f46e 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -56,28 +56,47 @@ 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.
- * Note that caller must use pskb_may_pull() before pulling GRE header.
+/**
+ * gre_parse_header() - parse the GRE header of a packet
+ * @skb: the packet; the GRE header starts @nhs bytes past skb->data
+ * @tpi: filled in with the fields of the header, and with the length of
+ * the header to be pulled in tpi->hdr_len
+ * @ignore_csum_err: do not reject the header when its checksum does not
+ * match. The ICMP error handlers set it, as they only get a part of the
+ * original packet; the checksum is still computed and the rest of the
+ * header is parsed.
+ * @proto: the protocol to report for a WCCP payload, ETH_P_IP or
+ * ETH_P_IPV6
+ * @nhs: the offset of the GRE header from skb->data
+ *
+ * The caller must use pskb_may_pull() before pulling the GRE header.
+ *
+ * Return: SKB_NOT_DROPPED_YET, or the reason to drop the packet if the
+ * header is rejected.
*/
-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 ignore_csum_err, __be16 proto, int nhs)
{
const struct gre_base_hdr *greh;
+ enum skb_drop_reason reason;
__be32 *options;
int hdr_len;
- if (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))
- return -EINVAL;
+ reason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));
+ if (unlikely(reason))
+ return reason;
greh = (struct gre_base_hdr *)(skb->data + nhs);
if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
- return -EINVAL;
+ return SKB_DROP_REASON_TUNNEL_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;
+ reason = pskb_may_pull_reason(skb, nhs + hdr_len);
+ if (reason)
+ return reason;
greh = (struct gre_base_hdr *)(skb->data + nhs);
tpi->proto = greh->protocol;
@@ -87,9 +106,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 (!ignore_csum_err) {
+ return SKB_DROP_REASON_GRE_CSUM;
}
options++;
@@ -117,7 +135,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_PKT_TOO_SMALL;
tpi->proto = proto;
if ((*val & 0xF0) != 0x40)
hdr_len += 4;
@@ -132,29 +150,35 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
greh->protocol == htons(ETH_P_ERSPAN2)) {
struct erspan_base_hdr *ershdr;
- if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
- return -EINVAL;
+ reason = pskb_may_pull_reason(skb,
+ nhs + hdr_len + sizeof(*ershdr));
+ if (reason)
+ return reason;
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)
{
const struct gre_protocol *proto;
+ enum skb_drop_reason reason;
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_TUNNEL_INVALID_HDR;
goto drop;
+ }
rcu_read_lock();
proto = rcu_dereference(gre_proto[ver]);
@@ -167,11 +191,12 @@ 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:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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 51fcd603939c5..58234e857d6c2 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,9 +264,11 @@ 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)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct net *net = dev_net(skb->dev);
struct metadata_dst *tun_dst = NULL;
struct erspan_base_hdr *ershdr;
@@ -288,9 +290,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, flags,
iph->saddr, iph->daddr, 0);
} else {
- if (unlikely(!pskb_may_pull(skb,
- gre_hdr_len + sizeof(*ershdr))))
- return PACKET_REJECT;
+ reason = pskb_may_pull_reason(skb,
+ gre_hdr_len + sizeof(*ershdr));
+ if (unlikely(reason))
+ return reason;
ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len);
ver = ershdr->ver;
@@ -306,13 +309,13 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
else
len = gre_hdr_len + erspan_hdr_len(ver);
- if (unlikely(!pskb_may_pull(skb, len)))
- return PACKET_REJECT;
+ reason = pskb_may_pull_reason(skb, len);
+ if (unlikely(reason))
+ return reason;
- if (__iptunnel_pull_header(skb,
- len,
- htons(ETH_P_TEB),
- false, false) < 0)
+ reason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),
+ false, false);
+ if (reason)
goto drop;
if (tunnel->collect_md) {
@@ -328,7 +331,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,18 +357,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_TUNNEL_NOT_FOUND;
drop:
- kfree_skb(skb);
- return PACKET_RCVD;
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ 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)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct metadata_dst *tun_dst = NULL;
const struct iphdr *iph;
struct ip_tunnel *tunnel;
@@ -377,8 +384,9 @@ 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(skb, hdr_len, tpi->proto,
+ raw_proto, false);
+ if (reason)
goto drop;
/* Special case for ipgre_header_parse(), which expects the
@@ -401,47 +409,49 @@ 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_TUNNEL_NOT_FOUND;
drop:
- kfree_skb(skb);
- return PACKET_RCVD;
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ 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_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 +461,28 @@ 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:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -496,6 +509,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 +518,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 +553,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 +573,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 +639,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 +652,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);
}
@@ -652,8 +686,10 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
const struct iphdr *tnl_params;
+ enum skb_drop_reason reason;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -664,10 +700,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 +716,32 @@ 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);
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
@@ -705,10 +751,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
{
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
+ enum skb_drop_reason reason;
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 +764,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 +799,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 +808,8 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
free_skb:
- kfree_skb(skb);
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
@@ -763,8 +819,10 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
{
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
+ enum skb_drop_reason reason;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -774,17 +832,22 @@ 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);
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ 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..98ebfadbf64b0 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_TUNNEL_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_TUNNEL_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_TUNNEL_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;
}
}
@@ -455,9 +466,10 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
return 0;
drop:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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 +587,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 +601,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 +623,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_TUNNEL_ENCAP;
goto tx_error;
+ }
use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
if (use_cache)
@@ -618,6 +635,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 +645,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 +654,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 +672,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 +687,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,6 +722,7 @@ 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;
}
@@ -713,9 +736,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
} else if (payload_protocol == htons(ETH_P_IP)) {
rt = skb_rtable(skb);
dst = rt_nexthop(rt, inner_iph->daddr);
- }
#if IS_ENABLED(CONFIG_IPV6)
- else if (payload_protocol == htons(ETH_P_IPV6)) {
+ } else if (payload_protocol == htons(ETH_P_IPV6)) {
const struct in6_addr *addr6;
struct neighbour *neigh;
bool do_tx_error_icmp;
@@ -723,8 +745,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,12 +765,15 @@ 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
+ } else {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_error;
+ }
if (!md)
connected = false;
@@ -769,8 +796,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_TUNNEL_ENCAP;
goto tx_error;
+ }
if (connected && md) {
use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
@@ -787,6 +816,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 +830,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 +840,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 +875,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 +891,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..6c2855adff289 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(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,7 +140,10 @@ 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);
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 258239a7c53bb..dbca782308158 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,31 +472,33 @@ 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_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;
+ enum skb_drop_reason reason;
struct erspan_md2 *md2;
struct ip6_tnl *tunnel;
u8 ver;
- if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))
- return PACKET_REJECT;
+ reason = pskb_may_pull_reason(skb, sizeof(*ershdr));
+ if (unlikely(reason))
+ return reason;
ipv6h = ipv6_hdr(skb);
ershdr = (struct erspan_base_hdr *)skb->data;
@@ -507,13 +510,14 @@ static int ip6erspan_rcv(struct sk_buff *skb,
if (tunnel) {
int len = erspan_hdr_len(ver);
- if (unlikely(!pskb_may_pull(skb, len)))
- return PACKET_REJECT;
+ reason = pskb_may_pull_reason(skb, len);
+ if (unlikely(reason))
+ return reason;
- if (__iptunnel_pull_header(skb, len,
- htons(ETH_P_TEB),
- false, false) < 0)
- return PACKET_REJECT;
+ reason = __iptunnel_pull_header(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 +534,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 +562,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_TUNNEL_NOT_FOUND;
}
static int gre_rcv(struct sk_buff *skb)
{
+ enum skb_drop_reason reason;
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(skb, tpi.hdr_len, tpi.proto, 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:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -674,10 +681,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 +704,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 +717,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 +745,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 +764,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 +775,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 +790,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 +810,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,17 +868,17 @@ 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,
@@ -877,41 +886,56 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
{
struct ip_tunnel_info *tun_info = NULL;
struct ip6_tnl *t = netdev_priv(dev);
+ enum skb_drop_reason reason;
__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 (!t->parms.collect_md && ipv6_addr_any(&t->parms.raddr)) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_err;
+ }
- if (t->parms.collect_md)
+ 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);
+ if (IS_ERR(tun_info) ||
+ unlikely(ip_tunnel_info_af(tun_info) != AF_INET6)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
+ goto tx_err;
+ }
+ }
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;
tx_err:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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;
}
@@ -922,27 +946,39 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
struct ip6_tnl *t = netdev_priv(dev);
struct dst_entry *dst = skb_dst(skb);
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
+ enum skb_drop_reason reason;
bool truncate = false;
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 (!t->parms.collect_md && ipv6_addr_any(&t->parms.raddr)) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_err;
+ }
+
+ 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 +998,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 +1015,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 +1030,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 +1055,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 +1066,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 +1094,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 +1112,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));
@@ -1078,10 +1129,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
tx_err:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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..7e444115f4314 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_TUNNEL_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_TUNNEL_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_TUNNEL_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;
}
}
@@ -896,9 +907,10 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
return 0;
drop:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
if (tun_dst)
dst_release((struct dst_entry *)tun_dst);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -941,6 +953,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
const struct ipv6hdr *ipv6h,
struct sk_buff *skb))
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip6_tnl *t;
const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
struct metadata_dst *tun_dst = NULL;
@@ -952,21 +965,30 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
if (t) {
u8 tproto = READ_ONCE(t->parms.proto);
- if (tproto != ipproto && tproto != 0)
+ if (tproto != ipproto && tproto != 0) {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto drop;
- if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
+ }
+ if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+ reason = SKB_DROP_REASON_XFRM_POLICY;
goto drop;
+ }
ipv6h = ipv6_hdr(skb);
- if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr))
+ if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr)) {
+ reason = SKB_DROP_REASON_DEV_READY;
goto drop;
- if (iptunnel_pull_header(skb, 0, tpi->proto, false))
+ }
+ reason = iptunnel_pull_header(skb, 0, tpi->proto, false);
+ if (reason)
goto drop;
if (t->parms.collect_md) {
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
tun_dst = ipv6_tun_rx_dst(skb, flags, 0, 0);
- if (!tun_dst)
+ if (!tun_dst) {
+ reason = SKB_DROP_REASON_NOMEM;
goto drop;
+ }
}
ret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,
log_ecn_error);
@@ -978,7 +1000,8 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
drop:
rcu_read_unlock();
- kfree_skb(skb);
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -1092,14 +1115,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 +1133,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 +1155,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,12 +1178,19 @@ 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));
}
+
+ if (ipv6_addr_any(&fl6->daddr)) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
+ goto tx_err_link_failure;
+ }
} else if (t->parms.proto != 0 && !(t->parms.flags &
(IP6_TNL_F_USE_ORIG_TCLASS |
IP6_TNL_F_USE_ORIG_FWMARK))) {
@@ -1169,8 +1203,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 +1215,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 +1240,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 +1254,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 +1277,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_TUNNEL_ENCAP;
goto tx_err_dst_release;
+ }
} else {
if (use_cache && ndst)
dst_cache_set_ip6(&t->dst_cache, ndst, &fl6->saddr);
@@ -1264,9 +1309,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_TUNNEL_ENCAP;
if (encap_limit >= 0) {
init_tel_txopt(&opt, encap_limit);
@@ -1283,21 +1327,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 +1351,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 +1363,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 +1400,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 +1442,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 +1462,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)
{
struct ip6_tnl *t = netdev_priv(dev);
+ enum skb_drop_reason reason;
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,27 +1484,31 @@ 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;
tx_err:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33575 output: 25 thoughts: 819 Thoughts: **Analyzing the Networking Code Patch** Okay, so this patch is a fairly extensive modification to the networking stack, touching a good chunk of tunnel and VXLAN code. I see it's spread across `drivers/net/vxlan/vxlan_core.c` and a whole host of include files and IPv4/IPv6 specific implementations. This means it's likely a foundational change. The patch instructions are clear: it's introducing detailed `skb_drop_reason` information across VXLAN, GRE, and various IP tunnel implementations. Looks like they're really trying to improve debugging and observability of packet drops within these tunnel mechanisms. That's a solid goal; understanding *why* packets are being dropped is crucial for performance and reliability. Alright, the core of the change seems to be the function signature modifications. We're moving from a simple `int` return code to an `enum skb_drop_reason` in a series of key functions: `gre_parse_header`, the various `_xmit` functions, and several `_rcv` functions. This signals a complete revamp of the error reporting methodology for a more comprehensive and structured drop reason output. Functions like `__iptunnel_pull_header`, `iptunnel_pull_header`, and others seem to be affected. The next significant change is the replacement of `kfree_skb(skb)` with `kfree_skb_reason(skb, reason)`. This is where the new `enum skb_drop_reason` comes into play. Everywhere a packet is being dropped, we're now providing the specific reason. That's a good move, this should offer far more granular insights into where things are going wrong. Taking a closer look at the code examples, I notice the change in the error handling logic. It looks like the patch is attempting to return a `reason` directly where it would previously use `goto drop;` and `kfree_skb`. This is happening in multiple places. It is also changing return values, making the changes much more explicit. For example, in the `vxlan_rcv` example, where previously we had a simple conditional check based on the return of `__iptunnel_pull_header`, it now captures the return value directly into the `reason` variable, which provides a drop reason. And in `__iptunnel_pull_header` the changes from `-ENOMEM` to a reason makes a lot of sense. The same goes for the change to `SKB_NOT_DROPPED_YET`, it's an interesting approach. I'll need to check the definition of `enum skb_drop_reason` to understand the significance of that return value. Let's see... looking at `include/net/dropreason-core.h`, and, ah, I see `SKB_NOT_DROPPED_YET`. That clarifies it. |
| 4/2 | 2026/10/01 19:27 | tool | grepper |
0mArgs:{
"Expression": "SKB_NOT_DROPPED_YET"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 385 lines.\nUse more precise expression if possible.\n\ndrivers/net/netdevsim/psp.c=18=nsim_do_psp(struct sk_buff *skb, struct netdevsim *ns,\n--\ndrivers/net/netdevsim/psp.c-29-\tif (!pas) {\ndrivers/net/netdevsim/psp.c:30:\t\trc = SKB_NOT_DROPPED_YET;\ndrivers/net/netdevsim/psp.c-31-\t\tgoto out_unlock;\n--\ndrivers/net/vxlan/vxlan_core.c=1451=static enum skb_drop_reason vxlan_snoop(struct net_device *dev,\n--\ndrivers/net/vxlan/vxlan_core.c-1484-\t\t\t rdst-\u003eremote_ifindex == ifindex))\ndrivers/net/vxlan/vxlan_core.c:1485:\t\t\treturn SKB_NOT_DROPPED_YET;\ndrivers/net/vxlan/vxlan_core.c-1486-\n--\ndrivers/net/vxlan/vxlan_core.c-1513-\ndrivers/net/vxlan/vxlan_core.c:1514:\treturn SKB_NOT_DROPPED_YET;\ndrivers/net/vxlan/vxlan_core.c-1515-}\n--\ndrivers/net/vxlan/vxlan_core.c=1565=static enum skb_drop_reason vxlan_remcsum(struct sk_buff *skb, u32 vxflags)\n--\ndrivers/net/vxlan/vxlan_core.c-1571-\tif (!(vh-\u003evx_flags \u0026 VXLAN_HF_RCO) || skb-\u003eremcsum_offload)\ndrivers/net/vxlan/vxlan_core.c:1572:\t\treturn SKB_NOT_DROPPED_YET;\ndrivers/net/vxlan/vxlan_core.c-1573-\n--\ndrivers/net/vxlan/vxlan_core.c-1582-\t\t\t !!(vxflags \u0026 VXLAN_F_REMCSUM_NOPARTIAL));\ndrivers/net/vxlan/vxlan_core.c:1583:\treturn SKB_NOT_DROPPED_YET;\ndrivers/net/vxlan/vxlan_core.c-1584-}\n--\ndrivers/net/vxlan/vxlan_core.c=1617=static enum skb_drop_reason vxlan_set_mac(struct vxlan_dev *vxlan,\n--\ndrivers/net/vxlan/vxlan_core.c-1644-\tif (!(cfg-\u003eflags \u0026 VXLAN_F_LEARN))\ndrivers/net/vxlan/vxlan_core.c:1645:\t\treturn SKB_NOT_DROPPED_YET;\ndrivers/net/vxlan/vxlan_core.c-1646-\n--\ninclude/linux/skbuff.h=2845=pskb_may_pull_reason(struct sk_buff *skb, unsigned int len)\n--\ninclude/linux/skbuff.h-2850-\tif (likely(len \u003c= skb_headlen(skb)))\ninclude/linux/skbuff.h:2851:\t\treturn SKB_NOT_DROPPED_YET;\ninclude/linux/skbuff.h-2852-\n--\ninclude/linux/skbuff.h-2858-\ninclude/linux/skbuff.h:2859:\treturn SKB_NOT_DROPPED_YET;\ninclude/linux/skbuff.h-2860-}\n--\ninclude/linux/skbuff.h=2863=pskb_may_pull(struct sk_buff *skb, unsigned int len)\ninclude/linux/skbuff.h-2864-{\ninclude/linux/skbuff.h:2865:\treturn pskb_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET;\ninclude/linux/skbuff.h-2866-}\n--\ninclude/linux/skbuff.h=3280=static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)\ninclude/linux/skbuff.h-3281-{\ninclude/linux/skbuff.h:3282:\treturn pskb_network_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET;\ninclude/linux/skbuff.h-3283-}\n--\ninclude/net/dropreason-core.h=143=enum skb_drop_reason {\ninclude/net/dropreason-core.h-144-\t/**\ninclude/net/dropreason-core.h:145:\t * @SKB_NOT_DROPPED_YET: skb is not dropped yet (used for no-drop case)\ninclude/net/dropreason-core.h-146-\t */\ninclude/net/dropreason-core.h:147:\tSKB_NOT_DROPPED_YET = 0,\ninclude/net/dropreason-core.h-148-\t/** @SKB_CONSUMED: packet has been consumed */\n--\ninclude/net/dropreason-core.h-673-\t\tif (name == SKB_DROP_REASON_NOT_SPECIFIED ||\t\\\ninclude/net/dropreason-core.h:674:\t\t name == SKB_NOT_DROPPED_YET)\t\t\\\ninclude/net/dropreason-core.h-675-\t\t\tSKB_DR_SET(name, reason);\t\t\\\n--\ninclude/net/dropreason-qdisc.h=34=enum qdisc_drop_reason {\n--\ninclude/net/dropreason-qdisc.h-36-\t * @QDISC_DROP_UNSPEC: unspecified/invalid qdisc drop reason.\ninclude/net/dropreason-qdisc.h:37:\t * Value 0 serves as analogous to SKB_NOT_DROPPED_YET for enum skb_drop_reason.\ninclude/net/dropreason-qdisc.h-38-\t * Used for catching zero-initialized drop_reason fields.\n--\ninclude/net/ip_fib.h=457=fib_validate_source_reason(struct sk_buff *skb, __be32 src, __be32 dst,\n--\ninclude/net/ip_fib.h-464-\t\treturn -err;\ninclude/net/ip_fib.h:465:\treturn SKB_NOT_DROPPED_YET;\ninclude/net/ip_fib.h-466-}\n--\ninclude/net/ip_tunnels.h=482=static inline bool pskb_inet_may_pull(struct sk_buff *skb)\ninclude/net/ip_tunnels.h-483-{\ninclude/net/ip_tunnels.h:484:\treturn pskb_inet_may_pull_reason(skb) == SKB_NOT_DROPPED_YET;\ninclude/net/ip_tunnels.h-485-}\n--\ninclude/net/ip_tunnels.h=490=skb_vlan_inet_prepare(struct sk_buff *skb, bool inner_proto_inherit)\n--\ninclude/net/ip_tunnels.h-520-\ninclude/net/ip_tunnels.h:521:\treturn SKB_NOT_DROPPED_YET;\ninclude/net/ip_tunnels.h-522-}\n--\ninclude/net/tcp_ao.h=301=static inline enum skb_drop_reason tcp_inbound_ao_hash(struct sock *sk,\n--\ninclude/net/tcp_ao.h-305-{\ninclude/net/tcp_ao.h:306:\treturn SKB_NOT_DROPPED_YET;\ninclude/net/tcp_ao.h-307-}\n--\nnet/bridge/br_device.c=30=netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n--\nnet/bridge/br_device.c-43-\nnet/bridge/br_device.c:44:\tif (unlikely(reason != SKB_NOT_DROPPED_YET)) {\nnet/bridge/br_device.c-45-\t\tkfree_skb_reason(skb, reason);\n--\nnet/core/dev.c=4195=static enum skb_drop_reason qdisc_pkt_len_segs_init(struct sk_buff *skb)\n--\nnet/core/dev.c-4203-\t\tqdisc_skb_cb(skb)-\u003epkt_segs = 1;\nnet/core/dev.c:4204:\t\treturn SKB_NOT_DROPPED_YET;\nnet/core/dev.c-4205-\t}\n--\nnet/core/dev.c-4215-\t\tif (unlikely(!skb_transport_header_was_set(skb)))\nnet/core/dev.c:4216:\t\t\treturn SKB_NOT_DROPPED_YET;\nnet/core/dev.c-4217-\t\thdr_len = skb_transport_offset(skb);\n--\nnet/core/dev.c-4253-\tqdisc_skb_cb(skb)-\u003epkt_len += (gso_segs - 1) * hdr_len;\nnet/core/dev.c:4254:\treturn SKB_NOT_DROPPED_YET;\nnet/core/dev.c-4255-}\n--\nnet/core/skbuff.c=1217=bool __sk_skb_reason_drop(const struct sock *sk, struct sk_buff *skb,\n--\nnet/core/skbuff.c-1222-\nnet/core/skbuff.c:1223:\tDEBUG_NET_WARN_ON_ONCE(reason == SKB_NOT_DROPPED_YET ||\nnet/core/skbuff.c-1224-\t\t\t u32_get_bits(reason,\n--\nnet/core/sock.c=525=sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb)\n--\nnet/core/sock.c-540-\t}\nnet/core/sock.c:541:\treturn SKB_NOT_DROPPED_YET;\nnet/core/sock.c-542-}\n--\nnet/ipv4/arp.c=970=static int arp_rcv(struct sk_buff *skb, struct net_device *dev,\n--\nnet/ipv4/arp.c-987-\tdrop_reason = pskb_may_pull_reason(skb, arp_hdr_len(dev));\nnet/ipv4/arp.c:988:\tif (drop_reason != SKB_NOT_DROPPED_YET)\nnet/ipv4/arp.c-989-\t\tgoto freeskb;\n--\nnet/ipv4/gre_demux.c=57=EXPORT_SYMBOL_GPL(gre_del_protocol);\n--\nnet/ipv4/gre_demux.c-73- *\nnet/ipv4/gre_demux.c:74: * Return: SKB_NOT_DROPPED_YET, or the reason to drop the packet if the\nnet/ipv4/gre_demux.c-75- * header is rejected.\n--\nnet/ipv4/gre_demux.c=78=gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n--\nnet/ipv4/gre_demux.c-161-\nnet/ipv4/gre_demux.c:162:\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/gre_demux.c-163-}\n--\nnet/ipv4/icmp.c=1115=static enum skb_drop_reason icmp_unreach(struct sk_buff *skb)\nnet/ipv4/icmp.c-1116-{\nnet/ipv4/icmp.c:1117:\tenum skb_drop_reason reason = SKB_NOT_DROPPED_YET;\nnet/ipv4/icmp.c-1118-\tconst struct iphdr *iph;\n--\nnet/ipv4/icmp.c=1231=static enum skb_drop_reason icmp_redirect(struct sk_buff *skb)\n--\nnet/ipv4/icmp.c-1243-\ticmp_socket_deliver(skb, ntohl(icmp_hdr(skb)-\u003eun.gateway));\nnet/ipv4/icmp.c:1244:\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/icmp.c-1245-}\n--\nnet/ipv4/icmp.c=1261=static enum skb_drop_reason icmp_echo(struct sk_buff *skb)\n--\nnet/ipv4/icmp.c-1269-\tif (READ_ONCE(net-\u003eipv4.sysctl_icmp_echo_ignore_all))\nnet/ipv4/icmp.c:1270:\t\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/icmp.c-1271-\n--\nnet/ipv4/icmp.c-1280-\telse if (!icmp_build_probe(skb, \u0026icmp_param-\u003edata.icmph))\nnet/ipv4/icmp.c:1281:\t\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/icmp.c-1282-\nnet/ipv4/icmp.c-1283-\ticmp_reply(icmp_param, skb);\nnet/ipv4/icmp.c:1284:\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/icmp.c-1285-}\n--\nnet/ipv4/icmp.c=1408=static enum skb_drop_reason icmp_timestamp(struct sk_buff *skb)\n--\nnet/ipv4/icmp.c-1433-\ticmp_reply(icmp_param, skb);\nnet/ipv4/icmp.c:1434:\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/icmp.c-1435-\n--\nnet/ipv4/icmp.c=1441=static enum skb_drop_reason icmp_discard(struct sk_buff *skb)\n--\nnet/ipv4/icmp.c-1443-\t/* pretend it was a success */\nnet/ipv4/icmp.c:1444:\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/icmp.c-1445-}\n--\nnet/ipv4/ip_gre.c=267=static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-359-\t\tip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\nnet/ipv4/ip_gre.c:360:\t\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/ip_gre.c-361-\t}\n--\nnet/ipv4/ip_gre.c-366-\tkfree_skb_reason(skb, reason);\nnet/ipv4/ip_gre.c:367:\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/ip_gre.c-368-}\n--\nnet/ipv4/ip_gre.c=370=static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-415-\t\tip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\nnet/ipv4/ip_gre.c:416:\t\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/ip_gre.c-417-\t}\n--\nnet/ipv4/ip_gre.c-422-\tkfree_skb_reason(skb, reason);\nnet/ipv4/ip_gre.c:423:\treturn SKB_NOT_DROPPED_YET;\nnet/ipv4/ip_gre.c-424-}\n--\nnet/ipv4/ip_input.c=269=ip_rcv_options(struct sk_buff *skb, struct net_device *dev)\n--\n\n"
} |
| 5/2 | 2026/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39246 output: 38 thoughts: 540 Thoughts: **Analyzing Potential Impact and Worthiness for Fuzzing** Okay, first things first, `SKB_NOT_DROPPED_YET = 0`. Let's dive in. This patch is touching some core virtual networking components: vxlan, gre, ip_tunnel, and ip6_tunnel. That's a good place to start. These virtual devices, including erspan, ip6gre, and ip6erspan, are all definitely reachable through the standard virtualized environments. Think netlink/rtnetlink to configure interfaces, tun/tap, packet sockets, raw sockets, even UDP sockets for vxlan... all standard. Alright, now to the negative criteria. Are we dealing with non-kernel code or things that aren't executable? Nope. This is C logic that touches `net/` and `drivers/net/vxlan/`. Structurally unreachable hardware? Nope, again. We're dealing with software networking and virtual devices. Unreachable execution paths? No way; vxlan, gre, ip_tunnel, and ip6_tunnel all have receive and transmit paths. Now for the positive side. Is this touching any core subsystems? Hmm, any modifications in memory management, BPF, the scheduler, core networking, VFS, or syscall handling? Yes, networking! Are there any drivers accessed through virtual buses or software devices, like virtio, USB gadget, loopback, netlink, binder, or sockets? Yes, certainly. Is there any refactoring or code cleanup that's restructuring reachable data structures, helper abstractions, or algorithm flows? Yes! This feels good. Reachability is the primary gate, so let's mark it as `WorthFuzzing = true!`. But wait. Gotta be careful. Let's dig deeper and verify if there are any subtle bugs or changes that might cause regressions, panics, or memory issues. Okay, let's look at `gre_parse_header`. This looks interesting, because the return value has changed! Previously it looked like this: ```c -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 ignore_csum_err, __be16 proto, int nhs); ``` Before, it returned an `int`, now it's an `enum skb_drop_reason`. But the bigger change here is that what was likely the `hdr_len` is being set somewhere within the function now: `tpi->hdr_len = ...` I need to confirm that `tpi->hdr_len` is being set and that it's being handled correctly. That means going back and looking at `net/ipv4/gre_demux.c` around the call to `gre_parse_header`. Gotta make sure nothing breaks! |
| 6/2 | 2026/10/01 19:27 | tool | read-file |
0mArgs:{
"File": "net/ipv4/gre_demux.c",
"FirstLine": 75,
"LineCount": 85
}Results: {
"Contents": " 75:\t * header is rejected.\n 76:\t */\n 77:\tenum skb_drop_reason\n 78:\tgre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n 79:\t\t\t bool ignore_csum_err, __be16 proto, int nhs)\n 80:\t{\n 81:\t\tconst struct gre_base_hdr *greh;\n 82:\t\tenum skb_drop_reason reason;\n 83:\t\t__be32 *options;\n 84:\t\tint hdr_len;\n 85:\t\n 86:\t\treason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));\n 87:\t\tif (unlikely(reason))\n 88:\t\t\treturn reason;\n 89:\t\n 90:\t\tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n 91:\t\tif (unlikely(greh-\u003eflags \u0026 (GRE_VERSION | GRE_ROUTING)))\n 92:\t\t\treturn SKB_DROP_REASON_TUNNEL_INVALID_HDR;\n 93:\t\n 94:\t\tgre_flags_to_tnl_flags(tpi-\u003eflags, greh-\u003eflags);\n 95:\t\thdr_len = gre_calc_hlen(tpi-\u003eflags);\n 96:\t\n 97:\t\treason = pskb_may_pull_reason(skb, nhs + hdr_len);\n 98:\t\tif (reason)\n 99:\t\t\treturn reason;\n 100:\t\n 101:\t\tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n 102:\t\ttpi-\u003eproto = greh-\u003eprotocol;\n 103:\t\n 104:\t\toptions = (__be32 *)(greh + 1);\n 105:\t\tif (greh-\u003eflags \u0026 GRE_CSUM) {\n 106:\t\t\tif (!skb_checksum_simple_validate(skb)) {\n 107:\t\t\t\tskb_checksum_try_convert(skb, IPPROTO_GRE,\n 108:\t\t\t\t\t\t\t null_compute_pseudo);\n 109:\t\t\t} else if (!ignore_csum_err) {\n 110:\t\t\t\treturn SKB_DROP_REASON_GRE_CSUM;\n 111:\t\t\t}\n 112:\t\n 113:\t\t\toptions++;\n 114:\t\t}\n 115:\t\n 116:\t\tif (greh-\u003eflags \u0026 GRE_KEY) {\n 117:\t\t\ttpi-\u003ekey = *options;\n 118:\t\t\toptions++;\n 119:\t\t} else {\n 120:\t\t\ttpi-\u003ekey = 0;\n 121:\t\t}\n 122:\t\tif (unlikely(greh-\u003eflags \u0026 GRE_SEQ)) {\n 123:\t\t\ttpi-\u003eseq = *options;\n 124:\t\t\toptions++;\n 125:\t\t} else {\n 126:\t\t\ttpi-\u003eseq = 0;\n 127:\t\t}\n 128:\t\t/* WCCP version 1 and 2 protocol decoding.\n 129:\t\t * - Change protocol to IPv4/IPv6\n 130:\t\t * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header\n 131:\t\t */\n 132:\t\tif (greh-\u003eflags == 0 \u0026\u0026 tpi-\u003eproto == htons(ETH_P_WCCP)) {\n 133:\t\t\tu8 _val, *val;\n 134:\t\n 135:\t\t\tval = skb_header_pointer(skb, nhs + hdr_len,\n 136:\t\t\t\t\t\t sizeof(_val), \u0026_val);\n 137:\t\t\tif (!val)\n 138:\t\t\t\treturn SKB_DROP_REASON_PKT_TOO_SMALL;\n 139:\t\t\ttpi-\u003eproto = proto;\n 140:\t\t\tif ((*val \u0026 0xF0) != 0x40)\n 141:\t\t\t\thdr_len += 4;\n 142:\t\t}\n 143:\t\ttpi-\u003ehdr_len = hdr_len;\n 144:\t\n 145:\t\t/* ERSPAN ver 1 and 2 protocol sets GRE key field\n 146:\t\t * to 0 and sets the configured key in the\n 147:\t\t * inner erspan header field\n 148:\t\t */\n 149:\t\tif ((greh-\u003eprotocol == htons(ETH_P_ERSPAN) \u0026\u0026 hdr_len != 4) ||\n 150:\t\t greh-\u003eprotocol == htons(ETH_P_ERSPAN2)) {\n 151:\t\t\tstruct erspan_base_hdr *ershdr;\n 152:\t\n 153:\t\t\treason = pskb_may_pull_reason(skb,\n 154:\t\t\t\t\t\t nhs + hdr_len + sizeof(*ershdr));\n 155:\t\t\tif (reason)\n 156:\t\t\t\treturn reason;\n 157:\t\n 158:\t\t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + nhs + hdr_len);\n 159:\t\t\ttpi-\u003ekey = cpu_to_be32(get_session_id(ershdr));\n"
} |
| 7/2 | 2026/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41838 output: 19 thoughts: 50 Thoughts: Okay, here's my assessment of that code snippet, delivered as if it's my own thought process: **Diving into the GRE Header Length Assignment** Alright, *that's* interesting. Line 143, specifically `tpi->hdr_len = hdr_len;`, is assigning a calculated header length (`hdr_len`) to a member (`hdr_len`) of a structure pointed to by `tpi`. It's a fairly straightforward assignment, but the *context* is what matters here. I need to understand what `tpi` is, what `hdr_len` represents in this particular situation, and most importantly, *who* is calling `gre_parse_header`. Let's not guess. It's time to follow the trail. I'm going to track down all the calls to `gre_parse_header`. I'm mentally picturing a quick `grep` through the codebase to pinpoint every instance of that function being invoked. That should give me the crucial upstream context I need to properly interpret what this line is doing. |
| 8/2 | 2026/10/01 19:27 | 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 ignore_csum_err, __be16 proto, int nhs);\n--\nnet/ipv4/gre_demux.c=57=EXPORT_SYMBOL_GPL(gre_del_protocol);\n--\nnet/ipv4/gre_demux.c-59-/**\nnet/ipv4/gre_demux.c:60: * gre_parse_header() - parse the GRE header of a packet\nnet/ipv4/gre_demux.c-61- * @skb: the packet; the GRE header starts @nhs bytes past skb-\u003edata\n--\nnet/ipv4/gre_demux.c=77=enum skb_drop_reason\nnet/ipv4/gre_demux.c:78:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\nnet/ipv4/gre_demux.c-79-\t\t bool ignore_csum_err, __be16 proto, int nhs)\n--\nnet/ipv4/gre_demux.c-163-}\nnet/ipv4/gre_demux.c:164:EXPORT_SYMBOL(gre_parse_header);\nnet/ipv4/gre_demux.c-165-\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=451=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv4/ip_gre.c-463-\nnet/ipv4/ip_gre.c:464:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IP), 0);\nnet/ipv4/ip_gre.c-465-\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=571=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-575-\nnet/ipv6/ip6_gre.c:576:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\nnet/ipv6/ip6_gre.c-577-\tif (reason)\n"
} |
| 9/2 | 2026/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43009 output: 39 thoughts: 716 Thoughts: **Analyzing the IPv6 GRE Receive Path** Alright, let's dive into this `gre_rcv` function within `net/ipv6/ip6_gre.c`. I'm seeing a core component of IPv6 GRE (Generic Routing Encapsulation) packet processing. My initial thought is to break down the logic. First, `gre_parse_header` seems to be responsible for parsing the GRE header itself, potentially extracting relevant information like the protocol type. Then, `iptunnel_pull_header` comes into play. I recognize this as the function that's going to strip the outer header, making the inner payload accessible, likely based on information from the header parse. Now, a conditional block appears. It checks for ERSPAN (Encapsulated Remote SPAN) packets, identified by their Ethernet protocol type. I see that ERSPAN processing is handled by `ip6erspan_rcv`. If it *is* an ERSPAN packet, and `ip6erspan_rcv` returns that the packet was handled, we're done. Otherwise, the code proceeds to `ip6gre_rcv`, which I assume handles standard IPv6 GRE traffic. Wait a second, let me zoom in on the previous version! I'm noticing a discrepancy! Before this patch, `gre_parse_header` seemed to return `hdr_len`, and the code *then* passed `hdr_len` directly to `iptunnel_pull_header`. But now, after the change, `iptunnel_pull_header` is called, *then* `hdr_len` is passed to `ip6erspan_rcv`. This is a red flag. Didn't `iptunnel_pull_header` *already* strip that many bytes off the packet? It looks like there's a potential double-decrement here. The code *should* be passing `tpi.hdr_len` instead of `hdr_len`, since it should be updated after `iptunnel_pull_header` has run. I need to confirm this assumption. I'm going to quickly check `ip6erspan_rcv` to see what it *does* with that length parameter. If it's *not* accounting for the header being already pulled off, this patch looks problematic. It appears this patch fixes the potential double-pull issue. If `ip6erspan_rcv` is passed `tpi.hdr_len` then it can process the packet correctly. |
| 10/2 | 2026/10/01 19:27 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_gre.c",
"FirstLine": 488,
"LineCount": 45
}Results: {
"Contents": " 488:\tstatic enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n 489:\t\t\t\t\t\t struct tnl_ptk_info *tpi,\n 490:\t\t\t\t\t\t int gre_hdr_len)\n 491:\t{\n 492:\t\tstruct erspan_base_hdr *ershdr;\n 493:\t\tconst struct ipv6hdr *ipv6h;\n 494:\t\tenum skb_drop_reason reason;\n 495:\t\tstruct erspan_md2 *md2;\n 496:\t\tstruct ip6_tnl *tunnel;\n 497:\t\tu8 ver;\n 498:\t\n 499:\t\treason = pskb_may_pull_reason(skb, sizeof(*ershdr));\n 500:\t\tif (unlikely(reason))\n 501:\t\t\treturn reason;\n 502:\t\n 503:\t\tipv6h = ipv6_hdr(skb);\n 504:\t\tershdr = (struct erspan_base_hdr *)skb-\u003edata;\n 505:\t\tver = ershdr-\u003ever;\n 506:\t\n 507:\t\ttunnel = ip6gre_tunnel_lookup(skb-\u003edev,\n 508:\t\t\t\t\t \u0026ipv6h-\u003esaddr, \u0026ipv6h-\u003edaddr, tpi-\u003ekey,\n 509:\t\t\t\t\t tpi-\u003eproto);\n 510:\t\tif (tunnel) {\n 511:\t\t\tint len = erspan_hdr_len(ver);\n 512:\t\n 513:\t\t\treason = pskb_may_pull_reason(skb, len);\n 514:\t\t\tif (unlikely(reason))\n 515:\t\t\t\treturn reason;\n 516:\t\n 517:\t\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\n 518:\t\t\t\t\t\t\tfalse, false);\n 519:\t\t\tif (reason)\n 520:\t\t\t\treturn reason;\n 521:\t\n 522:\t\t\tif (tunnel-\u003eparms.collect_md) {\n 523:\t\t\t\tstruct erspan_metadata *pkt_md, *md;\n 524:\t\t\t\tIP_TUNNEL_DECLARE_FLAGS(flags);\n 525:\t\t\t\tstruct metadata_dst *tun_dst;\n 526:\t\t\t\tstruct ip_tunnel_info *info;\n 527:\t\t\t\tunsigned char *gh;\n 528:\t\t\t\t__be64 tun_id;\n 529:\t\n 530:\t\t\t\t__set_bit(IP_TUNNEL_KEY_BIT, tpi-\u003eflags);\n 531:\t\t\t\tip_tunnel_flags_copy(flags, tpi-\u003eflags);\n 532:\t\t\t\ttun_id = key32_to_tunnel_id(tpi-\u003ekey);\n"
} |
| 11/2 | 2026/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 45025 output: 38 thoughts: 62 Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue: **ERSpan Header Length Investigation** Hmm, this is interesting. I'm looking at the `ip6erspan_rcv` function, and it's immediately apparent that the `gre_hdr_len` variable... it's just *sitting* there, completely unused! That's a red flag. What's the point of calculating or even receiving the length if it's never referenced? That screams potential bug or, at the very least, a significant inefficiency. I need to figure out the context, here. Now, let's step back a moment. Is this consistent across the board? I need to check the IPv4 implementation to see if it's exhibiting the same behavior. Where's that, in `net/ipv4`? Ah, yes, there's `ip_gre.c`. Let's take a look at the `erspan_rcv` function over there. I need to know if the handling in the IPv4 case is the same, and if the same value is unused. |
| 12/2 | 2026/10/01 19:27 | tool | read-file |
0mArgs:{
"File": "net/ipv4/ip_gre.c",
"FirstLine": 265,
"LineCount": 50
}Results: {
"Contents": " 265:\t}\n 266:\t\n 267:\tstatic enum skb_drop_reason erspan_rcv(struct sk_buff *skb,\n 268:\t\t\t\t\t struct tnl_ptk_info *tpi,\n 269:\t\t\t\t\t int gre_hdr_len)\n 270:\t{\n 271:\t\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n 272:\t\tstruct net *net = dev_net(skb-\u003edev);\n 273:\t\tstruct metadata_dst *tun_dst = NULL;\n 274:\t\tstruct erspan_base_hdr *ershdr;\n 275:\t\tIP_TUNNEL_DECLARE_FLAGS(flags);\n 276:\t\tstruct ip_tunnel_net *itn;\n 277:\t\tstruct ip_tunnel *tunnel;\n 278:\t\tconst struct iphdr *iph;\n 279:\t\tstruct erspan_md2 *md2;\n 280:\t\tint ver;\n 281:\t\tint len;\n 282:\t\n 283:\t\tip_tunnel_flags_copy(flags, tpi-\u003eflags);\n 284:\t\n 285:\t\titn = net_generic(net, erspan_net_id);\n 286:\t\tiph = ip_hdr(skb);\n 287:\t\tif (is_erspan_type1(gre_hdr_len)) {\n 288:\t\t\tver = 0;\n 289:\t\t\t__set_bit(IP_TUNNEL_NO_KEY_BIT, flags);\n 290:\t\t\ttunnel = ip_tunnel_lookup(itn, skb-\u003edev-\u003eifindex, flags,\n 291:\t\t\t\t\t\t iph-\u003esaddr, iph-\u003edaddr, 0);\n 292:\t\t} else {\n 293:\t\t\treason = pskb_may_pull_reason(skb,\n 294:\t\t\t\t\t\t gre_hdr_len + sizeof(*ershdr));\n 295:\t\t\tif (unlikely(reason))\n 296:\t\t\t\treturn reason;\n 297:\t\n 298:\t\t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + gre_hdr_len);\n 299:\t\t\tver = ershdr-\u003ever;\n 300:\t\t\tiph = ip_hdr(skb);\n 301:\t\t\t__set_bit(IP_TUNNEL_KEY_BIT, flags);\n 302:\t\t\ttunnel = ip_tunnel_lookup(itn, skb-\u003edev-\u003eifindex, flags,\n 303:\t\t\t\t\t\t iph-\u003esaddr, iph-\u003edaddr, tpi-\u003ekey);\n 304:\t\t}\n 305:\t\n 306:\t\tif (tunnel) {\n 307:\t\t\tif (is_erspan_type1(gre_hdr_len))\n 308:\t\t\t\tlen = gre_hdr_len;\n 309:\t\t\telse\n 310:\t\t\t\tlen = gre_hdr_len + erspan_hdr_len(ver);\n 311:\t\n 312:\t\t\treason = pskb_may_pull_reason(skb, len);\n 313:\t\t\tif (unlikely(reason))\n 314:\t\t\t\treturn reason;\n"
} |
| 13/2 | 2026/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46205 output: 39 thoughts: 1400 Thoughts: **Analyzing the IPv4 GRE and ERSPAN Packet Handling** Okay, let's break this down. My initial focus is on the interplay between `gre_rcv`, `erspan_rcv`, and `ipgre_rcv` within the IPv4 GRE implementation. Specifically, I'm examining the potential for packet dropping and ICMP generation. It seems there's a specific issue, or a potential inconsistency to highlight. My first observation is in `net/ipv4/ip_gre.c`. The `gre_rcv` function's behavior regarding ERSPAN packets is crucial. It calls `erspan_rcv` and `ipgre_rcv`, passing `tpi.hdr_len`. I noticed a code path where an error in `erspan_rcv` leads to... potentially unexpected behavior. Initially, I'm thinking about comparing the code before and after a patch. Specifically, when `erspan_rcv` returns an error, the code jumps to `out:`, and the `icmp_send` happens. But then, inside the `erspan_rcv` function, if there's an error, it returns `SKB_NOT_DROPPED_YET` (which is 0). And the key issue is this: if `erspan_rcv` drops the packet, it *does* call `kfree_skb_reason`, which should free the skb. The issue is that the return value from `erspan_rcv` causes `gre_rcv` to also return 0, which could cause a packet to be *undropped*. Then I looked at the more recent patch, where `erspan_rcv` would return a non-zero reason. This would take it to `out:`. So I was initially wondering if the call to `icmp_send` is *correct* in all error scenarios. Specifically, if `pskb_may_pull_reason` fails in `erspan_rcv`, the function returns an error `reason`. But this then makes `gre_rcv` send ICMP, and this *used* to happen. The previous patch contained an early return using `PACKET_REJECT`, which meant it was dropped before reaching `out:`, which also means that ICMP was not sent. It looks like the updated logic still sends ICMP in that scenario. Is this intended? I need to confirm this understanding, and perhaps look at `net/ipv6/ip6_gre.c` for any similarities. This seems like a point worth investigating further to ensure that error handling and ICMP generation are consistent and correct, especially considering the different error paths within `erspan_rcv` itself and the potential for double-freeing or missed ICMP messages. |
| 14/2 | 2026/10/01 19:27 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_gre.c",
"FirstLine": 555,
"LineCount": 45
}Results: {
"Contents": " 555:\t\t\t\t\t\t\t ERSPAN_V2_MDSIZE);\n 556:\t\t\t\t__set_bit(IP_TUNNEL_ERSPAN_OPT_BIT,\n 557:\t\t\t\t\t info-\u003ekey.tun_flags);\n 558:\t\n 559:\t\t\t\tip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\n 560:\t\n 561:\t\t\t} else {\n 562:\t\t\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);\n 563:\t\t\t}\n 564:\t\n 565:\t\t\treturn SKB_NOT_DROPPED_YET;\n 566:\t\t}\n 567:\t\n 568:\t\treturn SKB_DROP_REASON_TUNNEL_NOT_FOUND;\n 569:\t}\n 570:\t\n 571:\tstatic int gre_rcv(struct sk_buff *skb)\n 572:\t{\n 573:\t\tenum skb_drop_reason reason;\n 574:\t\tstruct tnl_ptk_info tpi;\n 575:\t\n 576:\t\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\n 577:\t\tif (reason)\n 578:\t\t\tgoto drop;\n 579:\t\n 580:\t\treason = iptunnel_pull_header(skb, tpi.hdr_len, tpi.proto, false);\n 581:\t\tif (reason)\n 582:\t\t\tgoto drop;\n 583:\t\n 584:\t\tif (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||\n 585:\t\t\t tpi.proto == htons(ETH_P_ERSPAN2))) {\n 586:\t\t\treason = ip6erspan_rcv(skb, \u0026tpi, tpi.hdr_len);\n 587:\t\t\tif (!reason)\n 588:\t\t\t\treturn 0;\n 589:\t\t\tgoto out;\n 590:\t\t}\n 591:\t\n 592:\t\treason = ip6gre_rcv(skb, \u0026tpi);\n 593:\t\tif (!reason)\n 594:\t\t\treturn 0;\n 595:\t\n 596:\tout:\n 597:\t\ticmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);\n 598:\tdrop:\n 599:\t\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n"
} |
| 15/2 | 2026/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 48946 output: 38 thoughts: 653 Thoughts: **Analyzing Potential Packet Drop Issues in IP Tunneling** Okay, let's break this down. I'm focusing on potential packet drop scenarios within the IPv6 and IPv4 tunneling code. First, I'm diving into `net/ipv6/ip6_gre.c`, specifically the `ip6erspan_rcv` function. I see a critical area where `__iptunnel_pull_header` is called. The original code's error handling, returning `PACKET_REJECT` if the header pull failed, immediately catches my eye, but a patch changes this. I need to understand what this means for packets that fail the header pull now. I also notice other key error paths. If `tun_dst` allocation fails, the code correctly returns `SKB_DROP_REASON_NOMEM`. This looks standard, and leads to an ICMPv6 Port Unreachable message via `icmpv6_send` and drops the skb. This seems correct. However, I'm concerned that `ip6_tnl_rcv` might consume the `skb`, but I am correct in noticing that `ip6_tnl_rcv` returns `SKB_NOT_DROPPED_YET` if successful, which leads `gre_rcv` to return 0, indicating that the skb has been passed to the tunnel. No drop occurs. This confirms my expectation. Now, I'm switching gears to `net/ipv4/ip_tunnel.c`. I need to review `ip_tunnel_rcv` to see how it handles similar situations. I'm looking for potential discrepancies between IPv4 and IPv6 tunnel handling. |
| 16/2 | 2026/10/01 19:27 | tool | read-file |
0mArgs:{
"File": "net/ipv4/ip_tunnel.c",
"FirstLine": 395,
"LineCount": 75
}Results: {
"Contents": " 395:\t\t}\n 396:\t#endif\n 397:\t\n 398:\t\tif (test_bit(IP_TUNNEL_CSUM_BIT, tunnel-\u003eparms.i_flags) !=\n 399:\t\t test_bit(IP_TUNNEL_CSUM_BIT, tpi-\u003eflags)) {\n 400:\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_crc_errors);\n 401:\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 402:\t\t\treason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;\n 403:\t\t\tgoto drop;\n 404:\t\t}\n 405:\t\n 406:\t\tif (test_bit(IP_TUNNEL_SEQ_BIT, tunnel-\u003eparms.i_flags)) {\n 407:\t\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags)) {\n 408:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n 409:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 410:\t\t\t\treason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;\n 411:\t\t\t\tgoto drop;\n 412:\t\t\t}\n 413:\t\t\tif (tunnel-\u003ei_seqno \u0026\u0026\n 414:\t\t\t (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0) {\n 415:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n 416:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 417:\t\t\t\treason = SKB_DROP_REASON_TUNNEL_OLD_SEQ;\n 418:\t\t\t\tgoto drop;\n 419:\t\t\t}\n 420:\t\t\ttunnel-\u003ei_seqno = ntohl(tpi-\u003eseq) + 1;\n 421:\t\t}\n 422:\t\n 423:\t\t/* Save offset of outer header relative to skb-\u003ehead,\n 424:\t\t * because we are going to reset the network header to the inner header\n 425:\t\t * and might change skb-\u003ehead.\n 426:\t\t */\n 427:\t\tnh = skb_network_header(skb) - skb-\u003ehead;\n 428:\t\n 429:\t\tskb_set_network_header(skb, (tunnel-\u003edev-\u003etype == ARPHRD_ETHER) ? ETH_HLEN : 0);\n 430:\t\n 431:\t\treason = pskb_inet_may_pull_reason(skb);\n 432:\t\tif (reason) {\n 433:\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n 434:\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 435:\t\t\tgoto drop;\n 436:\t\t}\n 437:\t\tiph = (struct iphdr *)(skb-\u003ehead + nh);\n 438:\t\n 439:\t\terr = IP_ECN_decapsulate(iph, skb);\n 440:\t\tif (unlikely(err)) {\n 441:\t\t\tif (log_ecn_error)\n 442:\t\t\t\tnet_info_ratelimited(\"non-ECT from %pI4 with TOS=%#x\\n\",\n 443:\t\t\t\t\t\t\u0026iph-\u003esaddr, iph-\u003etos);\n 444:\t\t\tif (err \u003e 1) {\n 445:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_frame_errors);\n 446:\t\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n 447:\t\t\t\treason = SKB_DROP_REASON_IP_TUNNEL_ECN;\n 448:\t\t\t\tgoto drop;\n 449:\t\t\t}\n 450:\t\t}\n 451:\t\n 452:\t\tdev_sw_netstats_rx_add(tunnel-\u003edev, skb-\u003elen);\n 453:\t\tskb_scrub_packet(skb, !net_eq(tunnel-\u003enet, dev_net(tunnel-\u003edev)));\n 454:\t\n 455:\t\tif (tunnel-\u003edev-\u003etype == ARPHRD_ETHER) {\n 456:\t\t\tskb-\u003eprotocol = eth_type_trans(skb, tunnel-\u003edev);\n 457:\t\t\tskb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);\n 458:\t\t} else {\n 459:\t\t\tskb-\u003edev = tunnel-\u003edev;\n 460:\t\t}\n 461:\t\n 462:\t\tif (tun_dst)\n 463:\t\t\tskb_dst_set(skb, (struct dst_entry *)tun_dst);\n 464:\t\n 465:\t\tgro_cells_receive(\u0026tunnel-\u003egro_cells, skb);\n 466:\t\treturn 0;\n 467:\t\n 468:\tdrop:\n 469:\t\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n"
} |
| 17/2 | 2026/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51310 output: 39 thoughts: 53 Thoughts: Here's my summary, as if I were thinking it: **Diving into the IPv6 Tunneling Code** Okay, let's get right to it. I'm focusing on `net/ipv6/ip6_tunnel.c` and specifically need to understand how tunnel packets are received. Let's zero in on the `__ip6_tnl_rcv` function. Right, so I'm going to scan the code from lines 820 to 915. I need to get a clear picture of the packet handling logic there. Let's see what interesting aspects of the receive path this reveals. I want to see how the system identifies and processes incoming tunnel packets. |
| 18/2 | 2026/10/01 19:27 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 820,
"LineCount": 95
}Results: {
"Contents": " 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_TUNNEL_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_TUNNEL_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_TUNNEL_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 910:\t\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n 911:\t\tif (tun_dst)\n 912:\t\t\tdst_release((struct dst_entry *)tun_dst);\n 913:\t\tkfree_skb_reason(skb, reason);\n 914:\t\treturn 0;\n"
} |
| 19/2 | 2026/10/01 19:27 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53179 output: 39 thoughts: 88 Thoughts: Here's my summary, as though I'm thinking through this myself: **Diving into IPv6 Tunneling Receive** Okay, so I need to understand the receive path for IPv6-over-IPv4 tunnels. Let's start with `ipxip6_rcv` in `net/ipv6/ip6_tunnel.c`. I'm going to quickly reference the function definition, specifically focusing on the function signature. This will give me the entry point and the expected parameters. Now I'll jump to lines 950-1010 in the same file. This section should cover the core logic of processing a received packet in this context, or at least a significant part of it. I'm expecting this will involve demultiplexing the inner IPv6 header from the outer IPv4 header, some basic sanity checks, and then handing the packet off to the IPv6 stack. I'll need to pay close attention to the error handling and any interesting edge cases they've considered, like fragmented packets or specific options. This should give me a solid base understanding of how the data is being passed around. |
| 20/2 | 2026/10/01 19:28 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_tunnel.c",
"FirstLine": 950,
"LineCount": 60
}Results: {
"Contents": " 950:\tstatic int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n 951:\t\t\t const struct tnl_ptk_info *tpi,\n 952:\t\t\t int (*dscp_ecn_decapsulate)(const struct ip6_tnl *t,\n 953:\t\t\t\t\t\t\t const struct ipv6hdr *ipv6h,\n 954:\t\t\t\t\t\t\t struct sk_buff *skb))\n 955:\t{\n 956:\t\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n 957:\t\tstruct ip6_tnl *t;\n 958:\t\tconst struct ipv6hdr *ipv6h = ipv6_hdr(skb);\n 959:\t\tstruct metadata_dst *tun_dst = NULL;\n 960:\t\tint ret = -1;\n 961:\t\n 962:\t\trcu_read_lock();\n 963:\t\tt = ip6_tnl_lookup(dev_net(skb-\u003edev), skb-\u003edev-\u003eifindex, \u0026ipv6h-\u003esaddr, \u0026ipv6h-\u003edaddr);\n 964:\t\n 965:\t\tif (t) {\n 966:\t\t\tu8 tproto = READ_ONCE(t-\u003eparms.proto);\n 967:\t\n 968:\t\t\tif (tproto != ipproto \u0026\u0026 tproto != 0) {\n 969:\t\t\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n 970:\t\t\t\tgoto drop;\n 971:\t\t\t}\n 972:\t\t\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {\n 973:\t\t\t\treason = SKB_DROP_REASON_XFRM_POLICY;\n 974:\t\t\t\tgoto drop;\n 975:\t\t\t}\n 976:\t\t\tipv6h = ipv6_hdr(skb);\n 977:\t\t\tif (!ip6_tnl_rcv_ctl(t, \u0026ipv6h-\u003edaddr, \u0026ipv6h-\u003esaddr)) {\n 978:\t\t\t\treason = SKB_DROP_REASON_DEV_READY;\n 979:\t\t\t\tgoto drop;\n 980:\t\t\t}\n 981:\t\t\treason = iptunnel_pull_header(skb, 0, tpi-\u003eproto, false);\n 982:\t\t\tif (reason)\n 983:\t\t\t\tgoto drop;\n 984:\t\t\tif (t-\u003eparms.collect_md) {\n 985:\t\t\t\tIP_TUNNEL_DECLARE_FLAGS(flags) = { };\n 986:\t\n 987:\t\t\t\ttun_dst = ipv6_tun_rx_dst(skb, flags, 0, 0);\n 988:\t\t\t\tif (!tun_dst) {\n 989:\t\t\t\t\treason = SKB_DROP_REASON_NOMEM;\n 990:\t\t\t\t\tgoto drop;\n 991:\t\t\t\t}\n 992:\t\t\t}\n 993:\t\t\tret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,\n 994:\t\t\t\t\t log_ecn_error);\n 995:\t\t}\n 996:\t\n 997:\t\trcu_read_unlock();\n 998:\t\n 999:\t\treturn ret;\n1000:\t\n1001:\tdrop:\n1002:\t\trcu_read_unlock();\n1003:\t\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n1004:\t\tkfree_skb_reason(skb, reason);\n1005:\t\treturn 0;\n1006:\t}\n1007:\t\n1008:\tstatic int ip4ip6_rcv(struct sk_buff *skb)\n1009:\t{\n"
} |
| 21/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 54561 output: 22 thoughts: 204 Thoughts: Here's my analysis of the provided code snippet: **Diving Deep into IPv6 Tunneling Logic** Okay, hold on a minute! Let me zoom in on `ipxip6_rcv`. The critical path here hinges on `t`, the tunnel device. If `ip6_tnl_lookup(...)` fails and returns a NULL `t`, a major red flag pops up. The code *doesn't* immediately jump to a "drop" condition! Instead, it elegantly returns `-1`. That `-1` return is significant. Now I need to remember, what does the calling function of `ip4ip6_rcv` do with that `-1`? Right, in the `inet6_protocol` handler, returning a value less than zero signals that the incoming packet wasn't processed successfully. This triggers the appropriate IPv6 error handling, whether it means sending an ICMP error or handing it off to another part of the IPv6 stack. But, back to `ipxip6_rcv` - I also need to think - what if `__ip6_tnl_rcv` returns? `__ip6_tnl_rcv` returns 0 for a *success* or even a *drop*! And that makes sense. So this -1 means the tunnel was missing - the packet *wasn't* dropped. Okay, let's switch gears and go the other way. I need to understand how the packets are getting *transmitted* over these tunnels. Let's look for the calls to `ip6_tnl_xmit`. A quick `grep` will get me that information. |
| 22/2 | 2026/10/01 19:28 | 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=720=static enum skb_drop_reason __gre6_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-788-\nnet/ipv6/ip6_gre.c:789:\treturn ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,\nnet/ipv6/ip6_gre.c-790-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_gre.c=884=static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-900-\nnet/ipv6/ip6_gre.c:901:\tif (!ip6_tnl_xmit_ctl(t, \u0026t-\u003eparms.laddr, \u0026t-\u003eparms.raddr)) {\nnet/ipv6/ip6_gre.c-902-\t\treason = SKB_DROP_REASON_DEV_READY;\n--\nnet/ipv6/ip6_gre.c=942=static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-966-\nnet/ipv6/ip6_gre.c:967:\tif (!ip6_tnl_xmit_ctl(t, \u0026t-\u003eparms.laddr, \u0026t-\u003eparms.raddr)) {\nnet/ipv6/ip6_gre.c-968-\t\treason = SKB_DROP_REASON_DEV_READY;\n--\nnet/ipv6/ip6_gre.c-1114-\t}\nnet/ipv6/ip6_gre.c:1115:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_gre.c-1116-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_tunnel.c=1060=ip6_tnl_addr_conflict(const struct ip6_tnl *t, const struct ipv6hdr *hdr)\n--\nnet/ipv6/ip6_tunnel.c-1064-\nnet/ipv6/ip6_tunnel.c:1065:int ip6_tnl_xmit_ctl(struct ip6_tnl *t,\nnet/ipv6/ip6_tunnel.c-1066-\t\t const struct in6_addr *laddr,\n--\nnet/ipv6/ip6_tunnel.c-1100-}\nnet/ipv6/ip6_tunnel.c:1101:EXPORT_SYMBOL_GPL(ip6_tnl_xmit_ctl);\nnet/ipv6/ip6_tunnel.c-1102-\nnet/ipv6/ip6_tunnel.c-1103-/**\nnet/ipv6/ip6_tunnel.c:1104: * ip6_tnl_xmit - encapsulate packet and send\nnet/ipv6/ip6_tunnel.c-1105- * @skb: the outgoing socket buffer\n--\nnet/ipv6/ip6_tunnel.c=1123=enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1124:ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\nnet/ipv6/ip6_tunnel.c-1125-\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)\n--\nnet/ipv6/ip6_tunnel.c-1205-\nnet/ipv6/ip6_tunnel.c:1206:\tif (!ip6_tnl_xmit_ctl(t, \u0026fl6-\u003esaddr, \u0026fl6-\u003edaddr)) {\nnet/ipv6/ip6_tunnel.c-1207-\t\treason = SKB_DROP_REASON_DEV_READY;\n--\nnet/ipv6/ip6_tunnel.c-1337-}\nnet/ipv6/ip6_tunnel.c:1338:EXPORT_SYMBOL(ip6_tnl_xmit);\nnet/ipv6/ip6_tunnel.c-1339-\nnet/ipv6/ip6_tunnel.c=1340=static inline enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1341:ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\nnet/ipv6/ip6_tunnel.c-1342-\t\tu8 protocol)\n--\nnet/ipv6/ip6_tunnel.c-1448-\nnet/ipv6/ip6_tunnel.c:1449:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_tunnel.c-1450-\t\t\t protocol);\n--\nnet/ipv6/ip6_tunnel.c=1472=ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n--\nnet/ipv6/ip6_tunnel.c-1500-\nnet/ipv6/ip6_tunnel.c:1501:\treason = ipxip6_tnl_xmit(skb, dev, ipproto);\nnet/ipv6/ip6_tunnel.c-1502-\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"
} |
| 23/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 57169 output: 23 thoughts: 63 Thoughts: Here's my summary, as if I were thinking these thoughts: **Examining IPv6 VTI Tunneling in the Kernel** Okay, let's dive into this IPv6 Virtual Tunnel Interface (VTI) code. The question I have right now is, does `net/ipv6/ip6_vti.c` actually *use* `ip6_tnl_xmit`? That's the function I really need to understand in the context of this VTI implementation. I need to know how packets are being transmitted through these tunnels, so I will now carefully review `net/ipv6/ip6_vti.c` to trace the control flow. I'll be looking for direct calls to that function. |
| 24/2 | 2026/10/01 19:28 | 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=720=static enum skb_drop_reason __gre6_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-788-\nnet/ipv6/ip6_gre.c:789:\treturn ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,\nnet/ipv6/ip6_gre.c-790-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_gre.c=942=static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-1114-\t}\nnet/ipv6/ip6_gre.c:1115:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_gre.c-1116-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_tunnel.c=1123=enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1124:ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\nnet/ipv6/ip6_tunnel.c-1125-\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)\n--\nnet/ipv6/ip6_tunnel.c=1340=static inline enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1341:ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\nnet/ipv6/ip6_tunnel.c-1342-\t\tu8 protocol)\n--\nnet/ipv6/ip6_tunnel.c-1448-\nnet/ipv6/ip6_tunnel.c:1449:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_tunnel.c-1450-\t\t\t protocol);\n--\nnet/ipv6/ip6_tunnel.c=1472=ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n--\nnet/ipv6/ip6_tunnel.c-1500-\nnet/ipv6/ip6_tunnel.c:1501:\treason = ipxip6_tnl_xmit(skb, dev, ipproto);\nnet/ipv6/ip6_tunnel.c-1502-\tif (reason)\n"
} |
| 25/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 58254 output: 23 thoughts: 52 Thoughts: Okay, here's my understanding, assuming I'm an expert in this area: **Digging into the IPv6 Tunnel Transmission Path** Right, so `vti6_xmit` isn't using `ip6_tnl_xmit`. That's a good starting point. I need to figure out *how* it's handling the transmission. My next step is definitely to investigate the `__iptunnel_pull_header` and `iptunnel_pull_header` functions. I have a hunch they're involved in managing the tunnel header, but I need to confirm. I need to see exactly where these functions are being called within the relevant code paths. The call sites will reveal the logic flow and hopefully clarify how the IPv6 traffic is being encapsulated and transmitted. Finding the callers will be key to understanding the full picture here. |
| 26/2 | 2026/10/01 19:28 | tool | grepper |
0mArgs:{
"Expression": "(__)?iptunnel_pull_header\\("
}Results: {
"Output": "drivers/net/amt.c=2304=static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb)\n--\ndrivers/net/amt.c-2321-\ndrivers/net/amt.c:2322:\tif (iptunnel_pull_header(skb, hdr_size, htons(ETH_P_IP), false))\ndrivers/net/amt.c-2323-\t\treturn true;\n--\ndrivers/net/amt.c=2375=static bool amt_membership_query_handler(struct amt_dev *amt,\n--\ndrivers/net/amt.c-2399-\thdr_size -= sizeof(*eth);\ndrivers/net/amt.c:2400:\tif (iptunnel_pull_header(skb, hdr_size, htons(ETH_P_TEB), false))\ndrivers/net/amt.c-2401-\t\treturn true;\n--\ndrivers/net/amt.c=2486=static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb)\n--\ndrivers/net/amt.c-2509-\ndrivers/net/amt.c:2510:\tif (iptunnel_pull_header(skb, hdr_size, skb-\u003eprotocol, false))\ndrivers/net/amt.c-2511-\t\treturn true;\n--\ndrivers/net/bareudp.c=62=static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/bareudp.c-135-\ndrivers/net/bareudp.c:136:\tif (iptunnel_pull_header(skb, BAREUDP_BASE_HLEN,\ndrivers/net/bareudp.c-137-\t\t\t\t proto,\n--\ndrivers/net/geneve.c=668=static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/geneve.c-703-\topts_len = geneveh-\u003eopt_len * 4;\ndrivers/net/geneve.c:704:\tif (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len, inner_proto,\ndrivers/net/geneve.c-705-\t\t\t\t !net_eq(geneve-\u003enet, dev_net(geneve-\u003edev)))) {\n--\ndrivers/net/gtp.c=318=static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb,\n--\ndrivers/net/gtp.c-331-\t/* Get rid of the GTP + UDP headers. */\ndrivers/net/gtp.c:332:\tif (iptunnel_pull_header(skb, hdrlen, htons(inner_proto),\ndrivers/net/gtp.c-333-\t\t\t !net_eq(sock_net(pctx-\u003esk), dev_net(pctx-\u003edev)))) {\n--\ndrivers/net/pfcp.c=52=static int pfcp_encap_recv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/pfcp.c-86-\ndrivers/net/pfcp.c:87:\tif (unlikely(iptunnel_pull_header(skb, PFCP_HLEN, skb-\u003eprotocol,\ndrivers/net/pfcp.c-88-\t\t\t\t\t !net_eq(sock_net(sk),\n--\ndrivers/net/vxlan/vxlan_core.c=1675=static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/vxlan/vxlan_core.c-1745-\ndrivers/net/vxlan/vxlan_core.c:1746:\treason = __iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,\ndrivers/net/vxlan/vxlan_core.c-1747-\t\t\t\t\t!net_eq(vxlan-\u003enet,\n--\ninclude/net/ip_tunnels.h=613=enum skb_drop_reason\ninclude/net/ip_tunnels.h:614:__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-615-\t\t __be16 inner_proto, bool raw_proto, bool xnet);\n--\ninclude/net/ip_tunnels.h=617=static inline enum skb_drop_reason\ninclude/net/ip_tunnels.h:618:iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-619-\t\t __be16 inner_proto, bool xnet)\ninclude/net/ip_tunnels.h-620-{\ninclude/net/ip_tunnels.h:621:\treturn __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);\ninclude/net/ip_tunnels.h-622-}\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-315-\nnet/ipv4/ip_gre.c:316:\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\nnet/ipv4/ip_gre.c-317-\t\t\t\t\t\tfalse, false);\n--\nnet/ipv4/ip_gre.c=370=static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-386-\nnet/ipv4/ip_gre.c:387:\t\treason = __iptunnel_pull_header(skb, hdr_len, tpi-\u003eproto,\nnet/ipv4/ip_gre.c-388-\t\t\t\t\t\traw_proto, false);\n--\nnet/ipv4/ip_tunnel_core.c=109=enum skb_drop_reason\nnet/ipv4/ip_tunnel_core.c:110:__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\nnet/ipv4/ip_tunnel_core.c-111-\t\t __be16 inner_proto, bool raw_proto, bool xnet)\n--\nnet/ipv4/ipip.c=215=static int ipip_tunnel_rcv(struct sk_buff *skb, u8 ipproto)\n--\nnet/ipv4/ipip.c-243-\t\t\ttpi = \u0026ipip_tpi;\nnet/ipv4/ipip.c:244:\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\nnet/ipv4/ipip.c-245-\t\t\tgoto drop;\n--\nnet/ipv6/ip6_gre.c=488=static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-516-\nnet/ipv6/ip6_gre.c:517:\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\nnet/ipv6/ip6_gre.c-518-\t\t\t\t\t\tfalse, false);\n--\nnet/ipv6/ip6_gre.c=571=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-579-\nnet/ipv6/ip6_gre.c:580:\treason = iptunnel_pull_header(skb, tpi.hdr_len, tpi.proto, false);\nnet/ipv6/ip6_gre.c-581-\tif (reason)\n--\nnet/ipv6/ip6_tunnel.c=950=static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n--\nnet/ipv6/ip6_tunnel.c-980-\t\t}\nnet/ipv6/ip6_tunnel.c:981:\t\treason = iptunnel_pull_header(skb, 0, tpi-\u003eproto, false);\nnet/ipv6/ip6_tunnel.c-982-\t\tif (reason)\n--\nnet/ipv6/sit.c=738=static int ipip6_rcv(struct sk_buff *skb)\n--\nnet/ipv6/sit.c-765-\nnet/ipv6/sit.c:766:\t\tif (iptunnel_pull_header(skb, 0, htons(ETH_P_IPV6),\nnet/ipv6/sit.c-767-\t\t !net_eq(tunnel-\u003enet, dev_net(tunnel-\u003edev))))\n--\nnet/ipv6/sit.c=814=static int sit_tunnel_rcv(struct sk_buff *skb, u8 ipproto)\n--\nnet/ipv6/sit.c-841-\t\t\ttpi = \u0026ipip_tpi;\nnet/ipv6/sit.c:842:\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\nnet/ipv6/sit.c-843-\t\t\tgoto drop;\n"
} |
| 27/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 61019 output: 27 thoughts: 1140 Thoughts: **Fuzzing Decision for Tunnel Header Pull Changes** Okay, so it looks like `iptunnel_pull_header` and `__iptunnel_pull_header` are now returning `enum skb_drop_reason` instead of a simple boolean success/failure (`SKB_NOT_DROPPED_YET = 0` for success). While existing callers will still treat non-zero as a failure, key functions like `vxlan_rcv` and `gre_rcv` are now capturing *why* a packet might be dropped. This change is interesting. Time to analyze if this warrants fuzzing. My initial thought? This smells like a potential spot for subtle bugs, especially given the guidelines. Let's see... I know that I shouldn't just trust "no functional change" claims or "refactoring" labels. These changes can introduce semantic shifts or uncover latent kernel bugs. The guidelines are pretty clear: any refactoring that rearranges logic or alters state management in core subsystems *needs* fuzzing, especially if reachable code is modified. Now, let's review the *negative* criteria for skipping fuzzing. The patch doesn't fall into any of those categories. None of these apply: - Non-kernel and non-executable changes, not applicable. - Structurally unreachable hardware, not applicable. - Unreachable execution paths, not applicable. This patch *definitely* touches reachable networking core code! It modifies: * `drivers/net/vxlan/vxlan_core.c` * `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` * `net/ipv6/ip6_tunnel.c` And it's not just a superficial change. It changes the way errors are propagated, the specific drop reasons, return types, and how conditions are handled (e.g., changes from checking `PACKET_NEXT` to checking for `SKB_DROP_REASON_TUNNEL_NOT_FOUND`). There are shifts in return values in functions like `__iptunnel_pull_header` and `gre_parse_header`. For instance, in `net/ipv4/gre_demux.c`, `gre_parse_header` now returns an `enum skb_drop_reason` instead of a header length on success or `-EINVAL` on failure, and stores `hdr_len`. Look at `ip_gre.c` how the changes were refactored to change how errors and header lengths are passed! These are substantial changes and refactorings that have the potential for errors. Given all of this, the `WorthFuzzing` flag is definitely `true`. Now, time to determine `EnableConfigs` and `FocusSymbols`. First up, the `EnableConfigs`. I need to check the Kconfig files associated with the modified files. For `drivers/net/vxlan/vxlan_core.c`, I need to check either `drivers/net/vxlan/Kconfig`, `drivers/net/Kconfig`, or `drivers/net/vxlan/Makefile` to see what configurations enable this code path. |
| 28/2 | 2026/10/01 19:28 | tool | grepper |
0mArgs:{
"Expression": "vxlan_core",
"PathPrefix": "drivers/net"
}Results: {
"Output": "drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c=47=struct mlx5_vxlan_port {\n--\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c-51-\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c:52:static int mlx5_vxlan_core_add_port_cmd(struct mlx5_core_dev *mdev, u16 port)\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c-53-{\n--\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c-61-\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c:62:static int mlx5_vxlan_core_del_port_cmd(struct mlx5_core_dev *mdev, u16 port)\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c-63-{\n--\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c=101=int mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port)\n--\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c-110-\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c:111:\tret = mlx5_vxlan_core_add_port_cmd(vxlan-\u003emdev, port);\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c-112-\tif (ret) {\n--\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c=124=int mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port)\n--\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c-138-\tsynchronize_rcu();\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c:139:\tmlx5_vxlan_core_del_port_cmd(vxlan-\u003emdev, port);\ndrivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c-140-\tkfree(vxlanp);\n--\ndrivers/net/vxlan/Makefile=5=obj-$(CONFIG_VXLAN) += vxlan.o\ndrivers/net/vxlan/Makefile-6-\ndrivers/net/vxlan/Makefile:7:vxlan-objs := vxlan_core.o vxlan_multicast.o vxlan_vnifilter.o vxlan_mdb.o\n--\ndrivers/net/vxlan/vxlan_private.h=182=static inline void vxlan_vnifilter_seq_inc(const struct net *net)\n--\ndrivers/net/vxlan/vxlan_private.h-188-\ndrivers/net/vxlan/vxlan_private.h:189:/* vxlan_core.c */\ndrivers/net/vxlan/vxlan_private.h-190-int vxlan_fdb_create(struct vxlan_dev *vxlan,\n"
} |
| 29/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 63767 output: 26 thoughts: 40 Thoughts: Okay, here's my interpretation of that. **Analyzing the VXLAN Makefile Entry** Right, so I'm looking at the `drivers/net/vxlan/Makefile`. I immediately spot the line: `obj-$(CONFIG_VXLAN) += vxlan.o`. My initial thought is, "Ah, okay, VXLAN is conditionally compiled based on a kernel configuration option." Makes perfect sense. This means the `vxlan.o` object file will only be included in the build if `CONFIG_VXLAN` is set. Now, the natural next step is to figure out the value of `CONFIG_VXLAN`, and how the system determines this value. So, I need to check the relevant `Kconfig` file. I need to understand what this option actually *does* and what it depends on. I'll head over there to get the full picture. |
| 30/2 | 2026/10/01 19:28 | tool | grepper |
0mArgs:{
"Expression": "config VXLAN",
"PathPrefix": "drivers/net"
}Results: {
"Output": "drivers/net/Kconfig=216=config IPVTAP\n--\ndrivers/net/Kconfig-229-\ndrivers/net/Kconfig:230:config VXLAN\ndrivers/net/Kconfig-231-\ttristate \"Virtual eXtensible Local Area Network (VXLAN)\"\n"
} |
| 31/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 64103 output: 34 thoughts: 22 Thoughts: Okay, let's dive into this. Here's how I'd approach that particular task, expressed as my internal thought process: **Diving into Network Driver Configuration** Right, so we're looking into something network-related, specifically in the `drivers/net/` directory. The question is, where do the dependencies reside? My initial hunch is that configuration options and their relationships are probably defined within the `Kconfig` files. That's the typical convention, and it's almost always the first place I'd check for dependencies. We are looking at line 230 specifically. Let's see what's defined and check whether or not it helps us understand the context. |
| 32/2 | 2026/10/01 19:28 | tool | read-file |
0mArgs:{
"File": "drivers/net/Kconfig",
"FirstLine": 229,
"LineCount": 25
}Results: {
"Contents": " 229:\t\n 230:\tconfig VXLAN\n 231:\t\ttristate \"Virtual eXtensible Local Area Network (VXLAN)\"\n 232:\t\tdepends on INET\n 233:\t\tselect NET_UDP_TUNNEL\n 234:\t\tselect GRO_CELLS\n 235:\t\thelp\n 236:\t\t This allows one to create vxlan virtual interfaces that provide\n 237:\t\t Layer 2 Networks over Layer 3 Networks. VXLAN is often used\n 238:\t\t to tunnel virtual network infrastructure in virtualized environments.\n 239:\t\t For more information see:\n 240:\t\t http://tools.ietf.org/html/draft-mahalingam-dutt-dcops-vxlan-02\n 241:\t\n 242:\t\t To compile this driver as a module, choose M here: the module\n 243:\t\t will be called vxlan.\n 244:\t\n 245:\tconfig GENEVE\n 246:\t\ttristate \"Generic Network Virtualization Encapsulation\"\n 247:\t\tdepends on INET\n 248:\t\tselect NET_UDP_TUNNEL\n 249:\t\tselect GRO_CELLS\n 250:\t\thelp\n 251:\t\t This allows one to create geneve virtual interfaces that provide\n 252:\t\t Layer 2 Networks over Layer 3 Networks. GENEVE is often used\n 253:\t\t to tunnel virtual network infrastructure in virtualized environments.\n"
} |
| 33/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 64699 output: 46 thoughts: 81 Thoughts: Okay, here's my take on those thoughts, framed as an expert's internal monologue: **VXLAN and Kernel Modules** Right, so we're dealing with VXLAN, and instinctively, I know that it relies on the INET layer. We need to confirm the underlying components. My next move is to dive straight into the heart of the kernel configuration: `net/ipv4/Makefile` and `net/ipv6/Makefile`. I'm mentally parsing those makefiles, and specifically, I'm going to look for the presence and configuration of several key modules. I'm thinking about things like `gre_demux.c`, which handles Generic Routing Encapsulation (GRE) demultiplexing – a common building block. Then `ip_gre.c`, `ip_tunnel.c`, and `ip_tunnel_core.c`, all related to IP-in-GRE tunneling, are critical. And, of course, the IPv6 equivalents: `ip6_gre.c` and `ip6_tunnel.c`. These modules are my prime suspects when it comes to VXLAN's dependencies. I want to see how these GRE implementations are being leveraged within the broader networking context. This will provide some clues on how the kernel supports VXLAN. |
| 34/2 | 2026/10/01 19:28 | tool | grepper |
0mArgs:{
"Expression": "(gre_demux|ip_gre|ip_tunnel|ip6_gre|ip6_tunnel)",
"PathPrefix": "net/"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 3323 lines.\nUse more precise expression if possible.\n\nnet/bridge/br_vlan_options.c-6-#include \u003clinux/slab.h\u003e\nnet/bridge/br_vlan_options.c:7:#include \u003cnet/ip_tunnels.h\u003e\nnet/bridge/br_vlan_options.c-8-\n--\nnet/bridge/br_vlan_tunnel.c=162=void br_handle_ingress_vlan_tunnel(struct sk_buff *skb,\n--\nnet/bridge/br_vlan_tunnel.c-165-{\nnet/bridge/br_vlan_tunnel.c:166:\tstruct ip_tunnel_info *tinfo = skb_tunnel_info(skb);\nnet/bridge/br_vlan_tunnel.c-167-\tstruct net_bridge_vlan *vlan;\n--\nnet/core/dev.c=762=int dev_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)\nnet/core/dev.c-763-{\nnet/core/dev.c:764:\tstruct ip_tunnel_info *info;\nnet/core/dev.c-765-\n--\nnet/core/fib_rules.c-16-#include \u003cnet/fib_rules.h\u003e\nnet/core/fib_rules.c:17:#include \u003cnet/ip_tunnels.h\u003e\nnet/core/fib_rules.c-18-#include \u003clinux/indirect_call_wrapper.h\u003e\n--\nnet/core/fib_rules.c=876=int fib_newrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,\n--\nnet/core/fib_rules.c-979-\tif (rule-\u003etun_id)\nnet/core/fib_rules.c:980:\t\tip_tunnel_need_metadata();\nnet/core/fib_rules.c-981-\n--\nnet/core/fib_rules.c=1011=int fib_delrule(struct net *net, struct sk_buff *skb, struct nlmsghdr *nlh,\n--\nnet/core/fib_rules.c-1065-\tif (rule-\u003etun_id)\nnet/core/fib_rules.c:1066:\t\tip_tunnel_unneed_metadata();\nnet/core/fib_rules.c-1067-\n--\nnet/core/filter.c=4903=BPF_CALL_4(bpf_skb_get_tunnel_key, struct sk_buff *, skb, struct bpf_tunnel_key *, to,\n--\nnet/core/filter.c-4905-{\nnet/core/filter.c:4906:\tconst struct ip_tunnel_info *info = skb_tunnel_info(skb);\nnet/core/filter.c-4907-\tu8 compat[sizeof(struct bpf_tunnel_key)];\n--\nnet/core/filter.c-4915-\t}\nnet/core/filter.c:4916:\tif (ip_tunnel_info_af(info) != bpf_tunnel_key_af(flags)) {\nnet/core/filter.c-4917-\t\terr = -EPROTO;\n--\nnet/core/filter.c-4930-\t\t\t */\nnet/core/filter.c:4931:\t\t\tif (ip_tunnel_info_af(info) != AF_INET)\nnet/core/filter.c-4932-\t\t\t\tgoto err_clear;\n--\nnet/core/filter.c-4944-\tif (flags \u0026 BPF_F_TUNINFO_FLAGS)\nnet/core/filter.c:4945:\t\tto-\u003etunnel_flags = ip_tunnel_flags_to_be16(info-\u003ekey.tun_flags);\nnet/core/filter.c-4946-\telse\n--\nnet/core/filter.c=4982=BPF_CALL_3(bpf_skb_get_tunnel_opt, struct sk_buff *, skb, u8 *, to, u32, size)\nnet/core/filter.c-4983-{\nnet/core/filter.c:4984:\tconst struct ip_tunnel_info *info = skb_tunnel_info(skb);\nnet/core/filter.c-4985-\tint err;\n--\nnet/core/filter.c-4987-\tif (unlikely(!info ||\nnet/core/filter.c:4988:\t\t !ip_tunnel_is_options_present(info-\u003ekey.tun_flags))) {\nnet/core/filter.c-4989-\t\terr = -ENOENT;\n--\nnet/core/filter.c-4996-\nnet/core/filter.c:4997:\tip_tunnel_info_opts_get(to, info);\nnet/core/filter.c-4998-\tif (size \u003e info-\u003eoptions_len)\n--\nnet/core/filter.c=5018=BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb,\n--\nnet/core/filter.c-5022-\tu8 compat[sizeof(struct bpf_tunnel_key)];\nnet/core/filter.c:5023:\tstruct ip_tunnel_info *info;\nnet/core/filter.c-5024-\n--\nnet/core/filter.c=5099=BPF_CALL_3(bpf_skb_set_tunnel_opt, struct sk_buff *, skb,\n--\nnet/core/filter.c-5101-{\nnet/core/filter.c:5102:\tstruct ip_tunnel_info *info = skb_tunnel_info(skb);\nnet/core/filter.c-5103-\tconst struct metadata_dst *md = this_cpu_ptr(md_dst);\n--\nnet/core/filter.c-5110-\nnet/core/filter.c:5111:\tip_tunnel_set_options_present(present);\nnet/core/filter.c:5112:\tip_tunnel_info_opts_set(info, from, size, present);\nnet/core/filter.c-5113-\n--\nnet/core/flow_dissector.c=366=skb_flow_dissect_tunnel_info(const struct sk_buff *skb,\n--\nnet/core/flow_dissector.c-369-{\nnet/core/flow_dissector.c:370:\tstruct ip_tunnel_info *info;\nnet/core/flow_dissector.c:371:\tstruct ip_tunnel_key *key;\nnet/core/flow_dissector.c-372-\tu32 ctrl_flags = 0;\n--\nnet/core/flow_dissector.c-405-\nnet/core/flow_dissector.c:406:\tswitch (ip_tunnel_info_af(info)) {\nnet/core/flow_dissector.c-407-\tcase AF_INET:\n--\nnet/core/flow_dissector.c-484-\t\tenc_opt-\u003elen = info-\u003eoptions_len;\nnet/core/flow_dissector.c:485:\t\tip_tunnel_info_opts_get(enc_opt-\u003edata, info);\nnet/core/flow_dissector.c-486-\nnet/core/flow_dissector.c:487:\t\tip_tunnel_set_options_present(flags);\nnet/core/flow_dissector.c:488:\t\tip_tunnel_flags_and(flags, info-\u003ekey.tun_flags, flags);\nnet/core/flow_dissector.c-489-\n--\nnet/core/net_test.c=147=static void gso_test_func(struct kunit *test)\n--\nnet/core/net_test.c-265-\nnet/core/net_test.c:266:#include \u003cnet/ip_tunnels.h\u003e\nnet/core/net_test.c-267-\nnet/core/net_test.c:268:struct ip_tunnel_flags_test {\nnet/core/net_test.c-269-\tconst char\t*name;\n--\nnet/core/net_test.c-290-/* These are __be16-compatible and can be compared as is */\nnet/core/net_test.c:291:static const u16 ip_tunnel_flags_1[] = {\nnet/core/net_test.c-292-\tIP_TUNNEL_KEY_BIT,\n--\nnet/core/net_test.c-308-\nnet/core/net_test.c:309:static const u16 ip_tunnel_flags_2_src[] = {\nnet/core/net_test.c-310-\tIP_TUNNEL_CONFLICT_BIT,\n--\nnet/core/net_test.c-312-\nnet/core/net_test.c:313:static const u16 ip_tunnel_flags_2_exp[] = {\nnet/core/net_test.c-314-\tIP_TUNNEL_CONFLICT_BIT,\n--\nnet/core/net_test.c-318-/* Bits 17 and higher are not compatible with __be16 flags */\nnet/core/net_test.c:319:static const u16 ip_tunnel_flags_3_src[] = {\nnet/core/net_test.c-320-\tIP_TUNNEL_VXLAN_OPT_BIT,\n--\nnet/core/net_test.c-325-\nnet/core/net_test.c:326:static const u16 ip_tunnel_flags_3_exp[] = {\nnet/core/net_test.c-327-\tIP_TUNNEL_VXLAN_OPT_BIT,\n--\nnet/core/net_test.c-329-\nnet/core/net_test.c:330:static const struct ip_tunnel_flags_test ip_tunnel_flags_test[] = {\nnet/core/net_test.c:331:\tIP_TUNNEL_FLAGS_TEST(\"compat\", ip_tunnel_flags_1, true,\nnet/core/net_test.c-332-\t\t\t cpu_to_be16(BIT(IP_TUNNEL_KEY_BIT) |\n--\nnet/core/net_test.c-334-\t\t\t\t\t BIT(IP_TUNNEL_ERSPAN_OPT_BIT)),\nnet/core/net_test.c:335:\t\t\t ip_tunnel_flags_1),\nnet/core/net_test.c:336:\tIP_TUNNEL_FLAGS_TEST(\"conflict\", ip_tunnel_flags_2_src, true,\nnet/core/net_test.c:337:\t\t\t VTI_ISVTI, ip_tunnel_flags_2_exp),\nnet/core/net_test.c:338:\tIP_TUNNEL_FLAGS_TEST(\"new\", ip_tunnel_flags_3_src, false,\nnet/core/net_test.c-339-\t\t\t cpu_to_be16(BIT(IP_TUNNEL_VXLAN_OPT_BIT)),\nnet/core/net_test.c:340:\t\t\t ip_tunnel_flags_3_exp),\nnet/core/net_test.c-341-};\n--\nnet/core/net_test.c=343=static void\nnet/core/net_test.c:344:ip_tunnel_flags_test_case_to_desc(const struct ip_tunnel_flags_test *t,\nnet/core/net_test.c-345-\t\t\t\t char *desc)\n--\nnet/core/net_test.c-348-}\nnet/core/net_test.c:349:KUNIT_ARRAY_PARAM(ip_tunnel_flags_test, ip_tunnel_flags_test,\nnet/core/net_test.c:350:\t\t ip_tunnel_flags_test_case_to_desc);\nnet/core/net_test.c-351-\nnet/core/net_test.c:352:static void ip_tunnel_flags_test_run(struct kunit *test)\nnet/core/net_test.c-353-{\nnet/core/net_test.c:354:\tconst struct ip_tunnel_flags_test *t = test-\u003eparam_value;\nnet/core/net_test.c-355-\tIP_TUNNEL_DECLARE_FLAGS(src) = { };\n--\nnet/core/net_test.c-364-\tKUNIT_ASSERT_EQ(test, t-\u003eexp_comp,\nnet/core/net_test.c:365:\t\t\tip_tunnel_flags_is_be16_compat(src));\nnet/core/net_test.c-366-\tKUNIT_ASSERT_EQ(test, (__force u16)t-\u003eexp_val,\nnet/core/net_test.c:367:\t\t\t(__force u16)ip_tunnel_flags_to_be16(src));\nnet/core/net_test.c-368-\nnet/core/net_test.c:369:\tip_tunnel_flags_from_be16(out, t-\u003eexp_val);\nnet/core/net_test.c-370-\tKUNIT_ASSERT_TRUE(test, __ipt_flag_op(bitmap_equal, exp, out));\n--\nnet/core/net_test.c=373=static struct kunit_case net_test_cases[] = {\nnet/core/net_test.c-374-\tKUNIT_CASE_PARAM(gso_test_func, gso_test_gen_params),\nnet/core/net_test.c:375:\tKUNIT_CASE_PARAM(ip_tunnel_flags_test_run,\nnet/core/net_test.c:376:\t\t\t ip_tunnel_flags_test_gen_params),\nnet/core/net_test.c-377-\t{ },\n--\nnet/ipv4/Kconfig=180=config NET_IPGRE_DEMUX\n--\nnet/ipv4/Kconfig-183-\t This is helper module to demultiplex GRE packets on GRE version field criteria.\nnet/ipv4/Kconfig:184:\t Required by ip_gre and pptp modules.\nnet/ipv4/Kconfig-185-\n--\nnet/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\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=25=obj-$(CONFIG_NET_IPIP) += ipip.o\nnet/ipv4/Makefile:26:gre-y := gre_demux.o\nnet/ipv4/Makefile-27-fou-y := fou_core.o fou_nl.o fou_bpf.o\n--\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/af_inet.c-112-#include \u003cnet/inet_common.h\u003e\nnet/ipv4/af_inet.c:113:#include \u003cnet/ip_tunnels.h\u003e\nnet/ipv4/af_inet.c-114-#include \u003cnet/xfrm.h\u003e\n--\nnet/ipv4/af_inet.c=1879=static int __init inet_init(void)\n--\nnet/ipv4/af_inet.c-1999-\nnet/ipv4/af_inet.c:2000:\tip_tunnel_core_init();\nnet/ipv4/af_inet.c-2001-\n--\nnet/ipv4/arp.c-112-#include \u003cnet/dst_metadata.h\u003e\n\n"
} |
| 35/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 69319 output: 35 thoughts: 15 Thoughts: Okay, let's dive into this. Here's my thought process on this: **Checking the `net/ipv6/Makefile`** Right, so we're looking at something network-related, probably related to IPv6. Given the context, my initial instinct is to make sure we haven't overlooked any changes or potential implications within the `net/ipv6/Makefile`. It's a key build configuration file for anything related to IPv6 in the kernel, so it's the logical place to start digging deeper. We can't afford to miss something crucial in such a core component. Time to examine the contents and see if anything jumps out. It's a fundamental part of the build system for the IPv6 stack, so it's a critical component. Let's see what we can find there. |
| 36/2 | 2026/10/01 19:28 | tool | grepper |
0mArgs:{
"Expression": "(ip6_gre|ip6_tunnel)",
"PathPrefix": "net/ipv6"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 392 lines.\nUse more precise expression if possible.\n\nnet/ipv6/Kconfig=210=config IPV6_GRE\n--\nnet/ipv6/Kconfig-225-\nnet/ipv6/Kconfig:226:\t Saying M here will produce a module called ip6_gre. If unsure, say N.\nnet/ipv6/Kconfig-227-\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\nnet/ipv6/Makefile-44-obj-$(CONFIG_IPV6_FOU) += fou6.o\n--\nnet/ipv6/af_inet6.c-54-#ifdef CONFIG_IPV6_TUNNEL\nnet/ipv6/af_inet6.c:55:#include \u003cnet/ip6_tunnel.h\u003e\nnet/ipv6/af_inet6.c-56-#endif\n--\nnet/ipv6/fou6.c-12-#include \u003cnet/ip.h\u003e\nnet/ipv6/fou6.c:13:#include \u003cnet/ip6_tunnel.h\u003e\nnet/ipv6/fou6.c-14-#include \u003cnet/ip6_checksum.h\u003e\n--\nnet/ipv6/ip6_gre.c-30-#include \u003clinux/if_tunnel.h\u003e\nnet/ipv6/ip6_gre.c:31:#include \u003clinux/ip6_tunnel.h\u003e\nnet/ipv6/ip6_gre.c-32-\n--\nnet/ipv6/ip6_gre.c-51-#include \u003cnet/ip6_route.h\u003e\nnet/ipv6/ip6_gre.c:52:#include \u003cnet/ip6_tunnel.h\u003e\nnet/ipv6/ip6_gre.c-53-#include \u003cnet/gre.h\u003e\n--\nnet/ipv6/ip6_tunnel.c-48-#include \u003cnet/addrconf.h\u003e\nnet/ipv6/ip6_tunnel.c:49:#include \u003cnet/ip6_tunnel.h\u003e\nnet/ipv6/ip6_tunnel.c-50-#include \u003cnet/xfrm.h\u003e\n--\nnet/ipv6/ip6_tunnel.c=2427=static struct pernet_operations ip6_tnl_net_ops = {\n--\nnet/ipv6/ip6_tunnel.c-2434-/**\nnet/ipv6/ip6_tunnel.c:2435: * ip6_tunnel_init - register protocol and reserve needed resources\nnet/ipv6/ip6_tunnel.c-2436- *\n--\nnet/ipv6/ip6_tunnel.c-2439-\nnet/ipv6/ip6_tunnel.c:2440:static int __init ip6_tunnel_init(void)\nnet/ipv6/ip6_tunnel.c-2441-{\n--\nnet/ipv6/ip6_tunnel.c-2490-/**\nnet/ipv6/ip6_tunnel.c:2491: * ip6_tunnel_cleanup - free resources and unregister protocol\nnet/ipv6/ip6_tunnel.c-2492- **/\nnet/ipv6/ip6_tunnel.c-2493-\nnet/ipv6/ip6_tunnel.c:2494:static void __exit ip6_tunnel_cleanup(void)\nnet/ipv6/ip6_tunnel.c-2495-{\n--\nnet/ipv6/ip6_tunnel.c-2508-\nnet/ipv6/ip6_tunnel.c:2509:module_init(ip6_tunnel_init);\nnet/ipv6/ip6_tunnel.c:2510:module_exit(ip6_tunnel_cleanup);\n--\nnet/ipv6/ip6_udp_tunnel.c-13-#include \u003cnet/netns/generic.h\u003e\nnet/ipv6/ip6_udp_tunnel.c:14:#include \u003cnet/ip6_tunnel.h\u003e\nnet/ipv6/ip6_udp_tunnel.c-15-#include \u003cnet/ip6_checksum.h\u003e\n--\nnet/ipv6/ip6_vti.c-10- *\tBased on:\nnet/ipv6/ip6_vti.c:11: *\tnet/ipv6/ip6_tunnel.c\nnet/ipv6/ip6_vti.c-12- */\n--\nnet/ipv6/ip6_vti.c-43-#include \u003cnet/addrconf.h\u003e\nnet/ipv6/ip6_vti.c:44:#include \u003cnet/ip6_tunnel.h\u003e\nnet/ipv6/ip6_vti.c-45-#include \u003cnet/xfrm.h\u003e\n--\nnet/ipv6/sit.c=69=MODULE_PARM_DESC(log_ecn_error, \"Log packets received with corrupted ECN\");\nnet/ipv6/sit.c-70-\nnet/ipv6/sit.c:71:static int ipip6_tunnel_init(struct net_device *dev);\nnet/ipv6/sit.c:72:static void ipip6_tunnel_setup(struct net_device *dev);\nnet/ipv6/sit.c-73-static void ipip6_dev_free(struct net_device *dev);\n--\nnet/ipv6/sit.c=89=static inline struct sit_net *dev_to_sit_net(struct net_device *dev)\n--\nnet/ipv6/sit.c-98- */\nnet/ipv6/sit.c:99:static struct ip_tunnel *ipip6_tunnel_lookup(struct net *net,\nnet/ipv6/sit.c-100-\t\t\t\t\t struct net_device *dev,\n--\nnet/ipv6/sit.c=166=static inline struct ip_tunnel __rcu **ipip6_bucket(struct sit_net *sitn,\n--\nnet/ipv6/sit.c-171-\nnet/ipv6/sit.c:172:static void ipip6_tunnel_unlink(struct sit_net *sitn, struct ip_tunnel *t)\nnet/ipv6/sit.c-173-{\n--\nnet/ipv6/sit.c-186-\nnet/ipv6/sit.c:187:static void ipip6_tunnel_link(struct sit_net *sitn, struct ip_tunnel *t)\nnet/ipv6/sit.c-188-{\n--\nnet/ipv6/sit.c-194-\nnet/ipv6/sit.c:195:static int ipip6_tunnel_clone_6rd(struct net_device *dev, struct sit_net *sitn)\nnet/ipv6/sit.c-196-{\n--\nnet/ipv6/sit.c-237-\nnet/ipv6/sit.c:238:static int ipip6_tunnel_create(struct net_device *dev)\nnet/ipv6/sit.c-239-{\n--\nnet/ipv6/sit.c-244-\nnet/ipv6/sit.c:245:\terr = ipip6_tunnel_clone_6rd(dev, sitn);\nnet/ipv6/sit.c-246-\tif (err \u003c 0)\n--\nnet/ipv6/sit.c-262-\nnet/ipv6/sit.c:263:\tipip6_tunnel_link(sitn, t);\nnet/ipv6/sit.c-264-\treturn 0;\n--\nnet/ipv6/sit.c-269-\nnet/ipv6/sit.c:270:static struct ip_tunnel *ipip6_tunnel_locate(struct net *net,\nnet/ipv6/sit.c-271-\t\t\t\t\t struct ip_tunnel_parm_kern *parms,\n--\nnet/ipv6/sit.c-308-\tdev = alloc_netdev(sizeof(*t), name, NET_NAME_UNKNOWN,\nnet/ipv6/sit.c:309:\t\t\t ipip6_tunnel_setup);\nnet/ipv6/sit.c-310-\tif (!dev)\n--\nnet/ipv6/sit.c-322-\trcu_assign_pointer(nt-\u003esit_parms, nt_parms);\nnet/ipv6/sit.c:323:\tif (ipip6_tunnel_create(dev) \u003c 0)\nnet/ipv6/sit.c-324-\t\tgoto failed_free;\n--\nnet/ipv6/sit.c=343=static struct ip_tunnel_prl_entry *\nnet/ipv6/sit.c:344:__ipip6_tunnel_locate_prl(struct ip_tunnel *t, __be32 addr)\nnet/ipv6/sit.c-345-{\n--\nnet/ipv6/sit.c-354-\nnet/ipv6/sit.c:355:static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __user *a)\nnet/ipv6/sit.c-356-{\n--\nnet/ipv6/sit.c=420=static int\nnet/ipv6/sit.c:421:ipip6_tunnel_add_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a, int chg)\nnet/ipv6/sit.c-422-{\n--\nnet/ipv6/sit.c=474=static int\nnet/ipv6/sit.c:475:ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)\nnet/ipv6/sit.c-476-{\n--\nnet/ipv6/sit.c-506-\nnet/ipv6/sit.c:507:static int ipip6_tunnel_prl_ctl(struct net_device *dev,\nnet/ipv6/sit.c-508-\t\t\t\tstruct ip_tunnel_prl __user *data, int cmd)\n--\nnet/ipv6/sit.c-523-\tcase SIOCDELPRL:\nnet/ipv6/sit.c:524:\t\terr = ipip6_tunnel_del_prl(t, \u0026prl);\nnet/ipv6/sit.c-525-\t\tbreak;\n--\nnet/ipv6/sit.c-527-\tcase SIOCCHGPRL:\nnet/ipv6/sit.c:528:\t\terr = ipip6_tunnel_add_prl(t, \u0026prl, cmd == SIOCCHGPRL);\nnet/ipv6/sit.c-529-\t\tbreak;\n--\nnet/ipv6/sit.c=537=isatap_chksrc(struct sk_buff *skb, const struct iphdr *iph, struct ip_tunnel *t)\n--\nnet/ipv6/sit.c-542-\trcu_read_lock();\nnet/ipv6/sit.c:543:\tp = __ipip6_tunnel_locate_prl(t, iph-\u003esaddr);\nnet/ipv6/sit.c-544-\tif (p) {\n--\nnet/ipv6/sit.c-562-\nnet/ipv6/sit.c:563:static void ipip6_tunnel_uninit(struct net_device *dev)\nnet/ipv6/sit.c-564-{\n--\nnet/ipv6/sit.c-570-\t} else {\nnet/ipv6/sit.c:571:\t\tipip6_tunnel_unlink(sitn, tunnel);\nnet/ipv6/sit.c:572:\t\tipip6_tunnel_del_prl(tunnel, NULL);\nnet/ipv6/sit.c-573-\t}\n--\nnet/ipv6/sit.c=578=static int ipip6_err(struct sk_buff *skb, u32 info)\n--\nnet/ipv6/sit.c-618-\trcu_read_lock();\nnet/ipv6/sit.c:619:\tt = ipip6_tunnel_lookup(dev_net(skb-\u003edev), skb-\u003edev,\nnet/ipv6/sit.c-620-\t\t\t\tiph-\u003edaddr, iph-\u003esaddr, sifindex);\n--\nnet/ipv6/sit.c=738=static int ipip6_rcv(struct sk_buff *skb)\n--\nnet/ipv6/sit.c-745-\tsifindex = netif_is_l3_master(skb-\u003edev) ? IPCB(skb)-\u003eiif : 0;\nnet/ipv6/sit.c:746:\ttunnel = ipip6_tunnel_lookup(dev_net(skb-\u003edev), skb-\u003edev,\nnet/ipv6/sit.c-747-\t\t\t\t iph-\u003esaddr, iph-\u003edaddr, sifindex);\n--\nnet/ipv6/sit.c=814=static int sit_tunnel_rcv(struct sk_buff *skb, u8 ipproto)\n--\nnet/ipv6/sit.c-822-\tiph = ip_hdr(skb);\nnet/ipv6/sit.c:823:\ttunnel = ipip6_tunnel_lookup(dev_net(skb-\u003edev), skb-\u003edev,\nnet/ipv6/sit.c-824-\t\t\t\t iph-\u003esaddr, iph-\u003edaddr, sifindex);\n--\nnet/ipv6/sit.c=910=static inline __be32 try_6rd(struct ip_tunnel *tunnel,\n--\nnet/ipv6/sit.c-917-\nnet/ipv6/sit.c:918:static bool ipip6_tunnel_dst_find(struct sk_buff *skb, __be32 *dst,\nnet/ipv6/sit.c-919-\t\t\t\t bool is_isatap)\n--\nnet/ipv6/sit.c-965-\nnet/ipv6/sit.c:966:static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,\nnet/ipv6/sit.c-967-\t\t\t\t struct net_device *dev)\n--\nnet/ipv6/sit.c-995-\tif ((dev-\u003epriv_flags \u0026 IFF_ISATAP) \u0026\u0026\nnet/ipv6/sit.c:996:\t !ipip6_tunnel_dst_find(skb, \u0026dst, true))\nnet/ipv6/sit.c-997-\t\tgoto tx_error;\n--\nnet/ipv6/sit.c-1001-\nnet/ipv6/sit.c:1002:\tif (!dst \u0026\u0026 !ipip6_tunnel_dst_find(skb, \u0026dst, false))\nnet/ipv6/sit.c-1003-\t\tgoto tx_error;\n--\nnet/ipv6/sit.c=1141=static netdev_tx_t sit_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/sit.c-1152-\tcase htons(ETH_P_IPV6):\nnet/ipv6/sit.c:1153:\t\tipip6_tunnel_xmit(skb, dev);\nnet/ipv6/sit.c-1154-\t\tbreak;\n--\nnet/ipv6/sit.c-1173-\n\n"
} |
| 37/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 73458 output: 54 thoughts: 209 Thoughts: Okay, let's break this down. **Investigating Network Tunnel Configuration in the Linux Kernel** Right, so I need to get a handle on how these network tunnels are configured. First, I'm going to dig into the `net/ipv4/Makefile` and `net/ipv6/Makefile` files. Looks like `ip_tunnel_core.o` is always built, but the actual tunnel implementations are conditional. Specifically, I'm noting the dependency of `ip_tunnel.o` on `CONFIG_NET_IP_TUNNEL`, `gre.o` on `CONFIG_NET_IPGRE_DEMUX`, and `ip_gre.o` on `CONFIG_NET_IPGRE` in the IPv4 stack. Over in IPv6, `ip6_tunnel.o` hinges on `CONFIG_IPV6_TUNNEL` and `ip6_gre.o` relies on `CONFIG_IPV6_GRE`. Now, the important part. I need to understand what these `CONFIG_` options actually *mean*. What's the context? What exactly are they enabling? This means I have to track down the definitions for `NET_IP_TUNNEL`, `NET_IPGRE_DEMUX`, `NET_IPGRE`, `IPV6_TUNNEL`, and `IPV6_GRE`, and also `VXLAN`, too. Time to delve into the Kconfig files and see what the build system is setting for each one. That's where the real detail will be, I suspect. Understanding the dependencies and what these config options control is key. |
| 38/2 | 2026/10/01 19:28 | tool | grepper |
0mArgs:{
"Expression": "config (NET_IP_TUNNEL|NET_IPGRE_DEMUX|NET_IPGRE|IPV6_TUNNEL|IPV6_GRE)",
"PathPrefix": "net"
}Results: {
"Output": "net/ipv4/Kconfig=162=config NET_IPIP\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\"\n--\nnet/ipv4/Kconfig-206-\nnet/ipv4/Kconfig:207:config NET_IPGRE_BROADCAST\nnet/ipv4/Kconfig-208-\tbool \"IP: broadcast GRE over IP\"\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-209-\nnet/ipv6/Kconfig:210:config IPV6_GRE\nnet/ipv6/Kconfig-211-\ttristate \"IPv6: GRE tunnel\"\n"
} |
| 39/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 74473 output: 35 thoughts: 32 Thoughts: Okay, let's dive into this. I need to get a handle on the configuration options related to IPv4. The best place to start, as always with the kernel, is the `Kconfig` files. Specifically, I'm thinking the `net/ipv4/Kconfig` file should hold the key, and I'll focus my attention roughly between lines 175 and 215. That area is likely to define the relevant options. Time to open that file and get started. I need to understand what's controllable there and how it impacts IPv4's behavior. |
| 40/2 | 2026/10/01 19:28 | tool | read-file |
0mArgs:{
"File": "net/ipv4/Kconfig",
"FirstLine": 175,
"LineCount": 40
}Results: {
"Contents": " 175:\t\n 176:\t\t Saying Y to this option will produce two modules ( = code which can\n 177:\t\t be inserted in and removed from the running kernel whenever you\n 178:\t\t want). Most people won't need this and can say N.\n 179:\t\n 180:\tconfig NET_IPGRE_DEMUX\n 181:\t\ttristate \"IP: GRE demultiplexer\"\n 182:\t\thelp\n 183:\t\t This is helper module to demultiplex GRE packets on GRE version field criteria.\n 184:\t\t Required by ip_gre and pptp modules.\n 185:\t\n 186:\tconfig NET_IP_TUNNEL\n 187:\t\ttristate\n 188:\t\tselect DST_CACHE\n 189:\t\tselect GRO_CELLS\n 190:\t\tdefault n\n 191:\t\n 192:\tconfig NET_IPGRE\n 193:\t\ttristate \"IP: GRE tunnels over IP\"\n 194:\t\tdepends on NET_IPGRE_DEMUX\n 195:\t\tselect NET_IP_TUNNEL\n 196:\t\thelp\n 197:\t\t Tunneling means encapsulating data of one protocol type within\n 198:\t\t another protocol and sending it over a channel that understands the\n 199:\t\t encapsulating protocol. This particular tunneling driver implements\n 200:\t\t GRE (Generic Routing Encapsulation) and at this time allows\n 201:\t\t encapsulating of IPv4 or IPv6 over existing IPv4 infrastructure.\n 202:\t\t This driver is useful if the other endpoint is a Cisco router: Cisco\n 203:\t\t likes GRE much better than the other Linux tunneling driver (\"IP\n 204:\t\t tunneling\" above). In addition, GRE allows multicast redistribution\n 205:\t\t through the tunnel.\n 206:\t\n 207:\tconfig NET_IPGRE_BROADCAST\n 208:\t\tbool \"IP: broadcast GRE over IP\"\n 209:\t\tdepends on IP_MULTICAST \u0026\u0026 NET_IPGRE\n 210:\t\thelp\n 211:\t\t One application of GRE/IP is to construct a broadcast WAN (Wide Area\n 212:\t\t Network), which looks like a normal Ethernet LAN (Local Area\n 213:\t\t Network), but can be distributed all over the Internet. If you want\n 214:\t\t to do that, say Y here and to \"IP multicast routing\" below.\n"
} |
| 41/2 | 2026/10/01 19:28 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 75308 output: 35 thoughts: 25 Thoughts: Okay, here's the summary, rendered as if I'm the one thinking it: **Examining IPv6 Configuration Options** Alright, I need to get a better handle on the IPv6 configuration options. Time to delve into the `net/ipv6/Kconfig` file. I'll focus my attention on lines 195 through 230, as I suspect that section might hold some key definitions or dependencies that are relevant to what I'm currently working on. Gotta see what's being enabled or disabled there. Let's dig in and see what configuration parameters are defined in that region and how they might affect the kernel's IPv6 behavior. |
| 42/2 | 2026/10/01 19:29 | tool | read-file |
0mArgs:{
"File": "net/ipv6/Kconfig",
"FirstLine": 195,
"LineCount": 40
}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 225:\t\n 226:\t\t Saying M here will produce a module called ip6_gre. If unsure, say N.\n 227:\t\n 228:\tconfig IPV6_FOU\n 229:\t\ttristate\n 230:\t\tdefault NET_FOU \u0026\u0026 IPV6\n 231:\t\n 232:\tconfig IPV6_FOU_TUNNEL\n 233:\t\ttristate\n 234:\t\tdefault NET_FOU_IP_TUNNELS \u0026\u0026 IPV6_FOU\n"
} |
| 43/2 | 2026/10/01 19:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 76119 output: 26 thoughts: 1420 Thoughts: **Focus Symbol Selection: A Deep Dive** Alright, let's break this down. First, I need to get a handle on the relevant configuration options. I see we're dealing with `VXLAN`, which depends on `INET`, naturally. Then there's `NET_IPGRE`, depending on `NET_IPGRE_DEMUX`, which in turn selects `NET_IP_TUNNEL`. `IPV6_GRE` is also in the mix, dependent on `NET_IPGRE_DEMUX` and `IPV6`, selecting both `IPV6_TUNNEL` and `NET_IP_TUNNEL`. Finally, we have `IPV6_TUNNEL` in `net/ipv6` depending on `IPV6` and `NET_IP_TUNNEL`. Got it. Now to identify our focus symbols. I've examined the modified functions across the relevant files: `vxlan_core.c`, `gre_demux.c`, `ip_gre.c`, `ip_tunnel.c`, `ip_tunnel_core.c`, `ip6_gre.c`, and `ip6_tunnel.c`. The initial list is fairly extensive: `vxlan_rcv`, `encap_bypass_if_local`, `vxlan_xmit_one`, `gre_parse_header`, `gre_rcv`, `gre_err`, `erspan_rcv`, `__ipgre_rcv`, `ipgre_rcv`, `gre_rcv`, `gre_fb_xmit`, `erspan_fb_xmit`, `ipgre_xmit`, `erspan_xmit`, `gre_tap_xmit`, `ip_tunnel_rcv`, `ip_md_tunnel_xmit`, `ip_tunnel_xmit`, `__iptunnel_pull_header`, `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`, `__ip6_tnl_rcv`, `ipxip6_rcv`, `ip6_tnl_xmit`, `ipxip6_tnl_xmit`, and `ip6_tnl_start_xmit`. Now, the crucial step: applying the FocusSymbol rules. We need to avoid ubiquitous lifecycle functions and target specific feature logic or API entrypoints. So, let's filter the list: `vxlan_rcv`, `vxlan_xmit_one`, `gre_parse_header`, `__iptunnel_pull_header`, `ip_tunnel_rcv`, `ip_tunnel_xmit`, `ip_md_tunnel_xmit`, `ipgre_xmit`, `erspan_xmit`, `gre_tap_xmit`, `ip6_tnl_rcv`, `ip6_tnl_xmit`, `ip6gre_tunnel_xmit`, and `ip6erspan_tunnel_xmit`. Good, seems like a reasonable start. But wait, the compiler might inline some of these. We must make sure they are distinct symbols. So, let's check what's in `vmlinux`. Okay, let's verify visibility: - `vxlan_rcv` - is this even in the kernel module, and not just local? - `vxlan_xmit_one` - non-static, okay. - `gre_parse_header` - `EXPORT_SYMBOL`, perfect. - `__iptunnel_pull_header` - `EXPORT_SYMBOL_GPL`, good. - `ip_tunnel_rcv` - `EXPORT_SYMBOL_GPL`, excellent. - `ip_tunnel_xmit` - `EXPORT_SYMBOL_GPL`. - `ip_md_tunnel_xmit` - `EXPORT_SYMBOL_GPL`. - `ip6_tnl_xmit` - `EXPORT_SYMBOL`. - `ip6_tnl_rcv` - `EXPORT_SYMBOL`. - `ipgre_xmit` - Static but appears to be non-static ndo_start_xmit, worth noting. - `ip6gre_tunnel_xmit` - Similar to ipgre_xmit, also static but used in ndo_start_xmit. Alright, that list should be solid. Now, to make sure these |
| 44/2 | 2026/10/01 19:29 | tool | grepper |
0mArgs:{
"Expression": "EXPORT_SYMBOL.*ip6_tnl_rcv"
}Results: {
"Output": "net/ipv6/ip6_tunnel.c=780=int ip6_tnl_rcv_ctl(struct ip6_tnl *t,\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-\n--\nnet/ipv6/ip6_tunnel.c=917=int ip6_tnl_rcv(struct ip6_tnl *t, struct sk_buff *skb,\n--\nnet/ipv6/ip6_tunnel.c-932-}\nnet/ipv6/ip6_tunnel.c:933:EXPORT_SYMBOL(ip6_tnl_rcv);\nnet/ipv6/ip6_tunnel.c-934-\n"
} |
| 45/2 | 2026/10/01 19:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 78823 output: 33 thoughts: 29 Thoughts: Here's my take on those thoughts, tailored for an expert audience: **Diving into `vxlan_xmit_one`** Alright, let's drill down into `vxlan_xmit_one` within `drivers/net/vxlan/vxlan_core.c`. This is where the rubber meets the road, the core function for transmitting VXLAN packets. I want to quickly refresh my understanding of how this handles the encapsulated packet's transmission. I'm particularly interested in the details of error checking, especially around potential flow control problems. What are the key elements, and are there any recent changes I need to keep in mind? Are there any obvious areas for optimization, or common pitfalls I can think to look for? |
| 46/2 | 2026/10/01 19:29 | tool | grepper |
0mArgs:{
"Expression": "vxlan_xmit_one",
"PathPrefix": "drivers/net/vxlan"
}Results: {
"Output": "drivers/net/vxlan/vxlan_core.c=2363=static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/vxlan/vxlan_core.c-2402-\ndrivers/net/vxlan/vxlan_core.c:2403:void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,\ndrivers/net/vxlan/vxlan_core.c-2404-\t\t const struct vxlan_config *cfg,\n--\ndrivers/net/vxlan/vxlan_core.c=2720=static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/vxlan/vxlan_core.c-2737-\tif (likely(do_xmit))\ndrivers/net/vxlan/vxlan_core.c:2738:\t\tvxlan_xmit_one(skb, dev, cfg, vni, \u0026nh_rdst, did_rsc);\ndrivers/net/vxlan/vxlan_core.c-2739-\telse\n--\ndrivers/net/vxlan/vxlan_core.c=2751=static netdev_tx_t vxlan_xmit_nhid(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/vxlan/vxlan_core.c-2775-\tif (likely(do_xmit))\ndrivers/net/vxlan/vxlan_core.c:2776:\t\tvxlan_xmit_one(skb, dev, cfg, vni, \u0026nh_rdst, false);\ndrivers/net/vxlan/vxlan_core.c-2777-\telse\n--\ndrivers/net/vxlan/vxlan_core.c=2796=static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)\n--\ndrivers/net/vxlan/vxlan_core.c-2825-\t\t\tif (info \u0026\u0026 info-\u003emode \u0026 IP_TUNNEL_INFO_TX)\ndrivers/net/vxlan/vxlan_core.c:2826:\t\t\t\tvxlan_xmit_one(skb, dev, cfg, vni, NULL, false);\ndrivers/net/vxlan/vxlan_core.c-2827-\t\t\telse\n--\ndrivers/net/vxlan/vxlan_core.c-2919-\t\t\tif (skb1)\ndrivers/net/vxlan/vxlan_core.c:2920:\t\t\t\tvxlan_xmit_one(skb1, dev, cfg, vni, rdst, did_rsc);\ndrivers/net/vxlan/vxlan_core.c-2921-\t\t}\ndrivers/net/vxlan/vxlan_core.c-2922-\t\tif (fdst)\ndrivers/net/vxlan/vxlan_core.c:2923:\t\t\tvxlan_xmit_one(skb, dev, cfg, vni, fdst, did_rsc);\ndrivers/net/vxlan/vxlan_core.c-2924-\t\telse\n--\ndrivers/net/vxlan/vxlan_mdb.c=1710=netdev_tx_t vxlan_mdb_xmit(struct vxlan_dev *vxlan,\n--\ndrivers/net/vxlan/vxlan_mdb.c-1732-\t\tif (skb1)\ndrivers/net/vxlan/vxlan_mdb.c:1733:\t\t\tvxlan_xmit_one(skb1, vxlan-\u003edev, cfg, src_vni,\ndrivers/net/vxlan/vxlan_mdb.c-1734-\t\t\t\t rcu_dereference(remote-\u003erd), false);\n--\ndrivers/net/vxlan/vxlan_mdb.c-1737-\tif (fremote)\ndrivers/net/vxlan/vxlan_mdb.c:1738:\t\tvxlan_xmit_one(skb, vxlan-\u003edev, cfg, src_vni,\ndrivers/net/vxlan/vxlan_mdb.c-1739-\t\t\t rcu_dereference(fremote-\u003erd), false);\n--\ndrivers/net/vxlan/vxlan_private.h=200=int vxlan_fdb_update(struct vxlan_dev *vxlan,\n--\ndrivers/net/vxlan/vxlan_private.h-205-\t\t bool swdev_notify, struct netlink_ext_ack *extack);\ndrivers/net/vxlan/vxlan_private.h:206:void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,\ndrivers/net/vxlan/vxlan_private.h-207-\t\t const struct vxlan_config *cfg,\n"
} |
| 47/2 | 2026/10/01 19:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 80263 output: 31 thoughts: 11 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and rendered in the first person: **Analyzing `vxlan_rcv`** Alright, time to dig into `vxlan_rcv`. This function, at the heart of VXLAN reception, is where the magic (or potential problems) happen. I immediately want to consider a few key aspects: the datapath's performance under load, potential bottlenecks, and any unusual corner cases. Specifically, I'm thinking about the encapsulation/decapsulation overhead, the context switching, the potential for lock contention within the receive path, and any vulnerabilities it might introduce. I'll need to look at buffer management, error handling, and how it interacts with other networking layers. Understanding the interaction between `vxlan_rcv` and the underlying hardware offloading capabilities, if any, is crucial. A quick scan suggests a deeper dive is required; let's see how efficiently it handles fragment reassembly and flow classification. I'm keen to check for any memory leaks and, of course, ensure there are no subtle race conditions that could lead to data corruption or security exploits. Time to start tracing the code! |
| 48/2 | 2026/10/01 19:29 | tool | grepper |
0mArgs:{
"Expression": "vxlan_rcv",
"PathPrefix": "drivers/net/vxlan"
}Results: {
"Output": "drivers/net/vxlan/vxlan_core.c=1651=static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph,\n--\ndrivers/net/vxlan/vxlan_core.c-1674-\ndrivers/net/vxlan/vxlan_core.c:1675:static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\ndrivers/net/vxlan/vxlan_core.c-1676-{\n--\ndrivers/net/vxlan/vxlan_core.c=3705=static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6,\n--\ndrivers/net/vxlan/vxlan_core.c-3742-\ttunnel_cfg.encap_type = 1;\ndrivers/net/vxlan/vxlan_core.c:3743:\ttunnel_cfg.encap_rcv = vxlan_rcv;\ndrivers/net/vxlan/vxlan_core.c-3744-\ttunnel_cfg.encap_err_lookup = vxlan_err_lookup;\n"
} |
| 49/2 | 2026/10/01 19:29 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 80849 output: 291 thoughts: 494 Thoughts: **Refactoring Packet Handling and Error Propagation in Tunneling Protocols** Okay, so `vxlan_rcv` is the UDP encapsulation receive callback for VXLAN sockets – that's the starting point. Let's compare that to `gre_rcv`. Looking at `net/ipv4/gre_demux.c`, `gre_rcv` is the `inet_protocol` handler for GRE within the demultiplexer. Aha, and in `ip_gre.c`, `gre_rcv` is the GRE protocol callback registered via `gre_add_protocol`! And, just to be thorough, `ip6_gre.c` also defines a `gre_rcv` as an `inet6_protocol` handler. Good, that's the receive path covered. Now, let's trace the critical functions: I need to look at `gre_parse_header`, `__iptunnel_pull_header`, `ip_tunnel_rcv`, `ip_tunnel_xmit`, `ip_md_tunnel_xmit`, `ip6_tnl_rcv`, `ip6_tnl_xmit`, `vxlan_xmit_one`, `vxlan_rcv`, `ipgre_xmit`, and `ip6gre_tunnel_xmit` to ensure I have all the key functions. Next, I'll review the required configuration options to make sure I'm capturing all the relevant scenarios. I need `VXLAN`, `NET_IPGRE`, `NET_IPGRE_DEMUX`, `NET_IP_TUNNEL`, `IPV6_GRE`, and `IPV6_TUNNEL`. These should be reachable in QEMU through netlink, sockets, loopback, or TAP interfaces; all standard networking paths. Now, let's do a sanity check on the reasoning: This patch fundamentally refactors how packet reception, header parsing, and transmission error handling are done within GRE, VXLAN, and IP-in-IP tunnels, and IPv6 tunnels (ip6_tunnel and ip6gre). The change is to return and propagate fine-grained `skb_drop_reason` codes instead of generic error codes. Specifically, this means modifications in `gre_parse_header`, `__iptunnel_pull_header`, and `ip6_tnl_xmit`, which are all crucial. Critically, these changes directly impact error-handling logic and skb consumption/drop flows within reachable virtual networking paths, triggered through standard networking and tunneling interfaces. Given that these functions and configuration options are clearly related, and that this change will be altering crucial virtual networking paths, I think it's a good place to focus our fuzzing efforts. Therefore, I need to specify `WorthFuzzing=true`, `FocusSymbols`, and `EnableConfigs`. Everything seems correct, and I've checked all of the crucial aspects. Let's call `set-results`. |
| 50/2 | 2026/10/01 19:29 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"VXLAN",
"NET_IPGRE",
"NET_IPGRE_DEMUX",
"NET_IP_TUNNEL",
"IPV6_GRE",
"IPV6_TUNNEL"
],
"FocusSymbols": [
"gre_parse_header",
"__iptunnel_pull_header",
"ip_tunnel_rcv",
"ip_tunnel_xmit",
"ip_md_tunnel_xmit",
"ip6_tnl_rcv",
"ip6_tnl_xmit",
"vxlan_rcv",
"vxlan_xmit_one",
"ipgre_xmit",
"ip6gre_tunnel_xmit"
],
"Reasoning": "The patch converts packet receive, header parsing, and transmission paths across core tunnel subsystems (VXLAN, GRE, IPv4 tunnel, and IPv6 tunnel) to use fine-grained skb drop reasons and updates error return conventions (e.g., in gre_parse_header, __iptunnel_pull_header, and ip6_tnl_xmit). These changes affect reachable virtual network device and packet handling logic, altering drop/error propagation and skb freeing paths that can be exercised via standard network namespaces and virtual netdevices.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"VXLAN",
"NET_IPGRE",
"NET_IPGRE_DEMUX",
"NET_IP_TUNNEL",
"IPV6_GRE",
"IPV6_TUNNEL"
],
"FocusSymbols": [
"gre_parse_header",
"__iptunnel_pull_header",
"ip_tunnel_rcv",
"ip_tunnel_xmit",
"ip_md_tunnel_xmit",
"ip6_tnl_rcv",
"ip6_tnl_xmit",
"vxlan_rcv",
"vxlan_xmit_one",
"ipgre_xmit",
"ip6gre_tunnel_xmit"
],
"Reasoning": "The patch converts packet receive, header parsing, and transmission paths across core tunnel subsystems (VXLAN, GRE, IPv4 tunnel, and IPv6 tunnel) to use fine-grained skb drop reasons and updates error return conventions (e.g., in gre_parse_header, __iptunnel_pull_header, and ip6_tnl_xmit). These changes affect reachable virtual network device and packet handling logic, altering drop/error propagation and skb freeing paths that can be exercised via standard network namespaces and virtual netdevices.",
"WorthFuzzing": true
} |
| 51/1 | 2026/10/01 19:29 | action | If |
2mArgs:{
"WorthFuzzing": true
}Results: null |
| 52/2 | 2026/10/01 19:29 | agent | kmsan-evaluator |
2mModel:core Args: null Results: {
"KMSANReasoning": "The patch series refactors network tunnel implementations (VXLAN, GRE, ERSPAN, and IPv6 tunnels) to propagate specific drop reasons (enum skb_drop_reason) to kfree_skb_reason() instead of using generic drops or negative error codes.\n\nKMSAN is specialized for detecting reads of uninitialized memory (stack, heap, page allocations) and information leaks to user space. The changes in this patch:\n1. Do not copy any kernel data or struct padding to user space.\n2. Do not introduce any new dynamic or stack allocations that could remain uninitialized.\n3. Only introduce and manipulate scalar local variables (`enum skb_drop_reason reason`) which are explicitly initialized or assigned before use on all code paths.\n4. Do not alter buffer bounds, packet length calculations, or offset handling in any way that would expose uninitialized bytes.\n\nBecause there is no risk of uninitialized memory use or kernel-to-user info-leaks, dedicated KMSAN fuzzing is not warranted; standard KASAN and compiler diagnostics are sufficient.",
"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 0c8100842fd2b89e6fd886a0c044bc8bdddfbb1d
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Oct 1 19:26:59 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
index 27b0b6567d521..7c94a630d184a 100644
--- a/drivers/net/vxlan/vxlan_core.c
+++ b/drivers/net/vxlan/vxlan_core.c
@@ -1700,7 +1700,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
if (!(vh->vx_flags & VXLAN_HF_VNI)) {
netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n",
ntohl(vh->vx_flags), ntohl(vh->vx_vni));
- reason = SKB_DROP_REASON_VXLAN_INVALID_HDR;
+ reason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;
/* Return non vxlan pkt */
goto drop;
}
@@ -1713,7 +1713,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
vxlan = vxlan_vs_find_vni(vs, skb->dev->ifindex, vni, &vninode);
if (!vxlan) {
- reason = SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND;
+ reason = SKB_DROP_REASON_TUNNEL_NOT_FOUND;
goto drop;
}
@@ -1729,7 +1729,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
* previous stack code, and also is more robust and provides a
* little more security in adding extensions to VXLAN.
*/
- reason = SKB_DROP_REASON_VXLAN_INVALID_HDR;
+ reason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;
DEV_STATS_INC(vxlan->dev, rx_frame_errors);
DEV_STATS_INC(vxlan->dev, rx_errors);
vxlan_vnifilter_count(vxlan, cfg, vni, vninode,
@@ -1743,11 +1743,11 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)
raw_proto = true;
}
- if (__iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,
- !net_eq(vxlan->net, dev_net(vxlan->dev)))) {
- reason = SKB_DROP_REASON_NOMEM;
+ reason = __iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,
+ !net_eq(vxlan->net,
+ dev_net(vxlan->dev)));
+ if (reason)
goto drop;
- }
if (cfg->flags & VXLAN_F_REMCSUM_RX) {
reason = vxlan_remcsum(skb, cfg->flags);
@@ -2389,7 +2389,7 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev,
DEV_STATS_INC(dev, tx_errors);
vxlan_vnifilter_count(vxlan, cfg, vni, NULL,
VXLAN_VNI_STATS_TX_ERRORS, 0);
- kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND);
+ kfree_skb_reason(skb, SKB_DROP_REASON_TUNNEL_NOT_FOUND);
return -ENOENT;
}
@@ -2547,7 +2547,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
tos, use_cache ? dst_cache : NULL);
if (IS_ERR(rt)) {
err = PTR_ERR(rt);
- reason = SKB_DROP_REASON_IP_OUTNOROUTES;
+ if (err == -ELOOP)
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
+ else
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
@@ -2633,7 +2636,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
if (IS_ERR(ndst)) {
err = PTR_ERR(ndst);
ndst = NULL;
- reason = SKB_DROP_REASON_IP_OUTNOROUTES;
+ if (err == -ELOOP)
+ reason = SKB_DROP_REASON_RECURSION_LIMIT;
+ else
+ reason = SKB_DROP_REASON_IP_OUTNOROUTES;
goto tx_error;
}
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 12f9096515912..40f23548f6685 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -111,8 +111,8 @@
FN(PACKET_SOCK_ERROR) \
FN(TC_CHAIN_NOTFOUND) \
FN(TC_RECLASSIFY_LOOP) \
- FN(VXLAN_INVALID_HDR) \
- FN(VXLAN_VNI_NOT_FOUND) \
+ FN(TUNNEL_INVALID_HDR) \
+ FN(TUNNEL_NOT_FOUND) \
FN(MAC_INVALID_SOURCE) \
FN(VXLAN_ENTRY_EXISTS) \
FN(NO_TX_TARGET) \
@@ -129,6 +129,10 @@
FN(PSP_INPUT) \
FN(PSP_OUTPUT) \
FN(RECURSION_LIMIT) \
+ FN(TUNNEL_OPT_MISMATCH) \
+ FN(TUNNEL_OLD_SEQ) \
+ FN(GRE_CSUM) \
+ FN(TUNNEL_ENCAP) \
FNe(MAX)
/**
@@ -539,13 +543,18 @@ enum skb_drop_reason {
*/
SKB_DROP_REASON_TC_RECLASSIFY_LOOP,
/**
- * @SKB_DROP_REASON_VXLAN_INVALID_HDR: VXLAN header is invalid. E.g.:
- * 1) reserved fields are not zero
- * 2) "I" flag is not set
+ * @SKB_DROP_REASON_TUNNEL_INVALID_HDR: tunnel header is invalid. E.g.:
+ * 1) VXLAN reserved fields are not zero
+ * 2) VXLAN "I" flag is not set
+ * 3) GRE version is not supported or the routing bit is set
*/
- SKB_DROP_REASON_VXLAN_INVALID_HDR,
- /** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */
- SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND,
+ SKB_DROP_REASON_TUNNEL_INVALID_HDR,
+ /**
+ * @SKB_DROP_REASON_TUNNEL_NOT_FOUND: no tunnel device found for the
+ * packet, e.g. no VXLAN device for its VNI or no GRE tunnel for its
+ * endpoints and key
+ */
+ SKB_DROP_REASON_TUNNEL_NOT_FOUND,
/** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */
SKB_DROP_REASON_MAC_INVALID_SOURCE,
/**
@@ -610,8 +619,34 @@ enum skb_drop_reason {
SKB_DROP_REASON_PSP_INPUT,
/** @SKB_DROP_REASON_PSP_OUTPUT: PSP output checks failed */
SKB_DROP_REASON_PSP_OUTPUT,
- /** @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device. */
+ /**
+ * @SKB_DROP_REASON_RECURSION_LIMIT: Dead loop on virtual device, e.g. a
+ * tunnel whose route to its remote end goes out of the tunnel device
+ * itself.
+ */
SKB_DROP_REASON_RECURSION_LIMIT,
+ /**
+ * @SKB_DROP_REASON_TUNNEL_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_TUNNEL_OPT_MISMATCH,
+ /**
+ * @SKB_DROP_REASON_TUNNEL_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_TUNNEL_OLD_SEQ,
+ /** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */
+ SKB_DROP_REASON_GRE_CSUM,
+ /**
+ * @SKB_DROP_REASON_TUNNEL_ENCAP: failed to build the encapsulation
+ * header of a tunnel, e.g. an unknown or unregistered encapsulation
+ * type.
+ */
+ SKB_DROP_REASON_TUNNEL_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..b5dbe00ab15ef 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 ignore_csum_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..792690ae4f266 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,11 +610,13 @@ 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(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 xnet)
+static inline enum skb_drop_reason
+iptunnel_pull_header(struct sk_buff *skb, int hdr_len,
+ __be16 inner_proto, bool xnet)
{
return __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);
}
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 96fd7dc6d82dd..fccdaa240f46e 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -56,28 +56,47 @@ 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.
- * Note that caller must use pskb_may_pull() before pulling GRE header.
+/**
+ * gre_parse_header() - parse the GRE header of a packet
+ * @skb: the packet; the GRE header starts @nhs bytes past skb->data
+ * @tpi: filled in with the fields of the header, and with the length of
+ * the header to be pulled in tpi->hdr_len
+ * @ignore_csum_err: do not reject the header when its checksum does not
+ * match. The ICMP error handlers set it, as they only get a part of the
+ * original packet; the checksum is still computed and the rest of the
+ * header is parsed.
+ * @proto: the protocol to report for a WCCP payload, ETH_P_IP or
+ * ETH_P_IPV6
+ * @nhs: the offset of the GRE header from skb->data
+ *
+ * The caller must use pskb_may_pull() before pulling the GRE header.
+ *
+ * Return: SKB_NOT_DROPPED_YET, or the reason to drop the packet if the
+ * header is rejected.
*/
-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 ignore_csum_err, __be16 proto, int nhs)
{
const struct gre_base_hdr *greh;
+ enum skb_drop_reason reason;
__be32 *options;
int hdr_len;
- if (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))
- return -EINVAL;
+ reason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));
+ if (unlikely(reason))
+ return reason;
greh = (struct gre_base_hdr *)(skb->data + nhs);
if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
- return -EINVAL;
+ return SKB_DROP_REASON_TUNNEL_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;
+ reason = pskb_may_pull_reason(skb, nhs + hdr_len);
+ if (reason)
+ return reason;
greh = (struct gre_base_hdr *)(skb->data + nhs);
tpi->proto = greh->protocol;
@@ -87,9 +106,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 (!ignore_csum_err) {
+ return SKB_DROP_REASON_GRE_CSUM;
}
options++;
@@ -117,7 +135,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_PKT_TOO_SMALL;
tpi->proto = proto;
if ((*val & 0xF0) != 0x40)
hdr_len += 4;
@@ -132,29 +150,35 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
greh->protocol == htons(ETH_P_ERSPAN2)) {
struct erspan_base_hdr *ershdr;
- if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
- return -EINVAL;
+ reason = pskb_may_pull_reason(skb,
+ nhs + hdr_len + sizeof(*ershdr));
+ if (reason)
+ return reason;
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)
{
const struct gre_protocol *proto;
+ enum skb_drop_reason reason;
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_TUNNEL_INVALID_HDR;
goto drop;
+ }
rcu_read_lock();
proto = rcu_dereference(gre_proto[ver]);
@@ -167,11 +191,12 @@ 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:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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 51fcd603939c5..58234e857d6c2 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,9 +264,11 @@ 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)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct net *net = dev_net(skb->dev);
struct metadata_dst *tun_dst = NULL;
struct erspan_base_hdr *ershdr;
@@ -288,9 +290,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, flags,
iph->saddr, iph->daddr, 0);
} else {
- if (unlikely(!pskb_may_pull(skb,
- gre_hdr_len + sizeof(*ershdr))))
- return PACKET_REJECT;
+ reason = pskb_may_pull_reason(skb,
+ gre_hdr_len + sizeof(*ershdr));
+ if (unlikely(reason))
+ return reason;
ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len);
ver = ershdr->ver;
@@ -306,13 +309,13 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
else
len = gre_hdr_len + erspan_hdr_len(ver);
- if (unlikely(!pskb_may_pull(skb, len)))
- return PACKET_REJECT;
+ reason = pskb_may_pull_reason(skb, len);
+ if (unlikely(reason))
+ return reason;
- if (__iptunnel_pull_header(skb,
- len,
- htons(ETH_P_TEB),
- false, false) < 0)
+ reason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),
+ false, false);
+ if (reason)
goto drop;
if (tunnel->collect_md) {
@@ -328,7 +331,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,18 +357,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_TUNNEL_NOT_FOUND;
drop:
- kfree_skb(skb);
- return PACKET_RCVD;
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ 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)
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct metadata_dst *tun_dst = NULL;
const struct iphdr *iph;
struct ip_tunnel *tunnel;
@@ -377,8 +384,9 @@ 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(skb, hdr_len, tpi->proto,
+ raw_proto, false);
+ if (reason)
goto drop;
/* Special case for ipgre_header_parse(), which expects the
@@ -401,47 +409,49 @@ 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_TUNNEL_NOT_FOUND;
drop:
- kfree_skb(skb);
- return PACKET_RCVD;
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ 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_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 +461,28 @@ 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:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -496,6 +509,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 +518,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 +553,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 +573,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 +639,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 +652,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);
}
@@ -652,8 +686,10 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
const struct iphdr *tnl_params;
+ enum skb_drop_reason reason;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -664,10 +700,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 +716,32 @@ 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);
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
@@ -705,10 +751,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
{
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
+ enum skb_drop_reason reason;
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 +764,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 +799,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 +808,8 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
free_skb:
- kfree_skb(skb);
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ kfree_skb_reason(skb, reason);
DEV_STATS_INC(dev, tx_dropped);
return NETDEV_TX_OK;
}
@@ -763,8 +819,10 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
{
struct ip_tunnel *tunnel = netdev_priv(dev);
IP_TUNNEL_DECLARE_FLAGS(flags);
+ enum skb_drop_reason reason;
- if (!pskb_inet_may_pull(skb))
+ reason = pskb_inet_may_pull_reason(skb);
+ if (reason)
goto free_skb;
if (tunnel->collect_md) {
@@ -774,17 +832,22 @@ 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);
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ 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..98ebfadbf64b0 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_TUNNEL_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_TUNNEL_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_TUNNEL_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;
}
}
@@ -455,9 +466,10 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
return 0;
drop:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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 +587,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 +601,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 +623,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_TUNNEL_ENCAP;
goto tx_error;
+ }
use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
if (use_cache)
@@ -618,6 +635,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 +645,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 +654,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 +672,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 +687,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,6 +722,7 @@ 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;
}
@@ -713,9 +736,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
} else if (payload_protocol == htons(ETH_P_IP)) {
rt = skb_rtable(skb);
dst = rt_nexthop(rt, inner_iph->daddr);
- }
#if IS_ENABLED(CONFIG_IPV6)
- else if (payload_protocol == htons(ETH_P_IPV6)) {
+ } else if (payload_protocol == htons(ETH_P_IPV6)) {
const struct in6_addr *addr6;
struct neighbour *neigh;
bool do_tx_error_icmp;
@@ -723,8 +745,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,12 +765,15 @@ 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
+ } else {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_error;
+ }
if (!md)
connected = false;
@@ -769,8 +796,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_TUNNEL_ENCAP;
goto tx_error;
+ }
if (connected && md) {
use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
@@ -787,6 +816,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 +830,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 +840,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 +875,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 +891,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..6c2855adff289 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(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,7 +140,10 @@ 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);
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 258239a7c53bb..dbca782308158 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,31 +472,33 @@ 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_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;
+ enum skb_drop_reason reason;
struct erspan_md2 *md2;
struct ip6_tnl *tunnel;
u8 ver;
- if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))
- return PACKET_REJECT;
+ reason = pskb_may_pull_reason(skb, sizeof(*ershdr));
+ if (unlikely(reason))
+ return reason;
ipv6h = ipv6_hdr(skb);
ershdr = (struct erspan_base_hdr *)skb->data;
@@ -507,13 +510,14 @@ static int ip6erspan_rcv(struct sk_buff *skb,
if (tunnel) {
int len = erspan_hdr_len(ver);
- if (unlikely(!pskb_may_pull(skb, len)))
- return PACKET_REJECT;
+ reason = pskb_may_pull_reason(skb, len);
+ if (unlikely(reason))
+ return reason;
- if (__iptunnel_pull_header(skb, len,
- htons(ETH_P_TEB),
- false, false) < 0)
- return PACKET_REJECT;
+ reason = __iptunnel_pull_header(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 +534,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 +562,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_TUNNEL_NOT_FOUND;
}
static int gre_rcv(struct sk_buff *skb)
{
+ enum skb_drop_reason reason;
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(skb, tpi.hdr_len, tpi.proto, 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:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
dev_core_stats_rx_dropped_inc(skb->dev);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -674,10 +681,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 +704,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 +717,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 +745,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 +764,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 +775,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 +790,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 +810,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,17 +868,17 @@ 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,
@@ -877,41 +886,56 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
{
struct ip_tunnel_info *tun_info = NULL;
struct ip6_tnl *t = netdev_priv(dev);
+ enum skb_drop_reason reason;
__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 (!t->parms.collect_md && ipv6_addr_any(&t->parms.raddr)) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_err;
+ }
- if (t->parms.collect_md)
+ 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);
+ if (IS_ERR(tun_info) ||
+ unlikely(ip_tunnel_info_af(tun_info) != AF_INET6)) {
+ reason = SKB_DROP_REASON_TUNNEL_TXINFO;
+ goto tx_err;
+ }
+ }
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;
tx_err:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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;
}
@@ -922,27 +946,39 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
struct ip6_tnl *t = netdev_priv(dev);
struct dst_entry *dst = skb_dst(skb);
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
+ enum skb_drop_reason reason;
bool truncate = false;
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 (!t->parms.collect_md && ipv6_addr_any(&t->parms.raddr)) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
goto tx_err;
+ }
+
+ 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 +998,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 +1015,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 +1030,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 +1055,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 +1066,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 +1094,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 +1112,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));
@@ -1078,10 +1129,11 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
tx_err:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
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..7e444115f4314 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_TUNNEL_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_TUNNEL_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_TUNNEL_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;
}
}
@@ -896,9 +907,10 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
return 0;
drop:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
if (tun_dst)
dst_release((struct dst_entry *)tun_dst);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -941,6 +953,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
const struct ipv6hdr *ipv6h,
struct sk_buff *skb))
{
+ enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
struct ip6_tnl *t;
const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
struct metadata_dst *tun_dst = NULL;
@@ -952,21 +965,30 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
if (t) {
u8 tproto = READ_ONCE(t->parms.proto);
- if (tproto != ipproto && tproto != 0)
+ if (tproto != ipproto && tproto != 0) {
+ reason = SKB_DROP_REASON_UNHANDLED_PROTO;
goto drop;
- if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
+ }
+ if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+ reason = SKB_DROP_REASON_XFRM_POLICY;
goto drop;
+ }
ipv6h = ipv6_hdr(skb);
- if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr))
+ if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr)) {
+ reason = SKB_DROP_REASON_DEV_READY;
goto drop;
- if (iptunnel_pull_header(skb, 0, tpi->proto, false))
+ }
+ reason = iptunnel_pull_header(skb, 0, tpi->proto, false);
+ if (reason)
goto drop;
if (t->parms.collect_md) {
IP_TUNNEL_DECLARE_FLAGS(flags) = { };
tun_dst = ipv6_tun_rx_dst(skb, flags, 0, 0);
- if (!tun_dst)
+ if (!tun_dst) {
+ reason = SKB_DROP_REASON_NOMEM;
goto drop;
+ }
}
ret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,
log_ecn_error);
@@ -978,7 +1000,8 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
drop:
rcu_read_unlock();
- kfree_skb(skb);
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+ kfree_skb_reason(skb, reason);
return 0;
}
@@ -1092,14 +1115,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 +1133,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 +1155,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,12 +1178,19 @@ 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));
}
+
+ if (ipv6_addr_any(&fl6->daddr)) {
+ reason = SKB_DROP_REASON_NO_TX_TARGET;
+ goto tx_err_link_failure;
+ }
} else if (t->parms.proto != 0 && !(t->parms.flags &
(IP6_TNL_F_USE_ORIG_TCLASS |
IP6_TNL_F_USE_ORIG_FWMARK))) {
@@ -1169,8 +1203,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 +1215,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 +1240,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 +1254,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 +1277,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_TUNNEL_ENCAP;
goto tx_err_dst_release;
+ }
} else {
if (use_cache && ndst)
dst_cache_set_ip6(&t->dst_cache, ndst, &fl6->saddr);
@@ -1264,9 +1309,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_TUNNEL_ENCAP;
if (encap_limit >= 0) {
init_tel_txopt(&opt, encap_limit);
@@ -1283,21 +1327,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 +1351,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 +1363,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 +1400,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 +1442,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 +1462,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)
{
struct ip6_tnl *t = netdev_priv(dev);
+ enum skb_drop_reason reason;
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,27 +1484,31 @@ 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;
tx_err:
+ reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
DEV_STATS_INC(dev, tx_errors);
DEV_STATS_INC(dev, tx_dropped);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return NETDEV_TX_OK;
}
|
| 53/3 | 2026/10/01 19:29 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32787 output: 37 thoughts: 1069 Thoughts: **KMSAN Fuzzing Justification: Tunnel Code Patch** Okay, let's break this down. The user wants me to decide if we need a dedicated KMSAN fuzzing session for this patch series. My first thought is: let's analyze what the patches *actually* do. It looks like the patch series is all about updating networking tunnel code – VXLAN, GRE, and related protocols. The core change is to replace generic drop mechanisms (or negative error codes) with specific `skb_drop_reason` values. This is generally good practice for debugging and root-cause analysis, and might make fuzzing more effective. They're renaming some drop reasons, adding a few new ones like `TUNNEL_OPT_MISMATCH` and `GRE_CSUM`, and updating functions to return and handle these `skb_drop_reason` values. Specifically, `__iptunnel_pull_header` is updated, and `-ELOOP` is assigned to `SKB_DROP_REASON_RECURSION_LIMIT`. That's reasonable, but it's not a clear indicator of immediate fuzzing need. Now, here's where it gets interesting: the change to `gre_parse_header`. This function's return type is changing from an `int` to an `enum skb_drop_reason`. This also affects the `hdr_len` being passed. It's also removing `bool *csum_err` to `bool ignore_csum_err`. Success is now signaled by `SKB_NOT_DROPPED_YET (0)`. The header length is now passed via `tpi->hdr_len`. My initial thought is to make sure this is handled correctly. Let's trace how the `tpi->hdr_len` is being set and used within `gre_parse_header`. I'll want to verify how `tpi->hdr_len` is handled in the code. I'm checking lines 56-150 in `net/ipv4/gre_demux.c`, which includes `gre_parse_header`. Ah, here it is: `gre_parse_header` *does* set `tpi->hdr_len`! I'm verifying this, and making sure that the logic is correct. I need to make sure `tpi->hdr_len` is set correctly inside `gre_parse_header`, that is key here. It seems that `hdr_len` is used to skip the header (and is based on a `proto` field read from the header) and the header length is also passed around to `erspan_rcv` and `ipgre_rcv`. This is definitely something to look at. Is this *correct*? Is it used correctly in the subsequent calls to `erspan_rcv` and `ipgre_rcv`? This could be a source of off-by-one errors or incorrect interpretation of packet data if there's a mismatch between what `gre_parse_header` calculates and how it's used later. I'm now digging into where `tpi.hdr_len` is *actually* set in `gre_parse_header`, looking at how the function is used in `gre_rcv`. I see how `gre_parse_header` is being called and how the `reason` is being checked. And I'm looking for where `tpi.hdr_len` is actually set. It is key to understand if it is. It looks like it is set correctly in `gre_parse_header` and used in `erspan_rcv` and `ipgre_rcv`. Now, does all this justify a KMSAN fuzzing session *specifically*? This patch series *introduces* new drop reasons and *modifies* how header lengths are calculated and used. These are changes that can, in principle, expose subtle memory errors. In conclusion, given these changes – especially the `hdr_len` calculation and handling – a targeted KMSAN fuzzing session seems *warranted* to ensure no unexpected memory corruption or invalid memory access. The new `skb_drop_reason` codes will provide better insight if KMSAN does identify any issues. It will be helpful to target the tunnel code with KMSAN. |
| 54/3 | 2026/10/01 19:30 | 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);\n--\nnet/ipv4/gre_demux.c-62- * @tpi: filled in with the fields of the header, and with the length of\nnet/ipv4/gre_demux.c:63: *\tthe header to be pulled in tpi-\u003ehdr_len\nnet/ipv4/gre_demux.c-64- * @ignore_csum_err: do not reject the header when its checksum does not\n--\nnet/ipv4/gre_demux.c=78=gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n--\nnet/ipv4/gre_demux.c-142-\t}\nnet/ipv4/gre_demux.c:143:\ttpi-\u003ehdr_len = hdr_len;\nnet/ipv4/gre_demux.c-144-\n"
} |
| 55/3 | 2026/10/01 19:30 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35064 output: 39 thoughts: 49 Thoughts: Here's my thought process, as if I were reviewing this code: **Analyzing the GRE Header Length Assignment** Okay, so `tpi->hdr_len = hdr_len;` is on line 143. That's a key line for setting the header length, obviously. Before I get lost in the weeds, let's zoom out and look at the context. I need to understand what's happening in the surrounding lines of `net/ipv4/gre_demux.c`. Specifically, I'll examine lines 135 to 155 to see how `hdr_len` is being calculated or used in relation to this assignment. I need to understand the logic flow here: how the header length is determined, if there's any error handling, and what this `tpi` struct actually represents. I need the full picture to be sure this is correct and efficient. |
| 56/3 | 2026/10/01 19:30 | tool | read-file |
0mArgs:{
"File": "net/ipv4/gre_demux.c",
"FirstLine": 135,
"LineCount": 25
}Results: {
"Contents": " 135:\t\t\tval = skb_header_pointer(skb, nhs + hdr_len,\n 136:\t\t\t\t\t\t sizeof(_val), \u0026_val);\n 137:\t\t\tif (!val)\n 138:\t\t\t\treturn SKB_DROP_REASON_PKT_TOO_SMALL;\n 139:\t\t\ttpi-\u003eproto = proto;\n 140:\t\t\tif ((*val \u0026 0xF0) != 0x40)\n 141:\t\t\t\thdr_len += 4;\n 142:\t\t}\n 143:\t\ttpi-\u003ehdr_len = hdr_len;\n 144:\t\n 145:\t\t/* ERSPAN ver 1 and 2 protocol sets GRE key field\n 146:\t\t * to 0 and sets the configured key in the\n 147:\t\t * inner erspan header field\n 148:\t\t */\n 149:\t\tif ((greh-\u003eprotocol == htons(ETH_P_ERSPAN) \u0026\u0026 hdr_len != 4) ||\n 150:\t\t greh-\u003eprotocol == htons(ETH_P_ERSPAN2)) {\n 151:\t\t\tstruct erspan_base_hdr *ershdr;\n 152:\t\n 153:\t\t\treason = pskb_may_pull_reason(skb,\n 154:\t\t\t\t\t\t nhs + hdr_len + sizeof(*ershdr));\n 155:\t\t\tif (reason)\n 156:\t\t\t\treturn reason;\n 157:\t\n 158:\t\t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + nhs + hdr_len);\n 159:\t\t\ttpi-\u003ekey = cpu_to_be32(get_session_id(ershdr));\n"
} |
| 57/3 | 2026/10/01 19:30 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35786 output: 19 thoughts: 106 Thoughts: Okay, let's see, my thinking goes like this: **Analyzing a Potential Kernel Vulnerability** Right, so I'm looking at this code and I see that line 143 is already setting `tpi->hdr_len` to `hdr_len`. That seems straightforward. However, what happens if `gre_parse_header` fails *before* that line? It seems to return a non-zero value, which is apparently assigned to the variable `reason`. Then the next line is `if (reason) goto drop;`. So, if the parsing fails, we jump to `drop` and never use `tpi`. That seems...okay, from a quick glance. The `tpi` struct appears safe from use if parsing fails. But wait, is this the only place `gre_parse_header` is called? This could be a blind spot for this specific fix. I should really check if any other parts of the kernel are also calling `gre_parse_header`. I need to ensure that this isn't an isolated incident and that the behavior I see here is consistent everywhere this function is used. A quick kernel-wide search is definitely in order, just to be sure. |
| 58/3 | 2026/10/01 19:30 | 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 ignore_csum_err, __be16 proto, int nhs);\n--\nnet/ipv4/gre_demux.c=57=EXPORT_SYMBOL_GPL(gre_del_protocol);\n--\nnet/ipv4/gre_demux.c-59-/**\nnet/ipv4/gre_demux.c:60: * gre_parse_header() - parse the GRE header of a packet\nnet/ipv4/gre_demux.c-61- * @skb: the packet; the GRE header starts @nhs bytes past skb-\u003edata\n--\nnet/ipv4/gre_demux.c=77=enum skb_drop_reason\nnet/ipv4/gre_demux.c:78:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\nnet/ipv4/gre_demux.c-79-\t\t bool ignore_csum_err, __be16 proto, int nhs)\n--\nnet/ipv4/gre_demux.c-163-}\nnet/ipv4/gre_demux.c:164:EXPORT_SYMBOL(gre_parse_header);\nnet/ipv4/gre_demux.c-165-\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=451=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv4/ip_gre.c-463-\nnet/ipv4/ip_gre.c:464:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IP), 0);\nnet/ipv4/ip_gre.c-465-\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=571=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-575-\nnet/ipv6/ip6_gre.c:576:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\nnet/ipv6/ip6_gre.c-577-\tif (reason)\n"
} |
| 59/3 | 2026/10/01 19:30 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37040 output: 21 thoughts: 29 Thoughts: Okay, here's my summary, tailored for an expert audience, in the first person, reflecting the described thought process: **Refactoring and Code Exploration: A Quick Audit** Alright, I've just finished going through the updates to all the callers of `gre_parse_header`. That's done. Now, I want to take a look at the other end of things – the interaction further down the chain. Let's dig into the callers of `__iptunnel_pull_header`. I want to understand the complete flow, ensuring that my previous changes have ripple effects that I expect, and also to ensure that there aren't any unexpected interactions in this related area. Let's see what's what. |
| 60/3 | 2026/10/01 19:30 | tool | grepper |
0mArgs:{
"Expression": "__iptunnel_pull_header"
}Results: {
"Output": "drivers/net/vxlan/vxlan_core.c=1675=static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/vxlan/vxlan_core.c-1745-\ndrivers/net/vxlan/vxlan_core.c:1746:\treason = __iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,\ndrivers/net/vxlan/vxlan_core.c-1747-\t\t\t\t\t!net_eq(vxlan-\u003enet,\n--\ninclude/net/ip_tunnels.h=613=enum skb_drop_reason\ninclude/net/ip_tunnels.h:614:__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-615-\t\t __be16 inner_proto, bool raw_proto, bool xnet);\n--\ninclude/net/ip_tunnels.h=618=iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n--\ninclude/net/ip_tunnels.h-620-{\ninclude/net/ip_tunnels.h:621:\treturn __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);\ninclude/net/ip_tunnels.h-622-}\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-315-\nnet/ipv4/ip_gre.c:316:\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\nnet/ipv4/ip_gre.c-317-\t\t\t\t\t\tfalse, false);\n--\nnet/ipv4/ip_gre.c-339-\nnet/ipv4/ip_gre.c:340:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv4/ip_gre.c-341-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv4/ip_gre.c=370=static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-386-\nnet/ipv4/ip_gre.c:387:\t\treason = __iptunnel_pull_header(skb, hdr_len, tpi-\u003eproto,\nnet/ipv4/ip_gre.c-388-\t\t\t\t\t\traw_proto, false);\n--\nnet/ipv4/ip_tunnel_core.c=109=enum skb_drop_reason\nnet/ipv4/ip_tunnel_core.c:110:__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\nnet/ipv4/ip_tunnel_core.c-111-\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);\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-516-\nnet/ipv6/ip6_gre.c:517:\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\nnet/ipv6/ip6_gre.c-518-\t\t\t\t\t\tfalse, false);\n--\nnet/ipv6/ip6_gre.c-542-\nnet/ipv6/ip6_gre.c:543:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv6/ip6_gre.c-544-\t\t\t * old pkt_md is no longer valid and we need to reset\n"
} |
| 61/3 | 2026/10/01 19:30 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38457 output: 20 thoughts: 16 Thoughts: Okay, here's my summary, tailored for an expert audience, presented as if it were my own thought process: **Diving Deeper into the `iptunnel_pull_header` Callers** Alright, I'm thinking we need to broaden our scope a bit here. We've been focusing on *this* specific area, but to get a truly comprehensive understanding, and to avoid potentially missing something crucial down the line, I'm going to take a look at the callers of `iptunnel_pull_header` as well. Checking where this function is *used* is just as important as the function itself. It could reveal dependencies or subtle interactions we haven't considered. This is about ensuring we have a complete picture. It's time to follow the chain upstream and understand the context within which this function operates. |
| 62/3 | 2026/10/01 19:30 | tool | grepper |
0mArgs:{
"Expression": "iptunnel_pull_header"
}Results: {
"Output": "drivers/net/amt.c=2304=static bool amt_multicast_data_handler(struct amt_dev *amt, struct sk_buff *skb)\n--\ndrivers/net/amt.c-2321-\ndrivers/net/amt.c:2322:\tif (iptunnel_pull_header(skb, hdr_size, htons(ETH_P_IP), false))\ndrivers/net/amt.c-2323-\t\treturn true;\n--\ndrivers/net/amt.c=2375=static bool amt_membership_query_handler(struct amt_dev *amt,\n--\ndrivers/net/amt.c-2399-\thdr_size -= sizeof(*eth);\ndrivers/net/amt.c:2400:\tif (iptunnel_pull_header(skb, hdr_size, htons(ETH_P_TEB), false))\ndrivers/net/amt.c-2401-\t\treturn true;\n--\ndrivers/net/amt.c=2486=static bool amt_update_handler(struct amt_dev *amt, struct sk_buff *skb)\n--\ndrivers/net/amt.c-2509-\ndrivers/net/amt.c:2510:\tif (iptunnel_pull_header(skb, hdr_size, skb-\u003eprotocol, false))\ndrivers/net/amt.c-2511-\t\treturn true;\n--\ndrivers/net/bareudp.c=62=static int bareudp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/bareudp.c-135-\ndrivers/net/bareudp.c:136:\tif (iptunnel_pull_header(skb, BAREUDP_BASE_HLEN,\ndrivers/net/bareudp.c-137-\t\t\t\t proto,\n--\ndrivers/net/geneve.c=668=static int geneve_udp_encap_recv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/geneve.c-703-\topts_len = geneveh-\u003eopt_len * 4;\ndrivers/net/geneve.c:704:\tif (iptunnel_pull_header(skb, GENEVE_BASE_HLEN + opts_len, inner_proto,\ndrivers/net/geneve.c-705-\t\t\t\t !net_eq(geneve-\u003enet, dev_net(geneve-\u003edev)))) {\n--\ndrivers/net/gtp.c=318=static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb,\n--\ndrivers/net/gtp.c-331-\t/* Get rid of the GTP + UDP headers. */\ndrivers/net/gtp.c:332:\tif (iptunnel_pull_header(skb, hdrlen, htons(inner_proto),\ndrivers/net/gtp.c-333-\t\t\t !net_eq(sock_net(pctx-\u003esk), dev_net(pctx-\u003edev)))) {\n--\ndrivers/net/pfcp.c=52=static int pfcp_encap_recv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/pfcp.c-86-\ndrivers/net/pfcp.c:87:\tif (unlikely(iptunnel_pull_header(skb, PFCP_HLEN, skb-\u003eprotocol,\ndrivers/net/pfcp.c-88-\t\t\t\t\t !net_eq(sock_net(sk),\n--\ndrivers/net/vxlan/vxlan_core.c=1675=static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/vxlan/vxlan_core.c-1745-\ndrivers/net/vxlan/vxlan_core.c:1746:\treason = __iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto,\ndrivers/net/vxlan/vxlan_core.c-1747-\t\t\t\t\t!net_eq(vxlan-\u003enet,\n--\ninclude/net/ip_tunnels.h=613=enum skb_drop_reason\ninclude/net/ip_tunnels.h:614:__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-615-\t\t __be16 inner_proto, bool raw_proto, bool xnet);\n--\ninclude/net/ip_tunnels.h=617=static inline enum skb_drop_reason\ninclude/net/ip_tunnels.h:618:iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\ninclude/net/ip_tunnels.h-619-\t\t __be16 inner_proto, bool xnet)\ninclude/net/ip_tunnels.h-620-{\ninclude/net/ip_tunnels.h:621:\treturn __iptunnel_pull_header(skb, hdr_len, inner_proto, false, xnet);\ninclude/net/ip_tunnels.h-622-}\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-315-\nnet/ipv4/ip_gre.c:316:\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\nnet/ipv4/ip_gre.c-317-\t\t\t\t\t\tfalse, false);\n--\nnet/ipv4/ip_gre.c-339-\nnet/ipv4/ip_gre.c:340:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv4/ip_gre.c-341-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv4/ip_gre.c=370=static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-386-\nnet/ipv4/ip_gre.c:387:\t\treason = __iptunnel_pull_header(skb, hdr_len, tpi-\u003eproto,\nnet/ipv4/ip_gre.c-388-\t\t\t\t\t\traw_proto, false);\n--\nnet/ipv4/ip_tunnel_core.c=109=enum skb_drop_reason\nnet/ipv4/ip_tunnel_core.c:110:__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\nnet/ipv4/ip_tunnel_core.c-111-\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);\nnet/ipv4/ip_tunnel_core.c-149-\n--\nnet/ipv4/ipip.c=215=static int ipip_tunnel_rcv(struct sk_buff *skb, u8 ipproto)\n--\nnet/ipv4/ipip.c-243-\t\t\ttpi = \u0026ipip_tpi;\nnet/ipv4/ipip.c:244:\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\nnet/ipv4/ipip.c-245-\t\t\tgoto drop;\n--\nnet/ipv6/ip6_gre.c=488=static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-516-\nnet/ipv6/ip6_gre.c:517:\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\nnet/ipv6/ip6_gre.c-518-\t\t\t\t\t\tfalse, false);\n--\nnet/ipv6/ip6_gre.c-542-\nnet/ipv6/ip6_gre.c:543:\t\t\t/* skb can be uncloned in __iptunnel_pull_header, so\nnet/ipv6/ip6_gre.c-544-\t\t\t * old pkt_md is no longer valid and we need to reset\n--\nnet/ipv6/ip6_gre.c=571=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-579-\nnet/ipv6/ip6_gre.c:580:\treason = iptunnel_pull_header(skb, tpi.hdr_len, tpi.proto, false);\nnet/ipv6/ip6_gre.c-581-\tif (reason)\n--\nnet/ipv6/ip6_tunnel.c=950=static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n--\nnet/ipv6/ip6_tunnel.c-980-\t\t}\nnet/ipv6/ip6_tunnel.c:981:\t\treason = iptunnel_pull_header(skb, 0, tpi-\u003eproto, false);\nnet/ipv6/ip6_tunnel.c-982-\t\tif (reason)\n--\nnet/ipv6/sit.c=738=static int ipip6_rcv(struct sk_buff *skb)\n--\nnet/ipv6/sit.c-765-\nnet/ipv6/sit.c:766:\t\tif (iptunnel_pull_header(skb, 0, htons(ETH_P_IPV6),\nnet/ipv6/sit.c-767-\t\t !net_eq(tunnel-\u003enet, dev_net(tunnel-\u003edev))))\n--\nnet/ipv6/sit.c-769-\nnet/ipv6/sit.c:770:\t\t/* skb can be uncloned in iptunnel_pull_header, so\nnet/ipv6/sit.c-771-\t\t * old iph is no longer valid\n--\nnet/ipv6/sit.c=814=static int sit_tunnel_rcv(struct sk_buff *skb, u8 ipproto)\n--\nnet/ipv6/sit.c-841-\t\t\ttpi = \u0026ipip_tpi;\nnet/ipv6/sit.c:842:\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\nnet/ipv6/sit.c-843-\t\t\tgoto drop;\n"
} |
| 63/3 | 2026/10/01 19:30 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41486 output: 39 thoughts: 1361 Thoughts: **Analyzing the IPTunnel Header Pull Patch** Okay, first things first, I need to understand the implications of this change to `iptunnel_pull_header`. It seems the return value has been altered. Previously, a zero meant success and a negative value indicated an error. Now, it returns `SKB_NOT_DROPPED_YET` (which is zero) on success, or a positive drop reason enum on error. I need to quickly check the callers. In `drivers/net/amt.c`, the existing `if (iptunnel_pull_header(...))` logic, which checks for non-zero (meaning an error), still works! The same applies to `bareudp.c`, `geneve.c`, `gtp.c`, `pfcp.c`, `net/ipv4/ipip.c`, and `net/ipv6/sit.c`. So, the truthiness checks remain valid, that's good. Now, I have to perform a comprehensive review of the entire patch. My main concern is any potential introduction of uninitialized memory vulnerabilities. I need to check the four KMSAN criteria: data sent to userspace, conditional logic using uninitialized variables, allocation of complex data structures with uninitialized fields, and bounds check issues allowing access to uninitialized data. Let's dive into the modified files, function by function. * `drivers/net/vxlan/vxlan_core.c`: I see the drop reason constants are replaced, but the use of the new return value seems safe; assigning `reason = __iptunnel_pull_header(...)` and the `if (reason)` check appears fine. No uninitialized variables here. * `include/net/dropreason-core.h`, `include/net/gre.h`, `include/net/ip6_tunnel.h`, `include/net/ip_tunnels.h`: Mostly just enum definitions and function prototype changes, nothing that jumps out as problematic in terms of uninitialized memory. * `net/ipv4/gre_demux.c`: This one needs a closer look. In `gre_parse_header`, a `reason` variable is declared, then initialized before being used. This looks fine. The same is in `gre_rcv`. I see a `reason` variable declared, and then initialized with the result of `pskb_may_pull_reason()`. There's also `reason = SKB_DROP_REASON_TUNNEL_INVALID_HDR`. Crucially, before any `goto drop`, `reason` is always set. And even if not, the `reason ?: SKB_DROP_REASON_NOT_SPECIFIED` handles the case where `reason` is zero. I have to verify where `gre_rcv` jumps to `drop`, let's check for any other `goto drop` calls. Nope, only two paths, and in both the reason variable is always initialized. I think we're safe. So far, from my initial assessment, this patch doesn't appear to introduce any uninitialized memory risks. But I'll need to double check to make sure my scan was thorough! |
| 64/3 | 2026/10/01 19:31 | tool | read-file |
0mArgs:{
"File": "net/ipv4/gre_demux.c",
"FirstLine": 160,
"LineCount": 45
}Results: {
"Contents": " 160:\t\t}\n 161:\t\n 162:\t\treturn SKB_NOT_DROPPED_YET;\n 163:\t}\n 164:\tEXPORT_SYMBOL(gre_parse_header);\n 165:\t\n 166:\tstatic int gre_rcv(struct sk_buff *skb)\n 167:\t{\n 168:\t\tconst struct gre_protocol *proto;\n 169:\t\tenum skb_drop_reason reason;\n 170:\t\tu8 ver;\n 171:\t\tint ret;\n 172:\t\n 173:\t\treason = pskb_may_pull_reason(skb, 12);\n 174:\t\tif (reason)\n 175:\t\t\tgoto drop;\n 176:\t\n 177:\t\tver = skb-\u003edata[1]\u00260x7f;\n 178:\t\tif (ver \u003e= GREPROTO_MAX) {\n 179:\t\t\treason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;\n 180:\t\t\tgoto drop;\n 181:\t\t}\n 182:\t\n 183:\t\trcu_read_lock();\n 184:\t\tproto = rcu_dereference(gre_proto[ver]);\n 185:\t\tif (!proto || !proto-\u003ehandler)\n 186:\t\t\tgoto drop_nohandler;\n 187:\t\tret = proto-\u003ehandler(skb);\n 188:\t\trcu_read_unlock();\n 189:\t\treturn ret;\n 190:\t\n 191:\tdrop_nohandler:\n 192:\t\trcu_read_unlock();\n 193:\t\tdev_core_stats_rx_nohandler_inc(skb-\u003edev);\n 194:\t\tkfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);\n 195:\t\treturn NET_RX_DROP;\n 196:\tdrop:\n 197:\t\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n 198:\t\tdev_core_stats_rx_dropped_inc(skb-\u003edev);\n 199:\t\tkfree_skb_reason(skb, reason);\n 200:\t\treturn NET_RX_DROP;\n 201:\t}\n 202:\t\n 203:\tstatic int gre_err(struct sk_buff *skb, u32 info)\n 204:\t{\n"
} |
| 65/3 | 2026/10/01 19:31 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44221 output: 38 thoughts: 758 Thoughts: **Analyzing SKB Drop Reasons in GRE/ERSPAN Code** Okay, let's break this down. In `gre_rcv`, the `reason` for a potential `drop` is always assigned before a `goto drop`, specifically when `pskb_may_pull_reason` returns non-zero, or when `ver >= GREPROTO_MAX`. So, initialization of `reason` is never skipped. Good. Now, let's shift focus to `net/ipv4/ip_gre.c`. First, in `gre_err`, it looks like `gre_parse_header` is responsible for populating `tpi`. If that function returns zero, `tpi` is populated. Otherwise, the function exits, similar to prior behavior. Then, moving on to `erspan_rcv`, `__ipgre_rcv`, and `gre_rcv` in `ip_gre.c`: they all explicitly initialize `reason` to `SKB_DROP_REASON_NOT_SPECIFIED` before doing anything. The `reason` is then potentially updated by some other function and, if not, the original initialization remains in effect. `kfree_skb_reason` is then called. Now, let's look at `ipgre_rcv`. `reason` here is declared but not initialized, then assigned the result of `__ipgre_rcv`. In the subsequent `if` statement, `reason` is checked against `SKB_DROP_REASON_TUNNEL_NOT_FOUND`. For `gre_fb_xmit` and `erspan_fb_xmit`, `reason` is initialized to `SKB_DROP_REASON_NOT_SPECIFIED` before being potentially used in `kfree_skb_reason`. Finally, regarding `ipgre_xmit`, a `reason` is assigned, specifically calling `pskb_inet_may_pull_reason(skb)`. There is a `free_skb` label, and I need to check the control paths to this label. I need to review lines 650-730 in `net/ipv4/ip_gre.c` to fully understand that logic. |
| 66/3 | 2026/10/01 19:31 | tool | read-file |
0mArgs:{
"File": "net/ipv4/ip_gre.c",
"FirstLine": 650,
"LineCount": 85
}Results: {
"Contents": " 650:\t\tip_md_tunnel_xmit(skb, dev, IPPROTO_GRE, tunnel_hlen);\n 651:\t\n 652:\t\treturn;\n 653:\t\n 654:\terr_free_skb:\n 655:\t\tkfree_skb_reason(skb, reason);\n 656:\t\tDEV_STATS_INC(dev, tx_dropped);\n 657:\t}\n 658:\t\n 659:\tstatic int gre_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb)\n 660:\t{\n 661:\t\tstruct ip_tunnel_info *info = skb_tunnel_info(skb);\n 662:\t\tconst struct ip_tunnel_key *key;\n 663:\t\tstruct rtable *rt;\n 664:\t\tstruct flowi4 fl4;\n 665:\t\n 666:\t\tif (ip_tunnel_info_af(info) != AF_INET)\n 667:\t\t\treturn -EINVAL;\n 668:\t\n 669:\t\tkey = \u0026info-\u003ekey;\n 670:\t\tip_tunnel_init_flow(\u0026fl4, IPPROTO_GRE, key-\u003eu.ipv4.dst, key-\u003eu.ipv4.src,\n 671:\t\t\t\t tunnel_id_to_key32(key-\u003etun_id),\n 672:\t\t\t\t key-\u003etos \u0026 ~INET_ECN_MASK, dev_net(dev), 0,\n 673:\t\t\t\t skb-\u003emark, skb_get_hash(skb), key-\u003eflow_flags);\n 674:\t\trt = ip_route_output_key(dev_net(dev), \u0026fl4);\n 675:\t\tif (IS_ERR(rt))\n 676:\t\t\treturn PTR_ERR(rt);\n 677:\t\n 678:\t\tip_rt_put(rt);\n 679:\t\tinfo-\u003ekey.u.ipv4.src = fl4.saddr;\n 680:\t\treturn 0;\n 681:\t}\n 682:\t\n 683:\tstatic netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n 684:\t\t\t\t struct net_device *dev)\n 685:\t{\n 686:\t\tstruct ip_tunnel *tunnel = netdev_priv(dev);\n 687:\t\tIP_TUNNEL_DECLARE_FLAGS(flags);\n 688:\t\tconst struct iphdr *tnl_params;\n 689:\t\tenum skb_drop_reason reason;\n 690:\t\n 691:\t\treason = pskb_inet_may_pull_reason(skb);\n 692:\t\tif (reason)\n 693:\t\t\tgoto free_skb;\n 694:\t\n 695:\t\tif (tunnel-\u003ecollect_md) {\n 696:\t\t\tgre_fb_xmit(skb, dev, skb-\u003eprotocol);\n 697:\t\t\treturn NETDEV_TX_OK;\n 698:\t\t}\n 699:\t\n 700:\t\tif (dev-\u003eheader_ops) {\n 701:\t\t\tint pull_len = tunnel-\u003ehlen + sizeof(struct iphdr);\n 702:\t\n 703:\t\t\tif (skb_cow_head(skb, 0)) {\n 704:\t\t\t\treason = SKB_DROP_REASON_NOMEM;\n 705:\t\t\t\tgoto free_skb;\n 706:\t\t\t}\n 707:\t\n 708:\t\t\treason = pskb_may_pull_reason(skb, pull_len);\n 709:\t\t\tif (reason)\n 710:\t\t\t\tgoto free_skb;\n 711:\t\n 712:\t\t\ttnl_params = (const struct iphdr *)skb-\u003edata;\n 713:\t\n 714:\t\t\t/* ip_tunnel_xmit() needs skb-\u003edata pointing to gre header. */\n 715:\t\t\tskb_pull(skb, pull_len);\n 716:\t\t\tskb_reset_mac_header(skb);\n 717:\t\n 718:\t\t\tif (skb-\u003eip_summed == CHECKSUM_PARTIAL \u0026\u0026\n 719:\t\t\t skb_checksum_start(skb) \u003c skb-\u003edata) {\n 720:\t\t\t\treason = SKB_DROP_REASON_SKB_CSUM;\n 721:\t\t\t\tgoto free_skb;\n 722:\t\t\t}\n 723:\t\t} else {\n 724:\t\t\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n 725:\t\t\t\treason = SKB_DROP_REASON_NOMEM;\n 726:\t\t\t\tgoto free_skb;\n 727:\t\t\t}\n 728:\t\n 729:\t\t\ttnl_params = \u0026tunnel-\u003eparms.iph;\n 730:\t\t}\n 731:\t\n 732:\t\tip_tunnel_flags_copy(flags, tunnel-\u003eparms.o_flags);\n 733:\t\n 734:\t\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {\n"
} |
| 67/3 | 2026/10/01 19:31 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46859 output: 38 thoughts: 15 Thoughts: Okay, here's my interpretation of that request, formatted as requested: **Navigating the Code - A Targeted Review** Alright, I'm diving back into this code. To make sure I haven't missed anything crucial, I'm thinking I need to circle back to lines 735-750. I want to zero in on that specific section because my gut tells me there might be something subtle lurking there, a potential edge case that I initially glossed over or a detail that needs a second, more critical look in light of the bigger picture. It's a targeted review to ensure nothing slipped past. Let's see what we find. |
| 68/3 | 2026/10/01 19:31 | tool | read-file |
0mArgs:{
"File": "net/ipv4/ip_gre.c",
"FirstLine": 735,
"LineCount": 20
}Results: {
"Contents": " 735:\t\t\treason = SKB_DROP_REASON_NOMEM;\n 736:\t\t\tgoto free_skb;\n 737:\t\t}\n 738:\t\n 739:\t\t__gre_xmit(skb, dev, tnl_params, skb-\u003eprotocol, flags);\n 740:\t\treturn NETDEV_TX_OK;\n 741:\t\n 742:\tfree_skb:\n 743:\t\treason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;\n 744:\t\tkfree_skb_reason(skb, reason);\n 745:\t\tDEV_STATS_INC(dev, tx_dropped);\n 746:\t\treturn NETDEV_TX_OK;\n 747:\t}\n 748:\t\n 749:\tstatic netdev_tx_t erspan_xmit(struct sk_buff *skb,\n 750:\t\t\t\t struct net_device *dev)\n 751:\t{\n 752:\t\tstruct ip_tunnel *tunnel = netdev_priv(dev);\n 753:\t\tIP_TUNNEL_DECLARE_FLAGS(flags);\n 754:\t\tenum skb_drop_reason reason;\n"
} |
| 69/3 | 2026/10/01 19:31 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 47376 output: 39 thoughts: 763 Thoughts: **Analyzing SKB Drop Reasons in IP Tunneling** Okay, so I'm looking at how `skb_drop_reason` is used throughout the IP tunneling code. I'm noticing a pattern: every `goto free_skb` in `ipgre_xmit`, and similarly in `erspan_xmit` and `gre_tap_xmit`, seems to have the `reason` variable set right before the jump. That's a good starting point. Now, let's dive into the specifics, starting with `net/ipv4/ip_tunnel.c`. In `ip_tunnel_rcv`, `ip_md_tunnel_xmit`, and `ip_tunnel_xmit`, I see `enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;` initialized, and then the drop sites *explicitly* setting the `reason` variable before jumping to their respective drop labels (`drop`, `tx_error`, or `tx_dropped`). That's clean. Moving on to `net/ipv4/ip_tunnel_core.c`, things get a bit more interesting. In `__iptunnel_pull_header`, it's returning either `SKB_NOT_DROPPED_YET` on success or a drop reason directly. This seems straightforward. Then there's `iptunnel_pull_offloads(skb)` which, if it fails, returns `SKB_DROP_REASON_NOMEM`. Simple. Now to the IPv6 side, specifically `net/ipv6/ip6_gre.c`. In `ip6gre_err`, `gre_parse_header` is called with `true` for `ignore_csum_err`, and the return value is checked. In `ip6gre_rcv` and `ip6erspan_rcv`, the functions are returning a drop reason or `SKB_NOT_DROPPED_YET`. The `gre_rcv` function is the most complex. It initializes a `reason` variable, calls `gre_parse_header` and `iptunnel_pull_header`, and checks their return values. This seems to be the pattern: the called function returns the drop reason, which is then handled. It also calls `erspan_rcv` and `ip6gre_rcv`, with similar logic. Finally, `icmpv6_send` and `kfree_skb_reason` are called. Importantly, the `reason` is checked and defaults to `SKB_DROP_REASON_NOT_SPECIFIED` if not set, before the `dev_core_stats_rx_dropped_inc` and `kfree_skb_reason` calls. Finally, `prepare_ip6gre_xmit_other`'s return type changed to `void`, but that's not a major issue here. More importantly, it looks like `__gre6_xmit` now returns an `enum skb_drop_reason` instead of a `netdev_tx_t`, so I should probably verify how that's used. Let me go check line 790 in `net/ipv6/ip6_gre.c` and a few lines around it to be sure. |
| 70/3 | 2026/10/01 19:31 | tool | read-file |
0mArgs:{
"File": "net/ipv6/ip6_gre.c",
"FirstLine": 780,
"LineCount": 20
}Results: {
"Contents": " 780:\t\t\tip_tunnel_flags_copy(flags, tunnel-\u003eparms.o_flags);\n 781:\t\n 782:\t\t\tgre_build_header(skb, tunnel-\u003etun_hlen, flags,\n 783:\t\t\t\t\t protocol, tunnel-\u003eparms.o_key,\n 784:\t\t\t\t\t test_bit(IP_TUNNEL_SEQ_BIT, flags) ?\n 785:\t\t\t\t\t htonl(atomic_fetch_inc(\u0026tunnel-\u003eo_seqno)) :\n 786:\t\t\t\t\t 0);\n 787:\t\t}\n 788:\t\n 789:\t\treturn ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,\n 790:\t\t\t\t NEXTHDR_GRE);\n 791:\t}\n 792:\t\n 793:\tstatic inline enum skb_drop_reason ip6gre_xmit_ipv4(struct sk_buff *skb,\n 794:\t\t\t\t\t\t\t struct net_device *dev)\n 795:\t{\n 796:\t\tstruct ip6_tnl *t = netdev_priv(dev);\n 797:\t\tenum skb_drop_reason reason;\n 798:\t\tint encap_limit = -1;\n 799:\t\tstruct flowi6 fl6;\n"
} |
| 71/3 | 2026/10/01 19:31 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49236 output: 23 thoughts: 1173 Thoughts: **Analyzing skb_drop_reason Usage in IPv6 Tunneling** Okay, so `__gre6_xmit` calls `ip6_tnl_xmit`, which, importantly, returns an `enum skb_drop_reason`. That's the starting point. I need to trace how this value is used and propagated. Let's see what we've got. First, I looked at `ip6_tnl_xmit` in `net/ipv6/ip6_tunnel.c`. The pattern is clear: a `reason` variable, initialized to `SKB_DROP_REASON_NOT_SPECIFIED`. The success path, unsurprisingly, returns `SKB_NOT_DROPPED_YET` (which is zero), and the error paths all return the `reason` variable, already set to the drop reason. Good. Predictable behavior. Next, I jumped into `ip6gre_tunnel_xmit` in `net/ipv6/ip6_gre.c`. Here, `reason` is also initialized, and, crucially, *every* path that leads to `tx_err` sets `reason` to a specific value or sets it to the default if there isn't a specific reason, so there's no way to end up with an uninitialized or indeterminate value. `reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;` acts as a guard against that. This confirms the pattern I expected. Every error case updates the `reason` variable, which is then used in `kfree_skb_reason`. Just to be thorough, I examined `ip6erspan_tunnel_xmit` in the same file. It also follows the same good practice: `reason` is initialized or set at every `goto tx_err;`. Great consistency. To get a complete view, I went back to `net/ipv6/ip6_tunnel.c` and looked at a few other functions, including `__ip6_tnl_rcv`, `ipxip6_rcv`, and `ipxip6_tnl_xmit`. In `__ip6_tnl_rcv` and `ipxip6_rcv`, the drop path ensures the `reason` variable is set correctly with a similar `reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED;` assignment. In `ip6_tnl_xmit`, and `ipxip6_tnl_xmit`, the error paths all set `reason` or return `SKB_NOT_DROPPED_YET`, so the pattern is consistent. It looks like the same reasoning has been used for consistency in `ip6_tnl_start_xmit`. Finally, to be really sure, I need to check where else `ip6_tnl_xmit` is *called*. That's my next step. I've only looked at the tunnel transmit and receive functions but I would like to know if there are any other usages of `ip6_tnl_xmit`. |
| 72/3 | 2026/10/01 19:31 | 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=720=static enum skb_drop_reason __gre6_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-788-\nnet/ipv6/ip6_gre.c:789:\treturn ip6_tnl_xmit(skb, dev, dsfield, fl6, encap_limit, pmtu,\nnet/ipv6/ip6_gre.c-790-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_gre.c=942=static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-1114-\t}\nnet/ipv6/ip6_gre.c:1115:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_gre.c-1116-\t\t\t NEXTHDR_GRE);\n--\nnet/ipv6/ip6_tunnel.c=1123=enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1124:ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev, __u8 dsfield,\nnet/ipv6/ip6_tunnel.c-1125-\t struct flowi6 *fl6, int encap_limit, __u32 *pmtu, __u8 proto)\n--\nnet/ipv6/ip6_tunnel.c=1340=static inline enum skb_drop_reason\nnet/ipv6/ip6_tunnel.c:1341:ipxip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev,\nnet/ipv6/ip6_tunnel.c-1342-\t\tu8 protocol)\n--\nnet/ipv6/ip6_tunnel.c-1448-\nnet/ipv6/ip6_tunnel.c:1449:\treason = ip6_tnl_xmit(skb, dev, dsfield, \u0026fl6, encap_limit, \u0026mtu,\nnet/ipv6/ip6_tunnel.c-1450-\t\t\t protocol);\n--\nnet/ipv6/ip6_tunnel.c=1472=ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n--\nnet/ipv6/ip6_tunnel.c-1500-\nnet/ipv6/ip6_tunnel.c:1501:\treason = ipxip6_tnl_xmit(skb, dev, ipproto);\nnet/ipv6/ip6_tunnel.c-1502-\tif (reason)\n"
} |
| 73/3 | 2026/10/01 19:31 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 51938 output: 32 thoughts: 337 Thoughts: **My Assessment of the `ip6_tnl_xmit` Conversion** Okay, so all the callers of `ip6_tnl_xmit` are accounted for and converted. Now, the crucial part: I need to ensure this doesn't introduce any vulnerabilities or regressions. Let's see... am I introducing any struct paddings, uninitialized variables, or potential info-leaks? It looks like no new structs are being allocated or copied to user space, which is good. Also, no structs are being copied across the user boundary, so that's another check in the "no harm" column. The change centers around refactoring error handling. The existing implementation used generic `kfree_skb()` or negative error integers. This patch is moving towards a more granular approach, returning detailed drop reasons (`enum skb_drop_reason`) to `kfree_skb_reason(...)`. That's smart; those drop reasons feed into `kfree_skb` tracepoints and tools like dropwatch and perf, giving us much better visibility. What about uninitialized data? It seems there's nothing copied uninitialized to userspace, which is a key security concern. The modified/added variables are all local `enum skb_drop_reason reason` variables. They're assigned values from helper functions like `pskb_may_pull_reason` or constants, and there's a fallback check using `reason ?: SKB_DROP_REASON_NOT_SPECIFIED`. Good, it's covered. So far, so good – none of them read uninitialized memory. Moreover, all the length calculations and bounds checks are staying untouched. That means I haven't altered any critical logic in a way that could allow uninitialized memory to be read. Specifically, the `pskb_may_pull_reason(skb, len)` implementation mirrors `pskb_may_pull(skb, len)`, returning the appropriate `SKB_DROP_REASON` instead of boolean. This keeps functionality the same, yet supplies the better information. Let's dig into that `pskb_may_pull_reason` implementation further, though... just to be completely sure. |
| 74/3 | 2026/10/01 19:31 | tool | grepper |
0mError:no matches Args: {
"Expression": "static inline enum skb_drop_reason pskb_may_pull_reason"
}Results: {
"error": "no matches"
} |
| 75/3 | 2026/10/01 19:31 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 52785 output: 22 thoughts: 14 Thoughts: Okay, here's my summary, tailored for an expert audience, as if I'm thinking these things myself: **Diving into the `pskb_may_pull_reason` Function** Alright, let's get down to brass tacks. I need to understand what's driving this decision. Let's find this `pskb_may_pull_reason` function. I'm assuming it's key to the logic for whatever component I'm investigating, most likely network related, given the probable context. I need to figure out the factors that influence the determination of whether a packet can be "pulled" or not. Are we talking about a check on the SKB itself, a hardware resource issue, a congestion flag, or something else entirely? The name suggests some sort of "reasoning" is involved, so it's probably not a simple boolean. This function is likely the crux of the efficiency, security, or error handling around data transfer. Time to dig in and see what's what. |
| 76/3 | 2026/10/01 19:31 | tool | grepper |
0mArgs:{
"Expression": "pskb_may_pull_reason"
}Results: {
"Output": "drivers/net/vxlan/vxlan_core.c=1565=static enum skb_drop_reason vxlan_remcsum(struct sk_buff *skb, u32 vxflags)\n--\ndrivers/net/vxlan/vxlan_core.c-1576-\ndrivers/net/vxlan/vxlan_core.c:1577:\treason = pskb_may_pull_reason(skb, offset + sizeof(u16));\ndrivers/net/vxlan/vxlan_core.c-1578-\tif (reason)\n--\ndrivers/net/vxlan/vxlan_core.c=1675=static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/vxlan/vxlan_core.c-1693-\t/* Need UDP and VXLAN header to be present */\ndrivers/net/vxlan/vxlan_core.c:1694:\treason = pskb_may_pull_reason(skb, VXLAN_HLEN);\ndrivers/net/vxlan/vxlan_core.c-1695-\tif (reason)\n--\ninclude/linux/skbuff.h=2844=static __always_inline enum skb_drop_reason\ninclude/linux/skbuff.h:2845:pskb_may_pull_reason(struct sk_buff *skb, unsigned int len)\ninclude/linux/skbuff.h-2846-{\n--\ninclude/linux/skbuff.h=2863=pskb_may_pull(struct sk_buff *skb, unsigned int len)\ninclude/linux/skbuff.h-2864-{\ninclude/linux/skbuff.h:2865:\treturn pskb_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET;\ninclude/linux/skbuff.h-2866-}\n--\ninclude/linux/skbuff.h=3275=pskb_network_may_pull_reason(struct sk_buff *skb, unsigned int len)\ninclude/linux/skbuff.h-3276-{\ninclude/linux/skbuff.h:3277:\treturn pskb_may_pull_reason(skb, skb_network_offset(skb) + len);\ninclude/linux/skbuff.h-3278-}\n--\ninclude/net/ip_tunnels.h=490=skb_vlan_inet_prepare(struct sk_buff *skb, bool inner_proto_inherit)\n--\ninclude/net/ip_tunnels.h-514-\t */\ninclude/net/ip_tunnels.h:515:\treason = pskb_may_pull_reason(skb, maclen + nhlen);\ninclude/net/ip_tunnels.h-516-\tif (reason)\n--\nnet/bridge/br_device.c=30=netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)\nnet/bridge/br_device.c-31-{\nnet/bridge/br_device.c:32:\tenum skb_drop_reason reason = pskb_may_pull_reason(skb, ETH_HLEN);\nnet/bridge/br_device.c-33-\tstruct net_bridge_mcast_port *pmctx_null = NULL;\n--\nnet/core/filter.c=1681=static inline int __bpf_try_make_writable(struct sk_buff *skb,\n--\nnet/core/filter.c-1684-#ifdef CONFIG_DEBUG_NET\nnet/core/filter.c:1685:\t/* Avoid a splat in pskb_may_pull_reason() */\nnet/core/filter.c-1686-\tif (write_len \u003e INT_MAX)\n--\nnet/ipv4/arp.c=970=static int arp_rcv(struct sk_buff *skb, struct net_device *dev,\n--\nnet/ipv4/arp.c-986-\t/* ARP header, plus 2 device addresses, plus 2 IP addresses. */\nnet/ipv4/arp.c:987:\tdrop_reason = pskb_may_pull_reason(skb, arp_hdr_len(dev));\nnet/ipv4/arp.c-988-\tif (drop_reason != SKB_NOT_DROPPED_YET)\n--\nnet/ipv4/gre_demux.c=78=gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n--\nnet/ipv4/gre_demux.c-85-\nnet/ipv4/gre_demux.c:86:\treason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));\nnet/ipv4/gre_demux.c-87-\tif (unlikely(reason))\n--\nnet/ipv4/gre_demux.c-96-\nnet/ipv4/gre_demux.c:97:\treason = pskb_may_pull_reason(skb, nhs + hdr_len);\nnet/ipv4/gre_demux.c-98-\tif (reason)\n--\nnet/ipv4/gre_demux.c-152-\nnet/ipv4/gre_demux.c:153:\t\treason = pskb_may_pull_reason(skb,\nnet/ipv4/gre_demux.c-154-\t\t\t\t\t nhs + hdr_len + sizeof(*ershdr));\n--\nnet/ipv4/gre_demux.c=166=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv4/gre_demux.c-172-\nnet/ipv4/gre_demux.c:173:\treason = pskb_may_pull_reason(skb, 12);\nnet/ipv4/gre_demux.c-174-\tif (reason)\n--\nnet/ipv4/ip_gre.c=267=static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-292-\t} else {\nnet/ipv4/ip_gre.c:293:\t\treason = pskb_may_pull_reason(skb,\nnet/ipv4/ip_gre.c-294-\t\t\t\t\t gre_hdr_len + sizeof(*ershdr));\n--\nnet/ipv4/ip_gre.c-311-\nnet/ipv4/ip_gre.c:312:\t\treason = pskb_may_pull_reason(skb, len);\nnet/ipv4/ip_gre.c-313-\t\tif (unlikely(reason))\n--\nnet/ipv4/ip_gre.c=683=static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-707-\nnet/ipv4/ip_gre.c:708:\t\treason = pskb_may_pull_reason(skb, pull_len);\nnet/ipv4/ip_gre.c-709-\t\tif (reason)\n--\nnet/ipv4/ip_tunnel_core.c=110=__iptunnel_pull_header(struct sk_buff *skb, int hdr_len,\n--\nnet/ipv4/ip_tunnel_core.c-114-\nnet/ipv4/ip_tunnel_core.c:115:\treason = pskb_may_pull_reason(skb, hdr_len);\nnet/ipv4/ip_tunnel_core.c-116-\tif (unlikely(reason))\n--\nnet/ipv4/ip_tunnel_core.c-123-\nnet/ipv4/ip_tunnel_core.c:124:\t\treason = pskb_may_pull_reason(skb, ETH_HLEN);\nnet/ipv4/ip_tunnel_core.c-125-\t\tif (unlikely(reason))\n--\nnet/ipv6/icmp.c=1037=enum skb_drop_reason icmpv6_notify(struct sk_buff *skb, u8 type,\n--\nnet/ipv6/icmp.c-1047-\nnet/ipv6/icmp.c:1048:\treason = pskb_may_pull_reason(skb, sizeof(struct ipv6hdr));\nnet/ipv6/icmp.c-1049-\tif (reason != SKB_NOT_DROPPED_YET)\n--\nnet/ipv6/icmp.c-1067-\t/* Checkin header including 8 bytes of inner protocol header. */\nnet/ipv6/icmp.c:1068:\treason = pskb_may_pull_reason(skb, inner_offset + 8);\nnet/ipv6/icmp.c-1069-\tif (reason != SKB_NOT_DROPPED_YET)\n--\nnet/ipv6/ip6_gre.c=488=static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-498-\nnet/ipv6/ip6_gre.c:499:\treason = pskb_may_pull_reason(skb, sizeof(*ershdr));\nnet/ipv6/ip6_gre.c-500-\tif (unlikely(reason))\n--\nnet/ipv6/ip6_gre.c-512-\nnet/ipv6/ip6_gre.c:513:\t\treason = pskb_may_pull_reason(skb, len);\nnet/ipv6/ip6_gre.c-514-\t\tif (unlikely(reason))\n--\nnet/ipv6/ip6_tunnel.c=808=static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n--\nnet/ipv6/ip6_tunnel.c-848-\tif (tunnel-\u003edev-\u003etype == ARPHRD_ETHER) {\nnet/ipv6/ip6_tunnel.c:849:\t\treason = pskb_may_pull_reason(skb, ETH_HLEN);\nnet/ipv6/ip6_tunnel.c-850-\t\tif (reason) {\n"
} |
| 77/3 | 2026/10/01 19:31 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 55658 output: 24 thoughts: 101 Thoughts: **Analyzing Packet Pulling Logic** Okay, so I'm looking at this code and immediately see something interesting. It looks like the change from `pskb_may_pull(skb, len)` to `pskb_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET` is essentially just a refactoring. Functionally, they're doing the *exact* same thing, but in a slightly different manner. The old method, just evaluated if the pull *could* happen. The new method gives some more information on *why* it can, or cannot. So, `reason = pskb_may_pull_reason(...)` with the `if (reason)` construct, is equivalent to the negation of the old check, the way `if (!pskb_may_pull(...))` was written. Seems like a readability and potentially more informative change, though functionally equivalent. Now, let's take a look at how this impacts the `pskb_inet_may_pull_reason` function, and how the reason that a packet is not dropped can be surfaced more widely. |
| 78/3 | 2026/10/01 19:32 | tool | grepper |
0mArgs:{
"Expression": "pskb_inet_may_pull_reason"
}Results: {
"Output": "drivers/net/vxlan/vxlan_core.c=1675=static int vxlan_rcv(struct sock *sk, struct sk_buff *skb)\n--\ndrivers/net/vxlan/vxlan_core.c-1801-\ndrivers/net/vxlan/vxlan_core.c:1802:\treason = pskb_inet_may_pull_reason(skb);\ndrivers/net/vxlan/vxlan_core.c-1803-\tif (reason) {\n--\ninclude/net/ip_tunnels.h=461=static inline enum skb_drop_reason\ninclude/net/ip_tunnels.h:462:pskb_inet_may_pull_reason(struct sk_buff *skb)\ninclude/net/ip_tunnels.h-463-{\n--\ninclude/net/ip_tunnels.h=482=static inline bool pskb_inet_may_pull(struct sk_buff *skb)\ninclude/net/ip_tunnels.h-483-{\ninclude/net/ip_tunnels.h:484:\treturn pskb_inet_may_pull_reason(skb) == SKB_NOT_DROPPED_YET;\ninclude/net/ip_tunnels.h-485-}\n--\nnet/ipv4/ip_gre.c=683=static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-690-\nnet/ipv4/ip_gre.c:691:\treason = pskb_inet_may_pull_reason(skb);\nnet/ipv4/ip_gre.c-692-\tif (reason)\n--\nnet/ipv4/ip_gre.c=749=static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-757-\nnet/ipv4/ip_gre.c:758:\treason = pskb_inet_may_pull_reason(skb);\nnet/ipv4/ip_gre.c-759-\tif (reason)\n--\nnet/ipv4/ip_gre.c=817=static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-823-\nnet/ipv4/ip_gre.c:824:\treason = pskb_inet_may_pull_reason(skb);\nnet/ipv4/ip_gre.c-825-\tif (reason)\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-430-\nnet/ipv4/ip_tunnel.c:431:\treason = pskb_inet_may_pull_reason(skb);\nnet/ipv4/ip_tunnel.c-432-\tif (reason) {\n--\nnet/ipv6/ip6_gre.c=884=static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-891-\nnet/ipv6/ip6_gre.c:892:\treason = pskb_inet_may_pull_reason(skb);\nnet/ipv6/ip6_gre.c-893-\tif (reason)\n--\nnet/ipv6/ip6_gre.c=942=static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-957-\nnet/ipv6/ip6_gre.c:958:\treason = pskb_inet_may_pull_reason(skb);\nnet/ipv6/ip6_gre.c-959-\tif (reason)\n--\nnet/ipv6/ip6_tunnel.c=1472=ip6_tnl_start_xmit(struct sk_buff *skb, struct net_device *dev)\n--\nnet/ipv6/ip6_tunnel.c-1477-\nnet/ipv6/ip6_tunnel.c:1478:\treason = pskb_inet_may_pull_reason(skb);\nnet/ipv6/ip6_tunnel.c-1479-\tif (reason)\n"
} |
| 79/3 | 2026/10/01 19:32 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 57174 output: 23 thoughts: 97 Thoughts: Here's my analysis of the provided code snippet: **Diving into VLAN Preparation** Okay, so it looks like `pskb_inet_may_pull_reason(skb)` is functionally the same as `pskb_inet_may_pull(skb)`, which simplifies things slightly. Now, I'm trying to understand the control flow here, so I'm moving on to `skb_vlan_inet_prepare`. I see that `skb_vlan_inet_prepare(skb, true)` is called, and the result is assigned to `reason`. Aha, `reason` is then checked immediately after the call to `skb_vlan_inet_prepare`. So, the implication is that `skb_vlan_inet_prepare` likely returns some sort of error code or indication of a problem if the return value of `reason` is non-zero. Let's dig into `skb_vlan_inet_prepare` to see exactly what's happening. I need to understand what constitutes a valid `reason` return value. This is where the core logic resides, so let's see what it does. |
| 80/3 | 2026/10/01 19:32 | tool | grepper |
0mArgs:{
"Expression": "skb_vlan_inet_prepare"
}Results: {
"Output": "drivers/net/bareudp.c=302=static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/bareudp.c-317-\ndrivers/net/bareudp.c:318:\tif (skb_vlan_inet_prepare(skb, skb-\u003eprotocol != htons(ETH_P_TEB)))\ndrivers/net/bareudp.c-319-\t\treturn -EINVAL;\n--\ndrivers/net/bareudp.c=372=static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/bareudp.c-387-\ndrivers/net/bareudp.c:388:\tif (skb_vlan_inet_prepare(skb, skb-\u003eprotocol != htons(ETH_P_TEB)))\ndrivers/net/bareudp.c-389-\t\treturn -EINVAL;\n--\ndrivers/net/geneve.c=1382=static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/geneve.c-1396-\ndrivers/net/geneve.c:1397:\tif (skb_vlan_inet_prepare(skb, cfg-\u003einner_proto_inherit))\ndrivers/net/geneve.c-1398-\t\treturn -EINVAL;\n--\ndrivers/net/geneve.c=1501=static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/geneve.c-1514-\ndrivers/net/geneve.c:1515:\tif (skb_vlan_inet_prepare(skb, cfg-\u003einner_proto_inherit))\ndrivers/net/geneve.c-1516-\t\treturn -EINVAL;\n--\ndrivers/net/vxlan/vxlan_core.c=2403=void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/vxlan/vxlan_core.c-2434-\tno_eth_encap = flags \u0026 VXLAN_F_GPE \u0026\u0026 skb-\u003eprotocol != htons(ETH_P_TEB);\ndrivers/net/vxlan/vxlan_core.c:2435:\treason = skb_vlan_inet_prepare(skb, no_eth_encap);\ndrivers/net/vxlan/vxlan_core.c-2436-\tif (reason)\n--\ninclude/net/ip_tunnels.h=489=static inline enum skb_drop_reason\ninclude/net/ip_tunnels.h:490:skb_vlan_inet_prepare(struct sk_buff *skb, bool inner_proto_inherit)\ninclude/net/ip_tunnels.h-491-{\n--\nnet/ipv6/ip6_tunnel.c=808=static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n--\nnet/ipv6/ip6_tunnel.c-870-\nnet/ipv6/ip6_tunnel.c:871:\treason = skb_vlan_inet_prepare(skb, true);\nnet/ipv6/ip6_tunnel.c-872-\tif (reason) {\n"
} |
| 81/3 | 2026/10/01 19:32 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 58418 output: 249 thoughts: 616 Thoughts: **My Analysis of the Packet Drop Reason Refactoring Patch** Okay, here's what I've got after reviewing this patch. It's a refactor, plain and simple. The key change is that the `skb_vlan_inet_prepare` function now returns an `enum skb_drop_reason`, which is then correctly used to inform the `kfree_skb_reason` function. Previously, if that function returned a value at all, it was a default and not very useful. This patch updates a few other functions, such as `__iptunnel_pull_header`, `gre_parse_header`, and `ip6_tnl_xmit`, to also correctly return the `skb_drop_reason` enum. This is a solid move towards more informative debugging and error tracking across the network stack, particularly for tunnel implementations like VXLAN, GRE, ERSPAN, and SIT/IPIP. Now, let's think about the security implications, specifically in the context of KASAN versus KMSAN. KMSAN is the one that really flags memory leaks. This is my assessment: this patch isn't introducing any new uninitialized memory issues. No new structs are being allocated with uninitialized fields. There are no changes to any logic that copies memory to user space that could lead to leaks. No bounds calculations look like they're being changed to expose uninitialized data. The patch's primary function is to pass specific error codes around, not to create or manipulate memory. All new local variables are clearly initialized or assigned values before they're used in any conditional logic. Basically, I'm confident that this doesn't need KMSAN specifically. Any potential bugs related to uninitialized variables or type mismatches should be caught by standard build checks, compiler warnings (`-Wmaybe-uninitialized`, `-Werror`), and the regular KASAN testing. So, I'm comfortable saying that KMSAN fuzzing isn't justified here, and we can rely on existing checks. |
| 82/3 | 2026/10/01 19:32 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series refactors network tunnel implementations (VXLAN, GRE, ERSPAN, and IPv6 tunnels) to propagate specific drop reasons (enum skb_drop_reason) to kfree_skb_reason() instead of using generic drops or negative error codes.\n\nKMSAN is specialized for detecting reads of uninitialized memory (stack, heap, page allocations) and information leaks to user space. The changes in this patch:\n1. Do not copy any kernel data or struct padding to user space.\n2. Do not introduce any new dynamic or stack allocations that could remain uninitialized.\n3. Only introduce and manipulate scalar local variables (`enum skb_drop_reason reason`) which are explicitly initialized or assigned before use on all code paths.\n4. Do not alter buffer bounds, packet length calculations, or offset handling in any way that would expose uninitialized bytes.\n\nBecause there is no risk of uninitialized memory use or kernel-to-user info-leaks, dedicated KMSAN fuzzing is not warranted; standard KASAN and compiler diagnostics are sufficient.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series refactors network tunnel implementations (VXLAN, GRE, ERSPAN, and IPv6 tunnels) to propagate specific drop reasons (enum skb_drop_reason) to kfree_skb_reason() instead of using generic drops or negative error codes.\n\nKMSAN is specialized for detecting reads of uninitialized memory (stack, heap, page allocations) and information leaks to user space. The changes in this patch:\n1. Do not copy any kernel data or struct padding to user space.\n2. Do not introduce any new dynamic or stack allocations that could remain uninitialized.\n3. Only introduce and manipulate scalar local variables (`enum skb_drop_reason reason`) which are explicitly initialized or assigned before use on all code paths.\n4. Do not alter buffer bounds, packet length calculations, or offset handling in any way that would expose uninitialized bytes.\n\nBecause there is no risk of uninitialized memory use or kernel-to-user info-leaks, dedicated KMSAN fuzzing is not warranted; standard KASAN and compiler diagnostics are sufficient.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|