From patchwork Tue Oct 8 14:22:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13826579 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) (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 6328B1DEFEC; Tue, 8 Oct 2024 14:24:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397448; cv=none; b=qus7tPy0ThR44aVHSzvJ+1hqt+VzEp4e/QiGnmGe6IbKfFdOLPxTt8feEXbmEvqoTH3j09iSC/mFFKGrEEAzjxrFn5b3sorjCPDgjjefLIxkrjdpMNxy6yq0N85CX6bhBJJk9RNuZgNgPJhEkZwFwWCrLkP1XllBYESCzk+/Cnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397448; c=relaxed/simple; bh=qDSFVKxj5P9OuUbcZh8vXPtfp9NKaBMFgSQrL48vbZk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DQ1IxzVTTy04uHGGw0F+qbaHrTUpnFgRn8LcEMVt8d/PBDrjnNRphzad5dkk8P6N3WEHfAeAiQtPVFRewcY79Eq2Q7bb3gSm2E235lUq0fn7Oq7KHrkckvNaT29bhzNt7cLWNZM5k+EE1K2K+a7dkncOBRzJvcPr6g8ZbcQZ53s= 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=GUs5lpLt; arc=none smtp.client-ip=209.85.216.67 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="GUs5lpLt" Received: by mail-pj1-f67.google.com with SMTP id 98e67ed59e1d1-2e2993de292so54202a91.2; Tue, 08 Oct 2024 07:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397446; x=1729002246; 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=GUs5lpLtKymu80RGcIXBSt1Bbp5eOhWoOps5xIw2SfPbTiolvyn0ioUYtJ2kzESmpk fNI3GHlyi+sc5uoAw1kZZ0/aXuIddqAAOXQ1bfisPJcxK11LaCPvjrjZOMl2uuXf9OEu qyOOM5hOvtTOuMo4Z/pq+BxiXSqEHLMTRmrcpxO2gRH0lMFfp00bjZrTSwrzpbRyJkrh PhEG4H/Qe903BDe77WEnnC46RXVle8REA46AnUMcXjikbq1NoM3PI05R9omdwFkYHBp4 +v7I2qLNsRGiyHx5FfBn2pkpgKuuFe/xNcs4/eEfJ2sSlGP/pgXJYPJg2kjzklbPQ1Iw imCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397446; x=1729002246; 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=ESIhMafk+tCAJwGRYt5+x5+CLSSbl0MOFPqrknp1wMyJfheprBbg+s+rLfC4wQZ2o2 QT9ppcM4x3OLksyVmoIRI54EGAO9vB05LxCkuee4RJtN+qe3ALn3/gAEV/As7hOA4lcs dmifUI3Jr/fAEh41uLUPKh5eXqmMpTa67KJIHppW7OkS9IpafEa41e234h10jJiptttA LN2gLnHYqqF5+r5HC7DFilibUFGI0jqiNVIrNTAasll64BgTDI2rXZSs9CJvYNcV5s+D a7m3ai5JbgX9XoweZ95iq92KsvXla0GfFVdH9DVs2W2YIifpyKfCqXtzyPKQ8VWiKU+k y7hA== X-Forwarded-Encrypted: i=1; AJvYcCUBf08w2llMcnwtBdEHKXhj48Uc/JGcoc2U9NFkjoILyLd1jANkaFGyvmTz1sqlbI4XV9+UJ6cnCb4UiGo=@vger.kernel.org, AJvYcCVLPIUA5sNsLxMqhfeTuc17VisAjC11FWsr9hFnShXb4ZvYNE4xgK1E+I3ADyw7UuzDQVO1w629@vger.kernel.org X-Gm-Message-State: AOJu0YylqbDOjnzBCuep4nS6Nm7GCkZsZ4fjjoa4NMRsT2iLwMOCvRbD 9riy2NKo3v18NE7cPaWFjbghdlwia+xbm1DvVWLZT+jUFrERHSkZ X-Google-Smtp-Source: AGHT+IGv7zNOT40cUxDCGMBKCOwZxYX68Vww/V+htCSaJv2yWGpwfzqQyiMhYZa8ep1bXYSRaHVvOw== X-Received: by 2002:a17:90a:3f09:b0:2e2:8f1b:371f with SMTP id 98e67ed59e1d1-2e28f1b382fmr1740282a91.26.1728397446372; Tue, 08 Oct 2024 07:24:06 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24:06 -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 v6 01/12] net: skb: add pskb_network_may_pull_reason() helper Date: Tue, 8 Oct 2024 22:22:49 +0800 Message-Id: <20241008142300.236781-2-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 Tue Oct 8 14:22:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13826580 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.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 478281E0488; Tue, 8 Oct 2024 14:24:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397454; cv=none; b=AUu9mGcsR78QJpP3kUDnuGQHYQ8zVAtyi8BXpj/sd1iExyl+l8QHX+F0EvKKDtDP17YUWRpm0F++Rj41PCQe9PC8znRWgTPTZNxacZCSsTAvJLFr9L/zpBT/eAGYVMiGwGKVBvk9ZXgsiX+ppYNs3xlTrTZzaFnwxK0awp0RCHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397454; c=relaxed/simple; bh=xmSEGfXWYYnrxahV/hxdM2xvbpsGMckUIHbpupwQeoA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cvhlbAwq5sYZuHHkux1UGrYbUZnC7AHqgzuQ166vPFgOxOVktfPNbpdCufpOzufxj/4xlBFki5MEc/CqUtH8eW1rDcdngLnafPk/NiYu4wKCvN/8KTCTvE2PcWPxEnoK3eLIMaPP2LaNkgntSHdwcxSe3rT1TC68Fto+oS/AV/g= 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=hve8338q; arc=none smtp.client-ip=209.85.214.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="hve8338q" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-20b9b35c7c3so59767515ad.3; Tue, 08 Oct 2024 07:24:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397452; x=1729002252; 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=hve8338qaPKc+mtU6TmLw1yW3YsOlOLEH1aJoOqzE1JchN+3+yipWUwsxZzchNnXVZ GDaJITru2ch/b4scOvtKoMpgUjF6ieZ/1ESu/m3yd17G+nYBcZ9BFLR7p9ndjvRJR1ly NXzOKdFz5GL653Mj27hFm0mxvc7by6kNb8E9JjTdFzeAU3FT8qA9eV/5ZTxMrs9xqbas aNOMrb9A9AjrEaIIhrLhr47QmUCiZ/DuA3bXLpHLkI911rUI2v5A9LceY2+Gfs6Jl+KB 6kWv7rME7N51S9y24jXZIZt0Ueqmgv67UxqDhwmUXptJjwD5a0EJoyo+Zc9tvnUrDKZY O7Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397452; x=1729002252; 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=N4c/KSHiO7qYJJeYQ+efm1w3eVlB1BiLvbKx9+JHSc4hKFV4pNah4QvfFnQcxYSANp Vp44IIowbFPS8FsWn/xC5kGuRrj8vdKcc5aRFoOJW777QFGfZs22AtFluZSkf5OpfLMl L2sWVVh04JBc2ibsEH2V430ZE7znWMJABCIN9feUKiPNlhWSArgVwpYE9inRyrc7ckCg kTrC29GF4ZvA/H8Vcif3v7RrNwXcziNAibhK/E4oXZQ3jgQwTuHluTI1KLEaW91KEVN/ 743QFbBvJSveLWPLXGtGuHvNbS+aKIRpqOmH7ooNB4Spn0ffeG2s7xrXxvGO5eLYSjf3 w8eQ== X-Forwarded-Encrypted: i=1; AJvYcCUfqFzkRfPa06JW7+bMONMOeTKKPpaegDD4uon9Xt1BjjgWuC3eo0QbKazVyjw0BLDa1E05wLhf@vger.kernel.org, AJvYcCUkkxmBETfMgdbhaYBLPBnV03a6PiF5/W3oIiJgA//fOOZhgPficDzr4baA+T429BiKrm41dEVf28MkZuM=@vger.kernel.org X-Gm-Message-State: AOJu0YwGGLKn+TQylIxvX8Olmavhy9njBuIW4qf9ZGBX6p4qnj0Y+Lhj h4ZCZ7PTY2N7lQsF05fhrdLsD0jnD9/M11ShMyxUDuXe2fxsQ2vh X-Google-Smtp-Source: AGHT+IFvNBxDQEa0XGqcHuykNEC8Z3ZPUOEa6O9cnvLrigfOqfS4ak9C4O+mvE6nDpNsQphiBcRekQ== X-Received: by 2002:a17:90b:4f8a:b0:2d3:bd6f:a31e with SMTP id 98e67ed59e1d1-2e1e636f8d4mr20800603a91.28.1728397452418; Tue, 08 Oct 2024 07:24:12 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24:12 -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 v6 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper Date: Tue, 8 Oct 2024 22:22:50 +0800 Message-Id: <20241008142300.236781-3-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 Tue Oct 8 14:22:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13826581 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) (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 558121DFE25; Tue, 8 Oct 2024 14:24:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397460; cv=none; b=k3GUYZlcjJ3/QSeBVDzSmKCeybjCn6aUtfq4vhNHXJtVh7MV/ZFG+oCG5qKIE2q+M0X7KWUISLTl/XqEFgBKdf+QumNZSogEgSpptvLy/QIou6bTYzz2pH/HCoMNDyPisZspa3cdE2GHp4gNsJFromg6MHxY7mHuDc0oUXR+kIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397460; c=relaxed/simple; bh=0LbNYkuc1H3teX+6zzjM43vRgSWAunIJN3Vzj/y7tNU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UISG9w7Ovaj62a2FSl/I2djznFnR7tVLXLOere5LX8G8xtyHjF9yrZ4ivYCuWK7QU1StH8krLupWBxr7sPsxGaqKulK/G930vguef6UC5c1ExBerCt648eJgt9FkeTolX52IL9UCiWFXr9WmJ4jWEGkmPOsXsBqGeF2BlrChXQs= 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=Huv+RGvE; arc=none smtp.client-ip=209.85.216.67 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="Huv+RGvE" Received: by mail-pj1-f67.google.com with SMTP id 98e67ed59e1d1-2e078d28fe9so3920108a91.2; Tue, 08 Oct 2024 07:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397458; x=1729002258; 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=Huv+RGvEWARXlDHZVKVgoPsEnSa3NgJmaIStCUeSuYzp+UE4owPPRAWOBXePaVUEzm fLd+HsUgiDal7NksdHV6heJ9/+KOFMhzgPOGQZ0PWDdzcNBSpAAVeu8NHJRkmKf4DqMU umjZAMjy1E1K7fH1DEUOKwtfwbEJoKpIwfWkQdXq2QbmBTqYjs3MxuhRwCRRmcE1dCWs cGYIYu1QpVsrrRFc06/xGHGrQqsT1qm3K6AEEzjKBxj+MfXQBEsNJFq4tgSFGD6h2u+H gSpELC4dw+4xLxAbAzF2e5cVsih3Dt6dDK/kr5StOAwD9VCkMrE/282O2sVapGxWst0M ejdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397458; x=1729002258; 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=kmDdqwrUwmnilg+tyxK3uHP72qC2z1AU4po6YFd5gDVy/17UDkYBsoRCj+DuEAFcRs Lm1BaJV4szmJToAusie4RX/YPTiRP3Ya7dvAHApnEZNWVvbJMy7wz/rFHLlXNafDCjgk S8GzanOuMullV9TK+OLeq/NfhHK2on2zpvhXp1Co5pl3V2ASDol3nRSsd9OJAWQJezh+ +ZIgbLa19irQDotNLCsjdduhC+i2zgBUL48hPO4aIg45OTooqV3ErbOOS4Bi+MjTa3dh z/hWv0IGRjr94KjBGgAnZUKtz+K9wXkerqqAngM7AP/GXYkHnFYmXL0VsppZ1na4tsxx sMug== X-Forwarded-Encrypted: i=1; AJvYcCV9pSF6km4+jAgb0nn2J3yJQgYd01VgAv6eUJkW/SN236XWic2jQ2L7NMCMjcK/aRDlAGqatFzz@vger.kernel.org, AJvYcCWAVdAU8GNAjFUHbM601DaEut299+Egnyd510/8EnDMKCz5UYStreQxOjkKghnDvgfCoSCBjKJXK336cPU=@vger.kernel.org X-Gm-Message-State: AOJu0YwRy0lk69V3t9hytyxMciTF3v9b2Qpruh0D8K6Tq/Jf/ho/EEuA RtRcjDn6Qj7MdpubpRqoYTB28JdKLdWpgoC8xlp4GJEbLEHKZ3tW X-Google-Smtp-Source: AGHT+IFfT1yusRFFBUbqO6fopPEa2Seo2/HoTTKsMfP0htTnanTBbl66j9j42Q9qjUh5OP4V8Wz3cg== X-Received: by 2002:a17:90a:4a8c:b0:2e2:8f1e:f5ea with SMTP id 98e67ed59e1d1-2e28f1efc06mr1736973a91.1.1728397458510; Tue, 08 Oct 2024 07:24:18 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24:18 -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 v6 03/12] net: tunnel: make skb_vlan_inet_prepare() return drop reasons Date: Tue, 8 Oct 2024 22:22:51 +0800 Message-Id: <20241008142300.236781-4-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 --- 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 Tue Oct 8 14:22:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13826582 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 BDDBF1E0B83; Tue, 8 Oct 2024 14:24:24 +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=1728397466; cv=none; b=tVRY9vs/nmowM+7sJUT90o0TpXMpMaYBSV4OwI5OYZ6i0NIGVRIFvjBahQ2ONMtLs9/iiiSY8j6Lw4fZRVC4nJPlElqvgTHsKnyo4C8u5AsSd0nIca/jrJD/PQGGeT61Givvc72fv52yxGDKWhbR2Uq3cixFqZR2KYYble5NKOw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397466; c=relaxed/simple; bh=Frgop5dI3MpmoWzTS13lVakpm6NizzC07ixLgWUG7hU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=k1jaUZwsC6xiIQBQNz6qc1l3K7eHFMPbGnucah2w0Ha0s+JokKM6nmlT4gmHvQqnkwioOQZk0sUnAR99D/fymFkI6QNvbroCAgYuwDmyZKCJUBsAVJU97svaFXhUNiYNC2cgq5YIziC9q0uJQGcadMKLjfPd11DD8BmwR0YgLPQ= 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=Xy+mqmE5; 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="Xy+mqmE5" Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-2e2840bb4a0so585765a91.3; Tue, 08 Oct 2024 07:24:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397464; x=1729002264; 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=Xy+mqmE5N5ldGrLozzjuxBsEWGE48lkZ4G3C2XQsHPy0NdyQAgR7vd6e8yDIbIe7uF XWYK6uJwEG8pw6N5IyfIwtjoHQ8KIy86NfXRL9eltqmla5rp2GLfxWi0Ya4Shj8+ApZB sOpq3eZdifWv+GGXaiItLNia+a+QhzDnds4W+DnQSsreu3rw/BdVykk1ycrzdaawph81 AyHAeDcJavItYD+6xJwp9IGwCxKFUdGIVvtPM0tcgPrO13oWzqgI4uGVsAEGHFPFN9rE viEE7DPdrOw4vzGZFPfsyNBudibjyIvXdTdp7pFm608rE7AVe5NWfQzxjlJJk6GontGI 1IBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397464; x=1729002264; 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=b/neGnZN4HE/5ekNJkEa9kVhlJW5+VS0HAeZdw1EsMdhfVNI8PhoYDu9g/IALqKuLP zr6ngRnbJ/EgQnIvWUWtcXd7ZsGfTKq2eiJ3MRKjbUVaelX/OX7P/s6qSSBMf7TEy7R0 xl1qQAAX8zCoDk8Q8onoWHSDuzPvpQgFAAEL4w3dSzal0UBto3VclsaQUMyjv4ndn/TB zu+wxLSETpcF/T8FJYltmD/ucUuN8PYh2qgW3douw6Hlag3QK067w4oPisYIhVKii8MQ OjqzlgqtpFnGJqUvaGUJGM7cKRkJBQSlAXhkkcQQP6I+vO2JIAfoeQeFRp+ELMhMnm00 LtTw== X-Forwarded-Encrypted: i=1; AJvYcCUjBBH8fJpb1vHmy1r5lXc/f3WEnQZm9n7VClF1oPhELNBMJ7QcZDdOwxzeuqw0eGC+nOrldfeilANCCBA=@vger.kernel.org, AJvYcCUvsRKLynW6y9YbZh0xWAqsBNASsbfP493esUPP/R6JVW6gMjvGQDdud4lz01pjXXf7vTCfO98L@vger.kernel.org X-Gm-Message-State: AOJu0YwFApZIFp8EgL3FahKn/6+YMEPLG+46YU3z4IKCTFyGhF8krF72 2HpkGRtKPOkLLTKkWjY0rJlrCVJUqWa8VpOkrP1FU/NQ06WIQMzF X-Google-Smtp-Source: AGHT+IGSPc6Bg0+tQQVjRsHH94uK2qsm4nZ4ooiU2r5+CrFZEIHiMx7Gan/HlETae+dh1eUChEDWmA== X-Received: by 2002:a17:90b:713:b0:2d8:94d6:3499 with SMTP id 98e67ed59e1d1-2e1e63763acmr21085389a91.37.1728397463979; Tue, 08 Oct 2024 07:24:23 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24: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 v6 04/12] net: vxlan: add skb drop reasons to vxlan_rcv() Date: Tue, 8 Oct 2024 22:22:52 +0800 Message-Id: <20241008142300.236781-5-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 --- 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 Tue Oct 8 14:22: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: 13826583 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 795A51DFDBE; Tue, 8 Oct 2024 14:24:32 +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=1728397473; cv=none; b=eM5c4j49OKhGUktpqJPBCZ9RkfJ2aaMWorjDO6xF89HPOUb9IKfTpVGIrfR/asf7rYJym75C5YStw/DiF59nC4ecBQkdJfa4pY5wl+yG1SKVJxCwwSIL5xMAskXj3mtzD8ECr86sofX/J/2kRaHwX01IjWPnxg3f27oOD1pNZac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397473; c=relaxed/simple; bh=RqJB6ZWkDR9/PDVgtjzb6hIWH6sz0+ZXugXeLypicD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kcNWD8BK41v1PH+GjEkOHcc2LZEdfWkz7KIiBZROt8yuYgIxh71llGSzd4aEYEeQf2xEAYtJ3T5gMzMJMYPtwfue3ZAcgO+UDcGlM0CTczCBsNwVHEO/ayPn+JxGGX2AleDTXXBw+tC+aDh/IN6nJTsBPBt7owD+w3h1nTt9edQ= 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=duBkNpI3; 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="duBkNpI3" Received: by mail-pj1-f65.google.com with SMTP id 98e67ed59e1d1-2e2840bb4a0so585900a91.3; Tue, 08 Oct 2024 07:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397472; x=1729002272; 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=duBkNpI3/05RgobsTst5727zLMAi2M0F/SZhjGC03FDuzZZjdsMz9Z17Yd8GQM4Cfx orIoOD9eQ8AH/z/Myrxx8eug4CAuMjc5aWU8ybZ72jUiBorfTdJsBtDmc01mtC4KTaSO kjMUrnSq4d8GlEge/hYKXfI+ASfbO54IJJ67YVGIIGt6OO9Y+KqnQ5qHVf/Q5QJNwpDC zuqzjGYUGDOnXzfPcxD17SaI25ZQdipFgG4jkP1jwxl6p0MRpM9pbWTkmAGpvyqGRiy8 j1HXpJN+exO/3Y8iM98KQTAks56QpYj/+zGS9j61GnIV5p4m2G3bq7NklDWlFfJ54Mzc uKfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397472; x=1729002272; 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=oQ8qfnha31VG2nLrAyMYz4YJXLn8Xbm1viq2+EC90OMxwSUVk5bAj0X2Rc7rmFiqcz IJ3wjS4XVcGl6n5WytBLqBeZfkkMxKfBPFDvmLXjHIEW0iEDAgM5fHi9GDTy5usmV2ef OE5y8WzmrLFGtzzMCli3ODdJ7LRBL6PVyObQn02Z9eUfOBnVB39QYiNUzlJYqCQANE4X 9IWMMEECOwulz/+YUBRXo9mkw5cPrz0jok1+U+3miGs1kKeiTtFf0CdJKKjk/dueSvL9 Z2Ijh1/EwbTKcXNc2cNbOY4P7ppvzfwKkyu6jEYlze1jt3cr7SO5KRbwsXwwzkwXKa3k 0kxA== X-Forwarded-Encrypted: i=1; AJvYcCUe0E9a+boN23AubjgCwHCTOH1N5blNCVYoldJJnvHASPw6bfAVatuXJwKFPt+5ITrx78dFAzaitPQITFk=@vger.kernel.org, AJvYcCVoxIYh4spaKyJcGD7m/IrbVOxMTc0RgC1PbsdUODvWarkDCZ9AbaGapRpki65uhVWemWsAO8I9@vger.kernel.org X-Gm-Message-State: AOJu0Ywov7P09p26gipVIcEm/L/+8OcsvtYLQwbenJyqjqen8IJ2sdRe jOMhv36mluxl6lUS4LBvVfam2sRRAFVHRqhuWySdMHevmae6k33l X-Google-Smtp-Source: AGHT+IFh/BFnmqLGxVjf6ON9fbWe2iL221pzBD6ykg1SSZzmyL7BJryXyk5AbXx53QLfrLOi4MWhAA== X-Received: by 2002:a17:90b:3891:b0:2d8:e3f3:fd66 with SMTP id 98e67ed59e1d1-2e1e636c2f7mr16356143a91.34.1728397471888; Tue, 08 Oct 2024 07:24:31 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24:31 -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 v6 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Date: Tue, 8 Oct 2024 22:22:53 +0800 Message-Id: <20241008142300.236781-6-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 --- 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 Tue Oct 8 14:22: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: 13826584 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 9D9FA1DFD9C; Tue, 8 Oct 2024 14:24:38 +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=1728397480; cv=none; b=VvAkFebo89qO5b1QMS49xz12HJvrTh2PJopogbcdZ1c8XDTs81SEXaxsGxNTYjuRYy9wF5bgel8QgHpsEQ6T+qUAkpAxNeuDgEgz26NuwZ10m2llWmRx6TvwCFqFdwgrsvSvRsL84PmBEzFDMH3KBLU0M4ZKyisUisYZp0qonpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397480; c=relaxed/simple; bh=0ZgJtJ+TjXiHcGPlxVYxhjDteuWSfgfQg0cBummbs2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RRK8AXDW73kTSdGoPHUxsbR/0VWzRo7fEodxgdiQoNae68DaWHXXpTKT9bUHYRbe2Zzw6XAM8f5Dwz24IOG3reF1FItKef0xYOmcl3qRR2mD9oGmoxQgdDgkzZ7ukL3cklCP+2rGeJ7L9hox8OYrcNxotO7OPaBNSTuPjZXittc= 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=jBt3Xidn; 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="jBt3Xidn" Received: by mail-pj1-f68.google.com with SMTP id 98e67ed59e1d1-2e0a060f6e8so4099313a91.1; Tue, 08 Oct 2024 07:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397478; x=1729002278; 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=jBt3XidnxzdAxtucOZYfomR1qAj4bVpYp7C6Mgp/YtF4GF1JVLEE/3bAXfcRS0TwZF Gmg74scEufNvVuKAPhvOJqNFeXxwlM08HmVHFgz2/FBizonMCvHt/qnCv/NyI4S10ylq 2QVInAyif+xinD0f5HRJwgN/3pHgbQpIS7qqGnIjBgTVKYHBR8PCnVegxCwuT2txzzmE f+61gY2PxjfDj4GzAaAqmJAZI3tdbAKZ+czQd9kRHkQJ01j+yd4aR7HpC+j5aD1Q3eOY D/4PtC9nQQsyev+1rByl5y4oZ6yH0fmiUK+gPNHYlYUG+4n/jguxP4oIzHoRLeIYqDOm /jIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397478; x=1729002278; 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=Lgf4zfguewOOgGTyduP6VaOdzv53JY4iyfOWWjXN14ZkzDUF0FBZXzxGXQ+RcCncB7 mkr5QEBWu9dubnM1zrGV2UaNySvT+KAZB4pbRtE0tDlVO1N/xV12UfbqTRznOx8MAkA5 H7CdJq/HNXdtqU+OaoADlNV/y5th7CU5Ja+sn43G5Du6Cw22o+dYxZDj/NP+1cA8j2Tg yMn81pJJXqU74+mPNoj0KlDfkpQ55LXxcRCdhZGDQr7ddKHZZLiulPsw/h1r4ZaSEzeA kcCzhWTg7lTKc6tTa6R7xBxgnAAQc4/uaWgkPC9j0j6360WhsCDJaaodny8+PYMXdIjf ltkA== X-Forwarded-Encrypted: i=1; AJvYcCV8MJdyx5vUZhmD8B6RoAadb2s0DTEHjlWtZWftVXNHvjpUN98NvX27272eYrWhwD06UaLC2ZYK@vger.kernel.org, AJvYcCVaFERnQf+vvTJFmiRXqyySYgT6uvzWwxn3cA4rk2VIdS08MuwV8oPMw9ydwsAlgtf9Sifkv1WUykl9QZM=@vger.kernel.org X-Gm-Message-State: AOJu0YzqtSJtb3kHDwlESaOuw/lqzdCs3GXpC55fB97UTn22gXmJINd2 Pyg0PHHfYgOcHiDZWTpR+q6/gkAcXvT1bh3RfIHpx5I3H1n+b3yY X-Google-Smtp-Source: AGHT+IG8MoHjjo51qBYhs4i8ZGQOZUrl13zdZKpODtG98tfAhVNGm6E4+o4ElDc1TrJLyHeklrMvEA== X-Received: by 2002:a17:90a:1782:b0:2e2:92dc:6fd4 with SMTP id 98e67ed59e1d1-2e292dc72e0mr988941a91.23.1728397477813; Tue, 08 Oct 2024 07:24:37 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24:37 -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 v6 06/12] net: vxlan: make vxlan_snoop() return drop reasons Date: Tue, 8 Oct 2024 22:22:54 +0800 Message-Id: <20241008142300.236781-7-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 --- 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 Tue Oct 8 14:22: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: 13826585 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) (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 B1E2E1DFE03; Tue, 8 Oct 2024 14:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397486; cv=none; b=Zf4h4S0IJGHWvHPGz3jHvZUydci3W2uO6jUo2knRvCQF/VCBH5LrIfJHe3la5TOu4vPRDhq3A/LN3aBTTs/NYoF5hS/s73P6l7TG0hfajjhP010HWmRNXrWjlUyIkIYAgWWOl3x23HnVR1OF6EEOGDE7qY20AY3zBR+LgHrlRoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397486; c=relaxed/simple; bh=4xIH7Aio0f4PBcaIE51Qch3dJo9N/MMWAobYuTWQmmc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tAVSLjBo5gZsYsYVb8NZpOZ6HYxpoCN4y5OfK2I+FCCgoJ/h3i4JHNn9jfFplpeFBA3/Sf3+feZcSE5PqPZPvTKoXDDrITEC1gftlKC5BZvCN3bKGRJpq+w1QcTVPNdROKir60f8DgCTvYqhkxluUE2oQjXcQbcyRvTCyZ0IAJ0= 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=iBRGQV6R; arc=none smtp.client-ip=209.85.216.67 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="iBRGQV6R" Received: by mail-pj1-f67.google.com with SMTP id 98e67ed59e1d1-2e18aa9f06dso4076549a91.0; Tue, 08 Oct 2024 07:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397484; x=1729002284; 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=iBRGQV6RzDZ6IpHbHPf6mGSkVVsN8BJQNqy9I5wDmOhTUyEkMYi7tXBGo23LwanlGN s4PFHylzhQ8/DpTMxNaUZf0ZO/erF13jsI9OBmJTNxKLLxfQ70IF45RzzQ+t7ZkEmgGQ i/5cT86ufZCa7nMtw3lUg802PPF0woVWFWFx5X4X/nn8ZCH0gxent+Kt5qtkg7CR8zsM 8WxbPMrz0XM8LshDfoeADhjdxgfkztGGXr7NcpWhVhz1vtcZXNQonbsFXvoRjjY0dFDP NakccIybXbOPVDb9hnrg1OIpTJrWtsqsE84eEg/A/Vax3vKHGKCW+fLKWCJ4/DsgImBA vLGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397484; x=1729002284; 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=OZZOhl1R+Y4rSPavgCXeuZBeK6Q/EhxVyHTjfQQB++ehcNn3FOZ/4NsvdHuVMfxbMi AXOlfFVAeKZVlmyiqjafXnPZmwdsYl4y+uU9HxeF4wmchGKPPl+nWIa9WBVpcRGtvDym vi+Mty/vdAQypAO3O/4kUdhyZLPecRmNw1S8yvniHDQGjh0wIp+uka5onDVmqENXnm2Y ZvcdkDBaBU6a2tHRGKykL/+u1JZYDrxqiXEAaIJkLyj7Ly8ZfoMFQKCJrbS9Id7+cAQG pcApnzSr8+9vjiEYEthE2LYhqNYqMrOAExcwStBoI1VBsIPvwtiCWTW2emte61BFjF0w vjWg== X-Forwarded-Encrypted: i=1; AJvYcCUo1u3Pp50WUS2hvUZLPUZDu1yaJUsOqqQTIi30BH5quJLkLGNUU5RQbeDeDqHc8mUQ6+co9ZLH@vger.kernel.org, AJvYcCW91HE4+Gb1yJh2sNv14LepF6MHxZxY+jpnn/prdYIamV9RNv3eY+Ycp+hLC/Vmeg0l+LpduIc2yzGLKIc=@vger.kernel.org X-Gm-Message-State: AOJu0YyR1Emp93HAPd6uLztAlmnbjfgk2Qdo3/FMaNOwUlXsNLGC9eKg g0CAVhKvsvzaaZ1ffrcr+8LY17rGoOA2YWQZdtZspU+JaQ986izl X-Google-Smtp-Source: AGHT+IFsKeuviJmC67BERfupvIjcmWh0fjkX6ZNBHS/mw3bApPLGr41y+B7mXbZzVdGy5XSBtUwemQ== X-Received: by 2002:a17:90a:7442:b0:2e0:a9e8:bb95 with SMTP id 98e67ed59e1d1-2e27dd3c32amr5159501a91.3.1728397483840; Tue, 08 Oct 2024 07:24:43 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24: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 v6 07/12] net: vxlan: make vxlan_set_mac() return drop reasons Date: Tue, 8 Oct 2024 22:22:55 +0800 Message-Id: <20241008142300.236781-8-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 --- 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 Tue Oct 8 14:22: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: 13826586 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 EAB5A1E4B0; Tue, 8 Oct 2024 14:24:50 +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=1728397492; cv=none; b=gu2ziA+UV87PsRQhq4tnn0zBouf0GbsR6JYGXOw+9kvbiTgfjSS9QXDkc8maFuViw98/Usq7yI6/n7iadbqDH9Qh2+8qwdbwcN2fatixKMJ9qhiuR6n+pgt147xrf89U8QCD1qWHc03oqehdhke2I12Hs5yish+9nqVh15REniY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397492; c=relaxed/simple; bh=XjVl5IC6KWGOO7eYiGVH450BK2nGVegv1T2ce52dkmc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rbDddtJ8UhkE4WEVRm8NYEfVpP3SV5Nrss6ZAiolVL4hsdMP+MFUWbkr5t5Yc1pwMe9eBTRANbsYAnc+p+uo2lWRG3BCpyH94u72UTG3U0lZKP0srq3qQbZq98D7L4BRw3duOWqfEDx+ChD7Q3nw7ZYifvaWzlBTvfd874ubpxU= 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=Ibf6ABGG; 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="Ibf6ABGG" Received: by mail-pj1-f65.google.com with SMTP id 98e67ed59e1d1-2e18293a5efso3919208a91.3; Tue, 08 Oct 2024 07:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397490; x=1729002290; 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=o/EXl6VMGsRbhKEY09CR1uoI7UwqjG6M9KgbLt7Z5gU=; b=Ibf6ABGGC43pUykDxXpnv3Aa+yDZDAhWgiCBczI45E2Pky/Bgn9yQ8KJOqWGlq9MRw p3mPn8TQn3ezHlJkcQd0rtw6a/ZibE/wtDCuQr8ZP7embvunR3mBHfnZYN6BOIt4ikfP Ihdukp/4GhJGoXpqsEqImMvW9jec3KAkLniKDK/jLMEaKl3KPQs4OdPZ1SSdBKiFUPaR HBrznwOQJb3QUt46b8gvbsrDVSuVx2Cw3GZh5J5rECL2XTrIyBTXWYtdWDnojTalyCiW TQdE3jxD8jaYJOtyogomYuh6WnGvumURXrAl91Mwm8RIn6ZrSi6aBYikzcZtGdRY8AeT 2baQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397490; x=1729002290; 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=o/EXl6VMGsRbhKEY09CR1uoI7UwqjG6M9KgbLt7Z5gU=; b=JQqS7W9nI687FyKfGQBVAq40+IJx+I8gYtQT6fC5BALVNF30M1Fl8vfTnY/FVpLYa8 kHROWKgSz9w9GhsoX2jVBCFR3zdbKXfO1uih77xuOyIQaojXwG9QSJlxxz6oJvHYEyyC i53nbL/9QjWoTm0gDpTcc8CRU3fsfKCGMhMd/fAGL8ZkhCtl91zOV/kbO/JRUyjkS0sZ yWhxi2k2wMs4grJZXbviEq9M3gvJKj7kGQZV5HRBcezxxmpt8qERzfcbeklJVDhdKQrA 0rOxQaHycR5AEs4urclMf92FekkOjJjjp6tgdfb6KkQsYQevgOPjC5u1hT2Zn/5uLo6x GD3g== X-Forwarded-Encrypted: i=1; AJvYcCU2fGQ5EV/DKs32ZW1Hhl+qtOiasDipNfanQobCY1iNuYzAeovUwJDFyVQK653C1RaxIhi+OhcNwS5anWQ=@vger.kernel.org, AJvYcCUfZpDcOKS/HIhGTCZSo49o7lN1CFUGs7thSkKBcG/OdKIdq3VHSqFWdS9xtGvtAa9YL+BMZj68@vger.kernel.org X-Gm-Message-State: AOJu0YzEYgWoNVbvMZGmM7dXRpzQY3IOf/lmVJCGcnGMJoZJlmUXYs6A jtxc4k//UtwimHyWS/NWfVVdKIFfMeyftfpRNsRTeQUALN8BU84a X-Google-Smtp-Source: AGHT+IEm/TFqbQj0kW7XFjlJYySvYq39X+CUWmAvwGlqSwYNlNGQ5xOM4bcOFH2Go4jUOcbYtZ142A== X-Received: by 2002:a17:90a:be13:b0:2e2:9314:2785 with SMTP id 98e67ed59e1d1-2e29314289fmr1249936a91.5.1728397490416; Tue, 08 Oct 2024 07:24:50 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24:50 -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 v6 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Date: Tue, 8 Oct 2024 22:22:56 +0800 Message-Id: <20241008142300.236781-9-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 * "eternal" mode */ SKB_DROP_REASON_TUNNEL_TXINFO Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- 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..59c87b2a1ab9 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 "eternal" 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 Tue Oct 8 14:22: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: 13826587 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 38FDD1DFE34; Tue, 8 Oct 2024 14:24:57 +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=1728397498; cv=none; b=VUei5DgRkx88CJKH2LJztwUUkFEavRvVm+fUnq5xKou2zXwvRK28c//69BbjqdZ8cFxHno8kG351MTBtGxqVzA+SIMsCNrXQqCdGCC6N3grO3Ff4KTl5MXtVApJucFlwKUR8Q/vUHonuyMj9ylLajILdfFPphoykCWBk/1zXcqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397498; c=relaxed/simple; bh=ZX6rpV2p4NCjpSh/ZKSJ+9hBSNtbI+i1jkrQAXbqfxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a7TLwmQsqipwKrtYWw6rXFgIkqa6ki2kU5PoKuUDPLwRu6MMfqLaaBJdvmKiEG4nvQZ/6lFr51uwN/de66iPbF98vhIOmgPATVaOUebfpuOi5sQTRXJJi8ZrFeXGv4n43MLrX+mktzOjOkw32ImEa0EP4Sc7cXNm6HZF5dQyjlA= 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=J35BBkPr; 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="J35BBkPr" Received: by mail-pj1-f66.google.com with SMTP id 98e67ed59e1d1-2e07d91f78aso4180956a91.1; Tue, 08 Oct 2024 07:24:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397496; x=1729002296; 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=J35BBkPr2dFARJ7pMqKz70iP4MAGkDbyfs4NIztUKcHPQx9i+cF5VHjkoRDhmRABgc xYqhC0CdeQVDFCmc0XWMBdtyMjwLnvKHCHSnNKGd+HMMZJIoiBfC4Lur7SlMI9K6C/1o HMYRU9ylxD88Tl320ZGmH/Ouwk2Bd94Hs2bmVv3N1AsEI3y3UXKhfKjZtdYpMfggeEYS ViyRXpuMgaejyQGvzejHOywzXOczr8d3C1WiyiC4pZQ3kD1gUog1Pzv77udV3IS61Y93 3zwo26+lYe4nrbTH9Zx154QgH3eVPCi8/cEyynJfEzCgIxRKAveMVPKLJxOK+X71vSpi QEgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397496; x=1729002296; 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=krgl22FRNi73vC/Mr1ph3awZzxrnupTWcYMeEmnxIIWZXY29C0UQZkTUhUSpwBZfW2 XSUOLboDj4V+uQtSQUBHFyCp72WDfR7lOpXSDruRvUQDZsLsopRwtLqHUaaOMNgBepd7 3dlqlthSRcn5181BHWPH0pDvpNKK+FAP3EvTR8mZV3loYO5mQ9TSHbuZBliRyHpcBZXb +SuA7daD5lmcAtF9dJbYcXuj4dFMd7R8qbvZ7Ikkb2K1RbJRW/fgBO7aaz0X51baLkm8 pYNPStirOgEEGU2M7mXV3fEN4eUnPfgsklRDTEX6nvQBmoeh5HCAGmTMkpwo+9NjYv3s nnpA== X-Forwarded-Encrypted: i=1; AJvYcCUxmqD3Wx+nbFt0fGqjpV/TX6FqVJMOkvrNTvvhk5LQKUXCXnIXFIjyX+tb2npVbGCHaADr7wx3@vger.kernel.org, AJvYcCXTYj9/6INSGt49YG6aAobw/Gq3rPoivbylKyxlqIS5Ha6nXD5nUh9qzbIIh4x/IS+h2uo5gQJnw9QrehI=@vger.kernel.org X-Gm-Message-State: AOJu0YyWjqy65DdUJ6QrYcBp7PYVvhTaKf0Cy6yU/INCx+sivVDjOCvr 6LhG7y4ofnJt6A0H8yMiFgdDS9GJTSOPASyWZRNVotR6AenofS+o X-Google-Smtp-Source: AGHT+IH2W7wHSG8PaTX6nFXJzwoyViApSjFxA09Y6xIr0Tt7JpquCVUfTZHCZOG0Mi8skmTn5ZWB0w== X-Received: by 2002:a17:90a:db14:b0:2e2:8d7a:f1ba with SMTP id 98e67ed59e1d1-2e28d7af415mr1743207a91.2.1728397496553; Tue, 08 Oct 2024 07:24:56 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:24:56 -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 v6 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Date: Tue, 8 Oct 2024 22:22:57 +0800 Message-Id: <20241008142300.236781-10-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 --- 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 Tue Oct 8 14:22: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: 13826589 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 E278B1E1A2C; Tue, 8 Oct 2024 14:25:02 +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=1728397504; cv=none; b=pjdQFDmy2iFejYRJSPDwzhGzMijsfRqZuxGEHwycF9LI3Co/CMsSgumYifD2mZG1qRTHAHrsJKx/ndRmGpKoQuoj++li2RurKcrRZ22QPVMQrPgnW++2ByNJS6/+eWGYgBp7xc4e1pD7RIClnNZE0qDmOWqDkQAvTSKguHEzuhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397504; c=relaxed/simple; bh=YBE7Gm/eB2TlKhxoUuPSI1O81VwH7aGArvM+el/K8oQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EnVflzCJx85unjBTTU1TZApwxeB549FFdXSUbb56dgRDRYaXn76xTHiwfKRSmZNTkFPDizD3Znz3JI/ldohG/Rtsu2caC0OnlihPrzlpoWAFs9amVzYtAxDDpS6nQq9k2v79hLuu9uyzYff75zFkMeBTeb8zfubNVw2x5pb0S1k= 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=iuNUyjhd; 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="iuNUyjhd" Received: by mail-pg1-f193.google.com with SMTP id 41be03b00d2f7-7d916b6a73aso3483949a12.1; Tue, 08 Oct 2024 07:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397502; x=1729002302; 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=iuNUyjhd+uUWLQVYV2XWn6PIgvvJBFH3KF01+GtbzOkKh75J09MN3Dac6LaqXtLAn8 7yEhLFvIDpgTAnIFeGo3ZkUAhHMPbbIFA9034aCr7Ua5IHAA/px19y/vE2gZRqbQnABx rSSq4SVlHJo01ONVYJqzOpn5dICk0KiIluur4kkLRb2Gyk1oLoeLE6xNZtuAWnCOU32u foHYCV59Zb4Ny1LeVw3AcHKQC1nQbMRzppPACsomSR+zN2RUvaQoM3xH0VzArxU9DN/p ATH3uhzz1LWLDVxsjH3jI07YzplPkekMwkjBDkiXFO4zKQpr2ytrKXEMlYXWQt96qAsl ALyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397502; x=1729002302; 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=Kxlqw0vmk3BshLOP+HhBqaqUWJ5s3xjG42DmvnqJr4pLf3k3JbPS9XS06idNlwCF7v wKd8odOxc23Fvl5qGTXf4gGVG3gxOvniPM20cy63V1zsPsum6iZbHMQvp8GCcalz9DPn XgHC/EGGbxavuxvfBIcFGxYGt54jBWr3PzfpQmqt3Pc9YnECWBszqv+q+ICIPuY2uoYN J5CbMs50iEKCsC2LeLpb5Q7Bu3SscArUfLmHIhzmP5yZdKySscan1OfY1HpqeQC5M4qJ HUc4tFflJE9pSuO9Gn938uwF84Pm9MlPAO+N0DhmKBih4VJ5tixYtbYRCBIiOVZ4xVxM t4AQ== X-Forwarded-Encrypted: i=1; AJvYcCUtwd4hed7VlhgbwOJcSNePCmzKCUkkScygIfD2wSR3hj+tM5U0pVkMDGSl//jqX6odo9DIVP6n@vger.kernel.org, AJvYcCXROLxu31AMgq+ue8E6pzyz83o4xNgadbRXBIKM2MJdIlmr/UTh5VmXkeBOSuaV7knEyG8VGUCcK2zKasY=@vger.kernel.org X-Gm-Message-State: AOJu0YwQHU70o5TBN//lYRKJ9MXjZaIoLoAfDyLKK375DY2cXwRj4y2+ vm7GOpHt6UKOTwV4NEVNcpuVdskrildrKnJS22x0yFPmxlqRbO5A X-Google-Smtp-Source: AGHT+IF7NEh6HwPJYwURl4Q03W7pTHQxSa7wxGdDQbLq67dvWX4otHkw1OSCc05u5+zH0PxNx2ta5g== X-Received: by 2002:a17:90a:de8c:b0:2cc:ff56:5be1 with SMTP id 98e67ed59e1d1-2e1e6211be0mr17855559a91.7.1728397502220; Tue, 08 Oct 2024 07:25:02 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:25:01 -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 v6 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit() Date: Tue, 8 Oct 2024 22:22:58 +0800 Message-Id: <20241008142300.236781-11-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 --- 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 Tue Oct 8 14:22: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: 13826591 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 7A70B1DFE2A; Tue, 8 Oct 2024 14:25:09 +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=1728397510; cv=none; b=Cit4BJWsqCCETmz//kKk5+cXtbh91FQT5JCktd0tBpYNUvzlWvR2IAditoZANfPRHOMp4c/MqUVWyu3N7XANicnUrnLe9uYUOmar+0/41c/aHJHqzjQHrYAUmyrgl3s6qhzjr8eG82biKgqn8LnpTH9jpiFgWfnUpI6KyvsrFCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397510; c=relaxed/simple; bh=dKbZM7+rvKdCAftLsIqRMrR/jd8BPaE4KCzu53bpfvM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RH8gBeOM9vKlg1mZwXR08bkefToMOh6uEXTPCnPysCCNeTP3wetfUQYMFLFBhwuIX9+pJIOlvrQMSspCn8Dv6HVHxbrdUCjA68ICAfHO31MH0GWiO40a5lj/YxMoLnFI9eOLAk5AjhY9gXzXhxyii9jjXX3OfqjsyBSF5/fWbik= 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=E5B1HrB8; 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="E5B1HrB8" Received: by mail-pj1-f66.google.com with SMTP id 98e67ed59e1d1-2e1bfa9ddb3so4400190a91.0; Tue, 08 Oct 2024 07:25:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397509; x=1729002309; 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=E5B1HrB8DZ6VSBZpE3p6M6WK+wmllsw/McANJFxGfy5Ilh+UPnRBCehFRCgK23lQmf jjK1SnvPJtw8+8zeeT+9JYZIanSOJLBqSZ1W/dUJlMBHPJX7YiWLMPF9/SsRq0NSbgg6 ogvNdnv3Nut8vmVuroQ7/rGHlSKU+mUjqHi1AHlKHcI7ZDzDOmklXMXfOGcOSAnCmbc1 H+/QruvXh644K7yGT+vbrx2TnJdRgJsN/uvbdhH7m7vKVzo49WOwbEZiqsP7ul2cSacT 9EmhrBxOnlOnm4fDfcVdoj85kNUwsjPMs9CNhxIhGInYBxZZE4Lg+q/DmFJIgJVD5k1V bxZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397509; x=1729002309; 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=hvUWlDSOE0A5tiGnYkTu8bR84UouZrgO4HQCAfiQbwHRiPeREpUxJLCX1lKAurCZyA mPtP2wiWbc7zlJqlg25aFKHdggbceafrEBisAEo2uIUE2507o/NQyN0oqkGs0tMKjCm/ xQFHvYC33A48WUO5hqYh1aBMUVZ0EZiWT4hFDA07Kueyi32yuiiy0LHi+e+99xfxvvuz /H4vUFBuyQ/wIDoALwKKaHhPULoc7VoRh+4giY2oNgmQ4xpELL1ldjLhfAcaXvVSTfBk H/rWHjdbaT0Zo9zlmTJKgbBAe3afAFysdD1ZOlJGCxkIa5kij1DDqUowkllR4zSg/iKE Uu+Q== X-Forwarded-Encrypted: i=1; AJvYcCU3TnWKzmsY0uCPq//hQhc34fUNibkbZetwZyuOGjolQSN/cH3WtmsXS9WzLpbAIlj6UQG0cLQQXLMQyhE=@vger.kernel.org, AJvYcCXZrEXbz5DBicL2wRPFcaQFRn7v9I7lb4qWGWiYkOi+j80KTolbA34LoZKoLxiS3Ere0QmJvDbD@vger.kernel.org X-Gm-Message-State: AOJu0YwF0OcaimTaYes4szUIes+bynqnfAN6eE1m69FK2Wg3e46dvqSi v7raEapm6Z95aX+lEP+Riwf2lWfdWLNr0WVFvDxay+2bBxP56gCN X-Google-Smtp-Source: AGHT+IF1PHBCFMaFpGeZDTlx9CT8HkOAtUml40nGMXnA+2Y228lOaD0QQtn/w3dqxiJOqTUOopcUKQ== X-Received: by 2002:a17:90a:71c8:b0:2d8:ea11:1c68 with SMTP id 98e67ed59e1d1-2e1e635434cmr17576173a91.31.1728397508617; Tue, 08 Oct 2024 07:25:08 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.25.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:25:08 -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 v6 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass() Date: Tue, 8 Oct 2024 22:22:59 +0800 Message-Id: <20241008142300.236781-12-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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 --- 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 Tue Oct 8 14:23: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: 13826592 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.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 B33D81DFD80; Tue, 8 Oct 2024 14:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397517; cv=none; b=tqQO3eFz86H7f4cU59CQf7wZTk+DVDD0V6VpvoZzaVe3Mx0hBj7odPwpeKxvbi1oS3dI0+JI5NZHYhemfUxirQsgovX4zvCkNWzhoOHpHqoS9fScZLhP8u/GXkAzI7A2hMPpNu0gzvliKUQHebY0kwgSDINuWJl4DQ3V/ztNGRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728397517; c=relaxed/simple; bh=R8vmG0u3lFl9fsXKHPJv8VqmdcKKDyrNnQXHw0Dmp2U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RE1HdbT+PQHkd5bV+G0/oJiAbVzDaEbuKrymri2BQA/Mj8iiszTCvnlwFDFFEwRxuXtjmM2SMkhe4JeXaFwoOKQ/RmVKwJjxNd70XlPrjXoNCaAHzgnm/Jm3ovStQLUsYk8aTMr7IRtUp7A/zPwY7S2IUUTs6gL7tqUp66CyRW8= 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=EHIpOFxQ; arc=none smtp.client-ip=209.85.214.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="EHIpOFxQ" Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-20b6c311f62so50406525ad.0; Tue, 08 Oct 2024 07:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728397515; x=1729002315; 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=EHIpOFxQ3aGXj+cPIGvdM6gx5kzLCHzB0pkML0gahVxKLi2b4PXNZFIj0YnfuUpXuw P7hoCManbsOYUmasE0rQ7FbZl6VCxV6/8fzBBvDQWN1oWVqtECyz0lq/L906leDxEDWb g3Qi9Lfoe1qUGJX9QKBPjQX3Xh256e2CxF//E/WKHStSlKHtYSW6q11pLmLM3uBszjWk dEIpSD1KiFHC0QuX3hhdTK2Ew9y4ECWLTEtw9yTLLY4zUWQM25m5Wp+VoGoz02LhwgNu xqwtFVGRhE4/qH6FHRpBNqOCvJEXfZvfrEHppwsrRPphC7S86nMKXtI3mbd0nfh0kQIr ldOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728397515; x=1729002315; 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=qNikPJXBfQAfTFKl2RvsbHwLXo6fWLWbn9YH63/ROo7bG6YB7iBiqyN3sz9uKbV0wm M0umH+uduDB6uxzPCyU2f8OT3MB1S8ItEKMIeYPOHq8oZRyuObUl2cKpTEcHHpOE80nZ RTvSs1t9RA7wRynOkBGfbvJWLAfYtfi269DWwXGrd5JmtbMCs1EKpcnmqxaZY1w3l4xk 3a5GXbPjQISAppdIT50Jtj7+swct6hy5bxNl/XyB5pPus1womkADVDB/8+THJntOJr8f VosOi1iouZ/KTrqhaLzYB8rXKz+SgnkVMjKLhHi8cuK/1YeZ5mnLvVa+MlqtDAFoAFBR tDUg== X-Forwarded-Encrypted: i=1; AJvYcCWKRgFd3QxU76VEE9z3qVvxlbtXKgEQGORMlai0vc7C0FRMY806af9VLFPvvi3KVxoPDkebEUHyG8TzT+s=@vger.kernel.org, AJvYcCWd8Qkh7oWfsda47FioIvZYEQbM9aGXJ+1DOBJekMTqV4fHeXxIdzmTMVgr3NtqyXLL5tThy+D1@vger.kernel.org X-Gm-Message-State: AOJu0Yx4LUTVdRAqkY14WHYedf8AXe+xu9sjtAmE7Gh9pV8dKgw2/h8w M2idkBuLHL5lDabKIE2ZCKYy9sJxuVhk1uUAFf+W3ZNtGZgE5RC/ X-Google-Smtp-Source: AGHT+IESTTBBft0mh5cCnBDcux0lVuyKjXuLuoYYeQ7sEweGaRbw6DoOZADQbnff7G6AV4W3htpsMQ== X-Received: by 2002:a17:902:cecc:b0:207:c38:9fd7 with SMTP id d9443c01a7336-20bfe290ebamr179165615ad.22.1728397515099; Tue, 08 Oct 2024 07:25:15 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e20b0f68a8sm7675987a91.36.2024.10.08.07.25.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 07:25: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, Kalesh AP Subject: [PATCH net-next v6 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local() Date: Tue, 8 Oct 2024 22:23:00 +0800 Message-Id: <20241008142300.236781-13-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241008142300.236781-1-dongml2@chinatelecom.cn> References: <20241008142300.236781-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; }