Article View: linux.kernel.netdev
Article #18107[PATCH net-next v7 1/8] ip_tunnel: add drop reasons to the generic RX path
From: Anton Danilov
Date: Tue, 17 Nov 2026 21:18
Date: Tue, 17 Nov 2026 21:18
123 lines
15500 bytes
15500 bytes
ip_tunnel_rcv() frees every rejected packet at the same call site.
Report the failing check through skb:kfree_skb and drop_monitor while
keeping the existing device error counters.
Use TUNNEL_OPT_MISMATCH when the checksum option differs from the
tunnel configuration in either direction, or a required sequence
number is missing. GRE checksum validation happens earlier. Use
TUNNEL_OLD_SEQ for a sequence number below the expected value. A
reordered packet or a peer that restarts its sequence numbering can
trigger this check.
Propagate the reason from pskb_inet_may_pull_reason() and report ECN
decapsulation failures as IP_TUNNEL_ECN.
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Anton Danilov <littlesmilingcloud@gmail.com>
---
include/net/dropreason-core.h | 17 +++++++++++++++++
net/ipv4/ip_tunnel.c | 19 +++++++++++++++----
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 27bc63cbc020..03c6f6aa1510 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -129,6 +129,8 @@
FN(PSP_INPUT) \
FN(PSP_OUTPUT) \
FN(RECURSION_LIMIT) \
+ FN(TUNNEL_OPT_MISMATCH) \
+ FN(TUNNEL_OLD_SEQ) \
FNe(MAX)
/**
@@ -618,6 +620,21 @@ enum skb_drop_reason {
* 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. the packet
+ * was reordered in the network or by the receive processing, or the
+ * remote endpoint restarted and reset its sequence numbering.
+ */
+ SKB_DROP_REASON_TUNNEL_OLD_SEQ,
/**
* @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/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 0875474a578a..7d8744ed1664 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;
}
}
@@ -457,7 +468,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
drop:
if (tun_dst)
dst_release((struct dst_entry *)tun_dst);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
return 0;
}
EXPORT_SYMBOL_GPL(ip_tunnel_rcv);
--
2.47.3
Technical Details
Message-ID:
<20261117211853.3733250-2-littlesmilingcloud@gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365616-linux-kernel-netdev=dewy.ruReferences:
<20261117211853.3733250-1-littlesmilingcloud@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365616-linux-kernel-netdev=dewy.ru
From: littlesmilingcloud@gmail.com (Anton Danilov)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v7 1/8] ip_tunnel: add drop reasons to the generic RX path
Date: Wed, 18 Nov 2026 00:18:46 +0300
Organization: Usenet Network
Message-ID: <20261117211853.3733250-2-littlesmilingcloud@gmail.com>
References: <20261117211853.3733250-1-littlesmilingcloud@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2429811"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:aZB/RVC1odSwcsshU4+nX2wtpFM= sha256:QMThaQVn1prJSVuglL9gB4DGkklL1T39mbjINP9kwKQ=
sha1:vD6wMBysuBsK+eSx8Z0jL4X/LAs= sha256:nWYZHAzo/4ci9Xs4rQCx/AqPN3XraTaM9lFVRcPPhZk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id B730C11508F; Wed, 18 Nov 2026 00:19:24 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id lGPOHZyw8r9z;
Wed, 18 Nov 2026 00:19:21 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365616-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 782C011508B; Wed, 18 Nov 2026 00:19:12 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 78DB06183E; Tue, 17 Nov 2026 21:19:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794950339;
b=a/+0HG4NiTLjYG1uzJufQY/eUV4cZYbiMH7wdmKcfJrSHWhAAtc0YLQl1al57yq0Q98S
7HNt9H+TusRvcGxkjia5o+m6bnRdTTHwBhNp9QkX+npd2T4j0u2TlwNCfd/WHBAkqyk2f
LJGg0JCCUgumcRL1yM/PfaOuKIJztgPAehS06VL+/1NIxWKmvSg0F+/xKeldiBMA3jl0A
uFOTTfvWROJl2jXEdB3rmCkX/t4fcDBH6Cw7rz00CzfPj3DHXDip8Vo3DeZuqUNSTjC+3
uLRDHxG1HZGKts4Z/zc/OBVykG/c9lXJRj+QxhC9WtkrXfPqPudqSUPHaCC77HVq3PA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794950339;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=7wB6bRo3lbSsZaUMjbOvD2Y5uBp3Ggx5j0TCCZ4sIdQ=;
b=g0wlfm17vBHA6rsPPKJr8gXMpu7IVizCbBcepbffeLNBzS4WQdIIngsiPARAeGwdx79h
WmjfhTrJNVMOsJUVQr2ui5kj50oPyQUVnndhu3sWzW/aLgp+dqKdd5h6Zk3tg7hpLVrvb
iY8WXMswEzkg+dxaEAuzL3mAz6hjIFVmsVT+29gjPw+YSNEZECC203b500uLX0jfW8oF8
FCLkJc5KrDQNDzXfpPvYOUWZr2bYYS8k7nNr64bok36E9sbOoVWrhIWty8JYdyfI0fxDw
MROl4I09p7vC66dxw55dQnd1xx1Kj1v3Mg43u2zV13dEDrORF19KaT6OxEg0upYAiIg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ul+Tq5Fb;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id A8C9E606A896;
Tue, 17 Nov 2026 21:18:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ul+Tq5Fb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.52
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794950338;
b=m4CKvFcxBRetd5ajJ9Fb3qHLhJOYf86eK1eBHjsWt8vekND3H2R8bssiaIbKJzk84G9F
EjoHxQKtjdj9Asjzb8fi8VhT25j77zWrwDLqpzxrcgDM60w+uJ2+wOPez5gAjOYKuKYpW
z1gqhhrX8Rpqx66xgLTes0Pm5hJTN/5Af+zxp4K07bg283yqM2h2rR3QO07vCDIkPjNT1
xjXRztO3llrdUkqNdcMxKEigkKSTDL4CRlpkkbbpNyE8rx+a3S8IuqK99i2LsqJ/29ah4
dovzvbT1psHPSnnv1+CJ120HZkAcl3NxL57wvG0cmC/v/GHEhFYBuo7D5Fy1gvQhKhg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794950338;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=7wB6bRo3lbSsZaUMjbOvD2Y5uBp3Ggx5j0TCCZ4sIdQ=;
b=ev2srbQ9A2ukdpaPN1Ym++AVR8zXC5eiiQCQxEQbTRcLNGkEj+mIVFLplNt0DMq5gsJP
HeryBw544RRy3HNO1Z+E7uRFV+uDI7zFbszUecORppsSq9PmDifvooG5FgXrC+/j7gLxC
TF1ag4nmz9HRZpuv3tVUSCfMsftLotVDNbEcCgZw9ITZKpcTIQJdewaI6p6NEtc2Au8Ks
OD5CPhLH0UKGSZaf2btgh5AN3ER1ua+LfJhVZkKUzC+rfdrw6viGW5sOfohhf/AR1FDP3
ZqTIdRIz6iDeJKcQhR3yTEaL9t1Mi0pyKOyzrV43UYj6rtuzJ3+ZHathsi4mO8YHaqQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=ul+Tq5Fb;
arc=none smtp.remote-ip=209.85.167.52
X-Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EEC9606A33D
for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 21:18:58 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7EEC9606A33D
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-5c14f3dab66so166810e87.0
for <netdev@vger.kernel.org>; Tue, 17 Nov 2026 13:18:58 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794950337; x=1795555137; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=7wB6bRo3lbSsZaUMjbOvD2Y5uBp3Ggx5j0TCCZ4sIdQ=;
b=ul+Tq5Fbf/Rlj42uDV+HtK2Sc4z2rbt+cr7mrr5+5lNqN+x6M0DJI04jGh5JECKpvS
+h3I4H2AdMHktmMxGjkgcz2exkmXqn594AqyoPxvX5mIhk6oM4lU3fy9ZETc/aKR2wqQ
4lhd1ZumDNlHtfPcsFGsvAuWA0HLdEfy7K9zilLPKCL0yf3qAPqPxBLmfMM67xH7Ad4S
4m5LSrzcWv5/cbPMgoCiKkcARGhlWJtUe538LubTWugGrpthM+ZL6ImHmctdS52z9hd+
a9gmiPJCd/eMi0pRPtcirjHZkPoeNncyx0AtOaALDtfRW3SLxvD5xh1G2kT17s+Gh/O7
awQQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794950337; x=1795555137;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=7wB6bRo3lbSsZaUMjbOvD2Y5uBp3Ggx5j0TCCZ4sIdQ=;
b=hY35H8qMvebPPBsGfBHS21xQzftYyrwn62IyATRs0reteYt8u0X0GMVkfCJn92Fyfl
ANXdiVPZLRn5Rz+HWS1xDM8YZ7xOOKDjYlRH02DokAyJqvIxHc0Vw6jfWZgxB4nvzdRD
MLTAKALeSOMq/8RU1yqGan0utN4TT06H88MDV7i3DMOT/4O3IrC5VkosbP5y8F5pfint
73RaCCZh4x4kjNngDbzUY5p499xeHR9REx4E7QSMqf97RwEVa8teIO5bclREmZlQ9u0E
ThEGJK6T/F+cTsaMg89HfeMci80tinV6GSBorZd/X1uXkirSDa8n64idZZNw9Fw57w/M
JEEQ==
X-Gm-Message-State: APuU4Z8ilsLicO++N6fUs33pamVUJFbGsKJikMq08nh7ujVZesOfvu5m
py7kLr5VPNxdxkba4EU7uhcGQpmYe0loaOr87t8ALiI3sHH5l+o64s6/GYXFOlFvhLH2cg==
X-Gm-Gg: AYBFou05JL8ARI+rRVH4XlTEa1pNnwU83AA0beaAm1Osy5CwhfDoC8+Ph127IlgNDeg
o1zfWrljezJyN4jGIhuQqSLmqEDN/1/c+kIZ1B294jbn6IdjgwnskK2xZmXOQx+tc6BO4RlDTcj
FjS5hBsuzXy3K5MgW6ktB3aylcXUAu+kps3XjkWNSgxCvCN8VDd+9FDRe1OoWIedpMWbu++XX01
oFPN3tKD3N75GpxV+eoJpxbvXUBsuVHKAXGaG/Wsep4pxMnkvDAyc90vTwl2z4EymdZlhL36MgA
X1qaqrpItJ19Ap3AE4fgRVG/V55pP6kmH8zrUAHBtmyL7Z3VAnIEDh/lLX4ViXUQiUT5bJikoKR
IS+TL7Ks0dKbN4JgBSyTxvImmcm6w3aVocwOKdKPZBQ3m24xakzvPlf7dgBDfESQez8S683MFww
NodUN/xm+dR8bcwXbeQzhd5p1FXPIK7xIGqqifO/Cm/ZNwc5hw9i99rF67w7tiZI6QCMFCELwPP
K25Hyw1xwju10pIMD2TBiUcUwJEudL/lCJr4ZYqXWXwb5mZFaKOnqwIZeEM0g9QehwnKla3/KuK
3nKQXOvvOMfUCtLDje0YNoVWp88K/1PvWhEdLaJPdLik3zB4uIaZFAvQfRPBOrnPaR97VW4/H03
R3ji3vp3jVCsM8yujdSI=
X-Received: by 2002:a05:6512:3043:b0:5bf:ca51:e25d with SMTP id 2adb3069b0e04-5c1aa07392fmr111858e87.11.1794950336433;
Tue, 17 Nov 2026 13:18:56 -0800 (PST)
X-Received: from dau-home-pc.megasoftware.org ([95.139.239.228])
by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5c1aa76037bsm66124e87.15.2026.11.17.13.18.55
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 17 Nov 2026 13:18:55 -0800 (PST)
X-Cc: "David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.47.3
X-In-Reply-To: <20261117211853.3733250-1-littlesmilingcloud@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list