From patchwork Tue Oct 1 07:32:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817581 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 A458C21373; Tue, 1 Oct 2024 07:34:45 +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=1727768087; cv=none; b=OTtkxr85Aom2Uq3yZ8Jou2NRywG7JzpG7OSS4V+MQsGmjhBYpr4ApJP2MtJ6xRC6hnBjOcEgg9GcM1by3J2500uk9elulyawr+q3Wz5Ly9m+/+802/IxfXgbKgjNaD2MHSyBJtDGeHks8KR7kY8jdeNMtIAsHvN9ddChfDJRmK4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768087; c=relaxed/simple; bh=JBRdn6lcWQQqA+78Zj5tgLu0QHhEr7otA+mjf1g+Jaw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HMWk341Z1MUE6TwpAS3IFe8QkbEJMkP+4acNVIJRTJ74qHSHa0PVrHXUFPSAfftnl4dBDI0VHRcYAjteQoDzyAn4o1+T0T/HvanLWu9fyyqHy7pw7Re6YW1nstFLEkFakxon3Yc2vjwkd4Zu3XxeWERnNv3X6Txwwc81aZJvK1M= 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=l/wtiZN0; 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="l/wtiZN0" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-20b93887decso14230035ad.3; Tue, 01 Oct 2024 00:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768085; x=1728372885; 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=fmrCBAr6gJsJ0RdHov3Wc0QJ/uFtz7BMKr05A4sbzbQ=; b=l/wtiZN0LRjMSiBTMx4y1yZHlcaqmEOAopWJpvhq4z2rOoa//4EgjptV+5b5Bf2NS7 Fo8BY4t0QpLq8DTfrFPeDWfiwhuOGFdSA6E+qz0QjXrRjKbfo4DFONjNxbaPE2mrg6MG i0rmTtNLYO3+IfsX5EmlF9xyE6Mj7+Cz/uqAXKTSNPzDCsNU5x2hz7l1gC5kfuVt5I30 1K+HSj6Q8C3SqCR7LAHMOmMF8UgzQKORgm1f+Du5J0TB0X2b9xmkAdSUUE76G0d3JBVf zUAVVRiUqJMGHbIBCBVxW044aMFJMzBhhjvhzgr6U2YwVU4O4QH6HdWRz7JzIsokH/fc OCXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768085; x=1728372885; 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=fmrCBAr6gJsJ0RdHov3Wc0QJ/uFtz7BMKr05A4sbzbQ=; b=cu0kEv2U4Q63MQtCh7y76QKMzJn5yYha/QH0vqQbruJVWBVqmQfnUTG+sZ2FBe8VsW jJTkP4PLY94Um7mqpr90EdWnS2If/KxhATSpT+sR+i0P8jpe5ODqgStrWiKPz3RYryQ5 7pJBlY5lqnkcWZWe6ad/mfrV5+vr18LCLgT16Cqek87hhG9jYrLeFePI89BhidCW7mYU /bESwXk04IZw1iz18VOtnDP/cbruCPs+5L1kRoYsIKEzktNFKZ7Z30erDpq9VH4vfqMs 3cooNJRZfT+/2YdZNpR4tpLfj+/QykT/ZUJRoc52BD5lUh4scFZbZQ+9KUZsTXfU5N2Q V/Iw== X-Forwarded-Encrypted: i=1; AJvYcCWj/Ce+EJrlEXD8+UoSJKqrG7ulJXa54TrfVM3nExAberYLO4kR2ym26DV97YJgstgbzy31r7CIf9Q8/Es=@vger.kernel.org, AJvYcCXHTt+5rC8yIIdNwPYSmGTx3udzXY0Fh2j48/92mL555dIaoAhdQ/0bd67NHunZi3aZXtL4l5VN@vger.kernel.org X-Gm-Message-State: AOJu0YyGSl2Zwj+Im1Y2S3GEaCUICxW0SVTxWn9naVuV91/71l2NPf7j 2AD9m4FmcIoztwxRPbhGrzOLHY1CH04J1HNp4C93oACvd029R1Gj X-Google-Smtp-Source: AGHT+IGv0H5OKHw0O2/rvRLwE3zCutemhqxw8UYFTNkB9h/GTuSbwTLlFZvbx2VM6a0B4fo3awml3w== X-Received: by 2002:a17:902:ef51:b0:205:4e15:54c8 with SMTP id d9443c01a7336-20b37bd5230mr190110535ad.61.1727768084855; Tue, 01 Oct 2024 00:34:44 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:34:44 -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 v4 01/12] net: skb: add pskb_network_may_pull_reason() helper Date: Tue, 1 Oct 2024 15:32:14 +0800 Message-Id: <20241001073225.807419-2-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 1 07:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817582 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 B8ED81BD035; Tue, 1 Oct 2024 07:34:50 +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=1727768092; cv=none; b=lB9diEOuC2qgL1n++NL9odFwHKu1UcmQRDV8Cyha+Gso9lZWNemwi6CFGty9wWmYNo8a+HewpISYFHM74cjatIUMc+5S6Q9EQRdE7Foq8BTwSSiAxpXat89IqMFAXpOnrCF7vuzmhP9En0DC1I8QHajwMwdJIGNUb7L4iF3mAO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768092; c=relaxed/simple; bh=SaptGihC86tNOvUkBDgiENqfMTP1m9x077S6luvzAhY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XpMqC/5WIwSyL1/1TXGQa0XIjX5UwJOx0KPvM44Viux6ttOCNqbWtyhg10VhS6MhvwyBKWOZw4jM8mKhK2ie+j9Pv6EQIknlNC0MFU9P7J1aGIX7O0h1lwVeGbRd/qVX2vFbRcKcaZd8T/w0oovsaAW99a+JX0E7mHqa8yJEPao= 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=NXMLIMFl; 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="NXMLIMFl" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-20b7463dd89so24385015ad.2; Tue, 01 Oct 2024 00:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768090; x=1728372890; 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=ulwkzfKvIm0r01HmjWcKI2Wp5D2pvG8AiNMhaNAoG+M=; b=NXMLIMFlTitkSkokDLg/KrzCH7izE9TKAYoHp1pVM6q5gSdd5DntxOAfxyLHbyC5ZZ JJF+qLeDvFkjwGyMVSWBIlcQhNaYCvffKHUdUFcxXYTHmJswe2l4AYaVlCOfL39jYWkw VxPS75jkNNKeZE4TVUf0EjdpvMF4bSTvSxivVEJSsypaqMFO9/KBhFlFs8OK0mPbTkN9 Wi1HaF8hyfVmqHh4Jx0JbsFspKG8ol9Y+oUJ6IWJXaJiaZHStLAoLlLaf2YrPjwRClW5 u9Al6PZCRMZ+N0+ksKWeprfRVRqYKW9QUqZ0DdnfX3upAZUvoxQ7Fq+l4pj75Lzj6TL+ m9vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768090; x=1728372890; 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=ulwkzfKvIm0r01HmjWcKI2Wp5D2pvG8AiNMhaNAoG+M=; b=PkUlHbOOuuwhff30gcHRAf5RWuIZD/e093nVGhhaeaZrzJIbGn5u2p3DB099J/oJ1S A1riPmYBEu83/sisPqAEh6moZsggjFe/Z81VcvlvmPN9NDH2KClK+72J4hZEyfVpEzrH IKEQ1Q4vafldiw1S1ObAS/6lRBZufspQkeozRubImAmVDJ5+nMC4k12oVVvMScnq2B6i RBIm1QVTGpwqN7BWy3RvL/n8kK+Y0FIh/3LYtHJsQ2WXPQaaNeNH+tQxRbx99i6ojlYW svxEzrl0w8ZAZnzDObn7zCQBVpIDWh0J1ym0rzAKmrhezh/D0qXB58H4Nc4kK/f27WSN y0hw== X-Forwarded-Encrypted: i=1; AJvYcCUHD7RJXP4b9jVn/JZWi3yqGUjd1thOnYd2p3r09SI9EDNCrLlVPvjMOisUNma0YdIC30Nk+WFXeCPSSZM=@vger.kernel.org, AJvYcCUk+BEJqRKg2f7+rBct8Mwrtgdt5afnhLFAi0QBv9/y5Aj2saaIchJ3tNwhNhlLF/mDJEVX8OU5@vger.kernel.org X-Gm-Message-State: AOJu0YziH60gu1eEte8wFir0E6lrT/oGecdIlYDhhKafKuIk1kbGD4et AxfosaeInIzk6GvWT6rxluYWUFuzeF57dVR2YwKB0O0+AccVZdcv X-Google-Smtp-Source: AGHT+IH8Az7a8k5Esao0GHXTNIsZl4hGxmMm6MIGP+3XpccZGm3FQrnP+P5BbVrY1YFLsyODPbf5uA== X-Received: by 2002:a17:902:d490:b0:20b:93be:a2b5 with SMTP id d9443c01a7336-20b93bea53bmr65337445ad.32.1727768090286; Tue, 01 Oct 2024 00:34:50 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:34:49 -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 v4 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper Date: Tue, 1 Oct 2024 15:32:15 +0800 Message-Id: <20241001073225.807419-3-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 1 07:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817583 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 0379A1BD035; Tue, 1 Oct 2024 07:34:55 +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=1727768097; cv=none; b=Ilofymrp3kqEUuCHt4MZJ6ODuFC0fTZ64u5VSPeAUy9F2vBpPdZtpN8sT43J87rVz0arM6VfvIEd5z5VyWSilo8YJconphakmM7poPke3ueYZgAVtdO/wWYMEIqUzwUkr8FvUhb08Tz62CwYBx7oruKhNsqxUFobbQihvENhiDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768097; c=relaxed/simple; bh=2kAxEGjit4mtFH9V00w/Gm2iNB6oUkSEyEwW+ddERcw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SHAOvQf+cKEwDbAfoPTHccQDe94arwTth8ANvAFQdQpgtWAU8w6uaIpR5nhLx3zivEqujuVYn6Q8RY6GhXNRpBJhgkNFpBZmUAOXMUCBvnkJipSEXpHgYvMW7YpomY5FnTAutPy6QHBHSM+OQg4Wl90aZnu6qHjYeIlXChaed9I= 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=R4yHDFsv; 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="R4yHDFsv" Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-20b49ee353cso35397145ad.2; Tue, 01 Oct 2024 00:34:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768095; x=1728372895; 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=cSsuSiiaj61uz7pRDUrPYhLqMHKa4jcQjUBCHvJMqsI=; b=R4yHDFsvHhaT5SesfCiKoWIyaz/kbNn3f7JhaxQQnMUzxDuz+miB2eJOykmbiWjRqG /8X70GdSSO7sqfb6sp95qAnY9a8PkbLO5t9zyzxiW6bMsNO9ZU2kv8slYoyNG+qkm9g0 KWzOagJVGS5g5BqwjbGJ4W+4m4TS1sKSi55ojQCQvDxd6KLuI0FVeSVwB3p+BUtUU46T D/B+KLIyKAfpfDfuaUWx+RIeltroWtCYQAEMBHI2F3WFcz94h26KxYL5y+bVNXsAoxNq CBhM1uUxmcY6UgSFjtwmZTBa+JrT/crhQVudxNsY3ccNbps2BbTklX+GnUJDtWCMGY7u 6pVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768095; x=1728372895; 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=cSsuSiiaj61uz7pRDUrPYhLqMHKa4jcQjUBCHvJMqsI=; b=Q26afonJVBTt56Df9uU6gSdlFj/YrPsBpDuiVoneCQVQiUjDhYX7Zt6LpyKO9Vxdbj e+XKpn8sHVJr3BpKXMwXQC0RFMLVZ9Yl2HXFonVs1Mjd1GwqV4MgBmAsmuMRK9YZKbbl ahrLYhH7wApzv/lQK/WT6k1S2AtqoUwAl8nSsd1n1UBxlnAXHa8IQ3KVFjDE8qZZSJii p9o6yiD25TYzNYMVeXgCXa+arJqDN9JzijCLy+C14LlWfuf2TV0zUJyxeGXZQEOSm3nw Yi63OMxkUqEQWSkjekpByZ1ChiwXS5LFfKaZMPTKL5D+cklJbkdRvcSWWGOjB0ogWM5G k1kw== X-Forwarded-Encrypted: i=1; AJvYcCUp0XkOYmrQLh5LbV1joIADwHIELiL+KqfrgEg8OVCd+EiQzH7moB5HNR5fjJx2LiPf/FIMdYVU7p05H4g=@vger.kernel.org, AJvYcCWCgsuupE34nEp6GuxDIwCZk/VIWrl6cZNTShKW29LNT+YDX/t8WLusFvhgK7HLzi5YdKI/igeV@vger.kernel.org X-Gm-Message-State: AOJu0Yyevrb71FRJ+ki9rY/G0iU4a9HHmOoqass9hqtA2hfgZYKQTja+ Q3qkuHz1SxwFW1tzOv9Tft8sg4mmoCfhlYfOPxdCTZt8RGO0n3mS X-Google-Smtp-Source: AGHT+IFt89okGzSxlu3iPI8mycwt8wE6y2TvpVmjZcrm2u4AUAQ1j2Q286OoKFk7Yk5scsf5X61gVQ== X-Received: by 2002:a17:902:c94a:b0:20b:9b07:7779 with SMTP id d9443c01a7336-20b9b077929mr70517835ad.15.1727768095207; Tue, 01 Oct 2024 00:34:55 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.34.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:34:54 -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 v4 03/12] net: tunnel: add skb_vlan_inet_prepare_reason() helper Date: Tue, 1 Oct 2024 15:32:16 +0800 Message-Id: <20241001073225.807419-4-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Introduce the function skb_vlan_inet_prepare_reason() and make skb_vlan_inet_prepare an inline call to it. The drop reasons of it just come from pskb_may_pull_reason. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- 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) == SKB_NOT_DROPPED_YET; } -/* Variant of pskb_inet_may_pull(). +/* Variant of pskb_inet_may_pull_reason(). */ -static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, - bool inner_proto_inherit) +static inline enum skb_drop_reason +skb_vlan_inet_prepare_reason(struct sk_buff *skb, bool inner_proto_inherit) { int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN; __be16 type = skb->protocol; + enum skb_drop_reason reason; /* Essentially this is skb_protocol(skb, true) * And we get MAC len. @@ -492,11 +493,20 @@ static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, /* For ETH_P_IPV6/ETH_P_IP we make sure to pull * a base network header in skb->head. */ - if (!pskb_may_pull(skb, maclen + nhlen)) - return false; + reason = pskb_may_pull_reason(skb, maclen + nhlen); + if (reason) + return reason; skb_set_network_header(skb, maclen); - return true; + + return SKB_NOT_DROPPED_YET; +} + +static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, + bool inner_proto_inherit) +{ + return skb_vlan_inet_prepare_reason(skb, inner_proto_inherit) == + SKB_NOT_DROPPED_YET; } static inline int ip_encap_hlen(struct ip_tunnel_encap *e) From patchwork Tue Oct 1 07:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817584 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 AB79E1BD035; Tue, 1 Oct 2024 07:35:01 +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=1727768103; cv=none; b=Ly6FuJ+0AFXRNe6U7FYrfd7GHkqQDFEzhICH4tXFlnPsSKvNE11nN2Jrnq6GFZB4YCPTyqqb7q5PkgHIdShAtTskNM71OqAtFjEHvsHYmqBJ063JhMWLVODc7eiJRPSNbHNOFe5Tih9JEiow8usGDM6RhxA5D3JUarVY4PHXd88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768103; c=relaxed/simple; bh=LHjrFsENDzImAMlLbJXgCPkwV+GY8wu50+WIKjPLPBA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NRwMtV0GIiwTaAbu5uKeN6MfEHAKxBvBeQHck0s0wn3YAgZVapyhsYa1DznzrR+mRqDLc2gaKZ0FFn7iDqF+PO0YjUSHoivdsHtz+d+/muP/Mp3uaiIeY9QFLM4V+bHmebZ/6jZT30aFpkOxtgnpr15YntWKxJxHDHbAMmwTB/Q= 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=cWBu/oH7; 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="cWBu/oH7" Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-20b6458ee37so31715845ad.1; Tue, 01 Oct 2024 00:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768101; x=1728372901; 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=fV5t/4F28NBF1vanp0Nr10+/6g51hEg6HDIVD4nVz0g=; b=cWBu/oH7b8ZkeJ/H0N/RoE2ID3bMZHr1A4lEzPtl+Ywn/F75SnBA82dnZCIDFVKRTD Y8T4ATge6opRF/YECbdvu1c9dqnzpvSPzxjfV+AR3Ulk/X8/SwZ+uvq4mD5geCQ6GFo4 xvvZd84QJYjvPryMhXmppwD+/A7PMrRR3mvFZPcUREKE0eGuUDWNYYjQa1T7BlzAwGUb zXPCcLMEB3hv4i+oKCzIPYpsAKiQAQQreFAr0rjB8bLRVZ2m+dgpSYkAOvknlBjK/qd0 J/khi4wwzhc87/3qLu3yfe702ZGIuY6DOeIlE0+lp17uKfEhSYjj4M4L+OSLVNvmQ3c6 M0JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768101; x=1728372901; 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=fV5t/4F28NBF1vanp0Nr10+/6g51hEg6HDIVD4nVz0g=; b=RrL49I3DajQ0jESrrPmCw9BSG+40GG7w860EHSvfml67MSvEWf+UZZmQzYxq89Elpd zX47V6hWYcOFNV3crSlHU/BytnuYI8daX1cJ1RxRYWrd8EK4BDZXkBQRo8R79n3sU7uP jjIxUVt/yezBZ/t7+5VMsHVCBTBtuQb7ouA8FnswaDw7NG3aZX8HADPIUS/U0C7EBkRL gn4M6sO8/QUYIMybjCnS6MvEoPd3Q5TGCUshVFCSRJN7U51TZq4M5Wz1XfQojWRdJxkN y7wdRfH0MKyVKlD0x3G3xTLOtL/lFaxVPNtRUziCJcbtvZyZhQktQvRZTy2e9aCctuv+ 2f3Q== X-Forwarded-Encrypted: i=1; AJvYcCU/5aeezr9V2XcOiKSqqNqbkYHg5v8th+YircDCS5VODb7SA/H+kPwugQqtjJrF/pVjbZD6E5bqHuyEoYs=@vger.kernel.org, AJvYcCXPQOPnNbJXOlpbOkLy0MlyFe6VUtuaFJPjYo6SMHTslwOAm6qYAdfWGuxWFqqbqP61iUhwrra4@vger.kernel.org X-Gm-Message-State: AOJu0YwSZ9fQi7hOyKDVendHhrqGUWIlFMIlaOzBLzlYUzX0DXuk0vIs vT1eecuggd/Zm4y4CYr6rZPPXDPRUUlTm43AAhHOUszzEU0iuiyy X-Google-Smtp-Source: AGHT+IHTbeRbLLeiETPaSestlxNuWwZMK1fU3X+yqy/e1gHPFdB2ZikcwhJwMyQ98n7HLwskJ1T+KQ== X-Received: by 2002:a17:903:230c:b0:20b:a9b2:b560 with SMTP id d9443c01a7336-20ba9b2b832mr36404425ad.6.1727768100901; Tue, 01 Oct 2024 00:35:00 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35: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 v4 04/12] net: vxlan: add skb drop reasons to vxlan_rcv() Date: Tue, 1 Oct 2024 15:32:17 +0800 Message-Id: <20241001073225.807419-5-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 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_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 1 07:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817585 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 B25D61BE257; Tue, 1 Oct 2024 07:35:07 +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=1727768109; cv=none; b=lSj+zp7efMYLpM24RFoqx/fqXryc0SffHMIXV1Ds0PE0Xyjsr5HRPmXuLPhHTrG0iyMWfcWLqrIC9QYLrAuIzJHht1oipu7ezZAzPiIXaozDOHdWX0hKouIM8IDNCbvNIb+e3fyauEXjXefwBLOEGqmDvGiPn7hp0LoD9Xsnh2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768109; c=relaxed/simple; bh=jsm8UzYJHtyzr0fmZQYa5FxmxIg6wgcjb9tBJoBw7hw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YgEV94e/gXCuOy6Vq2QprfYjKntY7qrxyQjwU9Eu39d3UM98PY+fghrNI2oA9LQDT3tQuXZF2N9Jd7XbaH5i6asN7aVijvBPFtGPyiy+pYxwxV7OKF6pUnwJoHtxOAWZlZ86LkWQUz6DcY7W1fdSIRvRLNzxedDPvt/55vAYKF8= 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=HkCP6Ddu; 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="HkCP6Ddu" Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-20b7259be6fso23189895ad.0; Tue, 01 Oct 2024 00:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768107; x=1728372907; 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=ObqaWI+h/lvogCrzNiugI15D5VX0ZGVlhesl4HFROZ0=; b=HkCP6DduUYYFo4Bo5W1Brz0wwwRaBV2JMzLHpxs7yPGXFdguNTFjMF/RMbb7K1+/FC OeRtpvewaCZdVD00a4nIlPN9/DXbrcfoYHPJWtNSUJRPNihj0HSNsO5EJ/A8sfPaBUsq V35bGaqWoPWRJBrW/UyvgrjOf1fzEdhjR+M7Thy5JDk6WR8Y/aNVXCOUjEvYQvOm+3sF ImB6JvIvqLHF71OeVRLuBvY7Q4ccQyAUIpOyGCpD2jODW9r8+tWLMeXjLsn6k6l1jltV XPuVxXZSRtMy5o00UgK93x7kfx2Q8U1Ecu4vES9YInxb7fSX2wKFIE/AnXkB8fiBDf7E bMNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768107; x=1728372907; 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=ObqaWI+h/lvogCrzNiugI15D5VX0ZGVlhesl4HFROZ0=; b=OUWZkXOCRcE7XOjQUtyNfbBsm6VeuLj5GreJ02l61YGFIOu6YXVRuyKHPVEQ2FsYLu so5Va8539dIac0fNrU0OCRB5Jk3xZy8T3k0LCqmxTj09KXGaLveBo06gRRYVDNPLzsCD S4Cz5D1plhWJRXl5uHWCLXU0/5WBxflSbjSt99PBIv3+W3mLcCGnDoEeqjiixfMoZNow 9CfgX+VWN2SxNHcTp6ODXiLWVq8CzfhR2AI8DC9q70jH8Js7C2rsGWkTQqwjx+7Vy7ad vYZqW78+Mgz+WKON/1PptZ95OXf0GetfB0LNdINkhOOZE8MvEGZPY1nHdgDR0K9pPztm 4lcA== X-Forwarded-Encrypted: i=1; AJvYcCUMbkRQUX++G0bsO8CcFEEOOq7afy/NAoI2hIHjpDO8G1ozzM5T0TJw7rYML1l3y9i/dxFcAwdl@vger.kernel.org, AJvYcCWhFCi/BbzR3qtwKg6+dpHRES98pyIYCi+WiXQxjA9OT4bTo9NHIUorCof6M5BRzlqgWcWUXdkAMsGAUrI=@vger.kernel.org X-Gm-Message-State: AOJu0YyCldOgMDR0/XcrplOhPJfQUzESy0FPmd4PLeWuXC+jORgJbJ3+ 3bo0bmX9EHmbM29CVDAkC55WvD9PgJRf24FOVrHrdk4NHNjRVIIn X-Google-Smtp-Source: AGHT+IE3q0Cj/fQSVHCHTYAIOHNlX97jEHV8+fJh4tfhENnwQ6rdgLLchY0qxZC7U8JD0cUZyJy7jw== X-Received: by 2002:a17:902:c403:b0:20b:4d4c:43e with SMTP id d9443c01a7336-20b4d4c057emr184733655ad.15.1727768106946; Tue, 01 Oct 2024 00:35:06 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35: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 v4 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Date: Tue, 1 Oct 2024 15:32:18 +0800 Message-Id: <20241001073225.807419-6-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 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 *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 1 07:32:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817586 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B7481BDA9A; Tue, 1 Oct 2024 07:35:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768115; cv=none; b=sj9nSG5wwG5qI8CSlfjlbozfl3kV5QDEafQyOY+2/PUaO526vdgbMSLWuqmTW/twVmBwyRFodOw4zzkh0u7/tghEYISZj371wWYOu6H/OoNNpdEAOzJ7b+pRRSNyhofJKZ0Dzgtgxdn+zWpt4sx/7oidOsMidN3FTE3SdOZX7dI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768115; c=relaxed/simple; bh=CJC9MvYOXdQ0d17RtkUiHV9XKe1Pb1/kTZG5foooLsA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uPWoymzQL3M/4W5qC3bZ4cWf4IwDA+w4LNU6BA1uZIjwWMkpGPeN1efftPUNn7SdzhKS5Q6PX+NQegHKEPnxhqikCda9nVrqxVEMTjaiUDQSq1tH/LN3sPzWvCAIxX4k7i0FhcAZLRG8ZeXnJWPYp7sv4ikpKEsI5+7wKEh4+1M= 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=QHAD/KqS; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QHAD/KqS" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20b95359440so13951095ad.0; Tue, 01 Oct 2024 00:35:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768113; x=1728372913; 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=KcXclLvyDz59q3EjnhNSrg2M+bwjmqEwBneCT75QXx8=; b=QHAD/KqSQidGE53jROfC0AC33hUhkzMvLlZo87ytst0mChwbzPGq6BLBDBImdbffaD KarYHfj/0Ek6mOSCz17PChPXTTIxpkrI1JdJfBIE2uo+wOCpcSXHoKQeba8VMuenExEb CJ/3QxSGW7Mfdvh4/qBz1WJ/6Xmw9rBm/4b6T0BjVyNoaJIusqwX5I4UPG4bri8eB0yi NHZZ6IQt+vYos8yvm/kDvkGmMkUJ/QMM4kY0XggbdeK82V6yQ2P7HULQFmd3JL9qnfa3 G39Y1e5i0jAyp36oNzmZtoYCmSXzTHMMjVlEXRpUQOgKmUP/PXXANKL+q5aWtUasuQbZ ob9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768113; x=1728372913; 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=KcXclLvyDz59q3EjnhNSrg2M+bwjmqEwBneCT75QXx8=; b=Ve7Ovjs5+GbM3SsdvGFJbdHrQt9/Ku8lHTnnlhBtpDX8QetzHUTl3K2pHAeJ5+hj2E QM82RjkfCsboOxVEKvr9HCppoQpRIvlpdLaQX9c7l6clY3Catpa62b8tHXTT3cnvBRAc b28IF5gZ9g4cbcN6SKDaV5BV9SLm3AVr+q+cY9Si6sWbik6OAxDYfBH5foSSiiRMg98d k8MfNzlQnZNm4WRhYpcvWtWdalCndMzxcmsFgaSFrGIrX0HAvIYQ2szaagpnTK4t1zza fhsiVciV5nww2aiZ9irzvUUNiJoGgp9mJHdri/Q0RWzvGE4P9FeXDnEf2EpNlyYrMMHd vvKQ== X-Forwarded-Encrypted: i=1; AJvYcCVt2mb0uXGelA8dRzgflERJ9ZQKMxnlaOgX+d+6IeqnEjKh6ufUTpA5tJk+3DvoUSj/i/wJO6y44SK2ctM=@vger.kernel.org, AJvYcCXbIU9KiBvgwHEcsqyjnM5aK/e5ryQsWyvKKsjwfbcNLZmMPIC8f3Jo6/G0l8cZoPqRoBRDAcQv@vger.kernel.org X-Gm-Message-State: AOJu0Yzw5VAcYRYgTEr734aqjaXocPw6EdBeqrhG+uHSyKjJybiL5rZK 54kKSxR9pc7KncoQkg5Mepm6xb8Q55neRE5ccA1ys/F39GPQQEV0 X-Google-Smtp-Source: AGHT+IHftE1vTPnFP5mCg4w8S/nnX8TBGa5HEt0rKLCBwvwBvV7rEWJ2iPjfzi82j+q2eT504jHeWQ== X-Received: by 2002:a17:903:230c:b0:20b:8642:9863 with SMTP id d9443c01a7336-20b86429c9bmr96228725ad.18.1727768112893; Tue, 01 Oct 2024 00:35:12 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35: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 v4 06/12] net: vxlan: make vxlan_snoop() return drop reasons Date: Tue, 1 Oct 2024 15:32:19 +0800 Message-Id: <20241001073225.807419-7-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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_VXLAN_INVALID_SMAC SKB_DROP_REASON_VXLAN_ENTRY_EXISTS Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- 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 03c82c945b33..09b705a4d1c2 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 1 07:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817587 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C1291BD4E2; Tue, 1 Oct 2024 07:35:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768120; cv=none; b=tviL+N3HYeIUi4Ezrld8gmanWetqYWsp3Gcm4D+DxuIEQi7nRB1rpZo+P9gdzlEQSRz9C0UyCJdu6egltfEPtARsKa5WcCuV1YWRbwYTDyKR2eKybgqzsPQbnHdeKr9+L+TaRdsHZCpnv2ugn87AHk/aOykITZ/m3SWGguibqLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768120; c=relaxed/simple; bh=FBRZwyP4u4gW7pNLbfjZRSK3qJR19rpUewV7EwSvMQ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Cyywox27Dt11eq5VxQ46fGxVpX+vRzbVI3bbEbd8/4soocEw/jnLPJpt0132Ie3kWuP0kgI/Lz6OJlwk5a1hWBvanLYC4MkvZpAF0nAm7lYZtncDzV8f1payazb9s1sfMbc3wLv07R5XN05rwkoS98MHOZJ6DjPkVyXyp9zVpPU= 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=T6O+K916; arc=none smtp.client-ip=209.85.214.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T6O+K916" Received: by mail-pl1-f193.google.com with SMTP id d9443c01a7336-20b8be13cb1so19003815ad.1; Tue, 01 Oct 2024 00:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768118; x=1728372918; 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=l/nkaKX1KgrE/XGBRYIFDbeQa02MCHHf0bCdomncKSI=; b=T6O+K916ib6dxHsA8TErWKHtKRsISVvl8nWsLQh/4gJJ9cGXUD8kaNkyBfzdaN8znt g3E+F8q8Nv9V93XUJlEkT7sWb2ULZrg9rDKXerRRALhDgwHwraUPqTQCiiBfvUqICFJC UYZ6576BVna2MtXJbBGI6HJDdETBMVyl/+ghHE9mrIsi5cf4FVOf0ng8tCgE3h4E0bHf 3xQoGBWgCj/y9v0JGUNv2tcmZtluNY4F2o9P1VnARAg/L4YvGM20tWzG3yVDglGBr8HO 7+4uE9watHMDXltuUU1CicgPiTsnVFmmD+79t7xbdA4nOU3eaRRDceBCqSL1bvaPNnfQ 2CMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768118; x=1728372918; 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=l/nkaKX1KgrE/XGBRYIFDbeQa02MCHHf0bCdomncKSI=; b=Q+CEcSZOuaP746O6O/a1crdJclT8sHMXGNr1Te3yegg1o+MQbSA6vYDxpNr2PHW3SC yCcgU3uSMn0RsSbA0jyS3j+cQ/5KnSmOFqpqVW6xcVQqKJ6viAN5EMnWyyQQh7mLwLEu WLcC7BiDZptvC7RGDvkEBHPQ3e9fQiA7IIS4eGsYBXDgYrwRBAc+VehNb0+JdN/BShJm Wo5GtU39t4iOlMDqm6qSkNFNsKkPA7GeuA4nbG+uoTvs+tfGEcSSQ5si2pcWHfcTnOT3 liDxGpKr+NLB8dU6TMGTFlYQn6qNx3r/KefAJ5DXI6Ik+Nld+0oQehQpkAjuMXP1zF51 Tr8w== X-Forwarded-Encrypted: i=1; AJvYcCXcXWDJKH0He6cQE+U2VATeAD1koBwgLE9yYZjDqtQvXcWeAyT0vkvzCdT52n0IXoUZ2w5YwwmfrtKwtKo=@vger.kernel.org, AJvYcCXnkNZDo546+w3/cA5h+AVIWJgLYCMjkGcTL4yZkV+N9L2RY6Kyswc4X25RePkakBmV0NJH4g1u@vger.kernel.org X-Gm-Message-State: AOJu0YxQvIK+4XCfOsrDuTSNMBNFDWZknrVqbJVTFye33MH6DZfVKzMO tYJAOGYAkOIWg0Q5lniT53kORaDSkiwmYG5BReTIfY3709IJXgcd X-Google-Smtp-Source: AGHT+IEXZF4elInZGptvZ3BAr7MuQJEACHuM2+hM84iovmGT61NAZ33NFYnjvGvc/67pq+k60nFm6Q== X-Received: by 2002:a17:902:e80a:b0:20b:59be:77b with SMTP id d9443c01a7336-20b59be09c4mr171947425ad.6.1727768118478; Tue, 01 Oct 2024 00:35:18 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35: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 v4 07/12] net: vxlan: make vxlan_set_mac() return drop reasons Date: Tue, 1 Oct 2024 15:32:20 +0800 Message-Id: <20241001073225.807419-8-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 --- 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 09b705a4d1c2..b083aaf7fd92 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..0d931a0dae5a 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 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 1 07:32:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817588 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 A82981BD4E2; Tue, 1 Oct 2024 07:35:24 +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=1727768126; cv=none; b=s9F74L4xacePMH9CYvurVrFNTtUcpOJ7rl2OnYFouDkm0pvYd2PTEjUhKwXvCHCSzlId6PaLu4P6DEaKi1Pe2Zfuvrvlu331BVPv4dVyWvt+b1l0p3DhhyQ7YmfbYi6ILzFEvDhoa/lJPx5reP7hbStuJgkxzxAVnA2PvoOSEhE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768126; c=relaxed/simple; bh=t0EIUrCVwE7d2xCGIvjjtdmS38hT+qvdd8x8DzPoNdg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LDhzBSVueZrOieHDiAQMqt5nJ9PZTiCbQFRKJxMXTjWgrnXMq9LN2oxy9/xvfuoQ0YtdAD2dKzEwTskatY1/r8AEeOn+mXPZs100qrZh0H+oICu6fHvl8dCB4hZE+ap/YCJkAeOYZ8XphwkuS09AlU5yjHsdQux2UjxyMMB5yd8= 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=eWVYy7oE; 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="eWVYy7oE" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-20b95359440so13952045ad.0; Tue, 01 Oct 2024 00:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768124; x=1728372924; 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=D+AhWGVHZRvRgtHPQc2knZ4d8aa8l8HCvTuwUct604k=; b=eWVYy7oELXeflxiI1otfwrQcNbBQSHpmuzlvVXRpuLRCWxsORhLzlz4WxtyhtapgVw Rm7aZI9KF4sN6gAU2RnxI8HpMS85OoFllTKQMqcrfMo+g9kg/nJv3nJDFLq58tJau8Ut VGI0bApw63vjzzorvNrpYAvK023cnjcI/hi5dxVj6G+A32qEqZMFeMJRty5M+Q4jpvJZ 7VFIr6fuDUXhiXT1AeTbmfFdNmEpEaKrHgX6izd4ZAtqUneX4bxxviQ1iB9dyp+16nbX kLTUGN0R1HQw5rCrS4Trd5LofCMJaIAGUMos4Lko21v4JGH78L453ScbHWYVEl5oSqQM fUEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768124; x=1728372924; 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=D+AhWGVHZRvRgtHPQc2knZ4d8aa8l8HCvTuwUct604k=; b=UqmQfRZoXttf1tPwKPDuuQmsSD97+5FTshIb3wD+O6ZFyKLBpgJ10SqBDBSDW7qg8b dEbj3O6RHZ4nF5TpO0Xp+9hwkukDT5A4yICTON+dL0R62BQM92kCxe3Xouo73vEuAF2i tTmTXkQy0BGVJfU6rG4r4WZHepkWr2O1GanCZ7BAkwU0OUpbhvc8NNXUS2T1SdOPcX3o LNQ9yHHIioVM++hSaoe3ToJMxCA4sn0hRwbhM3ibHXENdB8uEJftfRcahpzRDjMu7Y+3 853Bg1k/n2hYSqCYNSP4PCyfmhAUoAjs88NR8RSBGYfu/f1byQBtLEpr49fYj2Ra5BYN ZcnQ== X-Forwarded-Encrypted: i=1; AJvYcCW1FPOuzFGsUxJoLSXe64z6djj2GbDNl6s/kyPAq7oceDtkhqguufXYFem+QOg5bFCkbjrVdXO7@vger.kernel.org, AJvYcCXHbWdeMMyPwDJ6+iOdihWOzTv1WVRcOvIHhdeDVcyR3AYEDttSLTCt4Vj9GyfbILcga3hDZ0hvuS7BHN8=@vger.kernel.org X-Gm-Message-State: AOJu0Yxe/rA/yjKkcmaW1WyO2HL1Ra/9u1o3m9zNyfPRvzU+dzPIL8/x 5dOIg3K1oPuqCZXX+fBKtex4NlUdJtiGjBfsVl8xMwDFMjS7bo4t X-Google-Smtp-Source: AGHT+IEsxrFj8i3FzQ+cYDwwIPiOt7gSYpMAm6JQrCNDtpLtDqOm5EMzKiHCu/5e5p/0TFZ5sI1Vqw== X-Received: by 2002:a17:902:e945:b0:202:371c:3312 with SMTP id d9443c01a7336-20b37a538ddmr218284095ad.40.1727768123702; Tue, 01 Oct 2024 00:35:23 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35: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 v4 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Date: Tue, 1 Oct 2024 15:32:21 +0800 Message-Id: <20241001073225.807419-9-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 /* txinfo is missed in "external" mode */ SKB_DROP_REASON_TUNNEL_TXINFO Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- 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 b083aaf7fd92..3dc77d08500a 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 0d931a0dae5a..9f6ca70fc470 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,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. From patchwork Tue Oct 1 07:32:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817589 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA8861BDAAE; Tue, 1 Oct 2024 07:35:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768131; cv=none; b=u1iOXIHhtPc4OIZw+HZLnQ39Nqw37xYOn2YXL62OR+XtK4iVpB4SPYUsqaQ9MpLshyzxa5QLaeW6aeTHVmWaZ7AoTzp8kG9OqsiON0zM2wX8fUGUyesCaC2vVDbdUOyy2uQfWKZ1iW6FYxFP7nqltrxjpKm6e+PZnG5j4XSdtcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768131; c=relaxed/simple; bh=Eskjt8/K3RvO5IWzw9f31qf5TKx1X5OJbbSPCQDiH2o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bwGAJhncO1GsfFKOQcA654sL15oRyNCGacNWij72bVMaovzx+jDiTmPthK9z226c3WgldjiPZyVb7/ywtkjiFLDMHk3A6IgroybmP/kB4yLJCvuei5UDodCmFUMNWVqKyhl0lBmpJbOoVqyaqJKA7NGIFNMtZI7UVNKk9/yonKw= 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=kSgrYWJk; arc=none smtp.client-ip=209.85.214.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kSgrYWJk" Received: by mail-pl1-f193.google.com with SMTP id d9443c01a7336-20b7259be6fso23193185ad.0; Tue, 01 Oct 2024 00:35:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768129; x=1728372929; 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=PLFnOLx3trBv+pZcU+bR4JnQLj28jgmaQYcai1NCZuE=; b=kSgrYWJkP8M+kPC+W90cu4/p3g/cJmNBZf8pmWodltuRR2fM+m/fh8ZPEqnzszZ23F 1uhys+4z7aCDVXiOfmlcCDwLHCyMw+JwSxwgI/wM1nga1g9+wOIclC5nrcAarNY0e57I MWdshIJOVuPb25m5Hdb19zf7bZ4VnQmNhp15X5NN0TkVJj1mSOFOF4LvchKzy0Z4cA3Z SBmoGWP+2r29a8nA2kHM/84I2gDGTLIic/V+LK90IWHI9l6AwtXtxtQjykgCA5jxTqZm VI7GBz8PKb1N+ovlk9+eJ6fOCixv6NpyujWkItYBIFYqRMppwlyCUmXAGErZ6ebEJTu1 CSWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768129; x=1728372929; 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=PLFnOLx3trBv+pZcU+bR4JnQLj28jgmaQYcai1NCZuE=; b=qVswBoMKgY0Q24UR1TypCx3C6ieOK7Wn80x6Zu1JYRDH3+7ifcx8/2XU02JyAXqBeo AoNRBZfRsFY8k82jQ+sJ3+Y9nMEzPHH2MsuN1PEtkZCRe95cxOGLh9th8Je5/chTCM4K LUDqcRqws+1mMCzSW1Xb33dt2X6RZ3QTv6NhtcRuOCylheneu04KkA64LbqhPt4ia2Ye Ifrt2OD4T19/V1hsdIewdGLtfWQ7RmW1k/y+HxkGl21FyJis3jLm0TrL+H1SAudDEgZm g0HHoQLc0G/tBYLxnIkqj00KdyXlAYhnZHeFTv01xecO+iqR13PFHroeHbsltUnU6SOK 7gAA== X-Forwarded-Encrypted: i=1; AJvYcCUsyfXqWa5r2Zhh/F0Kezz8dG030eYOcUChU8dbtPr8/VId7QbZ61KkrLhZAsUDSmSLjYh0mZFzHI+TcQk=@vger.kernel.org, AJvYcCWdl4j1zguDhtsgkilzpdBxUphChhC+sSQMHkTDwmQmyQl1Z6sIbAKV3oNc6rMQ5DAHQYFQD8FU@vger.kernel.org X-Gm-Message-State: AOJu0YxBJS0Ql57AW7+Z2yS0hMMqSARxYwo5eLR4+9s0o71aDLHt9Sxw AfkNc9+yzyw1zRTCFVbbDO88vGwNujIfKX/gnRgkb1XDNwrpJbhc X-Google-Smtp-Source: AGHT+IGgvUBybK7vqZkWyhPGfFUIzCMqIuKjWVNutuCvf8UTmwfBRlRIvw3DkvyKLCfOe4rH9uoKkQ== X-Received: by 2002:a17:903:24e:b0:205:9220:aa37 with SMTP id d9443c01a7336-20b378623bdmr223266225ad.22.1727768129282; Tue, 01 Oct 2024 00:35:29 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35:28 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v4 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Date: Tue, 1 Oct 2024 15:32:22 +0800 Message-Id: <20241001073225.807419-10-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 3dc77d08500a..3da3ea27d3af 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_reason(skb, no_eth_encap); + if (reason) goto drop; + reason = SKB_DROP_REASON_NOT_SPECIFIED; old_iph = ip_hdr(skb); info = skb_tunnel_info(skb); @@ -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 1 07:32:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817590 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A16A91BDAAE; Tue, 1 Oct 2024 07:35:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768138; cv=none; b=FzMQrD6HG8+BsxT4pwy5QJnLdpZUdeLL5Qhbs2zq4N8pXZTXj/mhCTrTvGsiwnjxbSrm3ywyUTsyhnvcwMjdschQcnl02Dbt6M9hOfiad7KPnQP1krs1uhZD+eLsbfDCNYzJYLoddo4u36KtGqXIKrLSaZMeDYiYf533qjVsGIk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768138; c=relaxed/simple; bh=djL+yaG8xaOFgmwIqBiZ4eq9LtHa+73OeWcdrLgR0tU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SqiDZu+KIdflS5wAhXrMJUDqXU1uyEtSOrh3minZzrpB+Q8d6FysDisVPUwBwOxE4V4FEYIYimyBH2Y4eN2bEccfIfsk3HeaYsxDwC41Cv3rsVJdj2ANkIR41R2wMAgJ2zhEVsqE46dwqaCMbjN6HTvhjW43FRxq6FMwk5/BOeY= 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=mqzHVEYG; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mqzHVEYG" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20b5fb2e89dso18358545ad.1; Tue, 01 Oct 2024 00:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768136; x=1728372936; 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=DTE6FReM0lnwJXm9JKKvZJ6AqvoonbqtBXpWhb+TWWk=; b=mqzHVEYGwyqOqdppvoO+byTYgo6xVPMy/A21VThj9V1H7lazm1zSgFSVpCJlT2fF49 sbaJ7QRJx0rd5+l5Zhfp7KsfAktUvaB8Ak/9vxhE8qoSOj/MP1PZDJIS4l4tU6KhpsMm mxprt681UmXlsHsnqE2rLaU213xabLji9928B5mELxLWyg+iO7VqodtGlmpmLTiV4zzF N8ABSweUn+VJcxee6Tv9zuM7pUjK9bImWSGVqSKyRw29XgB1MyIX7kVnqTA5aEAVNFNM 3gCcNOPak3Bx6oYdP9XBrnTV5733TCrJEPtIDdONNJPMPBQVsHilpqZTVEXeA8WFYuN2 7PfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768136; x=1728372936; 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=DTE6FReM0lnwJXm9JKKvZJ6AqvoonbqtBXpWhb+TWWk=; b=qHCypkDajq6iOZUxLMmH2t+nprEEwKp2A60XSDrzINr+TfBnJG14B8+msL6bgYMePr xrf0odeF60M0BQx2nGSY0UI03QJrLScaNWF5TBO/Nbf0Bn/qAKABV1mZs62mVhImmBJh +dkReBL69b5wIq/ZOueTaFW1QI6lSpwM30L3hDANdOsmMTDA1JwIGo8eVug3W3FNwT4h Wec8yDd15CyKdtUQZVcv9oltHBJQRpo25gROnaNZyax9cEm8Fg9tfC8fsaMlZiAmvaG6 OeygVawQg9CJ6IcnucIpdqUz4URGfcaM1Ky7H9qRy4f7GD9WqXjsirnYy/1lOh0ReZuW OalA== X-Forwarded-Encrypted: i=1; AJvYcCVQzOYSkIkDKbX8O72+InYWChh5DFyi3p4JzoIvK6djKk6H2Y8SsQa7Nte/Eq60os/wfNz+GTCg@vger.kernel.org, AJvYcCX9MGAh8tOZI642YoXP4pqO9chdaQlWdGSFgGRu2GMp/4NaOe4Ee14PlpaHl3ITWz9RBQXupoOPuFKhDQY=@vger.kernel.org X-Gm-Message-State: AOJu0YxOWLCIwt4egr75h2khEZ8XZ7ML4acLVvCX3ddgaV2RxQAj4ehd BLMyCGmSw3mM76VcgzXTpajnZyr7qAia01AdQaaTUpE0totrJVBd X-Google-Smtp-Source: AGHT+IHB3no/+rM7bSM0Yc0r6+XQLqqmJOI3kt1ekkttVL052rnvDDwxKAjJ6xAdcrPdjQY3SnnZ7g== X-Received: by 2002:a17:902:d4cf:b0:206:a1ea:f4fe with SMTP id d9443c01a7336-20b367d032emr218297945ad.10.1727768135965; Tue, 01 Oct 2024 00:35:35 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.35.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35:35 -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 v4 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit() Date: Tue, 1 Oct 2024 15:32:23 +0800 Message-Id: <20241001073225.807419-11-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 1 07:32:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817591 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDAC41BE230; Tue, 1 Oct 2024 07:35:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768144; cv=none; b=aMUPWP9ykX43bodC6zPCh1gAE6F/WRtNCX29QuV6I8ZLwWv/VcURjMUUikc2hcezYX711Ot+ltsqDRk3ojWLCLinL6qti+AOsA+v4RC44v3hmm1WbacPc1xvVTHoUfLz9xa8nQKIS8WByTLexk+KCn2IYDxIjfOgjIKv/qAYZHA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768144; c=relaxed/simple; bh=Xwv0xzTlUnUYvqiILZTP3WXhHoXK10waOf42+YdskI4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=icjdK/uFd/tjXZdufgRrkNVMFPZvHtyMq18cCyIf3Cku/lD5YrBuPwDYOYW7OiM8mmosY8FNDuxruKu+CeOb4ODG201YShGe3MuE50zeMbmPcCRw2YTzaAF7ReYbWCjFARpyEF69WJqDgBpOFtzkkdBnxTzNu7+sVl7eggjz7sw= 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=XmNfqGm+; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XmNfqGm+" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20b6c311f62so21963655ad.0; Tue, 01 Oct 2024 00:35:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768141; x=1728372941; 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=BA2fUFMn2idXaRBnTEOav6pxPUiWEEV4wGmZD2xXtEE=; b=XmNfqGm+qZCFCAW003fl5pbVlfnB4nCYvunIsDccZZiDEQUYTrG2Q6+v/B5hnS1SGy 1wMhHgnWvF+4699XgeXBBawzUd7Tu+pVPelmlndTqfb1kP6PdZNcWNyPviNtTMiVJPhF ZXvfikdm0fUcEjW7Syh1Rxbsa3Ot23Bwmp2xWJ9Tfr/GD69IUePYe6UcQxa5UUN94Oy1 Rv/XQ6AsT8lHD3ED1xgo/xKsNeI1AucsCohICQSJZz7C/s6S8pLLcyksB+Eh8LpFRh2K qsCXP8s75FWSy1MNJdhN6A25/oNgYCduUE8rR5E5CyDvHmhfUBB/tZFkvRp197likne3 Z6Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768141; x=1728372941; 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=BA2fUFMn2idXaRBnTEOav6pxPUiWEEV4wGmZD2xXtEE=; b=uckh8Cie6djMhAGQZD4289NjUq7CaYQYNDHWR30vipGY9MDm3JlJbjuKg9T2v8DgsJ ZF/Nev52LVKZoWHCEuo4e7QTP/PwYBiAJwnK6CY2Aoh8h6s8AXSduF3S1HsM+Bk16IuQ xQokHGyjOWlY9lzK7epGGAz9jUcVPTDqJM/LOcg2Exx/Ms+DrFoq4L5jXCOo4LAXvSbd HBZtK+heeyWhhSlS1FIT3qno7+7N0GsFjG/Trr4gj/c8AKS8unFkhvm0eUD4XVc3AALR O0W+0cAQiyX29LVVJLzhoLXncAREM6zgN5Fhss0Ry9rny2BCeKEmi+sdJJ4Dq1YxvToL wtgg== X-Forwarded-Encrypted: i=1; AJvYcCUsbG2Vm3P0JEImQYiB0eyly/Z684pOydD7cvItY/Wtth4FbcgLWAFMlQAhUR1rsDC7Nqu0ohkE@vger.kernel.org, AJvYcCUvpH6Nj7dnMlo+HT/83qzDJVvhlq/4kKQiaSRIkZWaeIW32t28QKW5uJHUnZSWqKK8a5qQuVYnz1o+VpQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxiQ+rRE4bGvb1jc6WoIU4zgc1p2Tt3pGEQoPfV4oTAxhznn3Tx DHHM56lbFFrV/d3+56OOOoBBm7o2G+kuVhWoNdatwvmVJVhmKwSw X-Google-Smtp-Source: AGHT+IE8MYsUW2XHcXK15ojE0PGnLuOapVV6jHisnGTRUKUvTIREbWF6mCri2YjXMANowQyS0JmBRQ== X-Received: by 2002:a17:902:f552:b0:206:ae0b:bfb6 with SMTP id d9443c01a7336-20b37b7c38cmr218743265ad.40.1727768141196; Tue, 01 Oct 2024 00:35:41 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35:40 -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 v4 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass() Date: Tue, 1 Oct 2024 15:32:24 +0800 Message-Id: <20241001073225.807419-12-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 3da3ea27d3af..4610f3e194e0 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 1 07:32:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13817592 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E3491BE230; Tue, 1 Oct 2024 07:35:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768148; cv=none; b=Zzqx9vwD6VOoJ349Ig8M3Tp+yWO17hxt2/LGneGv6Co3blBguPmHGYscYhX41xwvJ1Kr02Kate0jxGhCuSM1fD3D6Z8DMktLnVuq554TPZrY5nqO6HpLAwhvRayjjfB+G/AjorpnNin462xhyvw8TplNnDvJiTJPZqFIkaG0NEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727768148; c=relaxed/simple; bh=DRruHCRnENQ79ahhT+FzmIftKb3nQXcCDlCBOH6ItHE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FTm6eDo62bJV89qR6jneJJmH65f4g9ZYJ8Y4w8BXZ4Wf898ZhcK4EdoHnguzM+aWs1AF0ES3xRsHlVATkD9e99jvS92kM6e1DSzW3ve388UIGDt+sTkxulI8cymIFFgOkT6LKnNdcvB17IrF4ow6tH8IQYDxslrVfXRll0KvyNk= 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=V50/wGcr; arc=none smtp.client-ip=209.85.214.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V50/wGcr" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20b7259be6fso23196265ad.0; Tue, 01 Oct 2024 00:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727768147; x=1728372947; 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=W1V9N70oMJz4WUMe5EpbB18XlrU5zPmMhWoAOGvVh9M=; b=V50/wGcr41susTZYVn+O0G+h2gA/Vl3dWbzpLH6wGVnbszE8p7EIFZg4Bgp2bH+wic UTPiuSXn5yKWqR9HwqWMugcJkUEktQs/3EHz2bU5wGCmWIFxc3kWA2RMIFfaqWdLLEcM phAQ3ZTFUvDtnnP0F+KcJEpVXhQVQEpIzrsHl1zdorlgdFssv3sTukLOhhugcGBt2qfu G4gDaanwBQZnN4YGOk7izDECXV9YEkEsRrHkSsdIawOs+8GHje6P67/0GD0iC5UqxjOv kSeA00TTUMiKNVshXoPYB/LkycOlYPyH9o5kqxcG2Rh67txCw2S4+hdPARSuqWnswraT PNAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727768147; x=1728372947; 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=W1V9N70oMJz4WUMe5EpbB18XlrU5zPmMhWoAOGvVh9M=; b=iCZeEmaqjthJAPH9YZIVPr1ZgajSOwdjvXcaakCPnLNbks6KNDCIJ74er39a0oY/W7 rps7rHp5OytLgLEv0UcGaoLih/wBjlv0iJbl0ilwliXFpcI+hZvX/Q3zJTRty8pJXY3F kn6FeSFpDlhqKyz7zEPOnkrXnAmkLnNg/e3UDM+9uGS+Z7Xi17ixCKnxJZPDbskS5yo+ XsbdnCGyz5jMhsFrrCXriMm/xPc8VUFZ0Wip4LtPGNmrAirfn492lJ1Ai5hbofGYmsjG D3AbHEvsF/rlD4R7LARBUfEm52Lm+4k+6nKZltE5u0CcHWXycIz5YfZNJYCpbKd4dl4E 1BXg== X-Forwarded-Encrypted: i=1; AJvYcCUW2LugLcx78GGYbmbQvExVEjAmDHJNzKMRp71ZXEtByvjb4lM+I7KTsDcKx4JsWi8Ov0j89em2GJ5Du4o=@vger.kernel.org, AJvYcCWZL1M14thS+uxlIir0BGQMzMEm369r/72cyprW2UDlYMKexzMl2prWvjHrPnl+RX8Lj0wvEt1o@vger.kernel.org X-Gm-Message-State: AOJu0YxKQZ6kG2jFz2It24vLug+8eMbYAIJJzJbEahnuqfn/TtzKEKcL ARZkuv/UdAZ4mHem/9AO0wmVMdTlD36thGLvhk/mTo4eBVSxCMSR X-Google-Smtp-Source: AGHT+IERNjlw9YWO+skQmU/xdIIE2M8GXqLKUErOo5pJwNMno/5VeXiFbXGd8CtLHqajrdgxoFSXDQ== X-Received: by 2002:a17:902:d50d:b0:207:1de9:1014 with SMTP id d9443c01a7336-20b37b7631dmr216756265ad.34.1727768146655; Tue, 01 Oct 2024 00:35:46 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37da2667sm64545575ad.102.2024.10.01.00.35.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 00:35: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 v4 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local() Date: Tue, 1 Oct 2024 15:32:25 +0800 Message-Id: <20241001073225.807419-13-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241001073225.807419-1-dongml2@chinatelecom.cn> References: <20241001073225.807419-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 4610f3e194e0..7ffbd06bd6c8 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; }