From patchwork Thu Aug 15 12:42: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: 13764743 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.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 8132E1AC88C; Thu, 15 Aug 2024 12:45:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725951; cv=none; b=ekK4UuypCueVr0ntFZwOfh8uwXrVJzFy9lvb6fOIzVEzEUFequlNERonmL5OBIlKVWWY/EZx6WANMWU2AscZQ3+Mn6K2wl49KanDycEe9IauU7Jpt93+sK8Y+gGqe/LKr2OHBtgykBM0cxxlXRhy3gfte88euWw0eWOEAc9XRJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725951; c=relaxed/simple; bh=tL6JvbRjlWSlxR/d/T0eoTIwMHVhyn1u2kUnYN6CNX0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I41LvMTfrrjs6TvvBsXvclT8JrkbEFyc73gSCy46unUk4gH2kI+jMdnx5RUqQTYrISy/UNP1W5oNLliS0tRs6bVx9ICMEW+mtz4IvAzNMgcDoUIahg91cETv4/BZqqT8Fe3dzTZXv0fIxT5jlajMR6grTCPUJRz46QFWDb3iBiU= 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=g3CM/Cqu; arc=none smtp.client-ip=209.85.215.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="g3CM/Cqu" Received: by mail-pg1-f195.google.com with SMTP id 41be03b00d2f7-7ae3d7222d4so681998a12.3; Thu, 15 Aug 2024 05:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725947; x=1724330747; 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=2fta6JFeSB7c5lYbnKfFdO8GDsHLzjfZEltROIk0550=; b=g3CM/Cquv1Fa9NOTei3pjTrQ2LeAp1E7Ahc8Su7QKRc7Vu4F3uo+5++qUgeSR1z24q gmNvcozeksCJ8pMyHTFm5iFfJL+H0V3Gc+DnsYI8T/f6NWGxhrp8VW5sIImVMCzspDAZ SRENaXoOtCHETUiURnp/w4I1iP6CQv/VC8DzcaYasZVZcR9z3tzT5XIv9fskiBA1gg7h xqLmxz1GRuAA72dEfSYCyVdnqToLRA58VlGoF0kbXjZVIAnxqUe9jvswnU0q9S0Zj/vq BU7MVppt3oyBkr7OZOa7JeTlYTZTlD8Tn9948eVe/xgz7QDpFUVhwQYh43/BJzKlqEsh MNFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725947; x=1724330747; 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=2fta6JFeSB7c5lYbnKfFdO8GDsHLzjfZEltROIk0550=; b=A97GMnIhysBMa2UA9jSuLDcfmG2jPzEp0sjXNqo+51tU4bQ2/X4Zt9A/mWSsMYyrR0 F7XgFPXxxWHViiw6rXq9jRlsgsw9Usq0aqWbkztNHUCK7Fmkw397ysxcoSjkJ7h3aCN6 mFaij+2pTYcKknBhKiZYFfrqRCBInpbtMprt/jjrizA+iSiGtBCor9SPdklIMPy1lLtN czYv87nOUOOMq5RXs7TCsX54I/VqWsx/d8ZigCuwjKjoplQNNaziS8u5cVbm0HOLHrct HFDz560h0+hjTVQRTVrushPIpHVQ+taQC1LQbkFlpoP9skK+qoVn5ilOw/tTb03jBHqs rkKg== X-Forwarded-Encrypted: i=1; AJvYcCX69+cKG0W3u9q/7OD8ZwmUm45MEIjEcGyF2QkmXZMP6PpgoGWrukm86qEqq9PlGkqHpYECo+13Sg1XFPTaGI38WJ77Unedv4Y5D9sHal7cFdNPLykfCAcGjrzHJZRVMtdKiswh X-Gm-Message-State: AOJu0YygU1TvIXMJQoqev5GHYRhYzB3QbpFRKnOngDOpfkvJxDlydBe2 MFCxP6Tam/43f0DVB0TEVOnqquoDkag4J+P3UNJhsD8CEpubgQ29 X-Google-Smtp-Source: AGHT+IGzeTxcYDyToKt5s0HI8cdzCxZaGdO46vqfYjT8o0A7YZnjgjuqL7cbmf0urTwPOjFBFnsOFg== X-Received: by 2002:a05:6a21:3483:b0:1c6:fbc8:670d with SMTP id adf61e73a8af0-1c8eaf63fc5mr6876058637.43.1723725946566; Thu, 15 Aug 2024 05:45:46 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:45:46 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 01/10] net: vxlan: add vxlan to the drop reason subsystem Date: Thu, 15 Aug 2024 20:42:53 +0800 Message-Id: <20240815124302.982711-2-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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. As the vxlan is a network protocol, maybe we can directly add it to the enum skb_drop_reason instead of a subsystem? Signed-off-by: Menglong Dong --- drivers/net/vxlan/drop.h | 30 ++++++++++++++++++++++++++++++ drivers/net/vxlan/vxlan_core.c | 15 +++++++++++++++ drivers/net/vxlan/vxlan_private.h | 1 + include/net/dropreason.h | 6 ++++++ 4 files changed, 52 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..83e10550dd6a --- /dev/null +++ b/drivers/net/vxlan/drop.h @@ -0,0 +1,30 @@ +/* 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, +#define ENUM(x) x, + VXLAN_DROP_REASONS(ENUM) +#undef ENUM + + VXLAN_DROP_MAX, +}; + +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 8983e75e9881..5785902e20ce 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -4834,6 +4834,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); @@ -4915,6 +4926,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); @@ -4929,6 +4943,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 Thu Aug 15 12:42: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: 13764744 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 0438D19DF60; Thu, 15 Aug 2024 12:45:52 +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=1723725954; cv=none; b=Elw4jOJBFM/p83BgEMRZCZg0PbizjD6Ws7SbNAy7HSgKH7qsQKKiTFqdKtg7G6COTp8N/s8LFQQUukTRmK5Uqmz/PbMpjJhmEcRBKqzu/YIft4R3uMkyw/4rxW2eRo5+sXE1oSi7HOky0CT6dJPCX7/9rIRAqGeP78Sr4LcSTmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725954; c=relaxed/simple; bh=OlbuseaNOvF3/Jn6P4MlwF+xvi30sjvfJ1q1ayGJ0vE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lS0dK+OUYpSdNhRGYim5ZDS3zqv3XpgnpARslk7TGnAgpMvB7gQa8Ukgju2aN/uKU+AQ3RLtKd6YD65cEcmi3zW9gvv1Kyovxn2OhlHUaujOpEoQseMXs9u0yU61wgz0XRsa85hYmb+d7lDlmgBKAOffl3rrpQ6S/uiCkc2DtUA= 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=jS4AkjLK; 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="jS4AkjLK" Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-70d2ae44790so652955b3a.2; Thu, 15 Aug 2024 05:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725952; x=1724330752; 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=Qp8zeXhcEXg8Pv4LgyftvHpTpRxQnDDkErPbz0q7r2E=; b=jS4AkjLKLjj/+Pbi+7o0f0pk9sRftLZCUNVnbnQfOsZuLi3YS7qzGvN7TTFbsAgZ+u hXpS/OJvkPRFoLMWVkwDanA3o4P5yAkodNT+ydgsNqnfdUkVqnTYsfDXUhVDIqq5vjJx +bKCgqvPGVvx43JMJ0HVHweTf+IVQ0QeidbiJUt1hlHIJbYzkskq5S6juMH4svz87Ahs hsGx6h0MwFih/dID4NMacA/s3U3Sc2WhrjG1uSgJ+40S7SmQXSNhPmQTKKBbJQBRY4fq jnMQ2apIWz3yUKMs9TXuqxH7p0T3mDZhlwjpzPTi3HRpm5Z7rtYiMaivuJ/9OLfHzUZN NOQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725952; x=1724330752; 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=Qp8zeXhcEXg8Pv4LgyftvHpTpRxQnDDkErPbz0q7r2E=; b=ci3/sHj+IuAummtF6+ntQxNyZ0qjJE1lHs3ciCuXkykpPJVq5cjep0tk0BjeNinHck eRK7Y6wSdl75dG89/fLIKqW0FvRELe3LRqEXnqGbNdZeiyXM37lC7aVnI3quZBkO12L9 U3fgXRBrF9Nv6eCmUQadCG46oGCW2W7qZMJgcvXDD68zLVURwh0L8XpEoqzWIgZVdWpC hu1nzjn/9mrzOgls1l2rjWm16eX1YX52kIAg0Z9R3tBMgLqXpTXnhZ4LDkH4zEvcJjoL tHiSx8sFgcDVqKZZLy04HEP9tnmBW3cdY2s1ssPnlcl2qqTZnTZn8zO8h+5RWhMUnBcj ym1A== X-Forwarded-Encrypted: i=1; AJvYcCXX0rYiEBIqyG5EuDJCcN3avMw7K09z+V8vF1qJ12KF97T/i/2cJANkhRyIb1DcuiHUTDVu6I1zPIaZbB8eFYDlgKnweRkmrrKYVeYGu/Ye7GOc5j3KhQvn0onZuJAIkZWTIf3j X-Gm-Message-State: AOJu0YxWbmaimSubRxLYqGO3CO1+L4XpivwhylaIioBg1n6bzyrbIy/L oZmby8L5++21zMuCPNKhRx+jIlYUop7fGcvcDsV4g5CPEIm/aauG X-Google-Smtp-Source: AGHT+IGiVfC6+BHZXeucoMuSKYp+sYroQa+K52k3ZPcfelHi33uZ4sXWZwIeo26CXGl1WMQp6mkKEg== X-Received: by 2002:a05:6a00:8d2:b0:705:9a28:aa04 with SMTP id d2e1a72fcca58-7126739c567mr6987357b3a.23.1723725952175; Thu, 15 Aug 2024 05:45:52 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.45.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:45:51 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 02/10] net: skb: add SKB_DR_RESET Date: Thu, 15 Aug 2024 20:42:54 +0800 Message-Id: <20240815124302.982711-3-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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 For now, the skb drop reason can be SKB_NOT_DROPPED_YET, which makes the kfree_skb_reason call consume_skb. In some case, we need to make sure that kfree_skb is called, which means the reason can't be SKB_NOT_DROPPED_YET. Introduce SKB_DR_RESET() to reset the reason to NOT_SPECIFIED if it is SKB_NOT_DROPPED_YET. Signed-off-by: Menglong Dong --- include/net/dropreason-core.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 9707ab54fdd5..8da0129d1ed6 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -445,5 +445,6 @@ enum skb_drop_reason { name == SKB_NOT_DROPPED_YET) \ SKB_DR_SET(name, reason); \ } while (0) +#define SKB_DR_RESET(name) SKB_DR_OR(name, NOT_SPECIFIED) #endif From patchwork Thu Aug 15 12:42: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: 13764745 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.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 9821C60B96; Thu, 15 Aug 2024 12:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725959; cv=none; b=mQpSeVo1L4MB8IBIPQ5FdHLDAjnRrO5NVscqEtJSd0bFi/ZYn9JFFUgGLNjiS1nXcrSCQi0hF4W+gnHRtKdpdDg+rONHKxEuspd9/BfUJfHOQ1zeh0HxkI+qE3KeiU46bHex+WfVPSk7iOWk5hwJKQl771X+wb9W2i6mPw0dyEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725959; c=relaxed/simple; bh=8LAOWEJKivormVDWhY8ctyx3bdfsXrYENOdStCSlCMo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o5d2J4pG8jBKysWCCmha80eZy9frRykUiJOq83L6v9LiP+cD/WtC/RIHT8Snwd/uTf77ivaX0uSCjUxf1jrO3H7HAdfxFi2phK4r+KdVxf5HEG7rN1dVvz3akS2+mU6EnaidWYUyGz5wxmqQRI5cweGgJTMICVCsuLIkdfQQY5I= 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=TeMM8esl; arc=none smtp.client-ip=209.85.215.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="TeMM8esl" Received: by mail-pg1-f193.google.com with SMTP id 41be03b00d2f7-7a103ac7be3so678239a12.3; Thu, 15 Aug 2024 05:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725957; x=1724330757; 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=Xj+qWSDyX4FBhZM05vM8itqjIPEXstrdTgRr1ZL+rkA=; b=TeMM8eslShkatQhJPmMyqxozDfKPUz0XGeIeAy4RhoNxm0PHbBBWeYlHIXIJEeYzHU 1jmmRpQIV4BntE9+SGDDB05adQp6rPFQ5igBPXYdEk73K1Tlqdu82CE8A9wSjlgoXAEM W/fMk0W9/M+wZg41xJR+EcBOfiqVxjmJbRJTM9/bzLFS2n053550sCW5XFJ91hISWKuU yPkCo7A8HJ+5UajAVk8nevgacJ00gTdXXn6SaS2HLD9yO1VWFzwTkRIgPve6XfH8df6N q+DNOgDIK99NI5x2mNGNIvDLilpNejq+HzadsPPhaq0PpFQmRboSkSJ7MxINLKn4MRYR W5Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725957; x=1724330757; 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=Xj+qWSDyX4FBhZM05vM8itqjIPEXstrdTgRr1ZL+rkA=; b=oW6uB3Gx5CVVhsdtRdftI/pCbf3+vWek3zSZjIeywfPm6VIxvSUlytw6fB4ZtItNd/ P9b47rr5MSg+viaLECDkVc6GqsOVdO5sN6o+ojGeDoWjcHTVjIFBIce57uhphfvUaZgz 4BvBFz9oOFOE2LtvHMkVP3AWXdhw3jbWJpFITBe/dumUM5Ev2Nw8QkE6RmbQystniUM4 nUQ3HDQAvRCRQJpvE224lYFx2+gKLv2+pytUNjpnUOZIwh5UMF0GTvxBw1o29/GTAbkE Yx5Dox9rx0pcSYbexZvEFDJiJnwVsitxH7tHheNG3QS7HBMXFfZ/133a58TlGk/w6Doz MlyQ== X-Forwarded-Encrypted: i=1; AJvYcCXdRG+wPcBKCCJo1bLp+0JQZ6GV/S1xaOSE7xygUX2AQhFieMy2W5MThGkmQyNKhOkYOUN4qcI2f+9Yq15KhljVvy2DAUJg1OUIdUjrNJO7BC/HumEA4nQGJGb6ljCw0YZOQZMr X-Gm-Message-State: AOJu0YwhLRNfZqL7oA6pgFMsDBlGtsEj2S8IW7wV7tDudr6LQ9wzjUbR 4ipS4USM1rlVQCICndKPrR3V/A2MgduEpMW/31gsirM5IRQ8gK7c X-Google-Smtp-Source: AGHT+IEcciK8oBshBV27dKgjADfcnngiRpIshadKUClsh24EnLpmUHM4kwEBkRoADhZa4q09ZKfgDw== X-Received: by 2002:a05:6a20:6f89:b0:1c4:b843:fa25 with SMTP id adf61e73a8af0-1c8eae900d5mr8335640637.26.1723725956738; Thu, 15 Aug 2024 05:45:56 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.45.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:45:56 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 03/10] net: skb: introduce pskb_network_may_pull_reason() Date: Thu, 15 Aug 2024 20:42:55 +0800 Message-Id: <20240815124302.982711-4-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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. 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 Thu Aug 15 12:42: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: 13764746 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.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 76BDF19F49B; Thu, 15 Aug 2024 12:46:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725965; cv=none; b=kAUhAZknmA0Q9wpA3uyqRd+kF6qOWTHBuZ6dazc1N4pXmt17PIH1NtNu+N+0Fj+20cjrGjjDU8V0BfrXwBe5Ov1+/idkVrOD0BtInnA/PnxtWe1sD8MhrJo7zCezfIFZFKC9TDTruRZ9oIAc6aIPffGRt1I7aPIqLbXf43mbrfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725965; c=relaxed/simple; bh=al8FeJDNANmBeWYeB5orKViRkkRdMcv1FPWSbriMh1I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=siopsPY42kXRN6t36G0C36bCwH0y4H9pAGcGcwnmDP8a4xwpiPd2hVr2najFFG/f+AQqIMg2lgLW1NHbzgnXY6AnABndDohwNjfOcB9JjEX5FIqXRc9S3AkFcspRq8rylw3F4VcEqLnePPtttpP3KurUFRlCS6tj52pp+sfGEwk= 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=YOTTKMSz; arc=none smtp.client-ip=209.85.215.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="YOTTKMSz" Received: by mail-pg1-f195.google.com with SMTP id 41be03b00d2f7-7163489149eso717496a12.1; Thu, 15 Aug 2024 05:46:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725962; x=1724330762; 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=VAYPfmQdBURVtmFJo/kNdkK9wo4RhP92Q0e8N3nnuIg=; b=YOTTKMSzTVg/E2Y7REQQdWg9FoMc3Ye/QrpMG3rEKS1NXCVvlcBPPV5igb7Yq2vQgI 76w6v81PFvRGaCzvDhPeVC30OGaH/HYX2fSUKNHaNG2R7TN95bhOQdfARyjqdG5lrkRt B0sMdBCSfn1SSIAAS+yz6r+dbiVeWpFjLTDIyHN13TDTQYVDWv52dfhMPnk5hV38Gvjx wOOvcSGlw0oOqgacYJJYoF/TWef7w+SpF+rbrl5/Wap4SH/EZXbJbac9rqosJSuk63fW K8uVzU0r9ru4Xf/2K98b189GGUu/pLcDtsBUmUwX/n3C/FT0Oa9nWesm+QLwe/uAD61C Scng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725962; x=1724330762; 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=VAYPfmQdBURVtmFJo/kNdkK9wo4RhP92Q0e8N3nnuIg=; b=OVH2VlZSKFPLSYyZycJvCnGQ2yROErv2fjnsASLzIbjkXBiG6z1QJp8n9YjaIDFjW1 aIp8sdgLF+1XfvFNd2XXjHbAIeG2wltmR7f5fcN/d2+G5nxj+/C60gEaGWFBOoAQoJj9 xkR+jMPTVmqebSqf2Uwr9eegD2jfhcHGa8a6vSYMUuCblGCb2ijwi71nQI9ph5zTBJ4f LElHdt4Kk4H4hHdve3XwUBpqPmGZgWBzHPPrXFi2MEJ+Ig9DYjs9ykR/NT3qKwapb9Dj kg+1S5+PAoyADfdhSoJuquZOTb6PeE2gvLzlvn5BO7nuq/18RLKG7pdyWvQKtsn8GP0o IhLg== X-Forwarded-Encrypted: i=1; AJvYcCUdJKxLsGWi05ZsO0M/A2mmaBdEqvi73iSgUZRay+6Ox16Y6yeGZdM5g0dLAsqJntigaFS8RsWgEKLwsv0=@vger.kernel.org, AJvYcCUo1N26kdbMIj+0g0VsuPCVlSNTjasc7V5jdK2rl2f9GNONK9BH5FDLJVYAyzMWqrG/mnEuNADm@vger.kernel.org X-Gm-Message-State: AOJu0YwpAKlcMpiQIq2cTSGAywHoH+70+DFzYizHewHBIh+BUD60djQs CFmh809Tw0s9KqhRXN5xY41qRIGgG92rd0wGrYUKclWSCg2Heil4iZ1ajEGL X-Google-Smtp-Source: AGHT+IHsnR0ieo0N7TBiEGpR5o2UiXO9Njg/AGFXhLg6fbxKtIkB9LaI39JJnqzTgOQn6Y1tVbVbTw== X-Received: by 2002:a05:6a20:d70b:b0:1c4:8bba:76e4 with SMTP id adf61e73a8af0-1c8eb046c44mr7587095637.50.1723725961651; Thu, 15 Aug 2024 05:46:01 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:46:01 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 04/10] net: ip: introduce pskb_inet_may_pull_reason() Date: Thu, 15 Aug 2024 20:42:56 +0800 Message-Id: <20240815124302.982711-5-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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. 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 1db2417b8ff5..12992aa792fc 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 Thu Aug 15 12:42: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: 13764747 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 63B7917C985; Thu, 15 Aug 2024 12:46:07 +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=1723725968; cv=none; b=Iww8BRmL6D1FI54Gnxa1JKZWx0u8C8VseSCbtUDWk7glKbMoKXDBsn+5qePlbjgcznawpLBu7E07oB6e+tulzhRgs/nA414WdDaF+E7oDiHxEk7elDCJ9eJvGLw/58Gz8ncRibSj/3TFqMi+1NX4ad8+ymuakFHGoS6cDhn1xd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725968; c=relaxed/simple; bh=G5lLnDhHXrlF2AtjMeSYBuRCfEWiWxms1p+t2sCISTc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=g7+dlzvgH9/gZiD968s8yfJNc+ZOFqx+HQPNBvQAyrj6bFhwBo3CIqwEWbjtL5epQvo7k+s18NOiD49/TRPK1IF5gu3yUpme9G9ZMBhynmmPRltJOjBCQHwhBhb/N20DrSkzc0cNyrDcLzlErmJ5zps4L2Ts9QQ3uFnMaYFkbjE= 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=AURHnKM3; 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="AURHnKM3" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-70d162eef54so626378b3a.3; Thu, 15 Aug 2024 05:46:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725967; x=1724330767; 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=J+/egqQWy/gMXXtQbdbR1ZUBy1BH/MhQG+mERgblVW8=; b=AURHnKM3kwZfBkl4dd59ApZTrhFibWi05xVUgSJo1KZCyIW3lex8LjC63LMD8yFYBJ NacY3Xf7ujOWTGD5PMaSfPIDYcPvYMilb//b6SIo51ORBatf9bU860ozhsHP6kM3/2uE gB6GPpqotRACjnqIm5oQZ7zT+fv/l/hESP9HuxXvLPi2E2oy07Ab7MTWIuMBWkH1u+pD K9XH4HwR/0q+59Zut9ADkRHs3FHXnwtL7tXD0STJL1jIGOOUtLDJM6Vm2RZLC2sFVyZm YaYUpvgKnctQ5+XbCPncClGasrFI4FbgBKeCl1Mx1dKsL4IPr9gBl4Lk4zjgunIlS4B3 D+ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725967; x=1724330767; 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=J+/egqQWy/gMXXtQbdbR1ZUBy1BH/MhQG+mERgblVW8=; b=XbwlY1i2NZluMA3Pzzw6rpbrQnWYwdcqPCZ7strAMEDRnqvGbiP63uLByYSzS4Ju3C UqV7uVX3gUuRA6kdnQ+t286kQV2aJ9ymg9QbB13DANHJWmYybT0DeKI/5VQ+tBW4lr7D AG6MBPP/r/YUWynOTbgwsprQYlwjJNXWyJS9s2J9xzyxJTtWeZ8iaW6Slr8djS35L900 L2JQz5qf0rmhSsFPSqDFpUMu7XYtr7nO/PeXc9DQzK9VKDmvafP/Xgc7iS9OTwxFY52M 6gNBML14jyU7+H5s7bI15UfZu6sCzNLFBzaC0/joTHgXlx7YEQrxUnKSqr0A03IY/7Xk l9oQ== X-Forwarded-Encrypted: i=1; AJvYcCXSmerQehzYLp5CmXRKNyFKzYyx6as2WAG4dDcG6hXT1dmRYvePeiMZ1Ir1mBqK4prHQWIyQcKznNihro1BiwZN0YPDGHBhw3xqcGEkFirgkVZrEseSGB8uDlV1EE0m9VaNRea/ X-Gm-Message-State: AOJu0Yyrq9/xlhLSV1mkvtJYWXw395ZQF90mGg2nnDn1nZ3B11+0aJeU 5Ot7WK6a4bMJ9An9cM0z1NspQMk0UiSpO8PbRBN+ahweNKAxVmKt X-Google-Smtp-Source: AGHT+IGJt70CGCmpTmOw+rSlXu92NewnfERqsmdxcVSMFyYYfy4MRPyOFgAObIqIPTcp69+4BfaWVw== X-Received: by 2002:a05:6a00:2e90:b0:710:d745:6f3c with SMTP id d2e1a72fcca58-7126710ca85mr6890048b3a.8.1723725966563; Thu, 15 Aug 2024 05:46:06 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:46:06 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 05/10] net: vxlan: make vxlan_remcsum() return skb drop reasons Date: Thu, 15 Aug 2024 20:42:57 +0800 Message-Id: <20240815124302.982711-6-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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 5785902e20ce..e971c4785962 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1552,9 +1552,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) @@ -1563,15 +1565,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 != SKB_NOT_DROPPED_YET) + 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 Thu Aug 15 12:42: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: 13764749 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 0EC7819D8B5; Thu, 15 Aug 2024 12:46:12 +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=1723725974; cv=none; b=kKbYR4Oy71uti13+ivIryxArioN7Tv1JdLUIFq2SdlR2/PXUMDJqsCILCJwcrIvtok0/FO3AtmZu+1EaVzuWXb1rOn2NWuUV74XjuH37J4ZPis35u6dEiBZmgc79S8ZQ+gfaFivspldQSigAu2tsF9XUjfq7kUWdblfRjfgPX5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725974; c=relaxed/simple; bh=kijj1/AFXNkC+5igNj4phJYmZKPlr4zd/y0SMGAtjgs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T0v7MfQh0QZQdVlJNvf48704q+aLo9428BM6LKohX5xC3kZ65+KnV9GkGQ0/i/RJmeHa2xdel59csflWwcUjfaqCad256kOrfMggVm3dB8x0RAUJFIyLLN8mK/xWoHgVT+CkXClzew3rWDiXX/vXF66rVTyiFYRtowzatBktrKk= 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=ZdEd9IZf; 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="ZdEd9IZf" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-70eae5896bcso726004b3a.2; Thu, 15 Aug 2024 05:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725972; x=1724330772; 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=2MkzFShyb9+4TRjrRvu+V84H/xt2mywXwxPvbQCkE2k=; b=ZdEd9IZfCgocsmR4j8N4sJS3RW2LpKWNqaDKBDLO/p2eK1UN9oMoNXuSlMN05ngOXh Skq9nN0yvOXmNZlv5X21nEKX6RrgNEdMJd1ZN9qNYWnqvcW/0gMm0u2fLzj81Qsg9Wn7 14NVd0qu/c4zkn+yIOn1QW+fIt6EjhxPVGxNo9hS5ntd8KjdNBdYZVOKoHW6m97b/qRW fbGmbnDZ7DafksXESnvyJ5h/D51sm/1b/MDTTxqQbU4i8E7il8zSv6+ZcfI1GvsGx7Pw ogv9YSIa3VjrpzrR15KWhpttJJ1iRGNzi1+S3eyCZBjF0Zaj7JII7YvLVCXrKw1TG59+ phFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725972; x=1724330772; 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=2MkzFShyb9+4TRjrRvu+V84H/xt2mywXwxPvbQCkE2k=; b=aR/exO3Fa7EmXP8jBlKtu615C0/izyOIljU8QEFSsCWp65n3TWNa8rvb98MEjsNjuB xduDvkOLxcrNxMOyrcJ6jhQfqn/2bma5zg0LsLIUC76LE7DGxkWLqRhFhCatbH/0qyC9 Eky8K/dBOqNVYW4MLUOrgtUbna26UOpjc3fusI88LUCW6XwWSsRvxNQ2UAu0XKXZUSi4 6yGlVvQksgh/aFgdFHI4YqXzNnvUl2E9mzS+AonX+AuuGUNwyxX8Cn++Hvy/oELjp2Kl LLWRJTCfG9+bPLsfd2q3j2eCMs/GgxSaNihve4gqGRdHnWEtvOT7JXzDdjMGlIdy7cjL ugkA== X-Forwarded-Encrypted: i=1; AJvYcCWPUvYIsJmIH1naei3EIxQJ6PKwi1M9nZWtHlktLrG4egrJT2o6WtwZfNifSQ2kRHZdtrkv+FMKKA5AxO87+By9qbIHh2LY5bcuB1GmlIsBoj6J664knlxv1tgln2D1//iVvyI7 X-Gm-Message-State: AOJu0YzbSrjBnlcqKFUWB/S8lTKXUA00RZKSZNdI7JwwO/MCY3lhuxcI DeTjH04g34YbvhVsWl8niNHJeMT54HW1t/UfCuFBWRL9torHADJo X-Google-Smtp-Source: AGHT+IG71xz8S5s9qS5q/Pu4ajD+UsYkmEJqo6Mje8PDFhxN0W7EfPJ0YZ5Vw3L0NbGWMb+cNy3oeA== X-Received: by 2002:a05:6a21:3403:b0:1c0:e925:f3e1 with SMTP id adf61e73a8af0-1c8eaf8eb8cmr7864555637.50.1723725972254; Thu, 15 Aug 2024 05:46:12 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:46:11 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 06/10] net: vxlan: add skb drop reasons to vxlan_rcv() Date: Thu, 15 Aug 2024 20:42:58 +0800 Message-Id: <20240815124302.982711-7-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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_FLAGS VXLAN_DROP_VNI VXLAN_DROP_MAC And Following core skb drop reason is added: SKB_DROP_REASON_IP_TUNNEL_ECN As ip tunnel is a public module, I'm not sure how to deal with it. So I simply add it to the core drop reasons. Signed-off-by: Menglong Dong --- drivers/net/vxlan/drop.h | 3 +++ drivers/net/vxlan/vxlan_core.c | 35 +++++++++++++++++++++++++--------- include/net/dropreason-core.h | 6 ++++++ 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h index 83e10550dd6a..cae1e0ea8c56 100644 --- a/drivers/net/vxlan/drop.h +++ b/drivers/net/vxlan/drop.h @@ -9,6 +9,9 @@ #include #define VXLAN_DROP_REASONS(R) \ + R(VXLAN_DROP_FLAGS) \ + R(VXLAN_DROP_VNI) \ + R(VXLAN_DROP_MAC) \ /* deliberate comment for trailing \ */ enum vxlan_drop_reason { diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index e971c4785962..9a61f04bb95d 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1668,6 +1668,7 @@ static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph, /* Callback from net/ipv4/udp.c to receive packets */ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) { + enum skb_drop_reason reason = pskb_may_pull_reason(skb, VXLAN_HLEN); struct vxlan_vni_node *vninode = NULL; struct vxlan_dev *vxlan; struct vxlan_sock *vs; @@ -1681,7 +1682,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) int nh; /* Need UDP and VXLAN header to be present */ - if (!pskb_may_pull(skb, VXLAN_HLEN)) + if (reason != SKB_NOT_DROPPED_YET) goto drop; unparsed = *vxlan_hdr(skb); @@ -1690,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_FLAGS; /* Return non vxlan pkt */ goto drop; } @@ -1703,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; goto drop; + } /* For backwards compatibility, only allow reserved fields to be * used by VXLAN extensions if explicitly requested. @@ -1717,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 != SKB_NOT_DROPPED_YET)) goto drop; + } if (vxlan_collect_metadata(vs)) { IP_TUNNEL_DECLARE_FLAGS(flags) = { }; @@ -1732,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); @@ -1757,12 +1767,15 @@ 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_FLAGS; goto drop; } if (!raw_proto) { - if (!vxlan_set_mac(vxlan, vs, skb, vni)) + if (!vxlan_set_mac(vxlan, vs, skb, vni)) { + reason = (u32)VXLAN_DROP_MAC; goto drop; + } } else { skb_reset_mac_header(skb); skb->dev = vxlan->dev; @@ -1777,7 +1790,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 != SKB_NOT_DROPPED_YET) { DEV_STATS_INC(vxlan->dev, rx_length_errors); DEV_STATS_INC(vxlan->dev, rx_errors); vxlan_vnifilter_count(vxlan, vni, vninode, @@ -1789,6 +1803,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, @@ -1803,6 +1818,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; } @@ -1815,8 +1831,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) return 0; drop: + SKB_DR_RESET(reason); /* 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 8da0129d1ed6..8388c0ae893d 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 Thu Aug 15 12:42: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: 13764750 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 E110B1A706B; Thu, 15 Aug 2024 12:46:17 +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=1723725979; cv=none; b=HEYmSWKzCktJj4qVyj7023nSwN5Q/gHoleU0G7Slb5HFbWLhgFO8YHrO2yb4UwtEcdkERVX9GpE38S5EPIFjcF0BnMwCvDSABCCESauZiXM7XIxvZDR6pkCFF0N9dzpOC/M5ZlJN9PA+7UJLMrJyVFx63JvJQopEBMLrKr9RBVE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725979; c=relaxed/simple; bh=/8Xjug9bDatFQaCoDv2mOXA+Ru/cTRDYG/LMRyOKDhM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JvvDR4kMOeWdMhDBeg30eVSEkVaiv4Aicn0Z/zPfB9imuRPd3/OiFZzfRfka4ftHBeYpM6fqHr+ewD2/K1JJBzLmpGDJNafcuf/r5rY5oo36OxRig2A40AhavoCsyzLnsD+GvZ49i+3WpLu4ABJjhyM6WnFvF88DpuQjweuLaxQ= 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=ZjRLxHbL; 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="ZjRLxHbL" Received: by mail-pf1-f195.google.com with SMTP id d2e1a72fcca58-70d1d6369acso1281052b3a.0; Thu, 15 Aug 2024 05:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725977; x=1724330777; 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=zZcwrG171fB+S6a+qbmGaXbr7G29MG8vYWKPAWyBxTA=; b=ZjRLxHbL8Nok+r7GmWmurF1aAncFDkcHFTV+J9AmM+OjK7srzxyvlTVgH4DEE8+GT2 OCgn8pMTW6IZyGt2hxsKpFRDRTt3Dj0KqDSxUwyWejr3uFfQHojjtWEHhlTO7qqUn1e/ uRzZc82hpIbnHt3JH/TialBbDVwH6h/6ojQcwP1i+HYjMbAdZPyyvd963rGs1n+6HOJX F4hQxOKnNka72fShqilMaaEy3Gnq0LvDAN936VtQdUylyVPQuOLHfrcCqudJrHwirOxA kog1RsBIm0fMJ35gyjWJ8NFysd6/eSsatc9RtpUHV7sJvUF2S5T2woiiMl4IjAwS4Fm5 6acQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725977; x=1724330777; 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=zZcwrG171fB+S6a+qbmGaXbr7G29MG8vYWKPAWyBxTA=; b=EqVHXAQz/dUMLhXYwUpt59+RSTEdZCCqS3BLEQzol69B0WBFZAB+hXAibkmmv09JEs li73vmlwKwZwMNdf7bcMB3A92AOjJ+zZO8uLzPhPVaIMwBRGEYU0AVJ0ftvcLaQpAyaa +/O2xTwkxHPrUVF4AIxMJzm1k0PItgIWUm8ah/wOrksdXF9+p4QgqmCbom7qt5qyeg0I +cOx94QvHULVVMzdmrz8RoEh6z+NKtdUnlwd2weXkc3MQeVLOULaw7UjxS6B4EUNfVeF dS2f3oHUHcSWg2OU8lY2MNtOiK3lm5QXI6WjwqXJxpgubgjImqIE5rFYZz7a8uC2vExc Q5DA== X-Forwarded-Encrypted: i=1; AJvYcCXdSC63EcQ5HXloOFXMB+OUTuRWJPFqbsoXEkx7Z3GaI2Kt1UXeVfmpAwb8MirPs1eVnqZ7PMXIOGEQ1P0p9nhyTaM2lTUJVfnsR/XhKZG+x0qxqDodBgj9+u/eY7PDWE5KeB4h X-Gm-Message-State: AOJu0Yy10JxF6ZnMOgpJtbwsuYKAbjtaATLG9O2suCN0gobb1Rj140h0 r7OhsfcobnqKnW4OrbEqb0NAaTPwR+sula7WM2s9L2oIRYwgNZXW X-Google-Smtp-Source: AGHT+IEWYmb+hdNdp2KsTxXJrtApwjcGEk4P+B81Hilxkx+v0GiVj67NqdVhzeA20pLc/09tWW6Yyw== X-Received: by 2002:a05:6a20:d487:b0:1c4:b2d8:43ed with SMTP id adf61e73a8af0-1c8f85c59f5mr6189269637.14.1723725977068; Thu, 15 Aug 2024 05:46:17 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:46:16 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 07/10] net: vxlan: use vxlan_kfree_skb() in vxlan_xmit() Date: Thu, 15 Aug 2024 20:42:59 +0800 Message-Id: <20240815124302.982711-8-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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: /* txinfo is missed in "external" mode */ VXLAN_DROP_TXINFO /* no remote found */ VXLAN_DROP_REMOTE Signed-off-by: Menglong Dong --- drivers/net/vxlan/drop.h | 2 ++ drivers/net/vxlan/vxlan_core.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h index cae1e0ea8c56..da30cb4a9ed9 100644 --- a/drivers/net/vxlan/drop.h +++ b/drivers/net/vxlan/drop.h @@ -12,6 +12,8 @@ R(VXLAN_DROP_FLAGS) \ R(VXLAN_DROP_VNI) \ R(VXLAN_DROP_MAC) \ + R(VXLAN_DROP_TXINFO) \ + R(VXLAN_DROP_REMOTE) \ /* deliberate comment for trailing \ */ enum vxlan_drop_reason { diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 9a61f04bb95d..22e2bf532ac3 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2729,7 +2729,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); + vxlan_kfree_skb(skb, VXLAN_DROP_TXINFO); return NETDEV_TX_OK; } } @@ -2792,7 +2792,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_REMOTE); return NETDEV_TX_OK; } } @@ -2815,7 +2815,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_REMOTE); } return NETDEV_TX_OK; From patchwork Thu Aug 15 12:43: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: 13764751 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 81FCF1ABEA7; Thu, 15 Aug 2024 12:46:22 +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=1723725984; cv=none; b=hNAv376+JugzdtNNwrrFNmjBQ4bXNPvrcjvY9GK5cFdLIFsfE9RglXpdXVadiZ7PmK4MnTwatibVNAWVqa5dwHQ7Meqvb2BecLimIISFsNcMaWsArA15HsfZ8V1S266xyKa48EjJTHlLUrEbk13Hd/mmEpZY6zSQ4w+3FnZUJHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725984; c=relaxed/simple; bh=DuiUksGCsUFlX1i6Q+VvSu/IajJRsDMDDAETiqCe05I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C/wZFxIHTRX8OQJLlc5+ZH5M1O1sFOTC78+0rUt0u5gXAC1edS1+J/jdWDrcvDp6CRBBNan0mQJvnpYwRVMOU0PAgOcDF32ykVw3WGiQ+IyWZTC8hlMYs5Xhdv5w8hFshKPqaQ8OkZ0N6RLeq5cbXaSXCf3DMawB8wdwqXOQuxQ= 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=lUiIZjJA; 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="lUiIZjJA" Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-70d2ae44790so653276b3a.2; Thu, 15 Aug 2024 05:46:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725982; x=1724330782; 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=SerQC29iHMyTIJeHsYTg1ulNf2UurMYXmMasoWFZmko=; b=lUiIZjJAohgKANybo9LmUrsppRmBopWT+rQ/pq2x2MjxSrnHhyk1qzKxFDn0os4flT LY86xqYtPAoPxb09ZFgEF9uWywNulzKTxk88X2eg1Lj8VrW+fO5YcHckt3q8VmzVpq/p jIxWyQyfIlFg/smD/JyrWILXo3HxyKS2a47zxbLuHl7W1Adl0DHQWEXBNNg+nM5GjMpl 4ntFIUH/6UUPNUF8HaTyIvOInJ/Q+oKMTgRPdR1BlCHSgZG78Bk+Qxe9qqJk4htEMovv EEMsSbaQw7YCq0NJPsY7lyXDEZnenlVe9zZRu2NTWlOUF0mroYF3wKwzSw1wCzF6IoaD yYIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725982; x=1724330782; 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=SerQC29iHMyTIJeHsYTg1ulNf2UurMYXmMasoWFZmko=; b=sRGr0I0nsJT70lQ3JjSfEI5/F+efdiPm6CwnJvMdbm9UhvcczS+VvhXbj/mDzGCPQL NhW2VAKHqKWhZkA1bQqLbiFXfcXvLie2tqjTxr+4OU3No971+XK3ZAJf9B16RTfpCPxy veIDrYvgIabcH25S/0DdV9k+gFT6wwUq3bHngXPLCQ8LYg7g+IZaf6+UQOWyxJG9gTNO NHuMwZxRvyK0nPwB+KyB34M6YQSGz8Ezfvxi59C+sHtSpe/8CMutpwFOGzSFZQtX3bRT 7Az3yc41aDSRQ0QxnlBS8F0yL2kntKmgB23uKJKgr8sgcCpbtBb6iq6qSYLkqtHW7OrK 5siQ== X-Forwarded-Encrypted: i=1; AJvYcCUxnny0K19Pwmpp7A8fyYD712NAHUCotn0sz7a2K30W4LdtkYHlHZKhsgdSkucSrhQhL3LWGoHbS2mDCXmzGVZvGGYkr/rn4RDC085dIpwy0alCblRTN+LqVnm4lZw5GsHK9Ei1 X-Gm-Message-State: AOJu0Yz+gHjZIT7Z/jcC4qQtoz/lNNYIosSByG5FURSJR+7qTa4ps9cv v5fBUvcUVVyM2PlqWsooWbqPSG5Il1zkwfAlJSt8y5gpbXbIcqA6 X-Google-Smtp-Source: AGHT+IGSdS7P65poLeQgstaqbBr7YkCBoWKv00pc4D4dA3y+15Gr6i/Jx7D+nfQEOEhDQWcdTqZLcg== X-Received: by 2002:a05:6a00:1910:b0:70d:2fb5:f997 with SMTP id d2e1a72fcca58-7126711aa53mr6470288b3a.16.1723725981629; Thu, 15 Aug 2024 05:46:21 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.46.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:46:21 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 08/10] net: vxlan: add drop reasons support to vxlan_xmit_one() Date: Thu, 15 Aug 2024 20:43:00 +0800 Message-Id: <20240815124302.982711-9-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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. The new skb drop reason "VXLAN_DROP_REMOTE_IP" is introduced, which is for a invalid remote ip. 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/drop.h | 1 + drivers/net/vxlan/vxlan_core.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/vxlan/drop.h b/drivers/net/vxlan/drop.h index da30cb4a9ed9..542f391b1273 100644 --- a/drivers/net/vxlan/drop.h +++ b/drivers/net/vxlan/drop.h @@ -14,6 +14,7 @@ R(VXLAN_DROP_MAC) \ R(VXLAN_DROP_TXINFO) \ R(VXLAN_DROP_REMOTE) \ + R(VXLAN_DROP_REMOTE_IP) \ /* deliberate comment for trailing \ */ enum vxlan_drop_reason { diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 22e2bf532ac3..c1bae120727f 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2375,6 +2375,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, bool xnet = !net_eq(vxlan->net, dev_net(vxlan->dev)); bool no_eth_encap; __be32 vni = 0; + SKB_DR(reason); no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB); if (!skb_vlan_inet_prepare(skb, no_eth_encap)) @@ -2396,6 +2397,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, default_vni, true); return; } + reason = (u32)VXLAN_DROP_REMOTE_IP; goto drop; } @@ -2483,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; } @@ -2534,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, @@ -2555,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; } @@ -2595,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, @@ -2611,7 +2619,8 @@ 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); + SKB_DR_RESET(reason); + kfree_skb_reason(skb, reason); return; tx_error: @@ -2623,7 +2632,8 @@ 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); + SKB_DR_RESET(reason); + kfree_skb_reason(skb, reason); } static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev, From patchwork Thu Aug 15 12:43: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: 13764752 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.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 594101ABEDC; Thu, 15 Aug 2024 12:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725988; cv=none; b=Wjgyw8m/EwsFzzxrKIb8KMk/3P/PAKQ9X2hRJ14vp4UONQjB4C7yhkBu8O6umbghgtBvE9YoR4SJXyWcrh+RY86uJ7xFrDTL9DNsJMrhkKpyDg/fIluqOefbz8T2Vy98QG2a2dKoZVIw8/mLyMc8flMELcbuoTu5MP05KxH2opc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725988; c=relaxed/simple; bh=apx84xl4/3+KifGzwzFZZG6iLBWLTuAtEndWD7esMFM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W6VWIj3H8PMRIw6vt6D0qayy1P1sB0gJ7Z8LDGLYnDwNFr3hBtrwXTJmFFEQe83lPqX3afES+4UmGIFwmt4WEaE4+Zw7QdchFInCacldwqFHgjhIT+MhnuIj0jphWtl7Z1zhEIGIDd9VjCCuYA1g2byyKa+wurIknsTEPAhDX4Y= 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=a+sXrDAV; arc=none smtp.client-ip=209.85.215.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="a+sXrDAV" Received: by mail-pg1-f193.google.com with SMTP id 41be03b00d2f7-7163489149eso717759a12.1; Thu, 15 Aug 2024 05:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725986; x=1724330786; 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=NQpzojWjKJEQFjwLDMnb7FOqAkEetAGb87y57DtpsyU=; b=a+sXrDAVTg6O/mJ82NlHK11ie+jmbDef0ZQQ8ZlLCiPQAvKC/M8qpa9gqKrKODtPoT y45psOuqA4DI0vhaZrFJ+8T1M2xgQTZxX5q0vCjVh5r0m+MWfaOvs/00qMjIw+Fku/xz 4VrqWgDIOMvMwoKvwaAd3UUu/5aNuZtU/yw/AUW4k6cpTVh6idG2fdU/w/Wt9xk0J8t1 OCyYxywTdsBPbbxv4ojC8q2hEClITvXRxNNriHDAIV5uuPQLVPLefDVE8uh8VfuxaHKQ QxMrT+JG7xV4biqOaSmmxt1Vi34gegHGApJwYiM9WGPufFquhmdz73NvJnPwzL5feqxu p3JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725986; x=1724330786; 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=NQpzojWjKJEQFjwLDMnb7FOqAkEetAGb87y57DtpsyU=; b=K9R6JmIIGdmEQk9+kpSohxRoJlj+YiW4QJFssSEokeMMAYC0XA45oLDQk2nEIDRIPg 3Y1tPWM9bfhwJHgElyFuehcasJk2M6kE/8pSzTgXTQI51LQzX0FGQ8a7imCgdIiaA1at uQ6si7ihtKmuZl8LyRk+nHAOhQLY2S33KHM7A67FUdB04UNBZ+KR/DK0fSzufRZirqpa HTNMlh1BznTfhe+vmfRImq8ne8Pwx062s05G7MtKNmMsy6R4dqH+fdpIB/9r5RirdFwQ I2xLLKD1sqI2+iRCiv2/gQey1pvvZIcY4vhtuy9l+cFYq+0h3kCSpFnnhHif8FLW9+pi XTFg== X-Forwarded-Encrypted: i=1; AJvYcCW55lNKbKEGLDX3x9UX1BZqtzoWtAFeDvltBuHNB9MZUsra4iQ9W+S6LE3n50gvUe5V9pISQhLzGXXn3zlvcANRXugn74vu2mSEveebGpzgRtLOhx0tKYIHOlUS+LPdmP9w2fdJ X-Gm-Message-State: AOJu0YzOAoIrz5TVtQHkSDwkRJk9dQRm0JkRfdW9PmyM4XQqO8gjmsKv 2tUShxAAk4Oa6aBdE4KDkvBdeY6XAnHcV1ohPOJaxF003rgo8bfNL7wq9QKK X-Google-Smtp-Source: AGHT+IGBfBjK+pv5E9XrEQyGMsWZeB2VO5qfAApVeAJWiNlOX+1Bq0JOqOOLa5naW35ArBLz/1BipA== X-Received: by 2002:a05:6a20:d50c:b0:1c3:b61c:57cb with SMTP id adf61e73a8af0-1c8eb049b00mr7080122637.53.1723725986537; Thu, 15 Aug 2024 05:46:26 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.46.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:46:26 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 09/10] net: vxlan: use kfree_skb_reason in vxlan_encap_bypass Date: Thu, 15 Aug 2024 20:43:01 +0800 Message-Id: <20240815124302.982711-10-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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 c1bae120727f..885aa956b5c2 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2289,7 +2289,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 Thu Aug 15 12:43:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13764753 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 B44ED19DF4A; Thu, 15 Aug 2024 12:46:32 +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=1723725995; cv=none; b=rNoyH2czxYg+zSrhx++gAYEclNThPy9T6gV6k/Q09+kHfY0XOCpza2aIhI3FH9QrZDJONW6LZLJcGlndpJMoFjTGlvK3RlNUahkNP2ZAAk8LXoOZefF9RHsXKXzu6FSvzA5WwrYnAzD2Ye0mirS5GTx872Q1OYrwRJZc0EYFw7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723725995; c=relaxed/simple; bh=3CB5+WYB/JCM8BXKmWb57xhOtRNKMSHonAri1yGtjc0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=p2bTHUyzmgn+qNGLdEli1XKutvKd/HNf5Ay1n4CQ33lsUyeokomW+eZNqjiKHUwS6nM48PRly0QU+t3t5HbhEP0djUT9WbFun5rHroa92hy2Rp/8xpiROW1QipZUvjHMnFOB7wwuXOQZf1EOLYASEtlV+9WqlN5HuGGFOmAXf6s= 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=mjF7EG6g; 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="mjF7EG6g" Received: by mail-pf1-f194.google.com with SMTP id d2e1a72fcca58-710bdddb95cso558003b3a.3; Thu, 15 Aug 2024 05:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723725992; x=1724330792; 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=9LvBHU4ajrcGnbQIJBpscVn3KQDzyzOuVH6Fpensg2A=; b=mjF7EG6gUjomNLL3vhUcdKJH9IEn3FQ8NqsqLKU0M8M+qUJv8otrg1gCoTGpIxL/Zb e9nv6RZUpAyl4O0kzcZlvZ+cxem7hw6e3ssG8B561j3iKHPbFIpnGABFQzz01sDU0QeS kE0MIT4PrPYPFvdGRq2zjZLWfWxIfufMFifmX/vSPHMDF+d5EBwKYveWPEMxzjdv2q/y TA7LOeOMxNcIW8kinLxf+isV3l5zc5vA2uGfxlNxtndLs8KA5JlJBJiFFSQUhJK6EgUn Vxa+Y63KF2F7+SxOznsk+31MUUTfKvfqEcGzCufPdSx6eazuXKD6BN42FKn+RFMqex0v KSmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723725992; x=1724330792; 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=9LvBHU4ajrcGnbQIJBpscVn3KQDzyzOuVH6Fpensg2A=; b=D1JuxC14ddhgPt6CsmmXdaId5Jy7zad4NcGPsXWLKyCveaRkQnHvgrk2C6t+fbS03C AupLsBEtAsaMCjawMh2lP8wp/a+edaXGS4+Ykd2yfv7VhLxYcnB0jew7xvaGDO5mDBgZ 4A/M0ZacuEgkkB6YElvFeFSd+/IACy9zgE9AIftOE+4CIcXi3Lt2xAJaeQnXSrZWqb/e Tvthqr8ZLASdM/Z/TvGh38+d2N+zvio5GG/S+gZEBVGLs3aYf3kwz2Zf514u5l+yxq1F 1xy8Zdf2vsH39pVQB00i8mWFNWdZFSIAvzhP6vqsZ8N0+al1wFjM1nuOb5D38oI78zd7 KqxA== X-Forwarded-Encrypted: i=1; AJvYcCVMK3JOjzgxpDWHuOyJGTUN52r7A3nnMjpeArO/lx9xxVsddZeTFiUTxXNVVDUdaXNWKhWQTmOsDEGaeqt8ngIKnxKev4HzmS/p+sG30Dy7QMhugMNgeu/Nh7qQurW36aGXc8r3 X-Gm-Message-State: AOJu0Yw9VdW6x3Z9fshhXshPyYnLh4Hy0slCZlwK6L21x3XQ/9ld3bJW JSNCGMjOLPAyBtTbsS3QF/ztRuZSItSnfy9tWZDObIeb+jjoWu8n X-Google-Smtp-Source: AGHT+IGDFLR335ccHyK2aSZ7q7ZUDdrCd7IGe3RKT4niKiFVLF6M7ja7YBFS9nlHizlX6jZP1/beEQ== X-Received: by 2002:a05:6a00:1402:b0:70d:2b23:a724 with SMTP id d2e1a72fcca58-712673abae5mr7748585b3a.23.1723725991961; Thu, 15 Aug 2024 05:46:31 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7127af2b942sm923605b3a.183.2024.08.15.05.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Aug 2024 05:46:31 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: kuba@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, idosch@nvidia.com, 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 10/10] net: vxlan: use vxlan_kfree_skb in encap_bypass_if_local Date: Thu, 15 Aug 2024 20:43:02 +0800 Message-Id: <20240815124302.982711-11-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240815124302.982711-1-dongml2@chinatelecom.cn> References: <20240815124302.982711-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 885aa956b5c2..87d7eca49e20 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2340,7 +2340,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_VNI); return -ENOENT; }