From patchwork Wed Oct 9 02:28:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827449 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.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 3239A1428E0; Wed, 9 Oct 2024 02:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440956; cv=none; b=mHMipIIAp/KgqJzZZo1WFS4hQ8kmupG81SD9c1flhKyXzCRmPPNEjwjjbeHawnKtez5fsJJt9dPJqhTkbVog5xmQWFQUL/XkaLssLs8nzs/wLaeISA7Ju9gl87U1nMCykCSD1UMBzz9hcZR2svbVsoa/AeAPlNeeTXhj2MW9398= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440956; c=relaxed/simple; bh=qDSFVKxj5P9OuUbcZh8vXPtfp9NKaBMFgSQrL48vbZk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cVsl8pw7x2pfv5AWUxIRtJVWfRm6DcAjhzV+39rZsK14Az2t59GK+dMqctasfBbTiFw9SmBg18NCkogq0Ku5p7owFEfzJ3+jnGMz3JvaOxFW9ZiKCI8djHtxhTYFWx5X3+7NZt10NImKkhugRQU7nbVbOc2j6dIVoJfh8b+iQv0= 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=Ukw3WwtA; arc=none smtp.client-ip=209.85.215.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="Ukw3WwtA" Received: by mail-pg1-f194.google.com with SMTP id 41be03b00d2f7-7d4f85766f0so5076880a12.2; Tue, 08 Oct 2024 19:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440954; x=1729045754; 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=zLvKfqnfSpZ28mnT6KrdGxzwf8Ry3wsHVE17xRaKj5k=; b=Ukw3WwtAOO/GEVNJjz/58nuIgJDpw+AJ21TLgBrTCil9NINWDPeDYr+5mJZFuECXjs Qg1RMGfISLekNxlkkkcOOHfIk9PWUeWdMwlnmnWVa+/n47vWmgMBYv5JZkPilRWgiuSs jZewM13NRUBZXpvYM6nhKNYMvqtXLhCBt2LBjtge2oYiqriFvL2U/hiYjGLpfDxq2+jS HAM4TECyXU/rGXvBm5Oc1cJfBlULf1ywhDrUSaveHgpq24+sKlomomd1o/fBxB21KH1n d3QfzvG95UoA3+gOjFmFW1VZLYRRrW929nKxuZx7bmZy+6AJ09bqk8P9DPhelgimcPgZ dzJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440954; x=1729045754; 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=zLvKfqnfSpZ28mnT6KrdGxzwf8Ry3wsHVE17xRaKj5k=; b=JFg7xqMQPdWDnou/2V82wYbkhQOSUPfexIkPUu5azV9Il87FAcRKOnZVEI+5oe4I1S P4Cm+JyGGou3tFzKN+5YXfxV6R0YjANeHSrfaGYXp9QbkFpPq2Zx2LRad6YKstT4HQf7 vuPZD5LXmIXtLssTxkEDc8WD13AE0ddZL2H4Ga6o1U6YN5I2aED6l/p+TedXYqIuRxKK DCYKOorRGoJRs92Rtaieasba8cv1nOjpZu2wWKAmHw3VYUrvxAxUq9KB1TBTZv+Tqc+6 boWJSx1spEqNk9z7EGpJJjKR6wV/BHhRihJHPKB7GcWWVS6Hz3++8tpxdYvkMeclmzT3 vL8w== X-Forwarded-Encrypted: i=1; AJvYcCWcTVzcbeRrEpIXCKwWpRNPE5zyO9KfdRKeMK1XFFREx2sMzrGb8f1Dh3IIzpeQICcxT6oxMuk6Aa6LL5I=@vger.kernel.org, AJvYcCXFt0bHeBqxQtgSYDqNIdCu/gkCCUtJuBc4EqnxiilzL9Xa+aZBrjjXIHmXhH54/h7RnIKsULqI@vger.kernel.org X-Gm-Message-State: AOJu0Yxt0zm752VDzepJFRKAR0lTNtMYBpNP3dDo1+rswGNUwLoeEbul dr0HA/086mRd0bgnaOJULcgz3GzgR/+zzRZ0fCd7SmTswvWp29CR X-Google-Smtp-Source: AGHT+IGNsCMih/0x2kJSzp5T+rkVUOL2c5mZmOtIfCCSq2Q+bvBVe4k6NXxs/YrH7h9b7z+5BMRrGA== X-Received: by 2002:a05:6a21:3a83:b0:1d6:e5ea:f985 with SMTP id adf61e73a8af0-1d8a3bf06cdmr1833623637.12.1728440954454; Tue, 08 Oct 2024 19:29:14 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:14 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 01/12] net: skb: add pskb_network_may_pull_reason() helper Date: Wed, 9 Oct 2024 10:28:19 +0800 Message-Id: <20241009022830.83949-2-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 Reviewed-by: Simon Horman --- 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 39f1d16f3628..48f1e0fa2a13 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3130,9 +3130,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 Wed Oct 9 02:28:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827450 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) (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 38A4856742; Wed, 9 Oct 2024 02:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440962; cv=none; b=gCpkPD42utRmeEX8STcep/bL/aT/jHot5OshW36ySHAcETnQkFdWH3YK2eLEzzz2hKbSjFbDX49qFjLtCP1V24NXHMkbsVTITeH5U5gOXF8fIPACReb3nRvNWF9efCnJNNSPDeicoiDiwgj1lnJM0ja/wOCxpPR3TtXytTYaeB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440962; c=relaxed/simple; bh=xmSEGfXWYYnrxahV/hxdM2xvbpsGMckUIHbpupwQeoA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FmWReJfodha3AVwTp7UOF06Hb4eiOE1yZWHr0EBskZ2bHeHp457eDKxkd4J0gAJd5jeXiqWLZ//caBREn3uuet1qQFK9q6q0UNqu6owIjC6GQSFPB1qYokXgejkI4DoHPPbwTZXCL1zgBcciVtXDyzmXR66OeQzY2EwiTpgbCQU= 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=SDrbA/wN; arc=none smtp.client-ip=209.85.216.66 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="SDrbA/wN" Received: by mail-pj1-f66.google.com with SMTP id 98e67ed59e1d1-2e18856feb4so5343155a91.3; Tue, 08 Oct 2024 19:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440959; x=1729045759; 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=BLQPPQHkux9UrJBZUqB+t1LpH9/HisAt/+hbWRBu/OA=; b=SDrbA/wN4FIEXJGX674ScIsyiTEoLvxdNtLNID5u4+dlqxnrC+2BjVfFQ6TJy7LItt Dk33ul/RrUcRGAe2enug8ezZiZGh4S/khBCWClDjP7tpqXOEMZT7l4BBkLtbxHi83EQA GE+WY+Dy7VkbOB8gUWN4oeqMvZHLsQv83TQh3SsmoFI0KqiTcXAOvSBBje6XACKMKTIE pzOGXWdSG67aMQs3hjynxR7INYZ4Wot9JAtLAPTOeDbb64eEjjiHInIA/vxm3pfm4vIU jjOY58VrkuRfQyGMkpawSYg4bONt84JzSj/U9vd1g9i0sQ4E73urUR1eaK8xz92kDJZp GWQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440959; x=1729045759; 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=BLQPPQHkux9UrJBZUqB+t1LpH9/HisAt/+hbWRBu/OA=; b=ZQaKEWsrwseODEUhChdKOx0pgxalRFbe4K9tZhpScSZ9wnYv2fYcJjYrUjK53k7Gkn h+ZyqMsPAsSl6nT5DIDZx6X3k2ay/sYkNsAOQe4RFiAq8gteGHUAwNUB0tH4pc4CgJBx T72NIBtPkBMSbJpldl1s15dRBhnLtmJuem4VqU6QGKZZD+/TsQO0lOt04jjZcERYjz81 1DvkRG94KpHNcPWrvIKliW53Sz5sVa3F//SJ3mZHPS1oTxKy6zxv2c8NpKOOc5JzHN3S Hgo5hmJGMQIa5htFVyZ6c/xrgn/84ORB7aFXxW+JEv97jV/oDhGnQjOvonSdUJROLKUE RuDg== X-Forwarded-Encrypted: i=1; AJvYcCUqzDTLyMGY/0WHPrSXhh0c/IkmGXyscJrYWDFrummDxb8HfpQOH1i0ICnGmD6fxtx0hbSgBXlJ@vger.kernel.org, AJvYcCVrcs66fbpqr5wvse2e2i0n4Wv+zkxOpMw/CbbAcDvgIMnd3u7oaSllQTCyj+nEWRDgJmdGMHwhrDES8O0=@vger.kernel.org X-Gm-Message-State: AOJu0Yxmd0bLFfaQRVJr7XcYZSiUQQAMVP3NYf2OwGWCwx+etx8VMV36 stzL0OltQvTQTIS1Wuzt8kZWMqjf3CaosSaEeYRSS22Bx3WA8Hmic305DpTt X-Google-Smtp-Source: AGHT+IFGXx9KEdhqXaWUZrRrow8SwRSDmZCT0Rqj4gq4A+htJhjF0rD5ZbLLId6II6j/zYD5kQKaKg== X-Received: by 2002:a17:90a:f696:b0:2e2:9a3e:68e1 with SMTP id 98e67ed59e1d1-2e2a246725bmr1078216a91.22.1728440959484; Tue, 08 Oct 2024 19:29:19 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:19 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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, Kalesh AP Subject: [PATCH net-next v7 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper Date: Wed, 9 Oct 2024 10:28:20 +0800 Message-Id: <20241009022830.83949-3-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 Reviewed-by: Simon Horman Reviewed-by: Kalesh AP --- 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 Wed Oct 9 02:28:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827451 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 25FCF15442D; Wed, 9 Oct 2024 02:29:24 +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=1728440966; cv=none; b=GisrsxJ6Lms5xbPZN/kaZCXbPuV8FcZXRWTlluivFUggTCM7ZVKQL9MoKQ7d3KHVWmSTU4cE+VCiJWO0AXGJYbN1ow0Huh3RblzaI33l9iDaIqy7Ha6p2TIOZ8N8ZBFkE7S9kLLVbAuwLiieBONauKdEIaikEQXO6wBpkbbeYOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440966; c=relaxed/simple; bh=0LbNYkuc1H3teX+6zzjM43vRgSWAunIJN3Vzj/y7tNU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F7kdVlurylOswSgZq4MG9ML3laqSSHI/2Bf+U0vAXT4j3QD8voDR/2c+gSOlYblKU0QXNSguhXYBkmpj7KrSVJK3vhGmwXOj2P/pxqQ4rnf4HxGHEYKdAyJRvStel3aj30NOl+9+oikuZ0+XIMkFKfj25wt1qqofqdpvX3rfo4M= 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=iqZcTaqk; 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="iqZcTaqk" Received: by mail-pg1-f195.google.com with SMTP id 41be03b00d2f7-7db54269325so5183011a12.2; Tue, 08 Oct 2024 19:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440964; x=1729045764; 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=PhsBrLEykAKb69NSSERrjcYKm3NYONaRl2vIIBwztDI=; b=iqZcTaqkCU1cwLw4n9Um65OpuBbCu2a/KGPq7LHrBkH6yDOfwqyOhqcl2oy+iYtn+o IF4oru7sGKtOd5AhWr/2+uJU5EJcPuf6iLMXTtEt/xfD6W4B2ZNGIDhlDQ8L8p6L6fmN AUbSi9NSOV3jA8yqzJw5VPMBLv+owYMrqx9kY9oFO0peJnf1yso3BU4DPVkSlpL+SaGP v2+mkivG55YpzuuAzwruTqMKGjsWb/djSCJrcSrby5f8ywtCEs41t/JY91iq53kJdny9 de39uPPpYoVFtMQcY8W8+PjicnN/1DVGEmbBOE2r2pz3lU7UlWZR9SGVvvBSYTfiCHws cDQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440964; x=1729045764; 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=PhsBrLEykAKb69NSSERrjcYKm3NYONaRl2vIIBwztDI=; b=YwFlkR718ixu9PwDlc+wk1HnBhCW/X5hDVyLCE3nk6Ydj76bZTg9M6N49/fs5nGJn7 6CiVbbiiBejqUHDW4jMFdxf6QJ080nNa5B30pklrKg9uzSFmxVae5aQVjKdpp06WxRjE 8zhavuowFNKHOq2InZ31Z1ayqdWbLsSmRenc8IkNfZTHGO7sdAQzsHV6Wl9aQ1gV65jl Rw6pqDxuChrHm9IoxH5TcdGDQ2Qz+Vf1bD5LMDokIMWh2bN1BMI8KzD11fsSPojHmTdG lEGXKtYzUHyhm4t0ATg78GJ2+d9s3z+fpLSa9xbVhuEPLah9UZ2T7a6oGsVlFPJ0bM48 HsVA== X-Forwarded-Encrypted: i=1; AJvYcCW/1nGz+ZXO7+2PGwgyCqYC8ABvi75DqEstCSnFZmLRPU1Zk7pGUAqnBZrrUw0TIf9jAaiyIQvH@vger.kernel.org, AJvYcCXQmJMK+luLiUCOCKOM/gqy88Txg3wf5tWIku1+5UOaxNUx1g/mvKI4hz6nh/HuT9ROpMAvk8y6CxmOf54=@vger.kernel.org X-Gm-Message-State: AOJu0YzLAmjaTnhS+iCoVj77koYDIPI8SrPomALvrhOTPcoB5uQ37/U4 QcLB16dBPtquZnZaBzDi4gOjq9RyBiFbhZAZRXwovtVGUo8Aenhl X-Google-Smtp-Source: AGHT+IHrOp2P6t+eOIjbQ1lt/3a1OJlLyJhfijDcz3Cqbcvdy3lLD6Ln6dw1DVNpI+QmJqELMu3eEg== X-Received: by 2002:a17:90b:1295:b0:2e0:8bf2:1d05 with SMTP id 98e67ed59e1d1-2e2a2563235mr1209148a91.39.1728440964242; Tue, 08 Oct 2024 19:29:24 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:23 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 03/12] net: tunnel: make skb_vlan_inet_prepare() return drop reasons Date: Wed, 9 Oct 2024 10:28:21 +0800 Message-Id: <20241009022830.83949-4-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 skb_vlan_inet_prepare return the skb drop reasons, which is just what pskb_may_pull_reason() returns. Meanwhile, adjust all the call of it. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- v5: - make skb_vlan_inet_prepare() return drop reasons, instead of introduce a wrapper for it. v3: - fix some format problems, as Alexander advised --- drivers/net/bareudp.c | 4 ++-- drivers/net/geneve.c | 4 ++-- drivers/net/vxlan/vxlan_core.c | 2 +- include/net/ip_tunnels.h | 13 ++++++++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index e057526448d7..fa2dd76ba3d9 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -317,7 +317,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be32 saddr; int err; - if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB))) + if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB))) return -EINVAL; if (!sock) @@ -387,7 +387,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be16 sport; int err; - if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB))) + if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB))) return -EINVAL; if (!sock) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 7f611c74eb62..2f29b1386b1c 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -827,7 +827,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be16 sport; int err; - if (!skb_vlan_inet_prepare(skb, inner_proto_inherit)) + if (skb_vlan_inet_prepare(skb, inner_proto_inherit)) return -EINVAL; if (!gs4) @@ -937,7 +937,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be16 sport; int err; - if (!skb_vlan_inet_prepare(skb, inner_proto_inherit)) + if (skb_vlan_inet_prepare(skb, inner_proto_inherit)) return -EINVAL; if (!gs6) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 53dcb9fffc04..0359c750d81e 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2356,7 +2356,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, __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)) + if (skb_vlan_inet_prepare(skb, no_eth_encap)) goto drop; old_iph = ip_hdr(skb); diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 7fc2f7bf837a..4e4f9e24c9c1 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -467,11 +467,12 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb) /* Variant of pskb_inet_may_pull(). */ -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(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,13 @@ 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 int ip_encap_hlen(struct ip_tunnel_encap *e) From patchwork Wed Oct 9 02:28:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827452 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.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 347CD15442D; Wed, 9 Oct 2024 02:29:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440971; cv=none; b=Ah07FgLRhpM4gOUjW9Pd/XE6eoWGHcG1YKaS8Pn4nVOG56TjNSfl0+fQuZa+MH2DK1qkPgpz33Z0s+AH2xAvpzgjL6lyAEQJoAED6a/8+1gksrSXsiuRqYNLMGElU622MiNaCqAvdvcfrxmhT+RltrMpYBiXKZn/0QWPuz4JZ/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440971; c=relaxed/simple; bh=Frgop5dI3MpmoWzTS13lVakpm6NizzC07ixLgWUG7hU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N2HIx7JX82uZmjkhn5C9w+Mol38aKbe+/zdl/uVEi0P4hMlZmDVtx9NfVlIdgJ+lnq7kssd2tILnc/lpyXvc+CXlm3ih6tp9m9GfETnkvU+iaSLOQdw86eHahbUvCiSNLKFCwhh+/n0Kvfymu88VvQAFSbkkiwd+vCxfFmf88BE= 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=jG28Ul+n; arc=none smtp.client-ip=209.85.216.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="jG28Ul+n" Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-2e077a4b8c0so306264a91.1; Tue, 08 Oct 2024 19:29:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440969; x=1729045769; 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=c+57bNIoFOfo1YPD2Iy9OO/eMOStU8dZYyQFQ7Wq2lE=; b=jG28Ul+nmNlVz+NQHziY1JLESGvbJzXvb1dnjx8Yu6DhNTBFK3x+CM8ZmJ9G00KdRr qVP+dHyHbBFjN/JWcWzg88ej0eywhZGnAWS5zoRx0kdKfay8uehMPoxbKCUbcbcL6bKC Dj3WcabbqrRPHMjpVRBUh48lmo7zI3g+ar2BC/a3uWaKWLX8ZjT1MpGJgl5V/7HGoMJm ftBsmvwFFkD6Nx+vlK0mAcwn0p7yn2ojnKyEGOqXyy3d+QvuCo5TeookoVuQ9NYh3+Ey BiH9mfDzwL9C0XCvJlfSFjd1EkHNX2wY/AelFYOv+jYA38WyGcJBPiS0cXX0XV2AAfpB kD+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440969; x=1729045769; 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=c+57bNIoFOfo1YPD2Iy9OO/eMOStU8dZYyQFQ7Wq2lE=; b=P0OcWG154pKi3UCypav1Ws7MOAFR34iKkI4zpaPLEbg32iN7kfX8tM1JYpK5hJbu1B VcYzyueIc63hfIpgdvvOHuCnGxjoEs/YT8OhvKiomIwj/8yiDi0j2frUwwECA/6OAVfN ffHmlQX6hGa7yJAIxaXqP1WOrrONiJir76cgeQdSUQruoXbBdyXGVP7O9/Yyao/Ow2xU YaQY6iw9TMzyKiPVvktg7wPnMPtc7wFI3S4lJcxyWABQZ5sUddLOFnABtWLWnOH7P+VS IylW7j5VO4rZYGNYjt/8qQvoWU+P8aDtGe6+TpkiL7P/ddYWlWGrx/EvsPhj0JYxspK9 1t5Q== X-Forwarded-Encrypted: i=1; AJvYcCWH2c6pMFONWHQYplLTfYE+BZe0Y6v5KENJ86Q65lEFDUsZ7zOEPcpmV5PscIvLv33T8x/ck68O@vger.kernel.org, AJvYcCWK/scAQKlTmKQf8e1ykkBbx8d/TazDZBuC6W3HY54SzUW20TVUBoT5jgOkQsahFlJM/RsXN4JY6sRcbJ4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw3y8pomYfhdNSCBqIN+S59Yffx8/0NhXlCFMmx3ZVuOklFN67v ylSeGfGznSSXUyHX2KqsxHgrIjvASUXc1PuAG9/rNLhGCk8qLgt1 X-Google-Smtp-Source: AGHT+IGP0BozauTf7SPCoHG24Nw2j8bYr1rrwkN7MuV4ZeX1FuYqQJwd5uqkhj2ywxtqUa6pNGGWRw== X-Received: by 2002:a17:90a:c798:b0:2d8:9fbe:6727 with SMTP id 98e67ed59e1d1-2e2a0756277mr1716739a91.4.1728440969384; Tue, 08 Oct 2024 19:29:29 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:28 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 04/12] net: vxlan: add skb drop reasons to vxlan_rcv() Date: Wed, 9 Oct 2024 10:28:22 +0800 Message-Id: <20241009022830.83949-5-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 drop reasons are added: SKB_DROP_REASON_VXLAN_INVALID_HDR SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND SKB_DROP_REASON_IP_TUNNEL_ECN Signed-off-by: Menglong Dong Reviewed-by: Simon Horman Reviewed-by: Ido Schimmel --- v3: - modify vxlan_set_mac() and vxlan_remcsum() after this patch v2: - rename the drop reasons, as Ido advised. - document the drop reasons --- drivers/net/vxlan/vxlan_core.c | 26 ++++++++++++++++++++------ include/net/dropreason-core.h | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 0359c750d81e..4997a2c09c14 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1671,13 +1671,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); @@ -1686,6 +1688,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 = SKB_DROP_REASON_VXLAN_INVALID_HDR; /* Return non vxlan pkt */ goto drop; } @@ -1699,8 +1702,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 = SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND; goto drop; + } /* For backwards compatibility, only allow reserved fields to be * used by VXLAN extensions if explicitly requested. @@ -1713,8 +1718,10 @@ 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))) @@ -1728,8 +1735,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); @@ -1753,6 +1762,7 @@ 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 = SKB_DROP_REASON_VXLAN_INVALID_HDR; goto drop; } @@ -1773,7 +1783,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, @@ -1785,6 +1796,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, @@ -1799,6 +1811,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; } @@ -1811,8 +1824,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..98259d2b3e92 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -92,6 +92,9 @@ FN(PACKET_SOCK_ERROR) \ FN(TC_CHAIN_NOTFOUND) \ FN(TC_RECLASSIFY_LOOP) \ + FN(VXLAN_INVALID_HDR) \ + FN(VXLAN_VNI_NOT_FOUND) \ + FN(IP_TUNNEL_ECN) \ FNe(MAX) /** @@ -418,6 +421,19 @@ enum skb_drop_reason { * iterations. */ SKB_DROP_REASON_TC_RECLASSIFY_LOOP, + /** + * @SKB_DROP_REASON_VXLAN_INVALID_HDR: VXLAN header is invalid. E.g.: + * 1) reserved fields are not zero + * 2) "I" flag is not set + */ + SKB_DROP_REASON_VXLAN_INVALID_HDR, + /** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */ + SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND, + /** + * @SKB_DROP_REASON_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 Wed Oct 9 02:28:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827453 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.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 3DCF315C156; Wed, 9 Oct 2024 02:29:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440977; cv=none; b=DVQv9JCxwyRJ4p2/dU7pA25FMVt7Z6a8ZxfVxVXH6NpFCCZv/uvbs9ML3+lvSfS298FHysXIxsLhNpqWBY9tkAzf6Ljyhkk5cFdP5nwZiaFY/aOXI8EAsfjN0n6s9FuLpvUukSgitiLIqY8019wUJAdHizI+JPKBzwBeBycfQaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440977; c=relaxed/simple; bh=RqJB6ZWkDR9/PDVgtjzb6hIWH6sz0+ZXugXeLypicD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sz4g2OofEzcqCCSfvz2z+yG0jTfAoGbf7sHk5v7nBQ4BuqHuvC6UNVQZGFzqtqpI6yiQMh1WO5Qv4j3yuGHd2RXPKDAuDaAKbXV5ND8JcrWfXL9pwQY9vQcYQMBOqyFMv97k1jo4gYtnuOSbT+kp/ZlwA5sr69Nm3uXG+g7X7Cc= 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=cWioyPdk; arc=none smtp.client-ip=209.85.216.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="cWioyPdk" Received: by mail-pj1-f65.google.com with SMTP id 98e67ed59e1d1-2e192a2fe6cso4629702a91.3; Tue, 08 Oct 2024 19:29:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440974; x=1729045774; 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=oYnO8bxbAcS5ofNqn2tjM8UFXYntoF7uV3soxSFaKsg=; b=cWioyPdkmmPi508gHeNwomxB4QM039W79rMAHC8+E1kkSTZXVbLnrSTuvzkaIBEMY8 HhofWSNaQGzqAuMbnVTquq+AssYVqAxM0GizG2Lc+G4ZKEecGs6xEqyJ81dJst4nmU2Z jcnY13nJSGxpm1n0onm6tYYuPanIro6ft7JJBaQST/J4ZKiXqhOKnQhwqAqTbktEFgjx nHvaxGvYWmDEabZAN3WwR3401jPn7fBNcMxSjO0Fo3urJ6kuPw4pcERliKreWEwBkXXg +lCixPfRNQgg+B9ECLyRYUwtx+JoqRco9WSzKG+f2BJ49qWYydhZoGDg20Aq0j1EBkZE iMdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440974; x=1729045774; 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=oYnO8bxbAcS5ofNqn2tjM8UFXYntoF7uV3soxSFaKsg=; b=v3EhD28FKtrt+REv7ymWmyPe+enYLFkduKgCLH3BU6Wsi/nYuhQxFHLBbbKwsnvw/O mqJ9zYE8BICHzCK2UZfCgBgrw581mJt+uex0+JPAFhcn8kfvBxW/kphbWt6SvotdXd/R HEOc9M0K4EDRDXagf2nzg8jSKrT9KCIfpj3MwFEs7xaQ0nfTtUS5dt+XMx7hAbjeMltQ 6SVLBbwECfZLD83AvoQp5+qfhpnfLTBd4OJ3260jMghjCmj7CIpdqg4lq8zX4IoRXBlb arX/GzseGpuFvG49/1cgnwnZZT0aEZRju+E5Hhnbu6gYOzEF2kyNz0kUCQ58Yow8o47r a7YQ== X-Forwarded-Encrypted: i=1; AJvYcCWAvL2kdnGt2QjbjaINiuqNTUe2I1PPpKE+2D0cPJTTBWSjYn3s1Ys10Qhjs1mt7LWKV8uTE7u/PBsuOeY=@vger.kernel.org, AJvYcCXgyE4WiJHJuHepgSeTrp6qIYYtna/jlPuWlCNUP2PeJtDc0HvaUHJQkuvuN5fvDLavXsDto7Gq@vger.kernel.org X-Gm-Message-State: AOJu0YwFOmf2sU9QGsgbQWMiV+9JF0C5ob6HrE9yIeCLK9aqX4HHTdui oB9dSopQuvn+fR1UzROH2pAEINXfO5TpCn5RuQrEsdjBk8SrD8mH X-Google-Smtp-Source: AGHT+IHvopXBkS77CfGAfceqFPdFPmSkEkinj3J8ogMlDEDDZIc/iQQe+FlS6tsyGMiLrZe2JoX9jw== X-Received: by 2002:a17:90a:6d65:b0:2d8:8430:8a91 with SMTP id 98e67ed59e1d1-2e2a2322fe7mr1353575a91.10.1728440974332; Tue, 08 Oct 2024 19:29:34 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:33 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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, Kalesh AP Subject: [PATCH net-next v7 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Date: Wed, 9 Oct 2024 10:28:23 +0800 Message-Id: <20241009022830.83949-6-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 Reviewed-by: Simon Horman Reviewed-by: Kalesh AP Reviewed-by: Ido Schimmel --- v3: - add a empty newline before return, as Alexander advised - adjust the call of vxlan_remcsum() --- drivers/net/vxlan/vxlan_core.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 4997a2c09c14..34b44755f663 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,17 @@ 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, @@ -1723,9 +1727,11 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) 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) = { }; From patchwork Wed Oct 9 02:28:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827454 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.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 E5DE7166F00; Wed, 9 Oct 2024 02:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440981; cv=none; b=AufHaRJNLcJDCbAhHm0MUbstrogpZ3sMi/qd/RTSU7WLXjdQhXCk9GLI2O0lQhoPXe2NgOz3mlt2vw3LNqEWpAsCKKXJmF5YwVF5qM+dEAY3HjwNRTTt/gHXXw3r9ZhP+MOxBIrrlzjzVVX53/Ny3suu0Hq3/ACHJwksD7OQuZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440981; c=relaxed/simple; bh=0ZgJtJ+TjXiHcGPlxVYxhjDteuWSfgfQg0cBummbs2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RhjHi73jKpw+fkhAfDZeHwvhYjD+mW7BsA2pYXUL3QveRq+iF12n/xqqJKLy3986lBcr9vb5L0wgw5JO3yOj9MdSNvQ1+JgCEftJHQYmXBkvK282fVhbP1TBGV+LpTOTq8sG/1b5uCfLwnWTpLjaeEiwIHbGPdTdKI0BSLALA8o= 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=eBb09Fhs; arc=none smtp.client-ip=209.85.215.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="eBb09Fhs" Received: by mail-pg1-f194.google.com with SMTP id 41be03b00d2f7-7db90a28cf6so304533a12.0; Tue, 08 Oct 2024 19:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440979; x=1729045779; 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=zDoqXpsFl8RNldAVAwpbrbVadRrwiVLnsOpDQV2p6FU=; b=eBb09FhsSuMtyPwmydxO+8DQH+x7dGX7+pK7BgUHUCl9IeINNRERJnlZcxZFJDccxE CpHwBuz6xikej+VWNLJYZ81BaUKWoBgqrz6PtZJOaGt32iHPNBNDIUZ5qvLu/DGWfB9d cyaDIrBpw9mtT9P7mVG162/CyUdC5VtvVFLK+1qf+7snf7MyWjqBdIHIqatmhzHNW/KS e5PDtACBUgTCkdsPDvIsUwL2CTiWjqqezONGeHR6B7x8DEZlt8rngQYcRvOeHcztA+63 GbAF5znZxCKq1muIrRJKhF9pO9vGiTJs2mu7vWN6cW32lPffWcNW9JJkD5hddixg7rYi sb9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440979; x=1729045779; 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=zDoqXpsFl8RNldAVAwpbrbVadRrwiVLnsOpDQV2p6FU=; b=Ua4j232r3i4f9rLEiO+5V/xkQ1J3xpeOMx98nuSqI0b3Hr2rgLSpZHAIv+dJlu5muL ip32Om+zuqj9S3o7Eup/7n0II1zepyOTNqqKYHnHV4fDBj+dXUocXvmEQlyYQV1tnw0L hwY9TOmfaseJkMPbR/gyjOVJSL8w11kqGEqUE4GZCXctX6A4dYDfoLQlqTBcf/Lne8zu wQFozBY8EeT10DpsCBQ9SaZbe6ZYu0UoFCk7kFfydEElzEWHgEvNjjS7MhgjyKDjVis6 V6d2EYu1pmTJtljlAp9g5JGjHJCBL1cscJyoT86YMNm1PYh9nAy+W+lxYhuDkC01zazA mGmg== X-Forwarded-Encrypted: i=1; AJvYcCWzMjIuKIjuO5kLI3bdiQ0idhrbDaj02gAXeF8NrKzQ/rgawg0s0dtsDFhbyFXKAw73r+QDP8iK@vger.kernel.org, AJvYcCXtNei2XISTIxzy2HsGhBgW0UOnu2NDfHxajQ0l6nicSOk2/Hez74UCm30wJf2C47gb7wpFoYVtg4oRslU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/1YLtRjd4N32gM1nrWk493b7iaP5+sSUV1TjovJFvNhqv6Qwj MWecZ7hEXni/Lv/DI5tS2OrffLP3uJwNuWKZjWnfMc/FwTStJgiq X-Google-Smtp-Source: AGHT+IEZicIJfJ4Otx0VliOjFPiPU10M2fkxD/CGDiT/CoxU+eCrV7IYk2nrZBNFO/KrE6Y+1YcTzQ== X-Received: by 2002:a17:90a:eb13:b0:2e0:f035:8027 with SMTP id 98e67ed59e1d1-2e2a0757524mr1871609a91.2.1728440979160; Tue, 08 Oct 2024 19:29:39 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:38 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 06/12] net: vxlan: make vxlan_snoop() return drop reasons Date: Wed, 9 Oct 2024 10:28:24 +0800 Message-Id: <20241009022830.83949-7-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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_snoop() from bool to enum skb_drop_reason. In this commit, two drop reasons are introduced: SKB_DROP_REASON_MAC_INVALID_SOURCE SKB_DROP_REASON_VXLAN_ENTRY_EXISTS Signed-off-by: Menglong Dong Reviewed-by: Simon Horman Reviewed-by: Ido Schimmel --- v5: - rename SKB_DROP_REASON_VXLAN_INVALID_SMAC to SKB_DROP_REASON_MAC_INVALID_SOURCE in the commit log v4: - rename SKB_DROP_REASON_VXLAN_INVALID_SMAC to SKB_DROP_REASON_MAC_INVALID_SOURCE --- drivers/net/vxlan/vxlan_core.c | 17 +++++++++-------- include/net/dropreason-core.h | 9 +++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 34b44755f663..1a81a3957327 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1437,9 +1437,10 @@ static int vxlan_fdb_get(struct sk_buff *skb, * and Tunnel endpoint. * Return true if packet is bogus and should be dropped. */ -static bool vxlan_snoop(struct net_device *dev, - union vxlan_addr *src_ip, const u8 *src_mac, - u32 src_ifindex, __be32 vni) +static enum skb_drop_reason vxlan_snoop(struct net_device *dev, + union vxlan_addr *src_ip, + const u8 *src_mac, u32 src_ifindex, + __be32 vni) { struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_fdb *f; @@ -1447,7 +1448,7 @@ static bool vxlan_snoop(struct net_device *dev, /* Ignore packets from invalid src-address */ if (!is_valid_ether_addr(src_mac)) - return true; + return SKB_DROP_REASON_MAC_INVALID_SOURCE; #if IS_ENABLED(CONFIG_IPV6) if (src_ip->sa.sa_family == AF_INET6 && @@ -1461,15 +1462,15 @@ static bool vxlan_snoop(struct net_device *dev, if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip) && rdst->remote_ifindex == ifindex)) - return false; + return SKB_NOT_DROPPED_YET; /* Don't migrate static entries, drop packets */ if (f->state & (NUD_PERMANENT | NUD_NOARP)) - return true; + return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS; /* Don't override an fdb with nexthop with a learnt entry */ if (rcu_access_pointer(f->nh)) - return true; + return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS; if (net_ratelimit()) netdev_info(dev, @@ -1497,7 +1498,7 @@ static bool vxlan_snoop(struct net_device *dev, spin_unlock(&vxlan->hash_lock[hash_index]); } - return false; + return SKB_NOT_DROPPED_YET; } static bool __vxlan_sock_release_prep(struct vxlan_sock *vs) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 98259d2b3e92..1cb8d7c953be 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -94,6 +94,8 @@ FN(TC_RECLASSIFY_LOOP) \ FN(VXLAN_INVALID_HDR) \ FN(VXLAN_VNI_NOT_FOUND) \ + FN(MAC_INVALID_SOURCE) \ + FN(VXLAN_ENTRY_EXISTS) \ FN(IP_TUNNEL_ECN) \ FNe(MAX) @@ -429,6 +431,13 @@ enum skb_drop_reason { SKB_DROP_REASON_VXLAN_INVALID_HDR, /** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */ SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND, + /** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */ + SKB_DROP_REASON_MAC_INVALID_SOURCE, + /** + * @SKB_DROP_REASON_VXLAN_ENTRY_EXISTS: trying to migrate a static + * entry or an entry pointing to a nexthop. + */ + SKB_DROP_REASON_VXLAN_ENTRY_EXISTS, /** * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail. From patchwork Wed Oct 9 02:28:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827455 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.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 977E61714A4; Wed, 9 Oct 2024 02:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440986; cv=none; b=Ia1+GL6XcYAfIB5qa6dECsB7U4xBK+bXjxF3+7EihmCQX/F9Bo28SD1ZlNqoiyvr4RKr4jTE0bzwRJ26twIU+/nkZ3YWeLAC92IGR/Gehd+gTkzbFwdtXZyDP2MbtZUibe1lk2bMMAW956CY7jYY872RcuvPp5jowv3+dGiYRPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440986; c=relaxed/simple; bh=4xIH7Aio0f4PBcaIE51Qch3dJo9N/MMWAobYuTWQmmc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZJH2r1lw15FJavvzHv9PUiRuM6pAgI39sYLa5FLBTQQK0zLDud+MK1NqL9ICYOtZVDjnc10AVoQ4wbLwUfffKviP7sdCK79h8ZfLvYkid+/Ss1Am794hbVhbhdqiXX0Z+crfgDL7BHE6t+bCx3fAWTeeMredVGGUoLpcnFLFjLQ= 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=ZXYckZcv; arc=none smtp.client-ip=209.85.216.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="ZXYckZcv" Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-2e28ba2d96aso1048820a91.3; Tue, 08 Oct 2024 19:29:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440984; x=1729045784; 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=mQoyYqReGxg6xit/tJWU0LNVGXnn5CuHq60bShXa6OE=; b=ZXYckZcvmW0zYSipoRbGkTd3wgOklMtE2PPJA2v4nMfybHSMCGWw/JPZjSApcIEnz0 ZmKlpOoOu9MuCKKM1Uh541j7R6abQDwVMI+fZsyKaWOkoNniuU6P2cEp4wVg4i+F9fHv qw8V7YwxDvA0IGy6lu5bHX6s+fK4TZ1ADbWXsKTgH4cJGOs/zdYDzUi2yPaGP0oW78je 4F4v8ln3FiE/tOUS9AyQqnmt/nZLAMV7fxM+HJ62OVMB/YRSgI6BsHRfC8vct7ZCoKGM JhKjlf6M9cyIk1itpmSDWhL643OZocFgaXwZ4HoVXMue6he4vYYC3dKSyawafIOeFGg2 aJ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440984; x=1729045784; 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=mQoyYqReGxg6xit/tJWU0LNVGXnn5CuHq60bShXa6OE=; b=BCDYyhgulKidS+sxvnHwBqELdKSkjrtyKDsCDXNEKeA8jFqY5QPtLc6cAHM85PmoQv 10UqK+k+WHwIG3PtaWvaSjXFKrzwZYwBjKIrK5xQSFYMlw7s7mzLvdTMC1fsQNjOdubg x6+1f2hDTo6QFempOCAlU6bo2KEfrZErComszqyRugqw/MNDHqKuGlO+4kgDmoxs7ezm fnmOGGC/ZB5GcAqSk2nAP8R4fe3kNZBrxtFjJ6TQ1DCvJsq39EpI9kGcXXw/oHHK5wiS syS7IDY+Yikmnaxq4Me0KKhpXcT9fif0v3zk30N+iYaptdJANlI7pfAo0/qY4r/dW9V5 MwGw== X-Forwarded-Encrypted: i=1; AJvYcCUaKEFPwKxuauTC5J0yjWUknAsTaowGVT4T97+KldZb3F368F+CIf4PjQDXxifyBRHU8bkn4vB7@vger.kernel.org, AJvYcCUkvE9Kod1WWdAIUazXLDi6GZNpXV4dIc9bTS8L3BSaJfB7tiumzYoQMPlG7JuKRENGFAxDzWbf2Cbb0yY=@vger.kernel.org X-Gm-Message-State: AOJu0YzqMwrW3KbQRixb3V6qh4Lv7uKKkZaLecWJ2Q3WJMTSLqDZKsTm CdOK3WygIN9m5N06cL7vkKq5EzqKTniVv8wGbh/eBDc02Q1SnbR+ X-Google-Smtp-Source: AGHT+IHcvi5PnR39Ef4kXioKWX3qb43ZnLATfsF6eNlxApMNwEwu+bMTSMCk3eLp2HYAFibQTy3OYA== X-Received: by 2002:a17:90a:bd97:b0:2e0:a508:77f2 with SMTP id 98e67ed59e1d1-2e2a2525fb1mr1226791a91.25.1728440983919; Tue, 08 Oct 2024 19:29:43 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:43 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 07/12] net: vxlan: make vxlan_set_mac() return drop reasons Date: Wed, 9 Oct 2024 10:28:25 +0800 Message-Id: <20241009022830.83949-8-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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, the drop reason "SKB_DROP_REASON_LOCAL_MAC" is introduced for the case that the source mac of the packet is a local mac. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman Reviewed-by: Ido Schimmel --- v5: - modify the document of SKB_DROP_REASON_LOCAL_MAC v3: - adjust the call of vxlan_set_mac() - add SKB_DROP_REASON_LOCAL_MAC --- drivers/net/vxlan/vxlan_core.c | 19 ++++++++++--------- include/net/dropreason-core.h | 6 ++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 1a81a3957327..41191a28252a 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1609,9 +1609,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; @@ -1622,7 +1622,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 SKB_DROP_REASON_LOCAL_MAC; /* Get address from the outer IP header */ if (vxlan_get_sk_family(vs) == AF_INET) { @@ -1635,11 +1635,11 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan, #endif } - if ((vxlan->cfg.flags & VXLAN_F_LEARN) && - vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, ifindex, vni)) - return false; + if (!(vxlan->cfg.flags & VXLAN_F_LEARN)) + return SKB_NOT_DROPPED_YET; - return true; + return vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, + ifindex, vni); } static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph, @@ -1774,7 +1774,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) } 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); diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 1cb8d7c953be..fbf92d442c1b 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -97,6 +97,7 @@ FN(MAC_INVALID_SOURCE) \ FN(VXLAN_ENTRY_EXISTS) \ FN(IP_TUNNEL_ECN) \ + FN(LOCAL_MAC) \ FNe(MAX) /** @@ -443,6 +444,11 @@ enum skb_drop_reason { * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail. */ SKB_DROP_REASON_IP_TUNNEL_ECN, + /** + * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to + * the MAC address of the local netdev. + */ + SKB_DROP_REASON_LOCAL_MAC, /** * @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 Wed Oct 9 02:28:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827456 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f68.google.com (mail-pj1-f68.google.com [209.85.216.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 8BDF71714A4; Wed, 9 Oct 2024 02:29:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440992; cv=none; b=Cek7jK+Kn4ICqRYhcExibw8a9a7jv83bQsfBUYstxqY8uPfJ+oUhSxYaqz+GaNGtvCmGXarfhCCRoHpjA4m9CJyF0/boYOMlflBoiIp912Dn4bDLdiWCM/QGeKDPuMn+cYhzoDUZ5/ZJ+HJti1Mrj/wfOAHePuebBQrlfQ9sZms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440992; c=relaxed/simple; bh=ZAosg6sRSO83NLhdq2XSdXeuJvr4vRDwWp0MpG86sgU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DeYTvRxsobe0PaNaq1QesVMTGojjP9Tw7d8utpA4TC7f4QXoMFUoPQX6ARxK77NwLPTqzOT6QlZ55NscJtCDka4L4VijH0UAo32Ycb8m4CkRnd3CyZmZFpXndNntWPY4iCOLxnF+sT2u9ic92jfP5gJGSXF6tD2+M9eTcts8Lqg= 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=P4EgHiFL; arc=none smtp.client-ip=209.85.216.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="P4EgHiFL" Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-2e18293a5efso4354442a91.3; Tue, 08 Oct 2024 19:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440989; x=1729045789; 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=ACzfDnBPZ2zKMK1LA1OtfcN5HTpxaKXpt8zIEOrq06Y=; b=P4EgHiFLNF7WMLg8PSBK9kRAkxQQ32O/wqv6vcqdGsp0Z7rK28Gw+WsU1t52YMV6qW 0auO2ovWsEuH0+7WH70BY3QRTCMLj2FcSYK/Z5EzUBUiL7eLGpGWlLA7UoOIm6S9IVyJ 7usWB+pE/rsb+yviwfJ1b34wHbSqH7kQfcIwIRrQzDNAf+KZlpYGsNIjYmt20j0Fp3aA +R1OdBwXi4Q9zwHUgJV+tWtBEVhmha2sPovGpwkxpr+REL0ZZMCqLlGF6KWm/TKfeVWc aqN9Yn8ElLZDJ4rCM2BsVCdZ4KsubwLLVHNNqD3C8hhf5TbUmon6M2EfEb/Wl1wn/4fs +pOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440989; x=1729045789; 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=ACzfDnBPZ2zKMK1LA1OtfcN5HTpxaKXpt8zIEOrq06Y=; b=WtYvYKRFeFijIh7hXO9Kc2jq0GeG9QgUaajBv5P4fTmImkxZYuc+5XD9sSkwZak/vu gweXRW42VoiePLDF7y8ogXTT2gxfbWN11oxLmFESRjP/M3+XdpFxuCJQhEYe+mPXkIoU 4pKusAH17CizsWPJnst3gHnfq6gNekXRhoeI8VttwCzs2AKuaH0j8+rM6MwQGK91LEAM zNnNF61WSasC14Z1YQoQ4qhDtey4AWwONeSErkiJGGQTxLWH3UTcw9wgJWWGqLHcoeDV pL+jr03VgfMX+0HpEvkdcNgVVoHFy/Fi1yBejMvoJKsoaG2NqxEOHmddImPfZmcT53pF etAw== X-Forwarded-Encrypted: i=1; AJvYcCV+Yp5XvLNe440PrGMyq/j390mPTArOagRxmzbr7ONTPzXcig4visybHRpwfamuysu+DKrLZG5GM+9J3EQ=@vger.kernel.org, AJvYcCW8Z/C6ttRrUdVF2P2HdbF3zWiSf2c5EAOn8SOfb0tt7Q/Iy35bXw7i3YDJvBfVjXw5f12QACBh@vger.kernel.org X-Gm-Message-State: AOJu0YzfSb/9GBLFEgaBR1idIf2kM1W7OoZ1CPePd9eo7qw9Hq9jUKuc 4+nsUqL8u+7bZj8K6XId0O6Jcu8Gf33/Ss4wAR+7xLu/I1LJ+xYA X-Google-Smtp-Source: AGHT+IH2HkD13szisgeE038Q7wOZH06A/YQxPXdL8g0hH/xvkHd36kJIorLKFigLqtRRu5rgK9tmcQ== X-Received: by 2002:a17:90a:1b86:b0:2e2:af53:9326 with SMTP id 98e67ed59e1d1-2e2af539345mr156947a91.30.1728440988736; Tue, 08 Oct 2024 19:29:48 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:48 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Date: Wed, 9 Oct 2024 10:28:26 +0800 Message-Id: <20241009022830.83949-9-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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_xmit(). Following new skb drop reasons are introduced for vxlan: /* no remote found for xmit */ SKB_DROP_REASON_VXLAN_NO_REMOTE /* packet without necessary metadata reached a device which is * in "external" mode */ SKB_DROP_REASON_TUNNEL_TXINFO Signed-off-by: Menglong Dong Reviewed-by: Simon Horman Reviewed-by: Ido Schimmel --- v7: - fix some typos in the document for SKB_DROP_REASON_TUNNEL_TXINFO v6: - fix some typos in the document for SKB_DROP_REASON_TUNNEL_TXINFO v5: - modify the document for SKB_DROP_REASON_TUNNEL_TXINFO v2: - move the drop reason "TXINFO" from vxlan to core - rename VXLAN_DROP_REMOTE to VXLAN_DROP_NO_REMOTE --- drivers/net/vxlan/vxlan_core.c | 6 +++--- include/net/dropreason-core.h | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 41191a28252a..b677ec901807 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2730,7 +2730,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; } } @@ -2793,7 +2793,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); + kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE); return NETDEV_TX_OK; } } @@ -2816,7 +2816,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); + kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE); } return NETDEV_TX_OK; diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index fbf92d442c1b..d59bb96c5a02 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -96,7 +96,9 @@ FN(VXLAN_VNI_NOT_FOUND) \ FN(MAC_INVALID_SOURCE) \ FN(VXLAN_ENTRY_EXISTS) \ + FN(VXLAN_NO_REMOTE) \ FN(IP_TUNNEL_ECN) \ + FN(TUNNEL_TXINFO) \ FN(LOCAL_MAC) \ FNe(MAX) @@ -439,11 +441,18 @@ enum skb_drop_reason { * entry or an entry pointing to a nexthop. */ SKB_DROP_REASON_VXLAN_ENTRY_EXISTS, + /** @SKB_DROP_REASON_VXLAN_NO_REMOTE: no remote found for xmit */ + SKB_DROP_REASON_VXLAN_NO_REMOTE, /** * @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_TUNNEL_TXINFO: packet without necessary metadata + * reached a device which is in "external" mode. + */ + SKB_DROP_REASON_TUNNEL_TXINFO, /** * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to * the MAC address of the local netdev. From patchwork Wed Oct 9 02:28:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827457 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.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 18E8C17BB32; Wed, 9 Oct 2024 02:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440995; cv=none; b=JGvRf8Ymnb5xgIxNY4gx2D4eg19ITpkNGsW/9/Jm6gkQwygVpZdd66Ea7WNOjauh5ynvdEEDWu+K5uwfRurdfihsMeWTZi1knU6qK3SxLWBacqJTEvRFjtAWgmJBD/PUGLlXepKBOfUTG4b00zK0G46MFw1tZQ0hEwWKKIIJNis= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728440995; c=relaxed/simple; bh=ZX6rpV2p4NCjpSh/ZKSJ+9hBSNtbI+i1jkrQAXbqfxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oTOuQbmZdwmOsNqaByYrgubra7HRcgs/Iuxxk3m8MEq3e9z44Yflw+7Vg8LLcHStB4yXTe+L0zejSE34ZhiHNPX2/QDGkalt6mXvUkNWW9SYjGNqEu3O0xWP9hbZhDPZ5bok9zkuTVr4OG3u1rPNVBHM1p2nD5rbIywu2nSxRBY= 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=EPQ0htWQ; arc=none smtp.client-ip=209.85.215.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="EPQ0htWQ" Received: by mail-pg1-f194.google.com with SMTP id 41be03b00d2f7-7e9fdad5af8so2307354a12.3; Tue, 08 Oct 2024 19:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440993; x=1729045793; 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=fbb7WoMAUR4wBk7UiHJwsRsFkglFtN6iutr69JSzLxM=; b=EPQ0htWQe9GiDMDtgyOlhrjTpPxplULVRB11JnfbEJysR7Xg7ZMZzv36XL86vpzg2Y 5cM/zHR+gw7NOe0JcgdbXTSv1Kdso2aAGh8j2wkK4dZeLZVjqu2jHtTHxyjuit7cfGS4 tLNWmGyUMcVWJpoQNpN3ohSZf0Fit2+XILK+h0yRVTbDjJSBsk+tNtj7etAPRtb4nAfu RrO7wrd0R4SX2wy/NQj1Yqh7EbOxRc65fRWc340gMJx0N4w8qK/7T8TLhkui723Mf5zx EBJhYn5VWTa+bVW/LkXegw/ReUfLefsaPQ3JGoz/c6TOY8VakYSrntypAI8yy8XTaAg7 kE5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440993; x=1729045793; 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=fbb7WoMAUR4wBk7UiHJwsRsFkglFtN6iutr69JSzLxM=; b=FcWBMOZZT1IQf42e83hrT+OTaR5Zy3gSARRQvTO2L/eestku8A0gRBhXXTZgxVFTpw y9Ax2eSwIGClQ68Al7yRK/9jvy7moHzYdw028VNcqe4prEwVLf5Bct8SRtvq943de+/0 AgYHIBxeoZQyL8Xx8UgBxLxX0cxZDe9x26DwcDjshkIwbPlWoJn4KPP3OAbRUN8OJg88 426wPhuWCh73fzERKSE2VKnHdVLTMx1X3Xk1SLth0n29YccNLsd5fbBw4PoJlbW2bxqL y/UPJV7lvAZ70cEye4FCGlPq4UWeOzxI+paSrQ9I3g4MJ7dckGEALsKBY3DpXlMGEbZZ 3Ozw== X-Forwarded-Encrypted: i=1; AJvYcCV1nQBczhRG1bEkoorYNi4mq1Nl425dbmbK8nan5cd/KJUgMpCB3ldsIq6o8QsNfdeBhuejn4K9@vger.kernel.org, AJvYcCXPrAOCTDjy4e0IzuhckFhp7fHUVweWHmHvimUDOXfM59CDAM+ZV5QUtTNaDr9zPOfwdnxlkEa25bRHYBk=@vger.kernel.org X-Gm-Message-State: AOJu0Yysz7GRNsJQ7sP8Fe70vy6ZL0S8Jx6UfTzHeG/j6zEAb5LTsFjT UVamjSyqjOuKwGCWnjRvF3ARSGspRaEHWASvPzG1ta45EFGg3GuD X-Google-Smtp-Source: AGHT+IFi3yVvPHZm2BOO4VxyWCdAAXZmT2MN/RZm8AmD+sj/tKxtLFQiULKpApXUlxpsPQA4d7ib7A== X-Received: by 2002:a17:90a:f02:b0:2e2:991c:d7a6 with SMTP id 98e67ed59e1d1-2e2a247aeabmr1108840a91.19.1728440993425; Tue, 08 Oct 2024 19:29:53 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:53 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Date: Wed, 9 Oct 2024 10:28:27 +0800 Message-Id: <20241009022830.83949-10-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 Reviewed-by: Simon Horman Reviewed-by: Ido Schimmel --- 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 b677ec901807..508693fa4fd9 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2374,13 +2374,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(skb, no_eth_encap); + if (reason) goto drop; + reason = SKB_DROP_REASON_NOT_SPECIFIED; old_iph = ip_hdr(skb); info = skb_tunnel_info(skb); @@ -2484,6 +2487,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; } @@ -2535,8 +2539,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, @@ -2556,6 +2562,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; } @@ -2596,8 +2603,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, @@ -2612,7 +2621,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: @@ -2624,7 +2633,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 Wed Oct 9 02:28:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827458 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.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 E9FA917CA0B; Wed, 9 Oct 2024 02:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728441000; cv=none; b=lOopgeAORcHywyYR0+S/POBpnnDzG058L+YBLVQx9nX2dPS2E4ej1bSq99owsNLYZ9qXcJgNtD7vExU6Fu9umghklsi9aM1b5DnCRbYzAfth1o1+WQyYk7Ieo6x8lPelRdV1KMGbkJeZH3LuihIZGksIsooU3FRqJbeRRSxtiLs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728441000; c=relaxed/simple; bh=YBE7Gm/eB2TlKhxoUuPSI1O81VwH7aGArvM+el/K8oQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T8m7XJGfa3wTo81ibNvs3PUaKyUrNw1FOlwJmGyUUgCbiztOzRRpkxga0kHPcN7Nwy7nB0//a35JmXkR/EVoMTvzibC0OcTGCG5h6rIz4tmfAlgujl24TnmVLBo/CcXBHDeTdJ1oEXal4ow200tDcC1Z8iculF8iwtrDeEudAWo= 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=YrFnIprV; arc=none smtp.client-ip=209.85.214.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="YrFnIprV" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20b86298710so54016945ad.1; Tue, 08 Oct 2024 19:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728440998; x=1729045798; 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=VUrRZI6iM2TdSh5ZMNy/fS83zTOTT53JwP3p/9CnIm0=; b=YrFnIprVsmEUz5TSZ3zpm2QxK+6a5HO2Crte+VnHWKa4K/aBLDHduvADoAJbok3pU/ KV+eGLma0m5hi/bIrcH3n2RUE3YruV172nedJ5ile3lL6Oa1ZyxYeYhrSCr42sJqsUAi HIxb0jcxZF8rVV0F/bzUJZXqv9lb8R1ovvOKR+kSKMcQ1QO2KUOIm5Z4udjC25H/o3M+ Eoo/OxiYInhqqwKJf454HexaB9xFHgrGS5tInXVVXjsUx0Reml2YewZb6p4HCfp39n18 RFP4Egcx8hkpfQpYHerEYPe0PlZRY6No/rN5Lfp7z+UZlSDHHsByfxc+Af1OsT/AqkKa 85Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728440998; x=1729045798; 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=VUrRZI6iM2TdSh5ZMNy/fS83zTOTT53JwP3p/9CnIm0=; b=rT1FBFz1MRGzjjNLxUutJBc9OijzCDxIAmCs1TViF9Fc1Kr9HodfclT/pvJbqWvVQ4 7+j9UDRUfHm7mD3Dr36l2qHjv/evTUCHgUaT8K7xjzFct8uERl/Y88jExsVl1NRmv95I 5hQdR3x/SGw/mk0sBxvybBYAJoapAvAfdc6RaozaQD7D9iByNq7wCUgImtgi6AUv1Gju Hrfeb1GPJRasSPO37610ohDOZfnR4XTEp/d5y6riukjnZkHkMJLmGpJAPAnV+8s8ms3M yKgc71Y1iP72Ch0GlQxbggNnX1Jk1qAWA66F1sWzbYyhZa8NZXIfzKEfS97C35ZYOuLN I+DA== X-Forwarded-Encrypted: i=1; AJvYcCU1NT0xl51pmik4uQOO4sXsZrZq57mrjvbhtE1RFnOkW2nZ/szNktkJxFjoswYMtcQWPWtSyLcMQ6CpbRo=@vger.kernel.org, AJvYcCUEdHiLvUvRttgRBHy1z4WKfXdZ5Z8KnNp93BnknYzh7vyVgO178Bn7McSn4qrOO7DEdtMZNguv@vger.kernel.org X-Gm-Message-State: AOJu0YzZ/SoWaVKLL2DlQVIs3VZBm+i6qfHWdPM48b9gWQE5JrcWp511 oITr5a006HYcaC9zG7TyTOQ0Nkkjb/DajPQANRPxERaWsaYqzhzI X-Google-Smtp-Source: AGHT+IEDWkwzAvcKuYIWzL4PV7Q3/38i4O5qIt5/Lk8iF/ZzYGbMknUTYLwJpmvJOayhQr/HNqCsWw== X-Received: by 2002:a17:902:e541:b0:20b:7d21:fb8a with SMTP id d9443c01a7336-20c6379b4c0mr13167735ad.61.1728440998272; Tue, 08 Oct 2024 19:29:58 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:29:57 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit() Date: Wed, 9 Oct 2024 10:28:28 +0800 Message-Id: <20241009022830.83949-11-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 reasons are introduced in this commit. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman Reviewed-by: Ido Schimmel --- 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..e1173ae13428 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); + kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE); return NETDEV_TX_OK; } From patchwork Wed Oct 9 02:28:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827459 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.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 C64B6152E02; Wed, 9 Oct 2024 02:30:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728441005; cv=none; b=NeKgcJdaiVWMoDz8a6oC2M9NjrIPK7U8waqFhdZthSI7FU/W+TCnyluAMUmpxlLH5WUKrEK+7xr2wJX9yWT7/uhFMXEK38wsiOEldB+iDClljgaFuenYk8ISfUFVJ8epqxaC+E4P9xJUZxxeO+3po90pNaBOTbjxaU8OQjLzZ5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728441005; c=relaxed/simple; bh=dKbZM7+rvKdCAftLsIqRMrR/jd8BPaE4KCzu53bpfvM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dJvtGRd5Bb7+nb6iwYe4lR4x5bDt7ORJ2iqM80aa/rHNdycDEUAPQ0vGHf3tOcrOx5y0cFkoyXjmitBfKUvF6yq1BoVsPD6yiUt6qgbqGYmMfj8kgKL26bbGRFERh/dExzP9jP8nvadxH9viap0rzOubVmObLagG3kMn0QOlJQs= 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=kaGTR18v; arc=none smtp.client-ip=209.85.214.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="kaGTR18v" Received: by mail-pl1-f193.google.com with SMTP id d9443c01a7336-20c693b68f5so1779405ad.1; Tue, 08 Oct 2024 19:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728441003; x=1729045803; 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=qwQKLkW+/qRHGLn4gTua8kQBWJmQk8KcS+aTLWa1XwA=; b=kaGTR18vBoHmkJeZFkYbC09fnpBd7nXgSjMDcW2EBUR6dlGSM+RmJHvs6URy/Hjorq w3ZAKqpuuJyppq/+pWOAmu7klRxJkwbAgfv1JXwW9FuMb2k1mwau6JSZEU9cdcxvCc4X iQqeMhs9RdFmLmBz4EO8rTs/zhOv9iLu4h2kXzedDLqdTpGNI2U8r0JtbBJm0zgOSqcm SncU9kWnphGbtwqVsAu0p5v3dd5oKEtQ6h90U1R4CX1LPnFBMlNXZi755qBQu6eTyDqx qv/REvCeHzKa4pjRQb55m4ud7duSzmIeouDvfnh8R2TgNrkyb3LUfslIr6+dYBC5MmZs EkDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728441003; x=1729045803; 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=qwQKLkW+/qRHGLn4gTua8kQBWJmQk8KcS+aTLWa1XwA=; b=Bv4SScpC1XGHSssnlkAxEqovgi53vMEbk4ldT4ffDGACjJD63P3HGj68z9eiGDTVDn ijv013S+1DWSSEOAvirtc++DvRQtuKPo0x3wzwcdIa6Q7LQ4Ul/zy+Gi/tlNukCEURDN zbKfIP41iPJ1om09ejjfXieiRfOkDwUg9NfK2+P963RmQNhGopuC2s1e2oz0NSlYfGez TFpFXkffwqnVNBNIt6t9LhhPimd3NywfmGCg2bYfil8DXh92b4WHpHsHphSvqcqzHeBI 7Yv3vkZMc9Dt89CTowyZvuCrHZ2bBZzee2BOjgFosCiw6nNXQnfIVrIIOTSWnfqPNtDl SJ/w== X-Forwarded-Encrypted: i=1; AJvYcCV3bWs+D6GFO2sOIA2pUyjj3/9Xn2mXDfDJrmqFEB0fXJArScDeDrK8QJM3IdH5G6EJqJ0l1FpFw7tQ5DU=@vger.kernel.org, AJvYcCWkYdBn0mtIqo8nTDioiFEFfp3pawjA0SoSVVmHb5+2BqWaOo3G69gC0ro+v0Ei09VC4lFHbT8G@vger.kernel.org X-Gm-Message-State: AOJu0Yxqws3FUhoCr9i9hCZbV3jQiSOj41OIohkBUX2/CmEGIQc3GPdo dezjYXAUtZZvKIts+2NRPdH59DbH0es+oIHtlLk3VyRL5P3mK4lL X-Google-Smtp-Source: AGHT+IEwVjJXtOtb8EqyvWRcdQ0mjFdDbsy4qfl1xKCyh//3oR4mPUP4YKlN2iEhcI4dlxILJ+h8wQ== X-Received: by 2002:a05:6a21:9d91:b0:1d4:fb5b:bf44 with SMTP id adf61e73a8af0-1d8a3bc30f2mr1586721637.5.1728441003135; Tue, 08 Oct 2024 19:30:03 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:30:02 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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 v7 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass() Date: Wed, 9 Oct 2024 10:28:29 +0800 Message-Id: <20241009022830.83949-12-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 Reviewed-by: Simon Horman Reviewed-by: Ido Schimmel --- 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 508693fa4fd9..da4de19d0331 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2290,7 +2290,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 Wed Oct 9 02:28:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13827460 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.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 BDFED76C61; Wed, 9 Oct 2024 02:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728441010; cv=none; b=bDZdc5ke8Sf8OREkTv7+9jtwsKhvAgGJxM2X+XljFY3hVbsJvqH6H59gYVfJoq9WjO3WY2IXjGJfitBBNPFbEWIUETSPOnMXWtFu8t9irKsntKO8WfP2wG0gBGK3WcEQo4tpW6WUsn4qyjFLCZ11QiXsdGEQoxejOrZ7ZuGEo7U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728441010; c=relaxed/simple; bh=R8vmG0u3lFl9fsXKHPJv8VqmdcKKDyrNnQXHw0Dmp2U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A06lwGmNL0lH0VLrlTxQATD/pMEH0j3JoEPHMLSNDQH8Jsvnw/cI0dFjWdEZlF1VZwNx4S3ihoB0mdp2nhmKCJQn4SrLT9L8uOP0BsaXOCoinwAyKXfTtHHw2d4bQ3dcZtIfZtPywDWnhrdKkuePLsCii/OUm94UjvMaPr3HS3U= 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=coIt0OyB; arc=none smtp.client-ip=209.85.214.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="coIt0OyB" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20b58f2e1f4so42963825ad.2; Tue, 08 Oct 2024 19:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728441008; x=1729045808; 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=KyNsEi0JeRXi6J1a9d2wdU47n7lnZVibMGfNyAtDMsk=; b=coIt0OyBkHIXXb+7PQZKDEwum2PZV/cYopb81enX6lHQHRRSqtXGYwyf5q0YHAZLJF SPT10Lbxlo33gxbIMm61md7u3TEa9gdN3j8CMo8QVHjpioMWXORCls6NoeZ31ziE/Jdm Y9ZsUMVgqIHbfatVqT3ayWePff55LR3q56IrlVvbJ9AlrmFMn1w7dIAZsjGFwVgiC22y 7FP4U9sulspT/CaoEdgK5QbdLZql3PPNtc0qtj7NqRQ/CcDmRh2HC8/PQPRiMoIqmdwP KOtefV4knb2F8mHHEE/DT2u2Z7AEobmyT7oEs9NrSVZtBJmEgUpjuFV27H7ZZJuHN4zm DADg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728441008; x=1729045808; 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=KyNsEi0JeRXi6J1a9d2wdU47n7lnZVibMGfNyAtDMsk=; b=SVKFvtMWZLKcIFLKFLsIMH+Gx4pq35sxymv3EN3lp1zQVryzTont1xdMgZOk/k8hqh mkVv8y6jq+SoHg3ccZNJtkwPG2UeTgvkGSxhjV5A1WGVPJXUF3Si/B/yDrFCIVAPyu0r ehl72Xglb57qsyUtpAgCI2LJwsviS+5GTF/wmuiwGzpKvvGpaWa0DWYKYPUCr/9aaoY4 9z7q6fOqOaPnN2A1Wq7shQEP3wrzUE5xR2kgnmwA69aE7HbsoOZk78r7USfsVUjCmjuO 0zOVN1Ue5ekuasJdbq5yrPhKnyMbWxZ89lgwcu+U77fExTvmWdB+ocx6r6SSd3ljUFiQ lsiQ== X-Forwarded-Encrypted: i=1; AJvYcCV1HJSRJxkiZcI8hWmV5rlePS4Jhh6S4bntfxnpDeghqCTMILIxrKqP0vuQT1p9Lbf5es62TEhC8qvE/hI=@vger.kernel.org, AJvYcCXZuvyxfCS008sTAxWMAyeOP6CwQBis5WKJeAF6oNKu0nK1XPFOPveF8b5c1s9UtcZQbQnIv6Mr@vger.kernel.org X-Gm-Message-State: AOJu0Yy/t1sxQBzejvbeZppVny435p99/eIX7+feBittCLyjdNyzoUQj YYn0ooIevX5gfFH3JC8x6LhNwKWFmu0Y2RhtxZhNtQAq16ZfmmOH X-Google-Smtp-Source: AGHT+IF63z2mmMAQqwEG9PWLmebWgkxbfTFUpNjLHfaMsBtbxJN/L+ziwODlqorfWpWvsmolRnDGLw== X-Received: by 2002:a17:903:1d1:b0:20b:51f0:c82e with SMTP id d9443c01a7336-20c637879bcmr15520125ad.51.1728441008109; Tue, 08 Oct 2024 19:30:08 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2a5706e8bsm336202a91.18.2024.10.08.19.30.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 19:30:07 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@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, Kalesh AP Subject: [PATCH net-next v7 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local() Date: Wed, 9 Oct 2024 10:28:30 +0800 Message-Id: <20241009022830.83949-13-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241009022830.83949-1-dongml2@chinatelecom.cn> References: <20241009022830.83949-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 encap_bypass_if_local, and no new skb drop reason is added in this commit. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman Reviewed-by: Kalesh AP --- 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 da4de19d0331..f7e94bb8e30e 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2341,7 +2341,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); + kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_INVALID_HDR); return -ENOENT; }