From nobody Sat Nov 30 16:19:58 2024 Received: from mail-oa1-f68.google.com (mail-oa1-f68.google.com [209.85.160.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E9851B1433; Mon, 9 Sep 2024 07:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866591; cv=none; b=F/tZ/NeGCOVCbCQXGGHMvLZO+ncbVnaWLm/8eAIfNSbhlvpU5HlZPjitMSYcwhq/VtHKNCIYUO58e7d9JddUVzuhv+Z8wOoZ+b3pT7yaN7Y3xYBr+d/+5sZ4AzBdMBVWE+hWEFa9Q3imV7wti/EcshT2h41oWZbfHwFdepK75/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866591; c=relaxed/simple; bh=OWM1Yfv0veEuuMTI6s3R2O/gIarAsPk1rPh9uwCGfKo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QP3QeKgLa780Y43bXTSo5FYnOW5dLbJ5/k7xtefjVQgnYoda6irJpkwZtieIIz+ivNT40oNMc/raqbBySw5p2LXtoADWBR9REEdE/8NrfK1oWKEtKO7MsXLwYycgmPCd+nyLhig37gH4kqkSR2n2zuVwCJuFJAfNw1VBduWX3TY= 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=mzHedYo8; arc=none smtp.client-ip=209.85.160.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mzHedYo8" Received: by mail-oa1-f68.google.com with SMTP id 586e51a60fabf-277df202ca9so2223080fac.0; Mon, 09 Sep 2024 00:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866588; x=1726471388; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=S15bsrAtKng24cEfr8xI1U+gVP6EbG/MdhFsVmoJxV8=; b=mzHedYo8fCj/RfkJC7nIzUw2SY4sZIF0WlQJABhlARyKTfF1IbF3INTve0a8IqBDC8 ZaDQ7eSpzsNSkYQZjuj6yJGQHd7TF9ypBjV3PQcjZlVy8Oi8LLyUXYTjbGV756+EhnWu TVCt6d2r6sAX1ownm+g8G0hh/qr2PmdBePXAZTb2TAnKmO8fMeAcM/eX14v2K+x0OGt7 6c6tPuOUHJ7N6IDQPB7XsJ2Z9CZ6yfdokD6UvWQAyS7mPttYP35n7+MXAVli/vY0y61/ /VQ0QaqsZsU+Qp4vSuh26lMGBb5pC3jegGvMc+BaAntKMsv5WMbQ8JFFnkjGEhyR/ch6 Y/lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866588; x=1726471388; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S15bsrAtKng24cEfr8xI1U+gVP6EbG/MdhFsVmoJxV8=; b=w/1xSn0gPQLvyeD7DgpHpH96pr8fH/FoZ6wEzQxtZKkL5briIk5E9kp7Txn60uZ2IT NhmJKE58hg7/Y4Hh33ixV9lAKBuLfVN7g000KDkDOjf0uOUJrfaP7Lu+iy68wrvx5xcv IXBnp9FMIpM7e6Rgr7bqr+9wRLdYKsuaX6qzNgpY06WL1Rx+PcapvYnvW12CziplPjff HUDsadFwPtxBAjPFkks9DipUj2ZE0/uPS1LEO3C3My9M9kM/Kd9rxLrD0lRha0uimc9R M/qAiEFuYDGvdE1FECu7rawMrorkT5AEnfYR5ZWaRwMThkG1J5jtPQ1GfRNLSK1dzVAZ 1ZXA== X-Forwarded-Encrypted: i=1; AJvYcCUX59czxNK1HHbouZre+p7Zchc0jHEAPP94jDNU48itIwiLcZLIclOReABleRsA6nLvJo+S2rk1@vger.kernel.org, AJvYcCXUAxKCiE5jjGD6rrb2yOoKM3NrhCdSCHjKdTSNGKV0kzjxYtL4KpBRn0xJpxAOzvNHrs3EhYbVqQ2QbzM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7Kt3jGAz5pf42TPLfr+a1HwHZsJqO8MyesuoPlK3cqkzUcAI7 duQcAgdQxqmebXxA0KW92NHx0hunmuBspqZlkwvmcMvY66sZQuus X-Google-Smtp-Source: AGHT+IEQXvn2SOwOm29+rtI6JhMQDL11GxzU3NymqcoXZabn/0JlDB/HAsAKTuaQukE+IyxWb3rj5w== X-Received: by 2002:a05:6870:56a4:b0:27b:6267:61b0 with SMTP id 586e51a60fabf-27b9daece55mr3048986fac.32.1725866588424; Mon, 09 Sep 2024 00:23:08 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23: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 Subject: [PATCH net-next v3 01/12] net: skb: add pskb_network_may_pull_reason() helper Date: Mon, 9 Sep 2024 15:16:41 +0800 Message-Id: <20240909071652.3349294-2-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce the function pskb_network_may_pull_reason() and make pskb_network_may_pull() a simple inline call to it. The drop reasons of it just come from pskb_may_pull_reason. Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index cf8f6ce06742..fe6f97b550fc 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3114,9 +3114,15 @@ static inline int skb_inner_network_offset(const str= uct sk_buff *skb) return skb_inner_network_header(skb) - skb->data; } =20 +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) =3D=3D SKB_NOT_DROPPED_YET; } =20 /* --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAD021AF4DC; Mon, 9 Sep 2024 07:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866595; cv=none; b=ofjdCGGSphx82yM+M5/9CV6rReSPLcsabVM0Jo/Sy3O8f8qiSTiaZtYDU7kodmzwfpJAWZ5nYBUSXBU/Q6lvbOJHyCOojUUpxG2ochuXmxHrP/AdBU5wG+3p01kLWjxtmBGiKcL6RjOgClitwx8L4wLI0yKB1tQ24d9gDobOd9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866595; c=relaxed/simple; bh=BjupJZu1E/fcfxWKlB66JWida6SqIOij/q7rMugI49E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y7TfglP1QRXmtiCU84/N17oHNmfuIjxABTrwwFzb1QYJyOCbmd++/jITiiotoh/u4uvlUbC956lFid0b2xuldLzVOaXrprGPCDjJTwXUsiSOoywd8AGwKqg6+SWPct9AkQwGBPZpnJIahA7ChM3LGSiYiYuWGDH6s2T/BEkxrc0= 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=djme4q8i; arc=none smtp.client-ip=209.85.210.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="djme4q8i" Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-7179802b91fso2368372b3a.3; Mon, 09 Sep 2024 00:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866593; x=1726471393; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1nl/wlYbJ8IhJjGotsXRWm/OkatmXtly5y1k+64ypkQ=; b=djme4q8ihUd/050sl5T8PnK0FVpDqlJxs1u1YO1Cbkv1TH0atOEktYr4kvuvfsGJp9 e/T7BWibQ6NfCu9hWlTdWyMGDA4YePIPHIXkmc0ZE+Rn3M6FXB8xecLYmhBB9jjjBP7K APP5WWvajskV2CfrvN66RDewZEh76c/c1whURcFQAZXRylt/v/LonhmmJ8JhQhsXOYtF /0WxUxlkUbA1HB3jYPCXum7QgtxL2RNCCb3Sz8t3q5pv0mo+4cVY7x9rBrywJ90i2jwj CsrFMeKrt90xrPTKOr/vw3RIzpKXS1gdli2mKFGo4na0KIZjyGWtfL/nybTo+kDSDLAL l4rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866593; x=1726471393; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1nl/wlYbJ8IhJjGotsXRWm/OkatmXtly5y1k+64ypkQ=; b=B+HPVPvxnlqBPYniDwKQMos0Bc+coO3xryZGosqgjpSh0r/kGMJPwF2m7NGN/+Hfv0 Ex48yF6Z4YBGscPmaRsrbrO0kUmr9cOTzjlhp/qmmLhUsJz1QbJKqStbB3KeCLwze/EQ Mgq3zoqa3mjmWKvhMqwzz2/RAbdzeyXeqxqvw7cdbl/y5PW8OAaqGoDlBpBS/oTavtCJ PKHfa42CbDTrA1tkDlfVJECpCQeVDk27Me780xOfW4DluyhLPbwW2SUcF39TWr8Pliwg uMJStoPvcbjJm9y//tbvjcr5Eepyro8ybFGzZiYqHeuCGJtovVzbFZF7ZsGwRAMqH6L+ 0i9w== X-Forwarded-Encrypted: i=1; AJvYcCWyAoXHbefQ8jLZAXlHPrRyyv2axRXq5YXEwDfja8HHbsGYsup/csueRufbKs47owiknJ3BcpkSyjKiJlA=@vger.kernel.org, AJvYcCXVXLDxZ7YfIM9jcqHuo3zdt8fW//4L117pGKW1ULJs4BmjGZ3eQWQSmG73Op3PYg/lYG/yF78s@vger.kernel.org X-Gm-Message-State: AOJu0YxygeIoD/MD2Q1mHdaCY5SM4K0lmqNMxMVhJNcmRa5o0RImOZJp HoC7hsK4m6Ntv9CpZ1VANOrcNyEw6WyIh4pdd2wt4RlHITSEdLbm X-Google-Smtp-Source: AGHT+IE05wiNONegbt3qbKksEiCrsguphPea11DGOiINAiQpv7hzrT9bIan5AHR/kE7p9qMBd16Tgw== X-Received: by 2002:a05:6a00:244e:b0:714:1a74:9953 with SMTP id d2e1a72fcca58-718d5e56277mr9144801b3a.16.1725866592936; Mon, 09 Sep 2024 00:23:12 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23: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 Subject: [PATCH net-next v3 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper Date: Mon, 9 Sep 2024 15:16:42 +0800 Message-Id: <20240909071652.3349294-3-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce the function pskb_inet_may_pull_reason() and make pskb_inet_may_pull a simple inline call to it. The drop reasons of it just come from pskb_may_pull_reason(). Signed-off-by: Menglong Dong --- include/net/ip_tunnels.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 6194fbb564c6..7fc2f7bf837a 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -439,7 +439,8 @@ int ip_tunnel_encap_del_ops(const struct ip_tunnel_enca= p_ops *op, int ip_tunnel_encap_setup(struct ip_tunnel *t, struct ip_tunnel_encap *ipencap); =20 -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; =20 @@ -456,7 +457,12 @@ static inline bool pskb_inet_may_pull(struct sk_buff *= skb) nhlen =3D 0; } =20 - 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) =3D=3D SKB_NOT_DROPPED_YET; } =20 /* Variant of pskb_inet_may_pull(). --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.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 9E55C1AF4DC; Mon, 9 Sep 2024 07:23:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866600; cv=none; b=Wt9/Vq5RiaSvSTGxb9lbnzHIno1BonBbP+PBVuQ3Sl2eroGa5aUoOKQTXuxJguUEUZiqtzj0VcMN8PiBXsJCc9qZFg85/BAJxdCK1+ngcP1wUJVtnql5NbdnzYLs6nSWA315S6PUiRtnYXJnrAF97DK6S8a483YTgd//xaYVyA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866600; c=relaxed/simple; bh=SyJTKVXW1KbX4FQYavgYyEaHhVURcihCQwW1NIvrKDY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JayVRTavTE5V+2mmlTZoMeaneMar+3JxzLvJN1fc/Etcu8GPsRUG8PiLZaWiGq2f/zWoZOsV/Y8L+A2rKYR3+op/apBMNERki80AlOmThSUNeA0K54kYoOMsM/2xDE5gYyGRrpKjFGxifcbJLwqfG2j0LNc2bZGRq1WHbu/XJQ8= 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=hHjQuzHc; arc=none smtp.client-ip=209.85.210.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="hHjQuzHc" Received: by mail-ot1-f68.google.com with SMTP id 46e09a7af769-710da656c0bso978604a34.0; Mon, 09 Sep 2024 00:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866597; x=1726471397; 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=Ac8M5GlxYy/WpcMspugo7rQDDvKUcBeSWvAozWoN7Vo=; b=hHjQuzHc3yMGGLMgODt0kM7qS2qVqM3vl4fu0BYugblEUKOGHTpwQS289fmVBV4Abo 7WYURklZaVMAzz673fXZnSc/hvfgKu3qqMjGo0ZuOKOE1Y0EnORYlWnUw77HPncvL0Uw 4WOdSrmlPqEmUBcQM0H06mEzapJSoENn6YKtXKuMao/I5FYPep7p45Eji5aJfB/y0p4x 4TXVmolg5uGcF6/qtQjmVYdbpa/Ub1+aZBFgqjxPBhd3KuvW0+Zof2nf/rTSoAKfnEvM JAng/2gGLZ1a4DgSpuAmP9iTj4ozZQKSOAhCO9XTMNsczOHsFfHbRke4xOTqwpdTRc4k AGZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866597; x=1726471397; 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=Ac8M5GlxYy/WpcMspugo7rQDDvKUcBeSWvAozWoN7Vo=; b=oSwxZ8i4YOaVZ0BoHaODmhH9lh/3O30L7nV5HZKuxmPXx0DVp06E209kK6d58UspTj ioJjgjAB8p/r4S+grxN0j6zCbm4j0Q8v8TuH1N1oblGQMwxcWDvGWN2sqUO26mEf1vjb AaU6gAzSSaiBiVqRnoInCh6RFi83qcSAyO24cabsFaQNGr9uJiDU2C+LMAGjzQOAOZaN KUK7fzbYBGQ+e4p0vRlnEkUPNE2c/fysiu0tRJJpvzJMPvhYdh4QdbU6eCS9N2b/rudC kSC41EP7pmq4SrAiMJl+cXPcw0IIX/nxurMC01rUWdBWru0uqs+ETck3gP3+VMnwOoOr L+9A== X-Forwarded-Encrypted: i=1; AJvYcCVJabzKQ412/DBZt6Ng9IVryPnbOgOJyoEZzTEpmvmIxamrgOvlBO3OQYvqwCPgxt1Ln1YVSGVb@vger.kernel.org, AJvYcCVZJV5uAI9yxzf5h71iuYxwLrimxZhEZgwHxmvJMoHZKmsusDerviW05RBSyUepxkR/c4dJbu+lUx1UocU=@vger.kernel.org X-Gm-Message-State: AOJu0YxjOP4mMA08ZD4a9ToSxukl3rSRnNpPf2NuNfTv3w3xTkexdQkv JG+v/daZyolZKZCHP7Szuq7XSic7cU4ecg0SUbTSs9tkHirXDb0R X-Google-Smtp-Source: AGHT+IEueFXOSqvHA5zJkZzocHizwoT4vYWdG6ztnHB94ljH2R8e7b1n4d0DtLxG4lwNO0oPh6j7Hg== X-Received: by 2002:a05:6830:348f:b0:710:b797:6b0b with SMTP id 46e09a7af769-710d5b9875emr9447169a34.17.1725866597647; Mon, 09 Sep 2024 00:23:17 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23:17 -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 v3 03/12] net: tunnel: add skb_vlan_inet_prepare_reason() helper Date: Mon, 9 Sep 2024 15:16:43 +0800 Message-Id: <20240909071652.3349294-4-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce the function skb_vlan_inet_prepare_reason() and make skb_vlan_inet_prepare an inline call to it. The drop reasons of it just come from pskb_may_pull_reason. Signed-off-by: Menglong Dong --- v3: - fix some format problems, as Alexander advised --- include/net/ip_tunnels.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 7fc2f7bf837a..d00d8835e789 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -465,13 +465,14 @@ static inline bool pskb_inet_may_pull(struct sk_buff = *skb) return pskb_inet_may_pull_reason(skb) =3D=3D SKB_NOT_DROPPED_YET; } =20 -/* Variant of pskb_inet_may_pull(). +/* Variant of pskb_inet_may_pull_reason(). */ -static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, - bool inner_proto_inherit) +static inline enum skb_drop_reason +skb_vlan_inet_prepare_reason(struct sk_buff *skb, bool inner_proto_inherit) { int nhlen =3D 0, maclen =3D inner_proto_inherit ? 0 : ETH_HLEN; __be16 type =3D skb->protocol; + enum skb_drop_reason reason; =20 /* Essentially this is skb_protocol(skb, true) * And we get MAC len. @@ -492,11 +493,20 @@ static inline bool skb_vlan_inet_prepare(struct sk_bu= ff *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 =3D pskb_may_pull_reason(skb, maclen + nhlen); + if (reason) + return reason; =20 skb_set_network_header(skb, maclen); - return true; + + return SKB_NOT_DROPPED_YET; +} + +static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, + bool inner_proto_inherit) +{ + return skb_vlan_inet_prepare_reason(skb, inner_proto_inherit) =3D=3D + SKB_NOT_DROPPED_YET; } =20 static inline int ip_encap_hlen(struct ip_tunnel_encap *e) --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E7041B0101; Mon, 9 Sep 2024 07:23:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866604; cv=none; b=gCUaR3Twu5+8i1XUNtMf0B0rTsagVrS5pEOUR1v+7r/smDCAgDEIdG5gCiZTtm5HKnkhOpHqb4FhQX5pbzh9Bf61TwQ82mrjMrhWXMcpS/P9BMk173sQ0qrJoLr1qZe5RojCnWU2O7+YUsmCmdX5hauOlTvc7nVJqJFZHy+JRtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866604; c=relaxed/simple; bh=6/cAchfE9wKx82RhNCQIfwfTkKQxc3oDpmxA29MlvcQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bl97PqE/AuqdUJZj8i6Da1Zw1kFfOLEvuEx6dHLAmMoZYnLNqkXY2d2VjqKWEXKwNy9WXdZzuZdkky/cfecHx2VvlVRmmds7773aDYkTR/jf2MFnL/DRn95nc2fTzByb4tceFqdT/2A9+NqgxiD8JTHzh/Q+hP5yGlD8iNaCXZY= 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=T1wTS99z; arc=none smtp.client-ip=209.85.210.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T1wTS99z" Received: by mail-pf1-f196.google.com with SMTP id d2e1a72fcca58-718d606726cso1923759b3a.3; Mon, 09 Sep 2024 00:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866602; x=1726471402; 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=ytwSdroJCAVZvIgbPCwCUn1vn1RYH4pr4hfvMUYl3Bw=; b=T1wTS99ze3wOTyWAgfmrmSM80dgkOnUIAKK5/MuRjdv/ueeJ+gnVN5vae75/BgAzNL jNQhuY5hQobXQF6abaVb0J9AEGmwJo17xKm+G7+/fVtjoBtZHvVKMa6SNF210Py6/uV7 MLtDku4xH3PAf23NUi5xO+8ZkL0xIzbDkvq/IzeBLtOmrN/KKnbqwMLsDBmLgYJGlXre XlHa3mza8MFo5Oq6FTVGEj87tuI2TmdNgBrPNNK7BKakN3dZhMay+HhoM/f1BVPiagTT qiTktsta3yl0YRbnq7HGJm1ZtlRgrofJL0/t3CLfLQ8jskNfAesa2pqbqV8cqQADKjdh GS9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866602; x=1726471402; 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=ytwSdroJCAVZvIgbPCwCUn1vn1RYH4pr4hfvMUYl3Bw=; b=kqFYY1RFv4WA09d3jG2WSWEPTIrntmZmEvp7NP5uYb/6i4KFI80F2SR4dSyV9/J0EG lIP5zKcXNRMLkl5FyhsxYlaedK11iNP6JrZ6iII7zQNe51AazHRmZJEOJedoQq4f8qxm gyoceNSuZYxukxbYeMltIvi+0zP9zNyWENbIt3XAVwrqVPMojvwBuU3FiH76eYUqw7P1 7CHtwbtNqGbyXhVp5y2n5jnBcqaQY6ubcOJ+FffM2uCVAazJeOfzdbEvE3E/cm+VInJr TIzUntW3+TWe6HiZAo+wr67CpO8+yIpWdWDOF5uW2Gis2x1bJGfZ5yPb2eMmhhBEazng 04sw== X-Forwarded-Encrypted: i=1; AJvYcCU2H/oJ++IA/Lr/haSuGx40wezJ/nDdXY5m6tduyb5dyGEifX/zH1uJTw7xdOAk9klmFpwmovsPek4Huwk=@vger.kernel.org, AJvYcCVAEFdCN7XXFebjqnyLZcZBzBKdt5S+EolqhNJnt4W2U6zvbDpYoiKtrAaI/MZxJ8ND0KWitQzQ@vger.kernel.org X-Gm-Message-State: AOJu0Yy3DU4yKpGorcftY1w5fOfIoFehZzlasaQk3kLZwkxqAYA5E16m SPlhfX7TcFN9EqPe8tTPoXeWWSwc+7sR18aLg9uG35it/Nb3w8NM X-Google-Smtp-Source: AGHT+IH8zqdEtoIVgkhJ6NInxC6+AOLdW6DRFrcntcqerEne/ltS5+PhTuYkh8uz1nWKcWg6ZpeeYA== X-Received: by 2002:a05:6a00:17a9:b0:70d:2e7e:1853 with SMTP id d2e1a72fcca58-718d5ef956cmr17390985b3a.19.1725866602345; Mon, 09 Sep 2024 00:23:22 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23:22 -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 v3 04/12] net: vxlan: add skb drop reasons to vxlan_rcv() Date: Mon, 9 Sep 2024 15:16:44 +0800 Message-Id: <20240909071652.3349294-5-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 53dcb9fffc04..04c56f952f29 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_buf= f *skb) struct vxlan_metadata _md; struct vxlan_metadata *md =3D &_md; __be16 protocol =3D htons(ETH_P_TEB); + enum skb_drop_reason reason; bool raw_proto =3D false; void *oiph; __be32 vni =3D 0; int nh; =20 /* Need UDP and VXLAN header to be present */ - if (!pskb_may_pull(skb, VXLAN_HLEN)) + reason =3D pskb_may_pull_reason(skb, VXLAN_HLEN); + if (reason) goto drop; =20 unparsed =3D *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=3D%#x vni=3D%#x\n", ntohl(vxlan_hdr(skb)->vx_flags), ntohl(vxlan_hdr(skb)->vx_vni)); + reason =3D 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 =3D vxlan_vni(vxlan_hdr(skb)->vx_vni); =20 vxlan =3D vxlan_vs_find_vni(vs, skb->dev->ifindex, vni, &vninode); - if (!vxlan) + if (!vxlan) { + reason =3D SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND; goto drop; + } =20 /* 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) } =20 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 =3D SKB_DROP_REASON_NOMEM; goto drop; + } =20 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 =3D udp_tun_rx_dst(skb, vxlan_get_sk_family(vs), flags, key32_to_tunnel_id(vni), sizeof(*md)); =20 - if (!tun_dst) + if (!tun_dst) { + reason =3D SKB_DROP_REASON_NOMEM; goto drop; + } =20 md =3D ip_tunnel_info_opts(&tun_dst->u.tun_info); =20 @@ -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 =3D SKB_DROP_REASON_VXLAN_INVALID_HDR; goto drop; } =20 @@ -1773,7 +1783,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff = *skb) =20 skb_reset_network_header(skb); =20 - if (!pskb_inet_may_pull(skb)) { + reason =3D 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 =3D skb->head + nh; =20 if (!vxlan_ecn_decapsulate(vs, oiph, skb)) { + reason =3D 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 =3D SKB_DROP_REASON_DEV_READY; goto drop; } =20 @@ -1811,8 +1824,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff = *skb) return 0; =20 drop: + reason =3D reason ?: SKB_DROP_REASON_NOT_SPECIFIED; /* Consume bad packet */ - kfree_skb(skb); + kfree_skb_reason(skb, reason); return 0; } =20 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) =20 /** @@ -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 --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09CE01B010C; Mon, 9 Sep 2024 07:23:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866609; cv=none; b=UHtytyBqw9TmxGZx/bdHS3aI7qu7/L2Ks9a2EDTwXJScCD2xL15VotZXyBMT5LZRmliA/GOpInK3aBZbygVj3kibdZm9ID5cq7vu1USRrtkHrxFjZG1+Rhj3fBA/ES4u+sVz7SaZ6uupwGbuSsiIcH6Hh4BjIbObOaFZsDQHGy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866609; c=relaxed/simple; bh=wI2H5N9tXc2PW4TlDXbNOg6wdyN4zCvZ2LYpG0hOK48=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lGilH5OIXVWYs/mgRou+i/q2lcMfh+SlHdAnver1qJYi7IeNgHD8ZmbYfX1iqGkYF96sxbupJPyskH3ULyDIYFzAxpafO2C58jmajv/hhSCuqHhDbq3PBQeUSVqTWDHiP40+TEjSUlAm7/V82kAF4g9GeS6Svn8SHvOAKulIf7s= 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=C7/qbCJg; arc=none smtp.client-ip=209.85.210.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C7/qbCJg" Received: by mail-ot1-f65.google.com with SMTP id 46e09a7af769-710f0415ac8so161481a34.1; Mon, 09 Sep 2024 00:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866607; x=1726471407; 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=1jvMzetSQgfaUIUzQnNbOMjOFgsmKOdJ2a5KEUYIEP0=; b=C7/qbCJgbe7REw4YLkh8UBTk6bnNOHMOOkIA+Gxf/dJb1EkzF0CdCkMMERHX3UlWvD 0O0iqGrKegsqEe1cmBD5IVUsmfXwo0w0i1x/ShB0+P4Ll+nBhOCGvTu/qyjd5ObjFJp2 q7liIr//SF2VYFVGBetvmdJ5Im270+W6+0LsJakXo5WZ+wHeLj0elbUXVgHVkFl9UCiG AND7ErqUzTPwiMr+mnBLhk0aDEpFRJZbFqbGD0fEH73qwblg1+pMhEeA52PtPa/PGzj5 6DOqBHP2IQcymQo/t5doDMcEDlYaukqN3j2S8vouXcVVMzspkOvPv16D5Gyx1JaYu0ls B+6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866607; x=1726471407; 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=1jvMzetSQgfaUIUzQnNbOMjOFgsmKOdJ2a5KEUYIEP0=; b=jqN9u0T3YZ0GoOY9gp/I5oAsLDnkN0Y4da6aaOfY15uUj2+HsOIyaseexvFIqPSCch /HmGp+S/NTfVwZwqqjw0c6C9fquGkPNF98xGtwOZtbI1/5XYUOz6XHqkcB49g3QERiYW X4IqLut9ddRcwnOxcFg6yjsYG6Xg7A4yZTaZHZACKzLiOKiKMMuCCQWFoRV+K8icUXO3 4Xknj8zLkZzjlIZ4iOhXuaA9xEylShkK0Mx8zWrIFxkv0Ef4In2Ahoq6MbkhXyljNpkz zo4uoAu1lnrSEryhhkiUmocu+QJqD7b6RnmPs0VXGYj9QtBe+037nl7sfKJDKe7H4M8n OsMw== X-Forwarded-Encrypted: i=1; AJvYcCVanic5SeibeqT5K5a2f1xaIPPiXTQmTsfIahzVHenVjADNyJVRqnmgNaFfCDMc3+q5mDVoRG0N4eNrAkk=@vger.kernel.org, AJvYcCWoTy4TlwJLOnQcwrcnMMyo3/U0wm8Lw9v7tTYVAiw8G4OXA4lioYiReizWo0OdjWux40qYrHYJ@vger.kernel.org X-Gm-Message-State: AOJu0YweEraIC2RXH9z3/7FJX3S4aX1LVpiWwhKUJSPaiJhxtEOlZC3R iinHzMLzJ0aoHd3AP6VGQjqm6asWoG1brf5TM/6sTVwwmVn766Ql X-Google-Smtp-Source: AGHT+IFnwQ4qKw3YdRdPnWWCvIHpSzE8mmzRk4hhqNwzzFWUwA1yxu41/7qIr4LPvwDhRQPAKssY8w== X-Received: by 2002:a05:6358:52c9:b0:1b8:44ac:e6be with SMTP id e5c5f4694b2df-1b84beae8e1mr948799555d.20.1725866607110; Mon, 09 Sep 2024 00:23:27 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23:26 -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 v3 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Date: Mon, 9 Sep 2024 15:16:45 +0800 Message-Id: <20240909071652.3349294-6-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 04c56f952f29..03c82c945b33 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 *vxl= an) #endif } =20 -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; =20 if (!(unparsed->vx_flags & VXLAN_HF_RCO) || skb->remcsum_offload) @@ -1562,15 +1564,17 @@ static bool vxlan_remcsum(struct vxlanhdr *unparsed, start =3D vxlan_rco_start(unparsed->vx_vni); offset =3D start + vxlan_rco_offset(unparsed->vx_vni); =20 - if (!pskb_may_pull(skb, offset + sizeof(u16))) - return false; + reason =3D pskb_may_pull_reason(skb, offset + sizeof(u16)); + if (reason) + return reason; =20 skb_remcsum_process(skb, (void *)(vxlan_hdr(skb) + 1), start, offset, !!(vxflags & VXLAN_F_REMCSUM_NOPARTIAL)); out: unparsed->vx_flags &=3D ~VXLAN_HF_RCO; unparsed->vx_vni &=3D VXLAN_VNI_MASK; - return true; + + return SKB_NOT_DROPPED_YET; } =20 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; } =20 - if (vs->flags & VXLAN_F_REMCSUM_RX) - if (unlikely(!vxlan_remcsum(&unparsed, skb, vs->flags))) + if (vs->flags & VXLAN_F_REMCSUM_RX) { + reason =3D vxlan_remcsum(&unparsed, skb, vs->flags); + if (unlikely(reason)) goto drop; + } =20 if (vxlan_collect_metadata(vs)) { IP_TUNNEL_DECLARE_FLAGS(flags) =3D { }; --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE7661B012B; Mon, 9 Sep 2024 07:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866614; cv=none; b=eijBb7Mt2ERPUEBp+Ufxaq5rhYcVfZqi7K9OVjbfi1LGZB7DdfuVNuFGr/kkadIfNcbIuuU9gKuSpjlNf3FxJFCGyCmNVzXPmKqof5L1rlQyY+bRRO7jfVih+6teSbKSVYkuTzld4GTL3gYPj5ApLW6YTiOhAF1Rurw/9KCX/LY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866614; c=relaxed/simple; bh=1Qy23l5ssKeKkewft6Dohq7iX8iCWlOdllvRz1XBS8M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Z8rnImh3wn4IhzuKS4aCqB0dbkw4nWNaXIuiFqoyBhIMI9k7V29xjMs+BXd72QoaH+kqTQey5UKF76z6nAotn9IoWH/pXI4or5aVRedL8aQyER4IiMCyQlYQKPb4IEFr67ZbSX3t7cWYh76g24WMCLfVv0gDI9Nc6eApuIaRqck= 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=DzSR0EPW; arc=none smtp.client-ip=209.85.210.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DzSR0EPW" Received: by mail-pf1-f195.google.com with SMTP id d2e1a72fcca58-718d79fb6f7so2239231b3a.3; Mon, 09 Sep 2024 00:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866612; x=1726471412; 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=vlvfeid9Q1xCebGaSBORoDLqRZBLxsFNr9K+AKcG+yo=; b=DzSR0EPWpbKXGcfzLPMYNcrvXI05P116CSi4Yk37q3wTBYatTANrFdNvQstcBO38Im zsrNkb/tSD+LsB//CwHTtGlyYkfwTn6GuPQi9VHoHc2+/RIme7Iz0bRbhgfCFr3R+jeZ xCmTqy1qVUlHSczQwVXsIqlSogxCocI+CvmbADffqJKq6m4tcFUPESg4iMWSliy8eXf7 367rMeoN7i3ONrv6r8EeS0zTQNMJiZBqiIzFUhPoMZJLYeqc7UVQUNNra4B20AdVgKqH chReLq12nmTuaVp9QE6OyKEw2aW3YEg2GjUND4gOtVUYYR817S0LmcrcImydPfpc3mWh Yv5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866612; x=1726471412; 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=vlvfeid9Q1xCebGaSBORoDLqRZBLxsFNr9K+AKcG+yo=; b=JO0iBYb9eF1TTG0evKq14BSjlu+vmsyi+8DBI37kWVsiZuj42fA+j0MfkIvSmB6IgT OAeobwcMfFzCmNmwVU+ulfR+KskScc4QTkjdYTvr6Rky0euzM8fGbWYUaNSgvQ4wMJ34 trG91+8kTKabCg0ZIxuzJTuHXv7uBlV5Cfakmwx4QAevNWt0A8i4UBdue3zyeX1OkTB+ gsoIzPoX8hulbnl+FiTr09XBBb4Rp51It4BrH2cWGjvkP2dUrPuvmRzItVFJ8Q7Fv72M jL0CWcV1/LbZclOfk30qnVeydScveU8GOLl42VrENuUCRdfAerh8meS1wQMXXdhoSf6R QH8A== X-Forwarded-Encrypted: i=1; AJvYcCVc82Zzxzm0xGiK7QMyrDbe8MJxyDDptGljfIjnlc0xFMT3xXqeMbPj5qR+gXnb+VqF3DTt7nVb@vger.kernel.org, AJvYcCWfMRg/e9Ebug/sfibcrGUN8ZnYmy1ijXZEDpw3yorTZGBbOopzZaR3oFnVYdEvWP2mRtZn7EpxdSzDwkc=@vger.kernel.org X-Gm-Message-State: AOJu0Yxn/IJEkmwJpUY+pMLAfXU7bNe1tbVQ1FkGaDftFkWG9OLrRVPB rsmsyD075TeqZdDoz7d8qMOlgfRTZAM2ETMBCTq6drP+W08PxYVD X-Google-Smtp-Source: AGHT+IErFuqI1lzKsH4+ypSIWJI5pKlNKnYY9F6d5Bbd14Qf/s1TVOkAjiv4ZH6vzCnPMXyV+fOGzg== X-Received: by 2002:aa7:88c8:0:b0:714:2cea:1473 with SMTP id d2e1a72fcca58-718d5f12932mr8319643b3a.23.1725866612086; Mon, 09 Sep 2024 00:23:32 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23: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 Subject: [PATCH net-next v3 06/12] net: vxlan: make vxlan_snoop() return drop reasons Date: Mon, 9 Sep 2024 15:16:46 +0800 Message-Id: <20240909071652.3349294-7-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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_VXLAN_INVALID_SMAC SKB_DROP_REASON_VXLAN_ENTRY_EXISTS Signed-off-by: Menglong Dong --- 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 03c82c945b33..2ba25be78ac9 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 =3D netdev_priv(dev); struct vxlan_fdb *f; @@ -1447,7 +1448,7 @@ static bool vxlan_snoop(struct net_device *dev, =20 /* Ignore packets from invalid src-address */ if (!is_valid_ether_addr(src_mac)) - return true; + return SKB_DROP_REASON_VXLAN_INVALID_SMAC; =20 #if IS_ENABLED(CONFIG_IPV6) if (src_ip->sa.sa_family =3D=3D AF_INET6 && @@ -1461,15 +1462,15 @@ static bool vxlan_snoop(struct net_device *dev, =20 if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip) && rdst->remote_ifindex =3D=3D ifindex)) - return false; + return SKB_NOT_DROPPED_YET; =20 /* Don't migrate static entries, drop packets */ if (f->state & (NUD_PERMANENT | NUD_NOARP)) - return true; + return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS; =20 /* 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; =20 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]); } =20 - return false; + return SKB_NOT_DROPPED_YET; } =20 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..1b9ec4a49c38 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(VXLAN_INVALID_SMAC) \ + FN(VXLAN_ENTRY_EXISTS) \ FN(IP_TUNNEL_ECN) \ FNe(MAX) =20 @@ -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_VXLAN_INVALID_SMAC: source mac is invalid */ + SKB_DROP_REASON_VXLAN_INVALID_SMAC, + /** + * @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. --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-oa1-f67.google.com (mail-oa1-f67.google.com [209.85.160.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 0B44D1B012B; Mon, 9 Sep 2024 07:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866619; cv=none; b=Hp9N//57Tx1J9vbGGZ6gP3GziDk/9Q5x0PO/0x9O9fS059OtJl8jN0/RSgrpNSV7OBRZ9MPxyOlTt8KmUcNYA/5Kx/r4JXtn+mP6MD2Dfo3gpnhN0ymcIJzWt5JZfXeXtR4gCVgn9i+bSjZGPArIYCeaEBLuujbh1GAmyUQ9Tr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866619; c=relaxed/simple; bh=YZfrPDhrnbuJUOmglcDwoOF5Zik8vvADBGA8aS7PD+g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iO9WuHe+8R/x4TcbmRMNjCxSp/Iqv3Hi+09NRuSM0r6bBDYoDSZ2LIkVTxpsxS1/1A3AcsNIrDWsjrP4+xX1vVevK8UpUAcZPTfTKT3MGwyd06wob8VA8AcnYLo5qBY/nzjUeRQb1TYDGybYxVbouMI6vyyRkKTiB5AuJNxMqKU= 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=nqMcnI7f; arc=none smtp.client-ip=209.85.160.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="nqMcnI7f" Received: by mail-oa1-f67.google.com with SMTP id 586e51a60fabf-277f815e6dcso2175483fac.2; Mon, 09 Sep 2024 00:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866617; x=1726471417; 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=Hz/ZZDJD7Pucm/Uf4aBWG6gS+O9yya4MSrYCj/xV9DM=; b=nqMcnI7f4YLpZfcL4lTD1oGqceXzaSUh8bC9Nplj0JIEiHBRFmC3fxW6pxZcptPgf1 CcBCZGFt9dL26fyuuPptrh+vJ5F3YHLGxgTPQPrWJ0yMKty0sUUIEbzFTXsafBh5hrEM 0DJZKDFi7ibT5ho/phKM1Uk+hhF9ASihr7a00/FYRhJOahS3X+7z2W7w3HW2S2lf+aKF H403wgnZ0vrgu8KGLO+d3ecvUcuAyiZZmop7y8+obYLpj8NFHDTEtdZ1MuE6yq8Yqbp1 by1Z2qn4R0UJqrQuMWM2JURGT1aSq3bIP6KrdvIDWSFVr8JJMiX5xCUdY82US+IZyVnN xs8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866617; x=1726471417; 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=Hz/ZZDJD7Pucm/Uf4aBWG6gS+O9yya4MSrYCj/xV9DM=; b=HFZsnpWag26KkpCnk3P74wOdjTH8DgGmALaUhU/KW8RHgph6Fl7gudXOntLcsLf8Uu cZE9yjZwY2jcvRrek01XdmXE39e46/AIVPC7Lckkn91mBkcfTGWiwTSK6xdPlHtMK1ej LeHXeBibinNRMvaVzfVv/6Ikv3mxRVa5UGm/as18xTuZhwfWkeeDVApixe4OTgqp0Mbh NhF4SpQTX+SE7cv97DNXRg2KMZl+L+xZmx/hontcIJMIjkbrfjQRVAxOMLzIVUsJ8D9y +qMXE4nkDwretvG3xQX88AAwovWNvtJVSc9wRDy1UX0Fjko+ULsdtj61OADLBu2fRgLa ImYQ== X-Forwarded-Encrypted: i=1; AJvYcCVth7dPITVX2lEiAyv9F8YGXZ9fW2tOYFKDTYukmMpxl6v3I5pmaEo6FTp2IV4tq7UwWvEhAmJm@vger.kernel.org, AJvYcCXY61eFpyuBE4bIb2JqLOKDaq0BOqlaulhLIRy0dTrvYiTxc1GXB6FXySRvvNW4R79DASf03cuQl90RuEc=@vger.kernel.org X-Gm-Message-State: AOJu0YwccHCFnc1ZaY0S5+SxZifHSH8H/MtQvRtsmKy5kLNsOeanQcxW 0Dlsf575rRhMz42u/A3X6V+edpXpnhcOdxLiT+8JlaKwYdM6MsA8ky+w/UGa X-Google-Smtp-Source: AGHT+IEuJnbNnQzojo+qINc4rSaCY6bZbPGRAjZR5SiiwEXY4cvcPuFulqoF2sKz7vrHkD6sJZ030Q== X-Received: by 2002:a05:6870:e387:b0:27b:583b:bfa8 with SMTP id 586e51a60fabf-27b9d8082ddmr2939414fac.17.1725866617049; Mon, 09 Sep 2024 00:23:37 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23:36 -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 v3 07/12] net: vxlan: make vxlan_set_mac() return drop reasons Date: Mon, 9 Sep 2024 15:16:47 +0800 Message-Id: <20240909071652.3349294-8-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 2ba25be78ac9..6fe5b75220df 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 *unpa= rsed, unparsed->vx_flags &=3D ~VXLAN_GBP_USED_BITS; } =20 -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 =3D skb->dev->ifindex; @@ -1622,7 +1622,7 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan, =20 /* 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; =20 /* Get address from the outer IP header */ if (vxlan_get_sk_family(vs) =3D=3D AF_INET) { @@ -1635,11 +1635,11 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan, #endif } =20 - 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; =20 - return true; + return vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, + ifindex, vni); } =20 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) } =20 if (!raw_proto) { - if (!vxlan_set_mac(vxlan, vs, skb, vni)) + reason =3D 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 1b9ec4a49c38..38f9d567f501 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -97,6 +97,7 @@ FN(VXLAN_INVALID_SMAC) \ FN(VXLAN_ENTRY_EXISTS) \ FN(IP_TUNNEL_ECN) \ + FN(LOCAL_MAC) \ FNe(MAX) =20 /** @@ -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 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 --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C98441B1401; Mon, 9 Sep 2024 07:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866624; cv=none; b=mjlnJtElsHX/KnhGecDYBFmPMzLrk4l/0nDVKzQZx/LG91xabKjymg9yYZpyAWz0a8YCxHXXr7X0YUQxWOpiUTFwBo9y7vZPQ0ZEWrKfiuSCwEYCbLGh22OgFdxvERybW+n7EjlcK0gEDcjNIz/BjGgicv70pK9G0ZQvvkckZck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866624; c=relaxed/simple; bh=xX6LjIMGAR+rjMFZMHvfPgfVPXeBb697cR8npOHoeXA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QltA02DEWcMmmEsdXlea6x9/1K0juLySnN6lh2V/3UTM3/QNr/j8MgtCoTfEAd7v/7+LoUBt4WsGRLUiOIWOK1Jb06TF4p/19NhE+3e329NvfVjUV9c+3zW6JxVu69qboGk0kGz1Uf8J8smDIH/l/iu5pCL1JYwJzm/xrnLRr8k= 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=KaybSFZU; arc=none smtp.client-ip=209.85.210.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KaybSFZU" Received: by mail-pf1-f195.google.com with SMTP id d2e1a72fcca58-718d8d6af8fso2210572b3a.3; Mon, 09 Sep 2024 00:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866622; x=1726471422; 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=PhzebvioE/S+RtKNos7CT8rVCz+51LAcKnC+aoJ/JjE=; b=KaybSFZUs7kJ0lk2TYqW55d38GEpb3i+YzYJ8/b5XIFWU+Pg6qBNZS8kr2ZEI1IIF3 8mKz14kGlYdFKsZSS/NRQfxV628SGlDd8Rjodt6BPGRqfTWm6eoNiGyE5L92fBNr3wiP aii4QZrrLf3gBhG2zoZ8NFKolnRr1+ET41DlKY7w4tItz6KWuSw+JE5hGScnAOcdV+CL LdNRfKqbIEFjKXGeOazh4Yzk7xSbAXj8Rf4ZTTgze76vsOnYxSRf6xn8gucwgbyUQu9J 78BbJOW4ch5vxe6SUxrsyHDE0260mM3mNOoHbzMZIdLb0UtyC6mWH9oPbhwBaUpADU8X TxKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866622; x=1726471422; 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=PhzebvioE/S+RtKNos7CT8rVCz+51LAcKnC+aoJ/JjE=; b=AOZ6vtUCAWifLW99MOHx/vtt523QP4jplkwLJGSG5udrUuvexlNcueygrdH8I1Uy2/ C9NmuzgLR3gejgaMCvRko2fa5BlJ/+G6wpAhXPrOX95Bui9NvByHkEDPvEaQJeZmhmgp LpWwXgOEiHNdOZIU+LcNDXkL7JV+DlHK84vVDWopaPX8PeZSSIi8aXCWLuLBudR+56LZ JXzbRh3yKfYYVMr4TfRfoXD2xXM0OlRArvT+b7COBD3mYqW7v8ZYmjmBJx9vo5iiFWwZ cLhx7l7ho4C+5MoIiSXM+k74jKDShMUPhrMsVFfCqjGhURflxiEEujLPULSSFrEf5AT1 HYKQ== X-Forwarded-Encrypted: i=1; AJvYcCUcbqPgi15re0Z5Py17nV5LZeSDfrrYURyWnQaSh8qkrH0guxtyPcLQL7rGwI69xQLitoceXMLiyvvmJ38=@vger.kernel.org, AJvYcCWtmj4AS4DgnH9oSsAXA7nKQYNdSr5BGde2mmaNz3rrKyy/TtZCVzD1muWdIge1nwWOgwpIsJl7@vger.kernel.org X-Gm-Message-State: AOJu0YxlDCR9bkGX878QrOzFhp3enXrZTQe1A6S6aCnW3/6/Ji4IPqse 7VFE7ZlSkZ2Px3yiefIckAt9lZ5ImsTCUFu8ULQiB/zhc3b43A18 X-Google-Smtp-Source: AGHT+IF2U93dDIx7KyH+rvbOjHbgHgSnrPnN3W9nHoTVZV10gqk9dA8rkI5/BKcHH+fdts//xLP1jg== X-Received: by 2002:a05:6a21:1796:b0:1c8:b255:486a with SMTP id adf61e73a8af0-1cf2ad2a4bbmr9593904637.35.1725866621822; Mon, 09 Sep 2024 00:23:41 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23:41 -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 v3 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Date: Mon, 9 Sep 2024 15:16:48 +0800 Message-Id: <20240909071652.3349294-9-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 /* txinfo is missed in "external" mode */ SKB_DROP_REASON_TUNNEL_TXINFO Signed-off-by: Menglong Dong --- v2: - move the drop reason "TXINFO" from vxlan to core - rename VXLAN_DROP_REMOTE to VXLAN_DROP_NO_REMOTE --- drivers/net/vxlan/vxlan_core.c | 6 +++--- include/net/dropreason-core.h | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 6fe5b75220df..6f35448fbf3c 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, st= ruct 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, st= ruct 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, st= ruct 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); } =20 return NETDEV_TX_OK; diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 38f9d567f501..03dd53a8c2ab 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -96,7 +96,9 @@ FN(VXLAN_VNI_NOT_FOUND) \ FN(VXLAN_INVALID_SMAC) \ FN(VXLAN_ENTRY_EXISTS) \ + FN(VXLAN_NO_REMOTE) \ FN(IP_TUNNEL_ECN) \ + FN(TUNNEL_TXINFO) \ FN(LOCAL_MAC) \ FNe(MAX) =20 @@ -439,11 +441,15 @@ 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: tx info for tunnel is missed */ + SKB_DROP_REASON_TUNNEL_TXINFO, /** * @SKB_DROP_REASON_LOCAL_MAC: the source mac address is equal to * the mac of the local netdev. --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D14811B1401; Mon, 9 Sep 2024 07:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866629; cv=none; b=iUOcjG2fm8WXZFBp1+7AeTmCG9hxjvJWjI3au62GT0U7wVFVjChYUtrpnMr2JXl/1zW9e39+ecDWKrBLzOAydRv8AGpaEnQuQuxUcaQXPrVD7f82fVW5F6JvdYsecjTtcVaWs6t6AH59IuZH2RaJ9zw1OkiAqqYHI9A+yFlu1uU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866629; c=relaxed/simple; bh=+UXQDusghy/g3bLTxXSK04B/KrYOMSJuNULja9Bj9WA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gK3gK3fKlpEA+u95ETYcU20kjw98MyQp6UyT+z0DjVUOQju46yAQ2K86tap526gs3WB1WQnUW/DEQZ8HnwVM6dPMF+b1QxkY20tUfoOWGfBbf7kIC7+ChD32i5+G9JOjCUJTeMJ9Wg8FIC6PkfMDC/rEcCRNOGGD6/3sVjZ7eT4= 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=LjUXx5Ke; arc=none smtp.client-ip=209.85.210.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LjUXx5Ke" Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-7178df70f28so3257818b3a.2; Mon, 09 Sep 2024 00:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866627; x=1726471427; 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=+nCNoGwTwkgct22qV08RLoPjiywczH5fgjahOYpVHXw=; b=LjUXx5KersmeXRjgqaLUEbuvxPj/RXUbPf28Dto20gRUdLx5VfhC7GJMZrkV7+rmFO oCKQX2V06KbDfqr8lMwqA2Y+ECePKo1EAM3AOG84HRYLqQPgYXu4fBf10pkhV/Q6rzWP Bdu32UcimGrwn5hGSQ473QzpgED5HlSSvzENtHKdY7W8NF1IcLVjym6Tbe+XtRK10Wkm mu3TVkYZIW7xYg6+MC1C3M9pGc7tUNT1yB48bEPKgD8hyLH4BbEbEfHbTLVTu3y66Yer PNNJ28B47F6DaN9fOQyY0oVl/pzZmRQos7DsselfWxA4h7c44Nh54ynblIihUnqbhlHm ONKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866627; x=1726471427; 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=+nCNoGwTwkgct22qV08RLoPjiywczH5fgjahOYpVHXw=; b=vg7SjJWFFK+4v1Xg9IdNSwK1YpHItGwn7jTwvIytTlDX/qtl4HZBKYnuC68q8i/3qY fzd5c+BnHuiAMYdi/aIkan+Ouwj1668Xh4h3zGBdWrgOkg5aWCeBosrEelyH++X5lj90 eabRIbEiVNK5e0ZX5SCBlpdk8HoFfIPEa91ANAt946uznTK/3wvoOZIoiQMoPZmtCFZY lrDIj/y5I2N02I83rDCvNGzB38nQ6XZ9wO9YBHQWFIT1F0TxEwg5R82M6qjWC7McoC4W CE155y++ZXkOhDIKnA4BJDMkHUbpARTqiBxFgaiLe8Kw7YMfKrKmNTiBerRnZ2l1qCR9 wD2Q== X-Forwarded-Encrypted: i=1; AJvYcCUfCVrwgtfHZ2ePv3GbQYFJQ53L4Z6jcW3RJGdrKQuc6KPp5S0y+VEw3/IvSdGSGwgHjlQgyKyMX2jZWhA=@vger.kernel.org, AJvYcCXBX7iKY4oCWD+6O+AxDEZDxMAECm+2Qz8p+/aDiWdyT6NtBWCxjl9VfJylGGqJJu/jRC9xYyeS@vger.kernel.org X-Gm-Message-State: AOJu0YwuqMfSk9Pq/C86SlJ/UwP1acdFlGLTN5nB7UdtaDHLR0gq8J5E usIHy7bzmC8UDvSe+Vso5lfoUOng7RcMAZxMoy1VJylYJd/f6v1b X-Google-Smtp-Source: AGHT+IEVrkVnXiVYVzYylENqz9nbU231rKDlGeDVy6ZBMbC739zd80S44W3EKcuAPsVu2KxOICIwLw== X-Received: by 2002:a05:6a00:a0e:b0:717:85a4:c7a1 with SMTP id d2e1a72fcca58-718d5f2fca0mr9273202b3a.27.1725866627029; Mon, 09 Sep 2024 00:23:47 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23:46 -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 v3 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Date: Mon, 9 Sep 2024 15:16:49 +0800 Message-Id: <20240909071652.3349294-10-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace kfree_skb/dev_kfree_skb with kfree_skb_reason in vxlan_xmit_one. No drop reasons are introduced in this commit. The only concern of mine is replacing dev_kfree_skb with kfree_skb_reason. The dev_kfree_skb is equal to consume_skb, and I'm not sure if we can change it to kfree_skb here. In my option, the skb is "dropped" here, isn't it? Signed-off-by: Menglong Dong --- drivers/net/vxlan/vxlan_core.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 6f35448fbf3c..78e4a78a94f0 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 =3D false; bool xnet =3D !net_eq(vxlan->net, dev_net(vxlan->dev)); + enum skb_drop_reason reason; bool no_eth_encap; __be32 vni =3D 0; =20 no_eth_encap =3D flags & VXLAN_F_GPE && skb->protocol !=3D htons(ETH_P_TE= B); - if (!skb_vlan_inet_prepare(skb, no_eth_encap)) + reason =3D skb_vlan_inet_prepare_reason(skb, no_eth_encap); + if (reason) goto drop; =20 + reason =3D SKB_DROP_REASON_NOT_SPECIFIED; old_iph =3D ip_hdr(skb); =20 info =3D skb_tunnel_info(skb); @@ -2484,6 +2487,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_d= evice *dev, tos, use_cache ? dst_cache : NULL); if (IS_ERR(rt)) { err =3D PTR_ERR(rt); + reason =3D SKB_DROP_REASON_IP_OUTNOROUTES; goto tx_error; } =20 @@ -2535,8 +2539,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_= device *dev, ttl =3D ttl ? : ip4_dst_hoplimit(&rt->dst); err =3D vxlan_build_skb(skb, ndst, sizeof(struct iphdr), vni, md, flags, udp_sum); - if (err < 0) + if (err < 0) { + reason =3D SKB_DROP_REASON_NOMEM; goto tx_error; + } =20 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_d= evice *dev, if (IS_ERR(ndst)) { err =3D PTR_ERR(ndst); ndst =3D NULL; + reason =3D SKB_DROP_REASON_IP_OUTNOROUTES; goto tx_error; } =20 @@ -2596,8 +2603,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_= device *dev, skb_scrub_packet(skb, xnet); err =3D vxlan_build_skb(skb, ndst, sizeof(struct ipv6hdr), vni, md, flags, udp_sum); - if (err < 0) + if (err < 0) { + reason =3D SKB_DROP_REASON_NOMEM; goto tx_error; + } =20 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_d= evice *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; =20 tx_error: @@ -2624,7 +2633,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_d= evice *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); } =20 static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev, --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.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 CC1D51B1401; Mon, 9 Sep 2024 07:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866634; cv=none; b=aVGwE3MiBnXkkVrig1kUPmfT4X1Sm7Zj5dM4eovvSejOmHaKuySAt3GQAb1RvKaGSlQrk96g2J66DJuLLtTXeg+9MTu6K2TuXHo26bmgqfBrJou3Ek9/m9h72Kg8IyOXo+I4Ih2jt1lhl0qD1sjubxBK2E7r3DW5dhRsKjVkzHE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866634; c=relaxed/simple; bh=Rr9RB6rPx8aBSG8JDHsFKgYqTcV7ecNiXdCKNntRjb0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ow0WDvzZQfJyMorG1VNYvVZnc2iymdbeqAprAQlg6mXAzmTaATO2sp9mUnyg96FhrxvHkDsQNokzgGrVSepB4oa4gAGW+RtfI7fAvlmThQKpASXiY9ZHuaIqhhYy+IFA05qYhPkO1H9hqcrwvbrj0BFSjy8exNPjBtIcnNLT4bc= 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=IOjCnDT0; arc=none smtp.client-ip=209.85.210.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="IOjCnDT0" Received: by mail-ot1-f68.google.com with SMTP id 46e09a7af769-710d77380cdso1165598a34.0; Mon, 09 Sep 2024 00:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866632; x=1726471432; 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=V/KxcFdkO/q8G/4oZRDXYZwcy84T8+3My1pCNg8ZJ14=; b=IOjCnDT0uhJU3cbbN5MeZ1qf7b8+XsKetIKgv5b3kcEUkfV8KC0zKZmN+tvHu88Og2 uBifp0Fk0Sf9ef4fTG3DedhH3/Wjabxt5RQyNO4lvOXsS4ja8ma4wvEPlf7kjln2mFNe ebcUsBTPrpte2+aH793GH+MXJnLjfCyBKo8aiCTPfx4RcmzNsP1REWMpJMjNwR1FEa5q fezsK7bg1xPWY3p896foRupEgghiLvhrtG8cZ260CtMs1TjU3nxBKGtv43+uIKH/jcQ2 GmxnfQD1klIb9qA6sm6uWJ+kN5E2uaZBpVP6y7mmZM79Ak1sSB0DC1+Y4ujMOt7cWvN+ b0GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866632; x=1726471432; 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=V/KxcFdkO/q8G/4oZRDXYZwcy84T8+3My1pCNg8ZJ14=; b=FtPB0gKpdK5cSCDA4WwrWrThxKvBrYTXUR7c0velvOXVkcc4tGlJa5i52qgnt0Kc2w objPWYEZZGLpqZzYos+nd1pqng8YNKZPSKplSVPRP1VRW9WWJhgyzd7hrp0n9iPxtTUQ p+SkwubeUbSpnlpZE2MOKNZVYvaVtKC2DhEXjd1wsFe7+lk7/cV20xvuC1vu7HaGPmdL LGfcBJv9mJYoCa3uY5buDB0SWDXT4pqcF5J1H1BQka6LV5Wq5NzCd4dOmoUOTzwFOUv4 RPE04DSglEZ7owvX6F4PfjNYzRoQsRVF4pXbuq79bGiN6htvZR0SNVPepTqh5HL3IS2P ZJfA== X-Forwarded-Encrypted: i=1; AJvYcCW3T4z7loo8hKSyI4xElf7XXwzRcm3C4ryP5nEY+F5jQwc9tdPH+Fvp2lViJnlhvMEohxA0RGIT@vger.kernel.org, AJvYcCXJi7Cmo++FhHflTaLt9daTtFHuTZAl/2h0Dr08gN0EjQdJ1UhT/eR/uyIRyRTFvJSjr7ZR7uTAWu505TQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyiQQ+m9Wk0Vr50YWnGn2Dw+ERTgMPC1ZUh0Zjl4cQQStLQMgnq ln0NY05hbkpMUqUn+qaWIXbhYcLZDlkjXdFePr3/svtN5T8z/kn/ X-Google-Smtp-Source: AGHT+IHxg8+zPAIuvGRLoN8oXLZ67VrBN/PDnzZCbR1frQinlKZsWvlqhilE0JHvpdTBU3tlJyNh8w== X-Received: by 2002:a05:6358:7623:b0:1b5:f95a:5a6c with SMTP id e5c5f4694b2df-1b8386e0c35mr1183317555d.20.1725866631762; Mon, 09 Sep 2024 00:23:51 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23:51 -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 v3 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit() Date: Mon, 9 Sep 2024 15:16:50 +0800 Message-Id: <20240909071652.3349294-11-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace kfree_skb() with kfree_skb_reason() in vxlan_mdb_xmit. No drop reaons are introduced in this commit. Signed-off-by: Menglong Dong --- drivers/net/vxlan/vxlan_mdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_mdb.c b/drivers/net/vxlan/vxlan_mdb.c index 60eb95a06d55..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); =20 return NETDEV_TX_OK; } --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-oo1-f66.google.com (mail-oo1-f66.google.com [209.85.161.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 4994B1B3735; Mon, 9 Sep 2024 07:23:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866638; cv=none; b=FgBx1o8YrkfOc68bkh8rJTyLrIUSLwmNyPml/iHf96tJ3DjteE0x0r8PVj71f5CpnUBkXjR1E9ktAi7iCWMfbaWcawVucQCIanFJP+yxvU6GZ5uduyU2LT4ndEcn3M6RRH8L4Lfc1Jsyt+neyBqV/0kc46XAYFxXgc6JA5kUpXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866638; c=relaxed/simple; bh=toj+Zj8YiksPTFP9u5LTXtJP7WTuLxp85UOH9c3IsJ4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h0w28da9WVh2cRB4WLgdB7CbkBPo8fii5DWWJ1MSyfSVAoSwcYTrHov04L46TXMZF+8Se0CXwd9CSxsN+e1oBqhIvg3SVbB4dXlDyCTpSK6yKzfmzQnBKSE44D33lB1Qiah7jNK5slUtME+un80YUd1rnSKXdCxBquEkjiQqONs= 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=cqgNyitc; arc=none smtp.client-ip=209.85.161.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="cqgNyitc" Received: by mail-oo1-f66.google.com with SMTP id 006d021491bc7-5e1c65eb5bbso704324eaf.1; Mon, 09 Sep 2024 00:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866636; x=1726471436; 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=jgqtJYbnjGs/2r/XECSuJ/EOdpL7pDrQy8nnT8uk/o4=; b=cqgNyitctuYKs69BjXnP4464CqOL3Fii7FXzrUVU+1X1HF++rHOHj42kfmiBNVz3Rs zX6qtgJ7kR3DRDGB3raOBz53LpkJSTSIaMy3vG7V9Jpe/1ojYK0u38upDEhwfN+K2/8v HEQsmUHKtCNIA7HMO0rD8JiXHN0s4PiVPf1npBIPuobB7/UtxQ9kVq/pPX4k6s06AT5R +n6mQB2DbioDOs8eS+YAmhagEueRXvMkb5c/eTAwlF0Bl2ZBL6Eh9RDKbkfefQbrEcYJ LP/Vp3mzG8v5m17uQ/D+BrxNFZxhbIOR6aQ8RYYPLVQ26aBuI4a4SS9DMECYeE4RX2+5 3asQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866636; x=1726471436; 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=jgqtJYbnjGs/2r/XECSuJ/EOdpL7pDrQy8nnT8uk/o4=; b=TBJWNyLtUdVgWqE/Z+mf9fn6uQ8LbekJTpvrTvoFkRTJgoihUv8U9bD4pswVS1DYuI r/V4JPbI/VrZmyYUaY6/HSEHqzcm0szp6f+SbfEc5WKgSfbAFMnuYCbMRZ0Yw3mOzOIq bKRd3O5odnYTytTNdVGbHaPXNsWn97kiQti3l3Q/2ppu+qmy707qE6FCu39+SPIVrEOJ MXRGw8fLeJs2VaCvkMyOyuG5w9edOq1+DQN7ri6PukAgkMusndxfPVyMSsG+fo5iPBdZ zyRAqbSX/Oiw/hwRJiTU8AkRI5rTxUMEmWijenEWIb4T7fn2SyMEEpXkU9S/v0Os3e0I Wzaw== X-Forwarded-Encrypted: i=1; AJvYcCU8PdZhVXRTsM00Fyz5OzOmoVDJAAlGyacusI1wvXEDhaIcfqOFhDutPDEzaAQoUmWo1OzxRzxf@vger.kernel.org, AJvYcCUGfifwjKHgouVGwN3PhCxUmosK1OGCgfDo08xPb/8FoBflZC6LcEIOACbiHXUD4aboMYe3A7vyzTDWEFk=@vger.kernel.org X-Gm-Message-State: AOJu0YxYd7WnK2KiU8ebMDlgsd+22OzlahZplSUq8eFhRNqI1dtnzpGY 2sSCKQkdre7R2byuOp8ylHVbzTLkQd/L/SQWERn8OXAsqHrzvYvd X-Google-Smtp-Source: AGHT+IENdfs1+2atwumCxfhREmOidOulsOVXV2bYz8Sd43xh93QvdzUxxqpYXCxI8qBRsgWGG6I7VQ== X-Received: by 2002:a05:6870:9629:b0:277:caf7:3631 with SMTP id 586e51a60fabf-27b9d92a835mr3095911fac.5.1725866636353; Mon, 09 Sep 2024 00:23:56 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:23: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 v3 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass() Date: Mon, 9 Sep 2024 15:16:51 +0800 Message-Id: <20240909071652.3349294-12-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Replace kfree_skb with kfree_skb_reason in vxlan_encap_bypass, and no new skb drop reason is added in this commit. Signed-off-by: Menglong Dong --- drivers/net/vxlan/vxlan_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 78e4a78a94f0..96afbb262ab6 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, s= truct vxlan_dev *src_vxlan, rcu_read_lock(); dev =3D skb->dev; if (unlikely(!(dev->flags & IFF_UP))) { - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_DEV_READY); goto drop; } =20 --=20 2.39.2 From nobody Sat Nov 30 16:19:58 2024 Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C1751B3735; Mon, 9 Sep 2024 07:24:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866643; cv=none; b=if0eCbDw4ki4U+lwC20pUusFPQYN7m5xc+BwDZnCDPCUcp626yITwlBg3TTWcyDSbCm12yk5dRuckMbgJmuLCIdXAfocOepkgvMpWx1Acy32Vc3QtVSEDbMinqZrnlsmG0MW3nxCZzAFIv/pIqmOtSTTI83JFceLMz0Qhaut4NY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725866643; c=relaxed/simple; bh=jiF6CyhLka73EUOdLzXLuUlOl0s0Weqg1Sd3NCize58=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Hy1jp2c5qSC1sT8m3IvoXyG81hc0exHHHnwFN8RDL+EnGYOBDrpt/iK6jn/LAJC5aay8dtudfXZWbHcAyXH6VaetKLkY469ibPYAfGDq39T/XdFN9dGHCDCx/qKH49TUPtGh8fpDr1XFrBfi8R1Vq0W3g0kpl9QfN1h5vF3olrY= 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=jrCNGhBs; arc=none smtp.client-ip=209.85.210.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jrCNGhBs" Received: by mail-pf1-f194.google.com with SMTP id d2e1a72fcca58-71798a15ce5so2392453b3a.0; Mon, 09 Sep 2024 00:24:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725866641; x=1726471441; 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=otE1G91dyHMa4xtnfM+kI4eXxOz0ijl9lZp21TWYDmA=; b=jrCNGhBszKSqp2QK3i+J9glQt2PLN00ctYpJMS4+8TJF4SXVYxGUSxQzBYxQ0GITVD EzPlS9u9zU0JoA3mQ5/r2sYj8rYdlE+KOEVQCIi5s3GFJn/8tQCll7Z39/mQLaxF6fCr 89vB7OVCYquv6Zu9bxEjl6xm22vxkoMG6Mu7k7fhqMFEzCu0cQNZ8G8p033sG28RzmyI TLk7zbDS1WE6QKoljZjNhYoxlazk0R2oC7QAai46cDIhytNZtpHjPbbtvKCvxaApUq4B wrG6H25PI+pdPifz9q4DYgG7J6QQSshRUcnTIQraaDs1FOczxehg201cHx80shYNPY9v L8/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725866641; x=1726471441; 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=otE1G91dyHMa4xtnfM+kI4eXxOz0ijl9lZp21TWYDmA=; b=Og4PDLcbbZ9d9ULnbaBf62CSvzFSHXInclqq21nQ/zKUmk1hno6pwxYKvmRc2SZYJf yaLRyiH4UJogeNfpqlZ6kT4ydwl5yaV7ZxPZ76VBD45XpqKCAOYcVVjevT5J48BwSvu1 DIywoNxPzaMvbguQ22pUGLNhP2pjOd8oRJqSUI00y38J+2077dFwvxddqhDvsZlkUwk/ I6trPcvCyk47p+g+kbVkKENOaWSupgqF2pFWU/MDRgjQ5NYcLQRg+6tnUHKv0jzZQot/ mj3dx1A1+m4z57NfQRan7Ohmep1HYE9m8AyqDIA3JZaM7solCrRVqO8g+aRNw6xqTRwJ EbxQ== X-Forwarded-Encrypted: i=1; AJvYcCWX4hAQA6EVH+MxT1ypG6m6J3EjJ97T4JAN0qXs3RirT1JbmBd4/mkkEw6XzH8QgYzZgXGJFFsr@vger.kernel.org, AJvYcCXMGDBVHEE+QcIzkmSZRhIkxkUr5XJzgcofkNBkMvv2Y+ZeIv6ymXVisEFKT68LacW/0rREPHHS9tOrRgI=@vger.kernel.org X-Gm-Message-State: AOJu0YzPE2fSRdODPfmESzfLMnKIwnOwSwYgoMLY/oAPNZMJ7EsOm3OM AdM/sNl8molAvprdfK7At4BO8VJvP6A3bg+ozVVJAaLI4OqRcJsx X-Google-Smtp-Source: AGHT+IF9OzXb53y6BQ6KJT9aZMh959GCMp82oKXHRCNaPLq7vK+/5XzXhDFOWY9kTmLyZvP0nCpvzg== X-Received: by 2002:a05:6a00:4f84:b0:70d:26cd:9741 with SMTP id d2e1a72fcca58-718d560aca0mr15979300b3a.12.1725866641373; Mon, 09 Sep 2024 00:24:01 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-718e58965bdsm2962094b3a.29.2024.09.09.00.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 00:24:00 -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 v3 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local() Date: Mon, 9 Sep 2024 15:16:52 +0800 Message-Id: <20240909071652.3349294-13-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240909071652.3349294-1-dongml2@chinatelecom.cn> References: <20240909071652.3349294-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 96afbb262ab6..554dbb65a209 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); =20 return -ENOENT; } --=20 2.39.2