From patchwork Fri Aug 30 01:59:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784107 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94D6E28EC; Fri, 30 Aug 2024 02:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983344; cv=none; b=uNdGTskEckMcIvKxqyHsvKLhFh/aNY/b7PimHM9tPhA7qB1W/wKk3fa2x/7RqQ0uZ69dfYPti7NvfUICbAR5dN8tthTMtrWZtzEd9MEJV0yBdU2eES7KGePjd8DsTUS18tyA1mVg3YtUWX1jKn0LOmrrDo6hdqcMYpQ/SDil+dY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983344; c=relaxed/simple; bh=2MsjVtpNSQ67FNJ4nyDqxQdzz20Ga+qv5kbPYvq6KC8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YXsDZGkZMB/22Gk4JfAeEu6jHHBGDYRe4tJV1cytHUFkhSoPAERlSR7orR57fzEOjiHNPgdhx8jK4MsNzf1Zts/6nZDRTCuTFi/Nf4UrU8AlEuxxH+/ERFetTEt3G04jRq1QKo8UL/G5DmYbGmNu8reTauKGMD2jo+Ya5aNDjUU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OouKwpdF; arc=none smtp.client-ip=209.85.210.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OouKwpdF" Received: by mail-ot1-f65.google.com with SMTP id 46e09a7af769-70df4b5cdd8so879114a34.1; Thu, 29 Aug 2024 19:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983341; x=1725588141; 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; bh=VQccGzW41EWAydouAjp2fjLVFqqDcbdOnftN+S5EC4E=; b=OouKwpdFveX9956ajn+Hkjn3jBmGCzAGy3L7fIgfarAOv2BEQs42Fj1r5QxQsZ7/Sy RJU8vb/IK5l6+5X8CIV2FpH/ar3pAmgq9KSriV9gHyyKUqEJ/lgTRX5a1Xqnneeyxj+q TJzw90L5scsn4uiwcZx0KQH2OUOlad5wl/1udPH16QhOITGna7ARLHr0DP1U/NYbNk6L 5FHggjsdMQMu1co/ETdd5bKFadqjE0yoV7dbFNp8QXVTAniFHfxPraOMQtFlHHm7R/ko datkcFeLY9MFYoalgcjbAk+wpfFhQF7UgWvZ19N+lzcN8wkCWL0cY/cT4JIifCzIJO+n GvLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983341; x=1725588141; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VQccGzW41EWAydouAjp2fjLVFqqDcbdOnftN+S5EC4E=; b=gHsJEs4r3mQsofkKGlzh752dZpZR4km0wtP2g5NWLb5QT94jeK+CFCtTuZUY5ZUXl2 SMI7fQ45EgioQz/WRA9gPM+egmxlVMSJRA9t8G+T4r8EykFyHoY0n73+Fy/e6gROcfyr iAVyYTOHeJYKE5p7VdDjgRUx3u+qUB2cxmYmlQMXGeJZuh39+brKMhHzZahrEciTskfZ fMQ9MqgrDGQ+je+x6dDkVc2bD17PkQ9T9tDTzbRfxI4IdkYn8cNiOdMPHt238CWCTdeh 9kgx0aV79CN+CJZS7WOuvcyDfa4ic5lQYJ22nFu9Br0AkNkdW7uD0mFKcQwh1FwUfhgM gjyg== X-Forwarded-Encrypted: i=1; AJvYcCWmObeYTemHs9vn5uZNaSSA7a0K9mcnsDZyrTA9NIUY1qXaBWN/k291YUZAQ8/GjnxkCQqlAagnaKS3aBY=@vger.kernel.org, AJvYcCXg+8KFBgFve7WAMfJbJVn4+cr7BAvYJPkNtVkBaJA04/ibs05z3pMU0Ttk2of+ft7s67yjtXAn@vger.kernel.org X-Gm-Message-State: AOJu0YzhFmI+GHQVWFZXKkRZy+JOHTS9bX4RDEjipY1qb/IDenfQUjHK lnzK99+GrbOChj0x/lmKaysa1QNa/GTQoJw7JdD2PtVboJtCo5AT X-Google-Smtp-Source: AGHT+IFtmKf1pY/c1Zqt1gsJnjZ6CBMnPaomHRo9QgpWAQw10PSevP0JfcBJ3F8Zd4RP0QRG/o7Ssw== X-Received: by 2002:a05:6870:1d1:b0:261:7af:719c with SMTP id 586e51a60fabf-277902b2b13mr4875252fac.35.1724983341517; Thu, 29 Aug 2024 19:02:21 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:21 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 01/12] net: vxlan: add vxlan to the drop reason subsystem Date: Fri, 30 Aug 2024 09:59:50 +0800 Message-Id: <20240830020001.79377-2-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org In this commit, we introduce the SKB_DROP_REASON_SUBSYS_VXLAN to make the vxlan support skb drop reasons. Signed-off-by: Menglong Dong --- drivers/net/vxlan/drop.h | 25 +++++++++++++++++++++++++ drivers/net/vxlan/vxlan_core.c | 15 +++++++++++++++ drivers/net/vxlan/vxlan_private.h | 1 + include/net/dropreason.h | 6 ++++++ 4 files changed, 47 insertions(+) create mode 100644 drivers/net/vxlan/drop.h diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h new file mode 100644 index 000000000000..6bcc6894fbbd --- /dev/null +++ b/drivers/net/vxlan/drop.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * VXLAN drop reason list. + */ + +#ifndef VXLAN_DROP_H +#define VXLAN_DROP_H +#include +#include + +#define VXLAN_DROP_REASONS(R) \ + /* deliberate comment for trailing \ */ + +enum vxlan_drop_reason { + __VXLAN_DROP_REASON = SKB_DROP_REASON_SUBSYS_VXLAN << + SKB_DROP_REASON_SUBSYS_SHIFT, +}; + +static inline void +vxlan_kfree_skb(struct sk_buff *skb, enum vxlan_drop_reason reason) +{ + kfree_skb_reason(skb, (u32)reason); +} + +#endif /* VXLAN_DROP_H */ diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 34391c18bba7..fcd224a1d0c0 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -4833,6 +4833,17 @@ static int vxlan_nexthop_event(struct notifier_block *nb, return NOTIFY_DONE; } +static const char * const vxlan_drop_reasons[] = { +#define S(x) [(x) & ~SKB_DROP_REASON_SUBSYS_MASK] = (#x), + VXLAN_DROP_REASONS(S) +#undef S +}; + +static struct drop_reason_list drop_reason_list_vxlan = { + .reasons = vxlan_drop_reasons, + .n_reasons = ARRAY_SIZE(vxlan_drop_reasons), +}; + static __net_init int vxlan_init_net(struct net *net) { struct vxlan_net *vn = net_generic(net, vxlan_net_id); @@ -4914,6 +4925,9 @@ static int __init vxlan_init_module(void) vxlan_vnifilter_init(); + drop_reasons_register_subsys(SKB_DROP_REASON_SUBSYS_VXLAN, + &drop_reason_list_vxlan); + return 0; out4: unregister_switchdev_notifier(&vxlan_switchdev_notifier_block); @@ -4928,6 +4942,7 @@ late_initcall(vxlan_init_module); static void __exit vxlan_cleanup_module(void) { + drop_reasons_unregister_subsys(SKB_DROP_REASON_SUBSYS_VXLAN); vxlan_vnifilter_uninit(); rtnl_link_unregister(&vxlan_link_ops); unregister_switchdev_notifier(&vxlan_switchdev_notifier_block); diff --git a/drivers/net/vxlan/vxlan_private.h b/drivers/net/vxlan/vxlan_private.h index b35d96b78843..8720d7a1206f 100644 --- a/drivers/net/vxlan/vxlan_private.h +++ b/drivers/net/vxlan/vxlan_private.h @@ -8,6 +8,7 @@ #define _VXLAN_PRIVATE_H #include +#include "drop.h" extern unsigned int vxlan_net_id; extern const u8 all_zeros_mac[ETH_ALEN + 2]; diff --git a/include/net/dropreason.h b/include/net/dropreason.h index 56cb7be92244..2e5d158d670e 100644 --- a/include/net/dropreason.h +++ b/include/net/dropreason.h @@ -29,6 +29,12 @@ enum skb_drop_reason_subsys { */ SKB_DROP_REASON_SUBSYS_OPENVSWITCH, + /** + * @SKB_DROP_REASON_SUBSYS_VXLAN: vxlan drop reason, see + * drivers/net/vxlan/drop.h + */ + SKB_DROP_REASON_SUBSYS_VXLAN, + /** @SKB_DROP_REASON_SUBSYS_NUM: number of subsystems defined */ SKB_DROP_REASON_SUBSYS_NUM }; From patchwork Fri Aug 30 01:59:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784108 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3241F13632B; Fri, 30 Aug 2024 02:02:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983348; cv=none; b=nh8gJoVDslX3TXLtmjNmm5JCx3vRbm8XVJEPUAPXvR32+9kQrsPpMhyp5c0rh6/tP00pWe0+KfBXj6DzwwNTJnSA4jyRx/FDLQrA5EOrc1O6b39HEOJ7D2x7rcKCWjhqzK2J6qpVZ1hEOApTNHvfy3z8tMb/8BIVUjwhLpWIA+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983348; c=relaxed/simple; bh=OWM1Yfv0veEuuMTI6s3R2O/gIarAsPk1rPh9uwCGfKo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vncq1mlJimSiJkMIS0GBY//2UHJJQ+pVXQhYm3xlFvBp9f9pqxUQvn238RUZ0AUafejSTp+d4Ji1unql0uegrUSJkU1kze+qbuLzUdfFd7r29Dz1zVXGwdbBAADAG4H8lytb0k5brAFY60RaqFAXUSn1eIQfEO0kw0YKO5re7fo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ok+XC3Pp; arc=none smtp.client-ip=209.85.210.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ok+XC3Pp" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-715cc93694fso1195352b3a.2; Thu, 29 Aug 2024 19:02:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983346; x=1725588146; 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; bh=S15bsrAtKng24cEfr8xI1U+gVP6EbG/MdhFsVmoJxV8=; b=Ok+XC3PpKMr6kvBc8Vf+npPmyto+BzSlVg5Oae626MYNhsRAW+7baQ0SBoB4JLQow0 F3lVvTJTlEEQqoQ08FOyOdjgQAppFjizr6Ogqu/aannfofgxoDYT5VdhUYk6wZDoLti3 oEfD94IawAc4vwlUoffp84sMkhwTwoAjO1WccYwNvSHDtxffjXuzMjAqRuTpQXFngzx3 QlEniDfzz1dkcSqOmzc17AwQh35RJ7+oGXplkHTrAQbvDC5DKb1U0ac9SkZhm7ehpFGF +MWo+d38Klyoxzq5f3Senjf20lA8uuIs7hMYxdb5ccoc3TRnhki7acmKVtimpUzRWpnF bGXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983346; x=1725588146; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S15bsrAtKng24cEfr8xI1U+gVP6EbG/MdhFsVmoJxV8=; b=EwQEwQTaP3VlloNsYD7mAPsgjvnVY+MnpwUyyJvizkjr9S9jBkcz+E8hKCxJJ6WXgb j4Z2T+9XQBlf2l4KPMKNuADUgIbo1X8aJbASpxJptPEHdAIP5MUscKKtOB9Y67hYO4tq Fk27EsE8RYiX2X+OW6rjPITMtPx7c6snMMKpPJTpZG7jD1Zpa5h2oPzD4DgyfQFe1OQq 0VIJJZ+fk+ipLA4XnVGuwRZSh0tZ6TW2N5FuYtkRUXqKybyRv804hOPG+FdTvfNhtzUk /MJFdk15CdCRoTJolR48J5CXmb1RY5pvNoeSPhDZjUC8tZwyMTywExZ4B1jBXD46bwNk +uHQ== X-Forwarded-Encrypted: i=1; AJvYcCUe9/URXpAfbxaUSUg5E9engsCz6ed7628W0XraWyzo1xz0xbNhIBWUd4sPhPV/V8GuIhwx9MSZ@vger.kernel.org, AJvYcCVqaEAgSBbPAxMdqFAw8yXV4OvXsUcpRN7Yvh7t8G7NIq2ZyqQBbRvjVjyYPZLU4IGmgTwb5x+nkY0b73s=@vger.kernel.org X-Gm-Message-State: AOJu0Yyf1mw/U4qgtNagLya0VMVjx2qF4D/kgdoZrjXeA91iEjbVOQX3 kBbeQJV9jz7rhQTb/CEvxTAwGMumULUSBDp8a/6sGKj7EaGWV373 X-Google-Smtp-Source: AGHT+IFpbCZIiwTD17FymKoKtocUjHWfH/6+9Drmx4DPOrX3Yzq29x88AvQykQz3hgBSZuiButrarA== X-Received: by 2002:a05:6a21:4a4a:b0:1c4:c3a1:efbc with SMTP id adf61e73a8af0-1cce10b17a1mr3685420637.39.1724983346149; Thu, 29 Aug 2024 19:02:26 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:25 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 02/12] net: skb: add pskb_network_may_pull_reason() helper Date: Fri, 30 Aug 2024 09:59:51 +0800 Message-Id: <20240830020001.79377-3-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Introduce the function pskb_network_may_pull_reason() and make pskb_network_may_pull() a simple inline call to it. The drop reasons of it just come from pskb_may_pull_reason. Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index cf8f6ce06742..fe6f97b550fc 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3114,9 +3114,15 @@ static inline int skb_inner_network_offset(const struct sk_buff *skb) return skb_inner_network_header(skb) - skb->data; } +static inline enum skb_drop_reason +pskb_network_may_pull_reason(struct sk_buff *skb, unsigned int len) +{ + return pskb_may_pull_reason(skb, skb_network_offset(skb) + len); +} + static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len) { - return pskb_may_pull(skb, skb_network_offset(skb) + len); + return pskb_network_may_pull_reason(skb, len) == SKB_NOT_DROPPED_YET; } /* From patchwork Fri Aug 30 01:59:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784109 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0348B71742; Fri, 30 Aug 2024 02:02:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983353; cv=none; b=I06i6mED2ku7E/Z0/CGixdfRJE7ZIS2gLfD56BfdAjBa+mJuz+//KELOQ5JKkpL3n422oCyh8GhGTHtTPZ78sLJqHp+8uuazI3YpVI5YM+eiMD7H+oRmR4UOWzoMKVuBxmoWJMKiLn2NmQS1zcKnH7CPo0uc+MhC7KuWWtfgQTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983353; c=relaxed/simple; bh=BjupJZu1E/fcfxWKlB66JWida6SqIOij/q7rMugI49E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c3kl5tv71vHBRGW4TyU1uLPrDOdHVnVgpfB6mnlTSbRy1u4BMNy6IVOnDOnGdiPoR17CsHA+Y0xDh3/v7ynliAPCgMJqZcgAqIGKlt1OXOKOyRN/CP/6rTDlNwWPrc5UKSSJCnj7XROPjUxxyx2oGLnzMJsdNdHMWP35vX3LhqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b4rwHzCC; arc=none smtp.client-ip=209.85.210.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b4rwHzCC" Received: by mail-pf1-f195.google.com with SMTP id d2e1a72fcca58-715e64ea7d1so1066442b3a.0; Thu, 29 Aug 2024 19:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983351; x=1725588151; 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; bh=1nl/wlYbJ8IhJjGotsXRWm/OkatmXtly5y1k+64ypkQ=; b=b4rwHzCCz1MCC6ZKCPOWS+iqZWhhOPoAHmSbTf7x7CYccp4a6LYLenJJvipSRJdCTv DVQkE3U9ld4KGByltxTT9Z9fjp84B/FDEobeUg5VbgKZ442uEV8I1lcX49sJAzK1HiFW Gxf25ncH2DRzjqD5LtHyXlAVMi3WGrco8ZHqe8O5j9O+3ZfykZpgDHzL2XQLxE6ZiFWh cLI4htRCWm0BAQr3L+ZmyduDsQEAWwjuCaezv/hMbzWiPaRz9OfK/qLmH17yIrErOiXs CZOTtVvMUQc1yY6FRBYP7FiSGkKyinbHVXi5qUCnM12HdbbD07DR1fq+M5gYXHrR6/Hl tVpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983351; x=1725588151; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1nl/wlYbJ8IhJjGotsXRWm/OkatmXtly5y1k+64ypkQ=; b=XQhaKMf7qAZPhdsOiPQqTNq0N7WCWkp1cT3Zs/X6YEsnS/rmj6GoMl8VtLgnppnhnt C0HGxoZhhMk6KkaEpHczaPcRTGiSUrmODxA5goFwpBb8vD+oFdJonoyoAC08tFOHzDD5 dcPb1ZVuExn79QwvTDrXoVr3tJeCW5WsBKr/YYe3E5dhyJn6kVIJ/pTssRf7jc/RGK+k a3itwKdwewVKBpQ6h1cZY+W/Ie3P0yHMTNsdHU6ShHk6weyHG1czuzABEFVJZkh1SUvr E4p6DQGLBuQy6ArnO0lmpj8q3PRPH/bVFmYEO02p90mv4NVaQbJ5p2FoG6joL43NkXAU eK5Q== X-Forwarded-Encrypted: i=1; AJvYcCWBqzB74NjpZCg7/VqIFYAIs3wuaAVi2dmgCPfB+e6n42SWi0+Wx7tCKnFV9snx9Z47xPMsfT3oA662ezM=@vger.kernel.org, AJvYcCWdxulVVRTpAtD9Ugqpc+5mbap8fLZSTaPPHF+9lWceWBdWkUrIPzFVL+PnLLBw8BAgHx/dfP9u@vger.kernel.org X-Gm-Message-State: AOJu0YzdCw55ScADKvUBZe9wSU4CyoIEWLewDznO6A7KwSsbzi8Zgj/L alTPvtz9o680xgywltHrsKBoZalGsomIMFcl8W/XqIfcpMQF4i9H X-Google-Smtp-Source: AGHT+IHDvvN8QviJNtA1TyJ59DoptfuF1c1cvOGiV9GfceeouVrlPsgaQP28qMxKWBm2Io/6CJ5Wkw== X-Received: by 2002:a05:6a00:855:b0:714:25aa:e56b with SMTP id d2e1a72fcca58-715dfb2d890mr6862607b3a.8.1724983351161; Thu, 29 Aug 2024 19:02:31 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:30 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 03/12] net: tunnel: add pskb_inet_may_pull_reason() helper Date: Fri, 30 Aug 2024 09:59:52 +0800 Message-Id: <20240830020001.79377-4-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Introduce the function pskb_inet_may_pull_reason() and make pskb_inet_may_pull a simple inline call to it. The drop reasons of it just come from pskb_may_pull_reason(). Signed-off-by: Menglong Dong --- include/net/ip_tunnels.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 6194fbb564c6..7fc2f7bf837a 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -439,7 +439,8 @@ int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op, int ip_tunnel_encap_setup(struct ip_tunnel *t, struct ip_tunnel_encap *ipencap); -static inline bool pskb_inet_may_pull(struct sk_buff *skb) +static inline enum skb_drop_reason +pskb_inet_may_pull_reason(struct sk_buff *skb) { int nhlen; @@ -456,7 +457,12 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb) nhlen = 0; } - return pskb_network_may_pull(skb, nhlen); + return pskb_network_may_pull_reason(skb, nhlen); +} + +static inline bool pskb_inet_may_pull(struct sk_buff *skb) +{ + return pskb_inet_may_pull_reason(skb) == SKB_NOT_DROPPED_YET; } /* Variant of pskb_inet_may_pull(). From patchwork Fri Aug 30 01:59:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784113 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f68.google.com (mail-oa1-f68.google.com [209.85.160.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D65471742; Fri, 30 Aug 2024 02:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983358; cv=none; b=NhzOnmBk4jX8iKlgfQ5OxYuIoccAqTQrNkPoMtKnsyZtZMmzvifm44N0Bm3g+ji46NWHQN6YkeTdVTx75ErC+foftDE8NTxNM5HAMB54UfK8u6Aa7CB6Oh+JELmnkRocJIuIAtiPF6ZuG+vznz3cEUPdzS58a2WTrLv0CBv7m4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983358; c=relaxed/simple; bh=3VmzH17Bhak8BEL9MhIovK/bRrLmZlG8N4KAYQwjE10=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BoJL17cn2wD+hJjnD8rtS9krkhaeQbyqytPfwwf5Awi0ZmQFMOZrCwr2vMG1QnZpQ4dwcZTobZdQpxi+08D5ojmXOWwrzC7lZp2DCmfhE5TtclaKfgxtKmC0ZCiXLVRU6nKJzbDnqsZ01RYy2meaTblKYkQS6YlgKX7SOiwGH8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=W0B8vbkh; arc=none smtp.client-ip=209.85.160.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W0B8vbkh" Received: by mail-oa1-f68.google.com with SMTP id 586e51a60fabf-273cf2dbf7dso739198fac.1; Thu, 29 Aug 2024 19:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983356; x=1725588156; 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; bh=N9mW2xX98zUSnOtqzxw2x7w49udx/6KrmxEjXJ5Yn7w=; b=W0B8vbkh2mbkvfl8T7/Lx9ZksVGA4+BaBgmLARh6zO1iBfCeQpSCGiU7UZGrBaIVNe PZj2BiCRSkBO6UqptG0bqpGt+496F/URvugk7NyagfK4e4GQpa1CVdXdRfDuB3DtK0Hh nDxu6WYBrbYo7xCXlubn/TDu9d9MQO11IswDnatoVw7Hyta3isVtRQcIrXT3Ou9qzq0Z EC0lrWeRPjQRsRqG93BWEUlwBinqDKIpUFYbDbxYe8PSrta258NoAgfgwHUo9jGR43Ih spY5vQUU7JtKRdoqZYyqTyT2rMqY33vDyj+mUedQQ0biV28RgC5qkPLaz25Ya2/iDyG/ X7Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983356; x=1725588156; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N9mW2xX98zUSnOtqzxw2x7w49udx/6KrmxEjXJ5Yn7w=; b=f5hiUlO77fwajc/V1bshBsBST+dtHtvZwaTCFtTP7wrerk0q3k8Yuu1VFIkfbygW5x +6RpKWBvdkyRVIyiVD0klJbFp1WHcdxXD//4+m9KLCBubxtaHe6snLnWUbHeaT1Owm3c LUY4C60xeffqk5myMxZWy7q08b9o8RmzeDgLr55EZq8zZLMFQyqiRvsQhGgMvXn3ZBn/ TAWFXn6pcA2swesH2Z/fAnvqRHJvtmFEM3wWPsp00vqH0ql/eiAlAeDUkyc31Wi69hvb ZrI+QsE6u3j7FLtpaJN7ln/PnuocxqNIx0RyYagQFIe7KZh4YJsNgqYsS4NmARNJSfFc ty0w== X-Forwarded-Encrypted: i=1; AJvYcCV+7ZOh+CGBd59nnBwRAmi/Gxj7ZIPTkvHhnfoBU5uLjLL1MGr7YmWFnuu2JpXpWCkK8tb/LPBf@vger.kernel.org, AJvYcCWNzcV7J6jHEbQR64/qC8SY4wdYQKFtGObvq2TR/my6ppbnZ/dD/rqZi/wPPpB6NnX+hlkcZ6Yhn4KIUGM=@vger.kernel.org X-Gm-Message-State: AOJu0Yyi65CYbzZa02yIILBFzDUtc23FGwLVjJKejvOUt2VrmacZ2/p0 8g28Fj+HdjT4PAIvtRC5A4xTdXr9ZfPW8dqkCQN+D8URWE2sX6xm X-Google-Smtp-Source: AGHT+IEcWxj+Mw5B/xtcrEbcXL+/ABGHL+89DOxNHzAmFTeBBlJ+YQWKaz8nmX24ejZiOH5826aEMA== X-Received: by 2002:a05:6870:910b:b0:270:2063:f166 with SMTP id 586e51a60fabf-2779012b632mr5049508fac.23.1724983356267; Thu, 29 Aug 2024 19:02:36 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:35 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 04/12] net: tunnel: add skb_vlan_inet_prepare_reason() helper Date: Fri, 30 Aug 2024 09:59:53 +0800 Message-Id: <20240830020001.79377-5-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Introduce the function skb_vlan_inet_prepare_reason() and make skb_vlan_inet_prepare an inline call to it. The drop reasons of it just come from pskb_may_pull_reason. Signed-off-by: Menglong Dong --- include/net/ip_tunnels.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 7fc2f7bf837a..90f8d1510a76 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -465,13 +465,14 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb) return pskb_inet_may_pull_reason(skb) == SKB_NOT_DROPPED_YET; } -/* Variant of pskb_inet_may_pull(). +/* Variant of pskb_inet_may_pull_reason(). */ -static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, - bool inner_proto_inherit) +static inline enum skb_drop_reason +skb_vlan_inet_prepare_reason(struct sk_buff *skb, bool inner_proto_inherit) { int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN; __be16 type = skb->protocol; + enum skb_drop_reason reason; /* Essentially this is skb_protocol(skb, true) * And we get MAC len. @@ -492,11 +493,19 @@ static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, /* For ETH_P_IPV6/ETH_P_IP we make sure to pull * a base network header in skb->head. */ - if (!pskb_may_pull(skb, maclen + nhlen)) - return false; + reason = pskb_may_pull_reason(skb, maclen + nhlen); + if (reason) + return reason; skb_set_network_header(skb, maclen); - return true; + return SKB_NOT_DROPPED_YET; +} + +static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, + bool inner_proto_inherit) +{ + return skb_vlan_inet_prepare_reason(skb, inner_proto_inherit) == + SKB_NOT_DROPPED_YET; } static inline int ip_encap_hlen(struct ip_tunnel_encap *e) From patchwork Fri Aug 30 01:59:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784114 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 363DB82481; Fri, 30 Aug 2024 02:02:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983362; cv=none; b=a6IG4sM35AIL/J8ewYJSYbx8CpZnqMcXMjpaSFqkKESnpiAHscpxVfRWDZtJuiIFSLTCZ9CUe0EezKeHO7EVftBwuAJgLemK0DS4UwP0WDowTO3WPaQbzozJ+Fsxw5/e2YYbK4qTKtbu22z6Z1T4OtB38pVuO5ekno8f7hLa0lk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983362; c=relaxed/simple; bh=/4tYqzlI0k4OL2sr+CkSR4OEplhZSoi5mzkyfIT1S7g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sabjaho5NXxTTCho//yUrZUqPty7N264jbXqE25v3eBdSspEEDEorfbNimGJeo9+v8ZgzRrTHC3TeVc5NauEOLjPRHbphUICS0Lfie7xAdycOP2AyfRqLzIpmc8GcgxZ7rTCW6XCnbHfwtlrEu8KHhaYZvZmL8CRUZiuZ6lHONo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y5V2nW6E; arc=none smtp.client-ip=209.85.210.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y5V2nW6E" Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-714302e7285so1156378b3a.2; Thu, 29 Aug 2024 19:02:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983360; x=1725588160; 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; bh=aA9owP7+Y0gC+y2zV5nnvicSUsa9DffbmtMLeqm5GkQ=; b=Y5V2nW6ENB5J2wfzU94wyWxK8hSOWjvpi/rtCwbKjzjZZly+6fftGxENgPHHaINtKt 7+F67IxUqZITZOTK5FLGQJXVsOhQ9F7n284vvgnlmhsQLY7Tr8dZneTk5na1j4vcK/Up dbYWfbQl/3dkN54uIgIJ2dPZ62z7YuA23IfCj5u9vk4UwLPPZxW3SQHYCOHsBPm0WBxJ 6jtvZFUFgmnxSAxwKIyGs02XguKggYCUSJ5QXJ9Ia/QoGg1UouPXp+xoR2n3q2xdZJmB n4S/r1M+EcX7SvJo0Wx0yf74tE3UONX348sJGQ6LaRTYXf9OBbaSmOJb2Jwl1pip3UD7 Aqjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983360; x=1725588160; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aA9owP7+Y0gC+y2zV5nnvicSUsa9DffbmtMLeqm5GkQ=; b=gsQlZdTQ/kfCV2YkxekT0vA/u3vrzV3/Sy1A4LuvHIiYELnjpbI/QJTT6PeaMYu/aw TpfqFSF9CYimLcvvn2sh3NadZw46MGsjRdj1pL2SnFUeQl8jocMrolOykA5MSYFOPl+k jE+pGsqiRaGdyM90roU0Vo4CIq7/mSMAgC56KWVgvL2ccMTd+mV99QDtZmIUxS5zJw9A xkWebK4wpJBpnC6Yp+dWKnxZqruh7e0jH01JupetBSPpbmSfa+pXatjHPgi72+TVLv0W 8WOx9xzC75mcxhVkl6zeUgaY7DpcSOQpyiP9ZLyjmN2YeqBtt0pVm8seWxdwfhh3XpNZ idEg== X-Forwarded-Encrypted: i=1; AJvYcCU5ybyBcHH1WUrw7A1eSZ3uu2vniCC3LYTGkRCICK8LP73O5EQEALcsBhzbX3Y3bDbUdJfFT2Yf@vger.kernel.org, AJvYcCW/+rRRBOPnggxw+Nnq56ooolHerrvFbQW0BZVn1K0Ery7ArX5rIX1MRlPrM032PeynP/gnmRwqOIgN50s=@vger.kernel.org X-Gm-Message-State: AOJu0YzvwsSWCc0HruIdoPAOzW6kRk7sV3TsVOP0igrqv6RfEynYr1Hm paGnAtFCO/HFgtE7Hg2qpcu1jAQfvTRjJf8lsYMbcUJcL30tjru0 X-Google-Smtp-Source: AGHT+IHd2TIKcKnwWdOXnb5BGaCutJq3T3Ami4HHCR7A0v3kN9CLnnSb/ED3bb5WQgenQ6c9JHhP4g== X-Received: by 2002:a05:6a00:2e96:b0:714:25ee:df58 with SMTP id d2e1a72fcca58-715dfc50607mr5898452b3a.18.1724983360303; Thu, 29 Aug 2024 19:02:40 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:39 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Date: Fri, 30 Aug 2024 09:59:54 +0800 Message-Id: <20240830020001.79377-6-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Make vxlan_remcsum() support skb drop reasons by changing the return value type of it from bool to enum skb_drop_reason. The only drop reason in vxlan_remcsum() comes from pskb_may_pull_reason(), so we just return it. Signed-off-by: Menglong Dong --- drivers/net/vxlan/vxlan_core.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index fcd224a1d0c0..76b217d166ef 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1551,9 +1551,11 @@ static void vxlan_sock_release(struct vxlan_dev *vxlan) #endif } -static bool vxlan_remcsum(struct vxlanhdr *unparsed, - struct sk_buff *skb, u32 vxflags) +static enum skb_drop_reason vxlan_remcsum(struct vxlanhdr *unparsed, + struct sk_buff *skb, + u32 vxflags) { + enum skb_drop_reason reason; size_t start, offset; if (!(unparsed->vx_flags & VXLAN_HF_RCO) || skb->remcsum_offload) @@ -1562,15 +1564,16 @@ static bool vxlan_remcsum(struct vxlanhdr *unparsed, start = vxlan_rco_start(unparsed->vx_vni); offset = start + vxlan_rco_offset(unparsed->vx_vni); - if (!pskb_may_pull(skb, offset + sizeof(u16))) - return false; + reason = pskb_may_pull_reason(skb, offset + sizeof(u16)); + if (reason) + return reason; skb_remcsum_process(skb, (void *)(vxlan_hdr(skb) + 1), start, offset, !!(vxflags & VXLAN_F_REMCSUM_NOPARTIAL)); out: unparsed->vx_flags &= ~VXLAN_HF_RCO; unparsed->vx_vni &= VXLAN_VNI_MASK; - return true; + return SKB_NOT_DROPPED_YET; } static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, From patchwork Fri Aug 30 01:59:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784115 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oa1-f65.google.com (mail-oa1-f65.google.com [209.85.160.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F421114B097; Fri, 30 Aug 2024 02:02:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983367; cv=none; b=pFGGLU8kRQhPFQD9igRwOivcsIshLTwZzSMTQM+0Nb4lQNtka0StVSMxN5QOATU1pBUX51HyETdsBI+7i1X6LO2UQ405tdsQDWrDYbRlt2WZ9urNKVCRXkbZaR2b52RJfqRO8mCWklyQsI1z8UxZCSDYUIWFHZ0Q9AydEIMUMT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983367; c=relaxed/simple; bh=aBF7BdEbtvUR3jPGtnebfo8mQ0ewwAnRt6acrSq9Ev0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AzYq1ZzcIqdJJyA8oZT1t4PbrHKw2+sGMtEHuMdWhrhZcNJNDRnDdQAxmtLftZElbVOcAZMe8pjLtIHFdgBoASTjaeQM7obJ84ODEfFxdRcakqpEns5a+zN+CRcDQo+Nhq42XUhsWqM6q6y6ilz7zFTxexyctvGP0y/Rn+PaWn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fJOFVQpH; arc=none smtp.client-ip=209.85.160.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fJOFVQpH" Received: by mail-oa1-f65.google.com with SMTP id 586e51a60fabf-2689e7a941fso809877fac.3; Thu, 29 Aug 2024 19:02:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983365; x=1725588165; 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; bh=Nb3cI/l2kR4qi2wOCdvzBBnO2j9CmeaZt8Yl3w3xMJw=; b=fJOFVQpHnYZTUIieFc31DXYeHA3QlLOiFxQsEhn494tgo6DZuwa1syVthbEMOjSL5M aRhIGmPn/Ek4o5NiB2gwbkViPocHdPFcq3+pOT3GvnezANteFyHGb6bcnPRK+vEXX6CQ xNuf6TwDEiMocb6Ik/cWC7vre0mVblh2oH5aPsjRI3lhDlYsKxeqKIeO+GyL32HLZJH2 6Y66WYsN4WYUQLNH7dEPWogSXOj5GSKIf72IOjedUmyoKVO6RZW//EBF7ua1qXMKB+EW DOoSkBo4y8RTAzauQ4RjcdaIkWnph2LULS2/kbxM9JRCHo3Vm3IPu6DpvwPXMz8tO38V rqSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983365; x=1725588165; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nb3cI/l2kR4qi2wOCdvzBBnO2j9CmeaZt8Yl3w3xMJw=; b=s+jM6YJIL8351n2fvULZAx/6Y2fzTFkpGKCXPdVvIH0oSKlT18XCUY1mGN1mITeXzl nCbt90H51j5xTqMWl6tzx/iAuiGpHvVn9474znXOUml0DDOPWT+jn0HOLrjS6S5JNqCA hHyrP8fRH6chi6laZ1Xe0iYqSY9GZBq/q7u2O6es4ZK0TUK2U7P36re+Dd9l3FbmyNKi yvajaYG8YtYpeccI8dW2WicyZdBGilLR8O7UT/wbygi9EZUWqO5oYGAQDtESGYQCy9ky vq9CxFjK64s8hA0HqS9De226FdcjicgQQWYlKKu/QtQgT1iVLKa0yGAbLT/TdT2gYDcT 1OBw== X-Forwarded-Encrypted: i=1; AJvYcCVR1l++bz0TzQIEVfCY8rN3d23vy5KSdmF/9/JepzBH4E9r4sJdZgmsP1dYWd5tcHedVxZMKltN@vger.kernel.org, AJvYcCWRsfc6fvxRMv6FxeiVKlXPMuK/fSZKOmvtaN1CfUTF80XrMiYKLCvHK310wYsHKQvSP6vdyXQ/LrxABSY=@vger.kernel.org X-Gm-Message-State: AOJu0YwOaKG/WE0Ih6BspgERMCGoOAiCT9St0MwcDKc+OQAGiU8IzolQ GFdNb6Q+9IHX1Xrutvt0a4IIs4xQZAy/ww2qBRa8fgxYt7mDd6WG X-Google-Smtp-Source: AGHT+IFQ8Vi7HEQbuJ3RGHdpRaJsG9O9Ytb9eOWl36HX4fN4OaNwWwJBtZY3HZxNsEakZRTF/fiVsg== X-Received: by 2002:a05:6871:ca0f:b0:260:e2ea:e67f with SMTP id 586e51a60fabf-27790080fbemr4717643fac.10.1724983364848; Thu, 29 Aug 2024 19:02:44 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:44 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 06/12] net: vxlan: make vxlan_set_mac() return drop reasons Date: Fri, 30 Aug 2024 09:59:55 +0800 Message-Id: <20240830020001.79377-7-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Change the return type of vxlan_set_mac() from bool to enum skb_drop_reason. In this commit, two drop reasons are introduced: VXLAN_DROP_INVALID_SMAC VXLAN_DROP_ENTRY_EXISTS To make it easier to document the reasons in drivers/net/vxlan/drop.h, we don't define the enum vxlan_drop_reason with the macro VXLAN_DROP_REASONS(), but hand by hand. Signed-off-by: Menglong Dong --- drivers/net/vxlan/drop.h | 9 +++++++++ drivers/net/vxlan/vxlan_core.c | 12 ++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h index 6bcc6894fbbd..876b4a9de92f 100644 --- a/drivers/net/vxlan/drop.h +++ b/drivers/net/vxlan/drop.h @@ -9,11 +9,20 @@ #include #define VXLAN_DROP_REASONS(R) \ + R(VXLAN_DROP_INVALID_SMAC) \ + R(VXLAN_DROP_ENTRY_EXISTS) \ /* deliberate comment for trailing \ */ enum vxlan_drop_reason { __VXLAN_DROP_REASON = SKB_DROP_REASON_SUBSYS_VXLAN << SKB_DROP_REASON_SUBSYS_SHIFT, + /** @VXLAN_DROP_INVALID_SMAC: source mac is invalid */ + VXLAN_DROP_INVALID_SMAC, + /** + * @VXLAN_DROP_ENTRY_EXISTS: trying to migrate a static entry or + * one pointing to a nexthop + */ + VXLAN_DROP_ENTRY_EXISTS, }; static inline void diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 76b217d166ef..58c175432a15 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1607,9 +1607,9 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS; } -static bool vxlan_set_mac(struct vxlan_dev *vxlan, - struct vxlan_sock *vs, - struct sk_buff *skb, __be32 vni) +static enum skb_drop_reason vxlan_set_mac(struct vxlan_dev *vxlan, + struct vxlan_sock *vs, + struct sk_buff *skb, __be32 vni) { union vxlan_addr saddr; u32 ifindex = skb->dev->ifindex; @@ -1620,7 +1620,7 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan, /* Ignore packet loops (and multicast echo) */ if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr)) - return false; + return (u32)VXLAN_DROP_INVALID_SMAC; /* Get address from the outer IP header */ if (vxlan_get_sk_family(vs) == AF_INET) { @@ -1635,9 +1635,9 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan, if ((vxlan->cfg.flags & VXLAN_F_LEARN) && vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, ifindex, vni)) - return false; + return (u32)VXLAN_DROP_ENTRY_EXISTS; - return true; + return (u32)SKB_NOT_DROPPED_YET; } static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph, From patchwork Fri Aug 30 01:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784116 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E36D14D44E; Fri, 30 Aug 2024 02:02:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983371; cv=none; b=gQ94mdrjMWyAiG8+QL30wzX610ne8UBIKtOH/P63ibyXrFe95fES/Cw4TaoDv3fsfWLakPHdBaYb+QOZAvAvd+Kc/k5A6G1XD6GGu+9ps/CDUJ/Zr7nBQN5B2C9d+tRGgSBufNeH7uCcVjCt23qNesFc+BkfI+AFF1u6XlwnLX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983371; c=relaxed/simple; bh=ZH7n45LSFeKrmwjcD4SmmDveEnkcgkl6hEY/I4tNcCM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QdAm+5GVL9yOO6KtAxulOiuXAs9LOGV4Z2gCSAb6f6eWYDQnlPOVKGehWKCEKqUD5Zzrpoyfl7xKah3JCZo8SLj1yim7x96dA5mGNEaK546xP4Qzt38nknRuk4+Xhxyqx4LwwJImCNLFHVm2q+7dOQm00Bwth34QjUeYmvo3xmY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=K6+5bdGu; arc=none smtp.client-ip=209.85.210.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K6+5bdGu" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-715cdc7a153so1058129b3a.0; Thu, 29 Aug 2024 19:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983369; x=1725588169; 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; bh=Dgev/vaZRZT3ES19Hr7IamdmE2x1ljBGTv1DhPYSR7k=; b=K6+5bdGunjpr+uN/M/CeLGfEWBZ5mmyIiNnsEoswsXb+Dr4n5sEEJsTMzYA2DUb4QY s/M0B5fyOpdD1T47gddoDctp7zk+y8UsCoDQfIJ1+4Ig1RPLNZ/kTFcjWsQhTR3lN6JO piQcFrWA1tLoIAQ1gNQOP2cKOq5GD8TdRQcLnhUnRUyDGUyZiqYllUpn5+0FJjPZtIXh V5GCoyqZ+dGVr1JtVf2/w6Hz8PbhSwJr2WYWD9OgCZBGt/lyWgOfDepReKWkqClNyJzE sghvbGNAJM67nklW+4UAoJ31ZtrBxUZPqDZOEVOZ0pAPkMrBaCD4xdn60mIsabY1rxa3 zXQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983369; x=1725588169; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Dgev/vaZRZT3ES19Hr7IamdmE2x1ljBGTv1DhPYSR7k=; b=m5bw5gYEhEgw+9lfvrS1OLnIU5+P4//6fDND9IqoxI78EMoZECKSvlW6tcygE3oL5X UUOfqgQ/BbfBPXqz9lueS2syt3dAkIzEQlBY7+tnUQPqu50qbfyLVxkbphzlEtVQZVDW SGTxFkcNLXrLLFErsxidYTuP2iXU1NrRmB4mSB02JDb+BC2V2kg0lnLk6itpwOngC8Ac v5X6zQd/2oYq4Cs6IjffX0N2LoodxZox+PjOn8rU49+f4PRFUC7Jdu/OMabn/3/8EBHH fvNQvd2b0zGcOOKxEQp20oUubWUnNLb41RBeEVoGJHbl0i1Gs9XG2MLYXLOTrCd7GxsS IrGA== X-Forwarded-Encrypted: i=1; AJvYcCWGT4g+hraULLxcWe2GEwQDFu9cPGgtlKuk/E1D3dWTRjy8/FinheBNpluI5mQW0jeHVtCJSwT996Bsomo=@vger.kernel.org, AJvYcCWvbA3RdFqUDr/ZYD/ae/54DRV1d7Y+BD0DohTJ06oJelR7UeX1GGZSe9vsc1q20btaLbJ9UITg@vger.kernel.org X-Gm-Message-State: AOJu0YxuL1YVMtb/w3hECOS6eRU5Tnn2Oy10okQwHgmTlXm2LtLYvF21 DqmFbXO7RYtB/R02PZTYoTjIV5l1ONoVOcLUdnun9MA0TG2nC1Pg X-Google-Smtp-Source: AGHT+IFVV05w1BOg6a02IYmRAUhJljTKcApeQedoMAfs0lF1Rb9x2GNI4Vy7/KDL89s30og/owLbmQ== X-Received: by 2002:a05:6a00:1905:b0:712:7512:add9 with SMTP id d2e1a72fcca58-7170a85ab58mr1203639b3a.13.1724983369201; Thu, 29 Aug 2024 19:02:49 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:48 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 07/12] net: vxlan: add skb drop reasons to vxlan_rcv() Date: Fri, 30 Aug 2024 09:59:56 +0800 Message-Id: <20240830020001.79377-8-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Introduce skb drop reasons to the function vxlan_rcv(). Following new vxlan drop reasons are added: VXLAN_DROP_INVALID_HDR VXLAN_DROP_VNI_NOT_FOUND And Following core skb drop reason is added: SKB_DROP_REASON_IP_TUNNEL_ECN Signed-off-by: Menglong Dong --- v2: - rename the drop reasons, as Ido advised. - document the drop reasons --- drivers/net/vxlan/drop.h | 10 ++++++++++ drivers/net/vxlan/vxlan_core.c | 35 +++++++++++++++++++++++++--------- include/net/dropreason-core.h | 6 ++++++ 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h index 876b4a9de92f..416532633881 100644 --- a/drivers/net/vxlan/drop.h +++ b/drivers/net/vxlan/drop.h @@ -11,6 +11,8 @@ #define VXLAN_DROP_REASONS(R) \ R(VXLAN_DROP_INVALID_SMAC) \ R(VXLAN_DROP_ENTRY_EXISTS) \ + R(VXLAN_DROP_INVALID_HDR) \ + R(VXLAN_DROP_VNI_NOT_FOUND) \ /* deliberate comment for trailing \ */ enum vxlan_drop_reason { @@ -23,6 +25,14 @@ enum vxlan_drop_reason { * one pointing to a nexthop */ VXLAN_DROP_ENTRY_EXISTS, + /** + * @VXLAN_DROP_INVALID_HDR: the vxlan header is invalid, such as: + * 1) the reserved fields are not zero + * 2) the "I" flag is not set + */ + VXLAN_DROP_INVALID_HDR, + /** @VXLAN_DROP_VNI_NOT_FOUND: no vxlan device found for the vni */ + VXLAN_DROP_VNI_NOT_FOUND, }; static inline void diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 58c175432a15..ab1c14a807f2 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1674,13 +1674,15 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) struct vxlan_metadata _md; struct vxlan_metadata *md = &_md; __be16 protocol = htons(ETH_P_TEB); + enum skb_drop_reason reason; bool raw_proto = false; void *oiph; __be32 vni = 0; int nh; /* Need UDP and VXLAN header to be present */ - if (!pskb_may_pull(skb, VXLAN_HLEN)) + reason = pskb_may_pull_reason(skb, VXLAN_HLEN); + if (reason) goto drop; unparsed = *vxlan_hdr(skb); @@ -1689,6 +1691,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n", ntohl(vxlan_hdr(skb)->vx_flags), ntohl(vxlan_hdr(skb)->vx_vni)); + reason = (u32)VXLAN_DROP_INVALID_HDR; /* Return non vxlan pkt */ goto drop; } @@ -1702,8 +1705,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) vni = vxlan_vni(vxlan_hdr(skb)->vx_vni); vxlan = vxlan_vs_find_vni(vs, skb->dev->ifindex, vni, &vninode); - if (!vxlan) + if (!vxlan) { + reason = (u32)VXLAN_DROP_VNI_NOT_FOUND; goto drop; + } /* For backwards compatibility, only allow reserved fields to be * used by VXLAN extensions if explicitly requested. @@ -1716,12 +1721,16 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) } if (__iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto, - !net_eq(vxlan->net, dev_net(vxlan->dev)))) + !net_eq(vxlan->net, dev_net(vxlan->dev)))) { + reason = SKB_DROP_REASON_NOMEM; goto drop; + } - if (vs->flags & VXLAN_F_REMCSUM_RX) - if (unlikely(!vxlan_remcsum(&unparsed, skb, vs->flags))) + if (vs->flags & VXLAN_F_REMCSUM_RX) { + reason = vxlan_remcsum(&unparsed, skb, vs->flags); + if (unlikely(reason)) goto drop; + } if (vxlan_collect_metadata(vs)) { IP_TUNNEL_DECLARE_FLAGS(flags) = { }; @@ -1731,8 +1740,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) tun_dst = udp_tun_rx_dst(skb, vxlan_get_sk_family(vs), flags, key32_to_tunnel_id(vni), sizeof(*md)); - if (!tun_dst) + if (!tun_dst) { + reason = SKB_DROP_REASON_NOMEM; goto drop; + } md = ip_tunnel_info_opts(&tun_dst->u.tun_info); @@ -1756,11 +1767,13 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) * is more robust and provides a little more security in * adding extensions to VXLAN. */ + reason = (u32)VXLAN_DROP_INVALID_HDR; goto drop; } if (!raw_proto) { - if (!vxlan_set_mac(vxlan, vs, skb, vni)) + reason = vxlan_set_mac(vxlan, vs, skb, vni); + if (reason) goto drop; } else { skb_reset_mac_header(skb); @@ -1776,7 +1789,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) skb_reset_network_header(skb); - if (!pskb_inet_may_pull(skb)) { + reason = pskb_inet_may_pull_reason(skb); + if (reason) { DEV_STATS_INC(vxlan->dev, rx_length_errors); DEV_STATS_INC(vxlan->dev, rx_errors); vxlan_vnifilter_count(vxlan, vni, vninode, @@ -1788,6 +1802,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) oiph = skb->head + nh; if (!vxlan_ecn_decapsulate(vs, oiph, skb)) { + reason = SKB_DROP_REASON_IP_TUNNEL_ECN; DEV_STATS_INC(vxlan->dev, rx_frame_errors); DEV_STATS_INC(vxlan->dev, rx_errors); vxlan_vnifilter_count(vxlan, vni, vninode, @@ -1802,6 +1817,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) dev_core_stats_rx_dropped_inc(vxlan->dev); vxlan_vnifilter_count(vxlan, vni, vninode, VXLAN_VNI_STATS_RX_DROPS, 0); + reason = SKB_DROP_REASON_DEV_READY; goto drop; } @@ -1814,8 +1830,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) return 0; drop: + reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED; /* Consume bad packet */ - kfree_skb(skb); + kfree_skb_reason(skb, reason); return 0; } diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 4748680e8c88..d38371f33e2b 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -92,6 +92,7 @@ FN(PACKET_SOCK_ERROR) \ FN(TC_CHAIN_NOTFOUND) \ FN(TC_RECLASSIFY_LOOP) \ + FN(IP_TUNNEL_ECN) \ FNe(MAX) /** @@ -418,6 +419,11 @@ enum skb_drop_reason { * iterations. */ SKB_DROP_REASON_TC_RECLASSIFY_LOOP, + /** + * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to + * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail. + */ + SKB_DROP_REASON_IP_TUNNEL_ECN, /** * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which * shouldn't be used as a real 'reason' - only for tracing code gen From patchwork Fri Aug 30 01:59:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784117 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDA1914EC48; Fri, 30 Aug 2024 02:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983376; cv=none; b=FPPp9+7H+6T+J+G+z8ZtRap+czCPHrtrG51QJUPGP2ElvZZ3Sz1StM+O/LifKlAQiYRHLaNGb9XGTfOF3xq6wkBn9VZuSW11KleT6PR8wnqG49aY4MOSQBoA5GZWv7czVh7jaovwSJxeLEgf9BEQMoXg9GyC4sjpriSCFJ1rGus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983376; c=relaxed/simple; bh=el+4PdY80DKzb3LKERekQ9J2SM6HRznhUExf+x3X8FM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oXjDtPSvxtIbiRtwMr5/NJRniZwqHYBgRcq4tjBxB7USO9RtC623wxHQUUC6gbDgeQ/vb5TAxjBvw+QXWrtAaJJrvwn1unw8G+MDP0orzIu1vTZtZyFdpxyGKiIeo4fPNyYHxmb7fhRZIjOlSQfg82/9QaDrLNUgmR9dR8qlmy0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=blMFAUmG; arc=none smtp.client-ip=209.85.210.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="blMFAUmG" Received: by mail-pf1-f194.google.com with SMTP id d2e1a72fcca58-7142448aaf9so946298b3a.1; Thu, 29 Aug 2024 19:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983374; x=1725588174; 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; bh=28Zad+V2vcstpXEFS5Vp943wu1V9ZiKrLymEzef3eY8=; b=blMFAUmGr0O4Lrs98gN2JULCJt3LLZLv2Of7b5RHWUazwEHf1RMTE2Qb/easG+MJ82 7L7GU9lr4xzh2fUVKZrmedRIZoGQK5wDyAebHW3J65Dl8s1m2jnFa4GCKYtcIL6ZsQUo UeUk2qo/E+DS91eZtOfE2o39iNNW8hKrQlTFYb1k7yRS5e0JV6qdNZJg94hZzKxLkolE KZCRNEeh4MYZeLDZi9+ateuKEjFslsy2oMe8lbJMbA/FEfo17e/GmaMpWSpEoD4Am+82 I/o2gtQ6tPmfTuCz3dEc0jS37AF5w90drYY5LWEyuuZW9Uqs4/vIS/SBlK/SUGKndGop 9o5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983374; x=1725588174; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=28Zad+V2vcstpXEFS5Vp943wu1V9ZiKrLymEzef3eY8=; b=KZJuc/NvyoJd6sAHkkPMpySgOPGc1fPslvhVcLMFvvVbGnsKXkhAmS+xFiLnFFQQ3z PBhA8gB6gMtRr6s4PpBk3t8GtmiQhVdDVfSQIwT0CbsDLXQPy+gLQUaABTyMggzarqi/ 7NA7/XsIz4WcdT39lQNwsvbKGR8O1RO9MrciygQF19EFhv2/4M80uopIPJ1Q2wTK9Bql XgxyM2aeywG1w7dvAJaLr6c+Ss/vTbBXMxBi2nY9HCcHQgzTDR27EDHTCrxfhOoA7AW2 6o5JBl6NX+mE6yEPMjcxvVwBced/o4B1tMKL2mKUSIQXgwqZ8yFTL3F52TKC5p6+PJeA pIEA== X-Forwarded-Encrypted: i=1; AJvYcCUdraoFUaLA0CgeLbONxpORqmDHxxogiY6sYolwPyolr6n+Ubd1iatieIlIAM5G4U1iujimMMQL@vger.kernel.org, AJvYcCX1PiYfa4O97PSgoXsPE27G3A4M1ekF/fDmAwD5YDpeFzVZ9u4nfK32wLntsain8bhEg4bErJPr8X1+ACY=@vger.kernel.org X-Gm-Message-State: AOJu0YzAf+Rda13JVPwSkX2x6c6Sr4uTML4cxJuiv5auMwkxbY58ViMC zDZKPDmBpVNDITvW62FSsNxJhawUeDTlIhNswn/V6YYu1Jtq6ffz X-Google-Smtp-Source: AGHT+IGOsCe6FSMMG65dm+WSBFBATv+MW2aJsrHTUa7DzJFZJIB38LTplp9ccmoF6A9NavwdNMUmAw== X-Received: by 2002:a05:6a00:2e97:b0:712:7195:265d with SMTP id d2e1a72fcca58-716f20916c8mr1162112b3a.0.1724983373950; Thu, 29 Aug 2024 19:02:53 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:53 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 08/12] net: vxlan: use vxlan_kfree_skb() in vxlan_xmit() Date: Fri, 30 Aug 2024 09:59:57 +0800 Message-Id: <20240830020001.79377-9-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb() with vxlan_kfree_skb() in vxlan_xmit(). Following new skb drop reasons are introduced for vxlan: /* no remote found */ VXLAN_DROP_NO_REMOTE And following drop reason is introduced to dropreason-core: /* txinfo is missed in "external" mode */ SKB_DROP_REASON_TUNNEL_TXINFO Signed-off-by: Menglong Dong --- v2: - move the drop reason "TXINFO" from vxlan to core - rename VXLAN_DROP_REMOTE to VXLAN_DROP_NO_REMOTE --- drivers/net/vxlan/drop.h | 3 +++ drivers/net/vxlan/vxlan_core.c | 6 +++--- include/net/dropreason-core.h | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h index 416532633881..a8ad96e0a502 100644 --- a/drivers/net/vxlan/drop.h +++ b/drivers/net/vxlan/drop.h @@ -13,6 +13,7 @@ R(VXLAN_DROP_ENTRY_EXISTS) \ R(VXLAN_DROP_INVALID_HDR) \ R(VXLAN_DROP_VNI_NOT_FOUND) \ + R(VXLAN_DROP_NO_REMOTE) \ /* deliberate comment for trailing \ */ enum vxlan_drop_reason { @@ -33,6 +34,8 @@ enum vxlan_drop_reason { VXLAN_DROP_INVALID_HDR, /** @VXLAN_DROP_VNI_NOT_FOUND: no vxlan device found for the vni */ VXLAN_DROP_VNI_NOT_FOUND, + /** @VXLAN_DROP_NO_REMOTE: no remote found to transmit the packet */ + VXLAN_DROP_NO_REMOTE, }; static inline void diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index ab1c14a807f2..c3bdac6834d4 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2728,7 +2728,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) if (info && info->mode & IP_TUNNEL_INFO_TX) vxlan_xmit_one(skb, dev, vni, NULL, false); else - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_TUNNEL_TXINFO); return NETDEV_TX_OK; } } @@ -2791,7 +2791,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) dev_core_stats_tx_dropped_inc(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); - kfree_skb(skb); + vxlan_kfree_skb(skb, VXLAN_DROP_NO_REMOTE); return NETDEV_TX_OK; } } @@ -2814,7 +2814,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) if (fdst) vxlan_xmit_one(skb, dev, vni, fdst, did_rsc); else - kfree_skb(skb); + vxlan_kfree_skb(skb, VXLAN_DROP_NO_REMOTE); } return NETDEV_TX_OK; diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index d38371f33e2b..77bd92f507d8 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -93,6 +93,7 @@ FN(TC_CHAIN_NOTFOUND) \ FN(TC_RECLASSIFY_LOOP) \ FN(IP_TUNNEL_ECN) \ + FN(TUNNEL_TXINFO) \ FNe(MAX) /** @@ -424,6 +425,8 @@ enum skb_drop_reason { * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail. */ SKB_DROP_REASON_IP_TUNNEL_ECN, + /** @SKB_DROP_REASON_TUNNEL_TXINFO: tx info for tunnel is missed */ + SKB_DROP_REASON_TUNNEL_TXINFO, /** * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which * shouldn't be used as a real 'reason' - only for tracing code gen From patchwork Fri Aug 30 01:59:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784118 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6ECC150989; Fri, 30 Aug 2024 02:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983381; cv=none; b=fOjy5V17z2frU3sw0vtIWwUeMoyq2rHRvwUWy7sS4lleIjpqiHnXJhTaNYC200SCdP21ixlmgBAxED3rv2457VlxRjU3LFFGpCWKljT+pHC11pacxD2n9vZxlDnaNy0buwqCBbFN5ogvlpVjodDWEeMh20If+7XGsR05lieCfvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983381; c=relaxed/simple; bh=HohUpHwem2OONADQ04JCzDOhWP6/OBSqC2vr2UZPRQE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J+5n6fSyGj3AbA8m2tXIIDtH3cPjezjoyKNWbrwzm6pdmQyIcf7LAPZn7d7oTdDl0AsdigzO0F27/sznTeFH0L1xKikUQo5/kdp9H7Ux9oerzhBBBY4Gf89P7ceqYcUCE9F9eM0WbbtegVHcwM0azNTg7r1c1qI/XICE8+iFL7E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cCqAEc/1; arc=none smtp.client-ip=209.85.210.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cCqAEc/1" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-715c160e231so1092751b3a.0; Thu, 29 Aug 2024 19:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983379; x=1725588179; 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; bh=JdKbe1x8arQSMRU9KwRJkz3u9sBrXr6XCe4fFX8GBXY=; b=cCqAEc/1slIQnKmgkLf4rVmR7aMBAYXr/xXvIIkwKQ/v+KJYUdgi+NMJbmmbjgRiUx xdg1qjXBAqd8+zvbWvSas9NkNzWaumt8HL98qU9Pe4/UJ5xFNejDoqUBDoeYQyNz3g/1 8ACBHSMDuuly7BO4Sz001X7IOMjWzghdG0ZOduKbeiHEuQtrXHnwAT61TwpLl3M6wuU3 /L6w6ZUxNeljym5fYeWxEvkH/ynWsBtys4M9EwqRE7K3dLMZeqMTspV6i1SSqPncY1iq qLnPO0gBApCh/qjECFOPxatqiVsFL/2q59OFEouI4Hn1EcUp1og/3zsPfE2SGYizeJ+s DQ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983379; x=1725588179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JdKbe1x8arQSMRU9KwRJkz3u9sBrXr6XCe4fFX8GBXY=; b=Wi7UCMbZgQtDvKCwxDBrLaTeBCc2MiE6qSZP21gZdKlyymMK3jWBqOP9ptDzpgYvdx l7IoNXeLR9tPk1iCf8+JsKUqisbIjStNg0/Z9nRRJHrbfuawnHkAHv42ThbSbpOH0eLZ DU+nmUCyn2VJUfppsBnyLkRz3fVp9auFR8Xsl09LMQWPKe31UunIDL4pGZ9QtY1QhNsS ke9kVYZDzii78Qum0QWO0W/BGaNVpDr9w7wt1sAPUsHIZw0tTDWRbWfYlABqmYHRku0v oLQ/qOr6xY4P2oqyo8fQd2GASgm1qHzmmTDgjniPYDK5XaC4p0mknJCmN/OBIfclXPAl bgYQ== X-Forwarded-Encrypted: i=1; AJvYcCVe3GO2db/XMfk0jdIw61AlBdNBzfRWTmO7pU6Mz365om8vxiJPYUrgF2/iKYakK8nDNiR1gwyLgdJh5OU=@vger.kernel.org, AJvYcCXwrBXwcgd8DuR7+GyOh6cel+ubmxXQ/2DqjpozTfrGEIAZa5/vhU+/kOCqQyxVFSgtcYDdV8aH@vger.kernel.org X-Gm-Message-State: AOJu0Yy9sB6d7Y5ffWnNL0Bb+l+F7iZ6WHtgmk0/iy92RTcSmhd1apC0 su28WTmiRWu3baKk1E98H/C5BYFzprosoWEIjvTO+gVAW0qcCtSK X-Google-Smtp-Source: AGHT+IFBOlgoSaSOc2zYFG1qT4obUuiLoGEDwnXk30s6Dtq2x36HDhoyWYzOGUnthpdf/ASjnNnj1g== X-Received: by 2002:a05:6a00:3911:b0:710:4d3a:2d92 with SMTP id d2e1a72fcca58-715dfba7c6bmr6116733b3a.4.1724983378748; Thu, 29 Aug 2024 19:02:58 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:02:58 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Date: Fri, 30 Aug 2024 09:59:58 +0800 Message-Id: <20240830020001.79377-10-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb/dev_kfree_skb with kfree_skb_reason in vxlan_xmit_one. No drop reasons are introduced in this commit. The only concern of mine is replacing dev_kfree_skb with kfree_skb_reason. The dev_kfree_skb is equal to consume_skb, and I'm not sure if we can change it to kfree_skb here. In my option, the skb is "dropped" here, isn't it? Signed-off-by: Menglong Dong --- drivers/net/vxlan/vxlan_core.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index c3bdac6834d4..f013b9007d3a 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2372,13 +2372,16 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, bool use_cache; bool udp_sum = false; bool xnet = !net_eq(vxlan->net, dev_net(vxlan->dev)); + enum skb_drop_reason reason; bool no_eth_encap; __be32 vni = 0; no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB); - if (!skb_vlan_inet_prepare(skb, no_eth_encap)) + reason = skb_vlan_inet_prepare_reason(skb, no_eth_encap); + if (reason) goto drop; + reason = SKB_DROP_REASON_NOT_SPECIFIED; old_iph = ip_hdr(skb); info = skb_tunnel_info(skb); @@ -2482,6 +2485,7 @@ 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; goto tx_error; } @@ -2533,8 +2537,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ttl = ttl ? : ip4_dst_hoplimit(&rt->dst); err = vxlan_build_skb(skb, ndst, sizeof(struct iphdr), vni, md, flags, udp_sum); - if (err < 0) + if (err < 0) { + reason = SKB_DROP_REASON_NOMEM; goto tx_error; + } udp_tunnel_xmit_skb(rt, sock4->sock->sk, skb, saddr, pkey->u.ipv4.dst, tos, ttl, df, @@ -2554,6 +2560,7 @@ 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; goto tx_error; } @@ -2594,8 +2601,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, skb_scrub_packet(skb, xnet); err = vxlan_build_skb(skb, ndst, sizeof(struct ipv6hdr), vni, md, flags, udp_sum); - if (err < 0) + if (err < 0) { + reason = SKB_DROP_REASON_NOMEM; goto tx_error; + } udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev, &saddr, &pkey->u.ipv6.dst, tos, ttl, @@ -2610,7 +2619,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, drop: dev_core_stats_tx_dropped_inc(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); - dev_kfree_skb(skb); + kfree_skb_reason(skb, reason); return; tx_error: @@ -2622,7 +2631,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, dst_release(ndst); DEV_STATS_INC(dev, tx_errors); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_ERRORS, 0); - kfree_skb(skb); + kfree_skb_reason(skb, reason); } static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev, From patchwork Fri Aug 30 01:59:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784119 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oo1-f68.google.com (mail-oo1-f68.google.com [209.85.161.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 61BA91531CB; Fri, 30 Aug 2024 02:03:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983385; cv=none; b=M3iaNuTTJek6TMtxvs8YaxenJJGHfRoqOXtTtfj6VqdS6CbV8leI5NPsACN6/gG+YYYcebo+uQ285cEFv0mltBTIXOuvhf8fJKp+Kr1GlNTrNlxOnOe+EjhixLxYVwUt+9zDN8rg0DgXS3lr7Fb73Q1Ll8vGZyRu9X7Fle7rp8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983385; c=relaxed/simple; bh=9P1mqG6VPSpkSc+cDNoawndgukB8gmMirUrypXaavhs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lDUub7q5Z1pYCPEtEy+HnFyI8/l8paTeGcOed96jtvFPJwIc5OzhblwUleS9TF1i7PrNuzGTuQb0EkGz5ZtPi9Ss+Aa7U232MXW31wLX6tqJjN4GoSD4jS1m6PySE+DHhztxcthtpgWREMsR/06deTCOlWyfHIY96LDeYLzrHzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OXCCBmSh; arc=none smtp.client-ip=209.85.161.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OXCCBmSh" Received: by mail-oo1-f68.google.com with SMTP id 006d021491bc7-5d5eec95a74so790266eaf.1; Thu, 29 Aug 2024 19:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983383; x=1725588183; 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; bh=Z/BYr9nbVa7vl+8GW2u0kvBaL1oxUPHU99B66m+wyqc=; b=OXCCBmShYrKACqV5/xJh65X97ON+3MncTVQK0gYKhCFqFIPKbYST1oV3HunbFk/Ayj m1GR8bebNNYv0HjFooBnZsrAR4loglaIbPZ98cyrEjEwWVzCYy37jn5sH8zhLqzvG1ok PvhGOy2Mf20A+kWwGTOK59Be1EfwYhXwZEGbrP0gpNPT5LKs2enO3eLkKn0L5ZGPqmv/ cgBrEhDsxaPCTTKN8eeSom/SlnVL3fSM9MLu/JzUX8otEgp4QU5bmbmYjgbcY7++ACl/ nbmL/+23OqhxHmznlw2HiOEuGACslq+hBeSdefvwb1AJC+F+GsjritN0/BgZwvhxdCip kVnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983383; x=1725588183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z/BYr9nbVa7vl+8GW2u0kvBaL1oxUPHU99B66m+wyqc=; b=cYNVF36bEMvsAwckau5TPXLzO5WKNbWh6IGk3+M1F6kOoWJQTkcDw9G1p75noj7bj5 MPvoZT3l+Z9+qgQhc2GR3uhDFKDDJ5ckLGHpn5vaAtdna1Pvu2Ep1ysElOTBKOebaaBl Q5HawenMs/Et2Mja661P9pnslIf+f59f9p1EsYjfCad3tavQCf2Q0FRJ0ps3kq3JBoT4 64WIgaCfNZCwvHaEt9HRBTU05P5droCD9MjvvomegDAi4DGvxnnbzbXdb+Jy6J0ofbLt 6jiT67rUNfaxtJ6qzhKxR2pDPpLtT4K2FMEwat+VYDMK2gBJZIX308wMZQnI0AbEVub8 2QuA== X-Forwarded-Encrypted: i=1; AJvYcCWIKTCt3tSbj/oDVJgtDBf/bGViEUYxg4JNA8V1k1AhyPlej+PfGgx7FlZcCe0PjdgBNxH+1mlLHTM3B8c=@vger.kernel.org, AJvYcCX47XDEuW5BwYTMFb5jJNeR8u64sWQIm7X/x7L/4ICqiMGIMMb5TOaotH16FMOalg8g300Jc9eC@vger.kernel.org X-Gm-Message-State: AOJu0YyAjpIGMhFxKYo32CWgBfAp6JSAF+xipUiPvkvaKhgG84lIpO/O hh57z3twhQhA0MOYJiD3uVucUQ4ZCCTo+W42jAP1VAPWTVdZ2DRH X-Google-Smtp-Source: AGHT+IFvq8fnAVyWcQ8UcYbVlwyoMwhB3N0J2npYlLizXXydKttTUGsZdh4CrpG7rsmq1M4e1s49Rg== X-Received: by 2002:a05:6358:52c7:b0:1b5:ff76:e076 with SMTP id e5c5f4694b2df-1b7e39333a8mr90531155d.17.1724983383159; Thu, 29 Aug 2024 19:03:03 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:03:02 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 10/12] net: vxlan: use kfree_skb_reason in vxlan_mdb_xmit Date: Fri, 30 Aug 2024 09:59:59 +0800 Message-Id: <20240830020001.79377-11-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb() with kfree_skb_reason() in vxlan_mdb_xmit. No drop reaons are introduced in this commit. Signed-off-by: Menglong Dong --- drivers/net/vxlan/vxlan_mdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_mdb.c b/drivers/net/vxlan/vxlan_mdb.c index 60eb95a06d55..eae3a05588d9 100644 --- a/drivers/net/vxlan/vxlan_mdb.c +++ b/drivers/net/vxlan/vxlan_mdb.c @@ -1712,7 +1712,7 @@ netdev_tx_t vxlan_mdb_xmit(struct vxlan_dev *vxlan, vxlan_xmit_one(skb, vxlan->dev, src_vni, rcu_dereference(fremote->rd), false); else - kfree_skb(skb); + vxlan_kfree_skb(skb, VXLAN_DROP_NO_REMOTE); return NETDEV_TX_OK; } From patchwork Fri Aug 30 02:00:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784120 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A27941531F9; Fri, 30 Aug 2024 02:03:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983390; cv=none; b=ZSw3pC6MMY5VPslvQMKKDKU+uUlQSkhdqo/wNriaCDVCiHgoJ/DwISiJDLyRQ0ZXPdwXVZC61/FtXyA5zfzC3Yk5DJTTNjEqlnAKczI1ykjIoaPyQGbzWVt+CH/uE6XdsK8hCiFvtowSZ4xgOElnSypIIPEfizVDlc10appHa3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983390; c=relaxed/simple; bh=/ygayHblCOTxFAz6eoXnqXHoViN5LhOqUxLiV2HDyEM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WdQ6U5ARVTkQS2WTcPyuU/NyG/AWrmQhDGjrmhIMvJ6WLnvEM87//wP9oKJ3cwiMgls6phGWt39CBqtCumXhB9ZE3iBIBn+K1X7ExZxM6iyQz9NUAc2oGsrbhMWrMy4Jn1/TOdiiq0tFdcoNlwlzvwYczIl0H4xbS98sZwCJ7FI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SB+9uyaK; arc=none smtp.client-ip=209.85.210.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SB+9uyaK" Received: by mail-pf1-f194.google.com with SMTP id d2e1a72fcca58-715cdc7a153so1058275b3a.0; Thu, 29 Aug 2024 19:03:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983388; x=1725588188; 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; bh=WDu2MVZvn2ikJWd9emVPbJH/BIivnGxQIwwx2gcqaW0=; b=SB+9uyaKvuqKcl9zg55IBCU1jsIMJdlooDnQnLSATP8N1noBF815j7tTEX8S+fNfni yovPU9oqPJ/EuffU3npvCMOxFXoJWB9u+muJ6zm+DuQbUFSKGLuyOLSKngHTKN5u63X1 0tQEfhjLWKQIQHLITtsAVoJmj4veEEVi7lFo086KtZz49loWzsak9KQCHHpddhuDWYqt iBaR9st15XzB/FDjo/v0iehPigrTIkq3HsvXcpnhhIN/qSbwe3ByxTjvWhSZq85dnJtn Tq0br4hKmokAeg3h6bHO2jtwTsFgQ6clZDLSWQ2lzpFS9qkQTs/vcQwIEjvJZeewysvh Ydkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983388; x=1725588188; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WDu2MVZvn2ikJWd9emVPbJH/BIivnGxQIwwx2gcqaW0=; b=wHj7pMQwPaPv5SlM6y+YvWVCFH+nLvb3ZCsyFrVf/aq6Gvyga7Yqoz9F87tibh7Rqk a0Wx+3X++BKaBBdIIrRNDN0MfcknoXwLa1hfftSi68Otsa2fNqn7EWjRfx8+FoPepKyo N2Tduy+Uu6C00RHULVp88USQqAymLLIsMk121TSBo1q5YkheT/naeR6IfEiCvWCJHF7m yZqe56D5ezlaW92lz/WR5ukC2HqS3AlaJbQTXhSjTPJC3JxfleRHehnDnEwjUip/G93v WfhVyj5bb91ef9gNPM4OhBePXRp62EHuw42Ky+6Vmp5ui2lMxbxUvTQYyabKzCC7FHyc XJFg== X-Forwarded-Encrypted: i=1; AJvYcCW3072D/7Sy26FQUpnhKTSydvvqvDt+FOVdUU1tWhwDucQZdRL7I0LUge2iyCT71blSwn2eweTcKF1w1qg=@vger.kernel.org, AJvYcCWgOAxLBdjCoWJeUklCGdwIFuSIfytGqEFDo2ju014AfRVR3PtLDsWYVr9Sd2xKDEJN8m44PU47@vger.kernel.org X-Gm-Message-State: AOJu0YztsBAdvpKwgfldDCXbP2WyCK63awYMhFSAb8xJv/g/fbnwEmW1 cqd+eZgpL/D+TvfgMHnBjxzmrTTQnzrK/fi2jrhVmVL9ZRQd1fdZ X-Google-Smtp-Source: AGHT+IECAxt/KKRq+Z6qTVSzI8FjmNUSPy+ysdiXw2gKK7eFF16UWBCUUQCK1+K3Yc2w96eBr62scQ== X-Received: by 2002:a05:6a00:85a5:b0:714:2336:fa91 with SMTP id d2e1a72fcca58-715e1046500mr6880515b3a.14.1724983387831; Thu, 29 Aug 2024 19:03:07 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:03:07 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 11/12] net: vxlan: use kfree_skb_reason in vxlan_encap_bypass Date: Fri, 30 Aug 2024 10:00:00 +0800 Message-Id: <20240830020001.79377-12-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb with kfree_skb_reason in vxlan_encap_bypass, and no new skb drop reason is added in this commit. Signed-off-by: Menglong Dong --- drivers/net/vxlan/vxlan_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index f013b9007d3a..adf89423e5fd 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2288,7 +2288,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, rcu_read_lock(); dev = skb->dev; if (unlikely(!(dev->flags & IFF_UP))) { - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_DEV_READY); goto drop; } From patchwork Fri Aug 30 02:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13784121 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3742139597; Fri, 30 Aug 2024 02:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983395; cv=none; b=JWkPSpy1tRN5zSj1ZNFDElKcHW+Blq64wK+8lWTsnjEWDqqrfTWO8tv8meqg2IpN9gGYA7goYkSAK7IdqlV+OFaNTaL1eu+iWdoErRcZk7dfQQeXhj9c1K1fitzvn5epEHjX753lG8OGL714VZ/7fJDRskY7stKdJnp0EkQDfBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724983395; c=relaxed/simple; bh=R4gv0SPgrsRUe46OTe7crquVQ/CEzuw0FVvWWYYcPE8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CZ1pUjrrdsq49Rn/r2s1M6BllYglrW9kVxnNgwJDUZsRRSQr5PEBqSBcSHIrBDCHruhwbxusjEH4RiLcwDmG5diQ69atR6nVnrzzybxTMsQ7NgtSj+byB20WX2j9eL1FR3BZDQxWF9isrFj/kU0yfdVJQ6HTvXs85DPn9hk58cw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CYicaLPU; arc=none smtp.client-ip=209.85.210.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CYicaLPU" Received: by mail-pf1-f195.google.com with SMTP id d2e1a72fcca58-715cdc7a153so1058306b3a.0; Thu, 29 Aug 2024 19:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724983393; x=1725588193; 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; bh=ywfiqKh4u7bFVVs+tIwjEBC2kXxlfEwBoFKokKTsO+g=; b=CYicaLPUdovYO2xTbF97dLVgbo8nqjChQi9I6/C19jQOu3yYquCWa73vrzupS2KHJM EIi3JRuSQTDpoSMF8mCFf/XB190Aruh0lD9GrsVMnBmbW5whTUxGSdWkfU+k3S9e94gC aHsXciWpkDyIchlmb+Hwaz0AuYjnI0yu1qMObWtUryQj38ip5qzKWiCN2ZGA2pOOltdy n26g8gpQT3zErZxVDqyX1FfEh4hsvZVWTBpueLpetAnWSXG7ISWRPEKjW8PYIlt3EorL XcwIM3L6GTPtLTQVlcceofAKle4ARg9KaucJrRtoZlruqIoKbxwy0ju0bhGrgnIuaMJf jgHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724983393; x=1725588193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ywfiqKh4u7bFVVs+tIwjEBC2kXxlfEwBoFKokKTsO+g=; b=S54mq6GqEwUahcgGr0gjTc2e/yYqx5POSLbjRxY7hkZD4TKVreD1dbuiGoWCG42A7q baNph/M7ke+KuauJrn9RszVfMslCXXW7Wo/pCzpY0GS6/wRGqP8ZS6wAt/yzfBZ8ntRL ut0c6z3ticAiR2YG/IOabOUZAHGsWuJUAexAIqg3q9+mXLhu/o+YZ6QnpqK7iQyhQq0c uEsuNt5mafDeEbr6dEECngflwcChnYC5cVNzIKDDDiNgy8sk5QaDkFimAMO4idiFHBXE iNz4xt0K6gizxN/IAi+wjCEXTx4sILxquPYNKJm+b5bGi5Kf8qZ1w+DlGCm6nSOQPLv5 MBlA== X-Forwarded-Encrypted: i=1; AJvYcCXB/di7YINEE7iGfTc7kkBZBOEUe0TRGhBe5cTZCzuOY1x8rSMbksZhPndPGpQ9UDW/HvhGqFXF7ZVvXzY=@vger.kernel.org, AJvYcCXr55TMwjvep3UmZur9BesiFSEHmyiueR4U0ZaBJHM1E3nGjKf+DFEl/oKM9MYGiyZLqttW4MTF@vger.kernel.org X-Gm-Message-State: AOJu0YzY/6+Lfk8FpOlEX6y0fSQldE1b0M1vTKrCrk1K8mA9YobKBMIq PyE4qkpRjfMWyR58zNPybGPa+Hlz+is9QLzMQV5hBTWwFhhNI9e8 X-Google-Smtp-Source: AGHT+IGOA/23GIGeKGBXHChGL+a631mrZR4C27wtUJFcsLMeHEsTgBEilGmHKdpL/ERsi3koNdAH1w== X-Received: by 2002:a05:6a21:10b:b0:1c4:779b:fb02 with SMTP id adf61e73a8af0-1ccee886705mr1352666637.21.1724983392693; Thu, 29 Aug 2024 19:03:12 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-715e55a6b60sm1764221b3a.87.2024.08.29.19.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 19:03:12 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v2 12/12] net: vxlan: use vxlan_kfree_skb in encap_bypass_if_local Date: Fri, 30 Aug 2024 10:00:01 +0800 Message-Id: <20240830020001.79377-13-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240830020001.79377-1-dongml2@chinatelecom.cn> References: <20240830020001.79377-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb with vxlan_kfree_skb in encap_bypass_if_local, and no new skb drop reason is added in this commit. Signed-off-by: Menglong Dong --- drivers/net/vxlan/vxlan_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index adf89423e5fd..65f532a000f0 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2339,7 +2339,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, vni, NULL, VXLAN_VNI_STATS_TX_ERRORS, 0); - kfree_skb(skb); + vxlan_kfree_skb(skb, VXLAN_DROP_INVALID_HDR); return -ENOENT; }