From patchwork Sun Oct 6 06:56:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823688 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 ECCF5249F9; Sun, 6 Oct 2024 06:56:51 +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=1728197813; cv=none; b=m8Af9weNRho9ZL7Q6vEQMXI2Zh3BFI1h12mnGFcbswDATidux51Ix9I9tUtC6ewdv7B5+E2GNekxjp2tgORRqPzF2yHhYH/680Enf+FXmuXuA/hJIEVyRYE3NIYJIqn3A/aymtJcUnTnmFvDUFKC4SJSaENijKL52GwfhlqKb1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197813; c=relaxed/simple; bh=qDSFVKxj5P9OuUbcZh8vXPtfp9NKaBMFgSQrL48vbZk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WU9GcMggjvNkOlyy3nmkfZ/xIrAJbqcgd838yE8DMk1YQ9hhtG/cVJiZspzB0+vcQR4O1TgyAdvey8HjW/VapRkm4voJHsqn+/7QRFLUAyYJ/Z77CQpGOAWKz6xzhc3edexMiL1m2mWKFfNTVN9jKjX/maU0bG2ZTHku0//PIb0= 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=Ahd5gSLj; 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="Ahd5gSLj" Received: by mail-pl1-f193.google.com with SMTP id d9443c01a7336-20bc506347dso28369205ad.0; Sat, 05 Oct 2024 23:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197811; x=1728802611; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zLvKfqnfSpZ28mnT6KrdGxzwf8Ry3wsHVE17xRaKj5k=; b=Ahd5gSLjX00Oaqcr7ENOrtJlSH1EyXW/VYXcBDLY71pbkkDEwTXjKK31ZKnOqAvVGp hQee2KDjGj7MJ/yMeEGCk/6GhX+xRSQSZvNwvBbl/FrB0JR0nVJwmVqHdrrwk7Ipx4Ol PtjWgS7Uy84UU6rtfutP7j5ZwYxlBpnnfwIFQS465h94gOf1kQK4JIk4YUj3l9Cv5nL4 cOqJV+SVt0lqVDgUDpST6d989KAMQDfO1zFvGH+VDKZ0g3fQmnYBv1PJZGa92HErin43 lJcBuXpQeWTz7V+NEHh6ZhHEVhir8SIa+cd3XRp3VyWJL76G7pFcfxo+DO/uDaXg4cQl cq0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197811; x=1728802611; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zLvKfqnfSpZ28mnT6KrdGxzwf8Ry3wsHVE17xRaKj5k=; b=kpciUd4cAQAe5Z7E32kE7VQJgqQa3abXWSPUTn3BQaDIaWug6+J37wAx5682XAkhl0 hHPzZx/JDgMuh7XHy+9K4Gm5lQBFqis6162JMBOzQtemJtOenobu7L8xmMqNoOGctnDW qSDFAf6LwOlrJLuqPDu394jaXJ46UCuS0DDM2002vqdwHWJxGljZmFgR0+LIGOd/2eNd 8di4oFhjRLVW4B5RDWncv3qJDJXNrpw16vq2czOz/BFty7/wxJcUfnagZL5EuTqOzlHD KICOxBX0GhI9QwycNC7PCzl7L7s1HY5XllLRq8lqpghTWCoNOBylMMu3CDUE7t64DO31 hbJw== X-Forwarded-Encrypted: i=1; AJvYcCUiv3S3iQHcLIAsp9f4JSh4QMPOwhiZDpzIKrzysVb1IPOVJjFWfli18sNSlJXY1/Y2QY3xQlXR@vger.kernel.org, AJvYcCVTWps3F1pvbsN/tCm0ueUK+2Haoky+8W53hJK/fNBq1HpU6r0hGw4RJqVGaO6zKc43GfjUQ4qRvVxPsuY=@vger.kernel.org X-Gm-Message-State: AOJu0Ywigvq35W1Uvaf55xWesgYIoKzprdBZEs8dWIe+qCHoMRHdXtuU Ce7uXIHqPTkvJtEETjHq2TsriWKRbg7Aj2HDv/3LUhEYK72Z8VYK X-Google-Smtp-Source: AGHT+IHVKesG+DMOV41EUd8YEt3kAqz8ZB6LgjCBY0UV2GF5BPA+76bBUjOlDhdYJGijMVnlHpkh/Q== X-Received: by 2002:a17:902:d505:b0:20b:5b16:b16b with SMTP id d9443c01a7336-20bfe4962d8mr129075365ad.36.1728197811266; Sat, 05 Oct 2024 23:56:51 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.56.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:56:50 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v5 01/12] net: skb: add pskb_network_may_pull_reason() helper Date: Sun, 6 Oct 2024 14:56:05 +0800 Message-Id: <20241006065616.2563243-2-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-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 Sun Oct 6 06:56:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823689 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 F22D9249F9; Sun, 6 Oct 2024 06:56:58 +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=1728197820; cv=none; b=o/OOiOA6ISSWHquXxoBHdoFw6Vw8x7CJH1Ck3KqOtx9P1PhnFtKf2FYkI0sv87ptclvj3496/8p/BkpL5Zex9dATW5xUjkl5r2EDj0JEzzLFoQKpCxwumO3DkRD3DTbTxaUJNxBNhd7de1WroVdrMl3TZ6UI7X3tQ3QbL2BE5Jc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197820; c=relaxed/simple; bh=xmSEGfXWYYnrxahV/hxdM2xvbpsGMckUIHbpupwQeoA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eA2O0ZsDoqOYlBv1LbUy0OJ/cOMO6Tl/DOV+NCXo3Z2sl9JaQNEzHI1YCNCDYWjooxTgqGI6PDOiTilMRWw4+U3oL82c5krY73xa36C+Yo3KI0MfFhfUJs1Ysr9f6++W3XUZ1UixWs01NhpwmRfEicxrdk9m+dGs9NCxbm8YOqY= 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=XVCpO1Ci; 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="XVCpO1Ci" Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-20b9b35c7c7so24199255ad.1; Sat, 05 Oct 2024 23:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197818; x=1728802618; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BLQPPQHkux9UrJBZUqB+t1LpH9/HisAt/+hbWRBu/OA=; b=XVCpO1CiVx+jgyK9Sx3WOL3kD9QT+3D8k/zShPXQAsoH7zOfhsrOmIng7Tb9bYo5M6 /zw+tn+ijhI1o/gw+tymdQ5Lg0Cu+9l069fj2az4C0PWoelAz6NhyMYqqWfewOi+G+Zs sJ42fdVcn7xG0pxO6BiB+66LxJx3ROL5tGAr5GOEOi+Kkz0BadwRBo1S8gw+NC8fQdpa MXSdbZlegJIe6DXoTEhI2kRsw6TSTkLu67JqSK+2wL8QLo/qnAjwYBZVuWCTx0QOZgPg JB5/NBmv7qRzBTvW2Oj2OtOwUFeUo7eZsOaXHSBxNA3XoOSHB4VInEPXl0z2phiH89YG otCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197818; x=1728802618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BLQPPQHkux9UrJBZUqB+t1LpH9/HisAt/+hbWRBu/OA=; b=CXFbFa09toaKOewRMO4xzhyWDiJiVUnMSQ9CeNXNy+gT2TiKIbSfgCpELcLhgBf8iy 1VXZl04MeA2YrsZnCOPQBZkzUgrLGPoSr6dH4mEYk1Pl5nRfXnUfm/EqTGuBAb3jMwDj ESQqwWTXMhscMWWuxynpeeD6X9h4meiJInLXw9IChw9MGzz60TyZyfcHPgkUBrvMttmh gAAotJq5179T6pAbFaav6+bKlGZPwqpmNmXuT+Vt8omOsHDnEO6ti+ubW2ZMYtWYimza jbEw3WSLDN/rvFoJQ6/Rgo8q4ijHuMvDc3LCSCit0mW9IwpyqaNoJN7xmOTPBjlTVNaF lMjQ== X-Forwarded-Encrypted: i=1; AJvYcCVJR7SIMHTZ09PoxWnNaKEf4EYNP4dObzmhZE+2/IZamOaSGxukjgasyPiz9oerkb42pnNlbH+n@vger.kernel.org, AJvYcCW8KJdU5YkqgPJrHAnBgyAMd4a2MbaMuKYvNpjGlZp8w1pq0ZZIPo1PHGNxm3zHjjaJPArbzf2OQp4vB/E=@vger.kernel.org X-Gm-Message-State: AOJu0YxTx1LG35nJrh6VSD22pj68z5mZSALjPild6CocxMcqFpzZyY+A F3puAOhnEcFajvCYHKXrZ+5NFGYGqC9nftEdAa17T+4kEsYkHlwi X-Google-Smtp-Source: AGHT+IHRxM/eFfj7oV4FYggeajJH62XqNTw09SnTgpexKuFVTDOT95I0ZcVEeCQmRAFW2BKsoafDpQ== X-Received: by 2002:a17:903:2450:b0:20b:2eb3:97ac with SMTP id d9443c01a7336-20bfdfe26e4mr103883825ad.24.1728197818333; Sat, 05 Oct 2024 23:56:58 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:56:57 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Kalesh AP Subject: [PATCH net-next v5 02/12] net: tunnel: add pskb_inet_may_pull_reason() helper Date: Sun, 6 Oct 2024 14:56:06 +0800 Message-Id: <20241006065616.2563243-3-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-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 Sun Oct 6 06:56:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823690 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 739E0249F9; Sun, 6 Oct 2024 06:57:05 +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=1728197826; cv=none; b=WUks6n5u3P+H0BBIyHnmG2zbpYjm9Bd1dHvTRSTR+LJuoougzz8+5q3bVFS+/6jVyry3ZN9eTHG+0CxsKQ9ORbR3xgkkKtZCDqCZTZjtGDkF7/nrOLUAu6do9RxHczsIE/330NcM+faVtLpRA9fOfMKS9ahVb5srDtlpGQcjAL8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197826; c=relaxed/simple; bh=0LbNYkuc1H3teX+6zzjM43vRgSWAunIJN3Vzj/y7tNU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LjxotMtLruOx3VZgS1vaFdMyL+5nMjPnPIcGPmP8oSTg0vwodQdkDbA8nBpJIpCTYSi6FcyQNYBjRcXVnW0tZubg3Cxq/YxTgVhKYW9SplZPraFLyV1EzM4a+E/VYaVXkQejfT/wgQwh+JUyPymnq0neA+2a3n4/nxdMSMhvw4Q= 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=lviuPNLt; 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="lviuPNLt" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-20b78ee6298so21825345ad.2; Sat, 05 Oct 2024 23:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197825; x=1728802625; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PhsBrLEykAKb69NSSERrjcYKm3NYONaRl2vIIBwztDI=; b=lviuPNLt3IKEuCuxJVVlZo19Zt6u7dkvCXMIrbkuUojM6D6QiLtV5GrEiStLdzVvih WkOZm0w4DrIeqiuoDu8XEy9gn41UL/W7G4+Ap9aUYNXUypAVn6l/OIGuKeo25ZnOPmYS GgdwVtp6osHCKIv4WPJabliM3PlkLStKGoIKddzYsNzovUgYHZguS3eMLbk2apAJRy0h 6UX2sR9gU+ouwr6nqHzM3GnK50BYZJg5b8b4OZ6HtXpHi5EK/i8sQQrgyxl8Nwk0UsV9 I+omqI2lOfH5a37FdcIo0XF88jmZJ95iThX6vkpYFrm0ASc7yxq/FXw6z5Y/Jq+jfHzf roSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197825; x=1728802625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PhsBrLEykAKb69NSSERrjcYKm3NYONaRl2vIIBwztDI=; b=U85OkXmQRv/TO0G3HYvCpQqZPDs/Mo38Om+NSQv+hN6Xdvr9+xF3kGjR/tnDC9Bn5G 2GF1Yx/JeklxajvFynZoTwjgpHaTHdVo+ReuNwCW0hwQAwMm+edSJX1HbOm3MUKU0l5B TJ+Q49Qp0VTT0i/YBti4haok13+zbQ9yk6iUWqtrspqhFoW0oeJL2UKgQyCUOcsP6cFw 2oRnx3mqRoA3tJKVd97qhep/+tv4+8hD04q3TN0eFC8cbDRiBQDK0+JHL0/9AcIpJ41S BJINkrnvnHHDLGtGDRGMvjNLHIcX8lgBvS9msA+tyaVLPkueSJhLmicWDgOg+y3krOH4 0OYQ== X-Forwarded-Encrypted: i=1; AJvYcCV9P+9JhXXczMi3X1HmF0HoyqQhaLdr4oBb7TlIBm4tfAcPpmCCJ8nGa4UDR9s6+uuQO/K5tDlxn60KCVA=@vger.kernel.org, AJvYcCXahWe7jEC2oxpQ27UifZnROO2fdf6XiOOkkAdphRj6NQYrKtOLEqa03QyL2QS02FE1NWAvLhbI@vger.kernel.org X-Gm-Message-State: AOJu0Yxp9MKSUtP0ssBVk+QZtWuGAqmiO5NqzwXj5QiY+86Ai0wIm14j A7mBczNl7POx+4x8Oi/yeAz2F20dYyQBXlIE4AznXfEYDHQIr2/K X-Google-Smtp-Source: AGHT+IHNbLfZqI+v2NrvEtvMO+odpAfD/JZS/c1dZ9oH6s55C9NnDTj4lq2MfD5wyO6VeEsWNtg4Nw== X-Received: by 2002:a17:902:e849:b0:20b:a10c:9be3 with SMTP id d9443c01a7336-20bfdfe4834mr136171975ad.21.1728197824770; Sat, 05 Oct 2024 23:57:04 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:57:04 -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 v5 03/12] net: tunnel: make skb_vlan_inet_prepare() return drop reasons Date: Sun, 6 Oct 2024 14:56:07 +0800 Message-Id: <20241006065616.2563243-4-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Make skb_vlan_inet_prepare return the skb drop reasons, which is just what pskb_may_pull_reason() returns. Meanwhile, adjust all the call of it. Signed-off-by: Menglong Dong --- v5: - make skb_vlan_inet_prepare() return drop reasons, instead of introduce a wrapper for it. v3: - fix some format problems, as Alexander advised --- drivers/net/bareudp.c | 4 ++-- drivers/net/geneve.c | 4 ++-- drivers/net/vxlan/vxlan_core.c | 2 +- include/net/ip_tunnels.h | 13 ++++++++----- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/net/bareudp.c b/drivers/net/bareudp.c index e057526448d7..fa2dd76ba3d9 100644 --- a/drivers/net/bareudp.c +++ b/drivers/net/bareudp.c @@ -317,7 +317,7 @@ static int bareudp_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be32 saddr; int err; - if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB))) + if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB))) return -EINVAL; if (!sock) @@ -387,7 +387,7 @@ static int bareudp6_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be16 sport; int err; - if (!skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB))) + if (skb_vlan_inet_prepare(skb, skb->protocol != htons(ETH_P_TEB))) return -EINVAL; if (!sock) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 7f611c74eb62..2f29b1386b1c 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -827,7 +827,7 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be16 sport; int err; - if (!skb_vlan_inet_prepare(skb, inner_proto_inherit)) + if (skb_vlan_inet_prepare(skb, inner_proto_inherit)) return -EINVAL; if (!gs4) @@ -937,7 +937,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be16 sport; int err; - if (!skb_vlan_inet_prepare(skb, inner_proto_inherit)) + if (skb_vlan_inet_prepare(skb, inner_proto_inherit)) return -EINVAL; if (!gs6) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 53dcb9fffc04..0359c750d81e 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2356,7 +2356,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, __be32 vni = 0; no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB); - if (!skb_vlan_inet_prepare(skb, no_eth_encap)) + if (skb_vlan_inet_prepare(skb, no_eth_encap)) goto drop; old_iph = ip_hdr(skb); diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 7fc2f7bf837a..4e4f9e24c9c1 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -467,11 +467,12 @@ static inline bool pskb_inet_may_pull(struct sk_buff *skb) /* Variant of pskb_inet_may_pull(). */ -static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, - bool inner_proto_inherit) +static inline enum skb_drop_reason +skb_vlan_inet_prepare(struct sk_buff *skb, bool inner_proto_inherit) { int nhlen = 0, maclen = inner_proto_inherit ? 0 : ETH_HLEN; __be16 type = skb->protocol; + enum skb_drop_reason reason; /* Essentially this is skb_protocol(skb, true) * And we get MAC len. @@ -492,11 +493,13 @@ static inline bool skb_vlan_inet_prepare(struct sk_buff *skb, /* For ETH_P_IPV6/ETH_P_IP we make sure to pull * a base network header in skb->head. */ - if (!pskb_may_pull(skb, maclen + nhlen)) - return false; + reason = pskb_may_pull_reason(skb, maclen + nhlen); + if (reason) + return reason; skb_set_network_header(skb, maclen); - return true; + + return SKB_NOT_DROPPED_YET; } static inline int ip_encap_hlen(struct ip_tunnel_encap *e) From patchwork Sun Oct 6 06:56:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823691 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.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 D7774249F9; Sun, 6 Oct 2024 06:57:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.196 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197832; cv=none; b=F/jYHjSS8aupeODW33JGrJfKNoQnDeQpue0+Mw2axyFOWR+Qzb9DxPBrBB+OuDOGyOslPt/Phasrl6usI7GvaylYE6+BTD+Qe+8Z3tF4/Z0MvlRI1Pky5QPQGJxhEL0yF67SG4uQ0DyGcj+gUUOlWFxXjmlXUkgkKLJzdkd2IN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197832; c=relaxed/simple; bh=Frgop5dI3MpmoWzTS13lVakpm6NizzC07ixLgWUG7hU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JzEjFFtI9zIgbWiGEMksabSzHPjzbobgvApDo1JSqASYUGz6jIgqjTPFZIOGwMORLhl4EK3Xwu+2oVlRljJFT0mZ9SUSojQZmjytOFCrZaI/gG5W1RhyVp95plCL4mEckDswxJuhlwt25lxMSGDCeG84fWReIgblwkQjxK115dc= 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=UdxcwWQu; arc=none smtp.client-ip=209.85.215.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="UdxcwWQu" Received: by mail-pg1-f196.google.com with SMTP id 41be03b00d2f7-7db908c9c83so2080933a12.2; Sat, 05 Oct 2024 23:57:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197830; x=1728802630; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c+57bNIoFOfo1YPD2Iy9OO/eMOStU8dZYyQFQ7Wq2lE=; b=UdxcwWQuK56wrsmKaBSuZMgHFpbpHoYxMnDryXE/Mfg6vwZ6NO2GK5PKlRMobcrXcu WzlwbdmAZoXt6M5YLWr7QeDKBZhJWH8b0s9mQwr7yOEq+mxr5m/FzKxlmLPcvzs6nTkP ndt/7BOhpYmkOU0fzC4+geTY23l6fBQdawjXhU+rsVqHnV2fQAp5PZXw5NEx5J+pVY3Q WaDRv1FgK15Z8SzvbjOv09ai2iS+P8Q4wBhE2glIQURVrLpIh2RnsOb3H1L8uO2yBaeJ XzBc8Fq8fr1E6YuUe4/3/tl4u24nH5VY66RxcEdGGJmxhuFl2fuyEsv/1mY5wN3bbAVp xyRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197830; x=1728802630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c+57bNIoFOfo1YPD2Iy9OO/eMOStU8dZYyQFQ7Wq2lE=; b=DIrYU+lP25RGQBcOcKpiihSHbGze7iBpS5tt4flhHylx3TY2LCfZNv58x+PsgcH4V/ PGYkp3I4J269DlR3rHnoWb0VVueW1CK7tAS2gnhph35qyEyJCNH2duRsjP+CyT8Xd8gr MdLWk9hVpenbUIB3EY8Z1LqoEq4kmJG4Y45uX8K3/jZS0+E/JB0VB+jzeYE4JFVWntDg MTGpoegq1olPqgf6AVXPRRdLBi8HHSsq575c/FsXusKiMBsDU/R8eVxdEUU9/vZ6/DGt HXiRd3s5O2I4vz6T17/BIvKnt5LFxKxtx8Ul4POni4gqiyKtGLGb1+m/HkXU9gnaYmym dUgA== X-Forwarded-Encrypted: i=1; AJvYcCXdwWbw+QEjd7PAskH9NU/5Cq9Rgk8UVygWIsEiXnTyXvQjY/vojVMJIXQv/I3yPO4SF9Ic/EwR5+i747A=@vger.kernel.org, AJvYcCXz5qAcUZNSnrqwKXGvzFqOTwZhShOMRuXRDXf2ZeUfVO3tyahms4/nSrVmAhioV3I7Q2i621tP@vger.kernel.org X-Gm-Message-State: AOJu0YykApU3AoKZOfrQzV8gk+H+pT5lGcDI5zu/BDsnuT3FO1kAPkcK Sx8HCalTVMyfs2QXBZlNt4fHSSseLy0qnUIqQONn7a+//Wt43X/Q X-Google-Smtp-Source: AGHT+IF16Q0VFxMmBbVU5wZu/KZiIVVjG+ymcsTyHDlpfITH1HwpjHwRb8kaotXJhZDFgNATyDvS8Q== X-Received: by 2002:a17:902:e745:b0:20b:9c8c:e9f3 with SMTP id d9443c01a7336-20bfe05cfb6mr134162745ad.14.1728197830122; Sat, 05 Oct 2024 23:57:10 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:57:09 -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 v5 04/12] net: vxlan: add skb drop reasons to vxlan_rcv() Date: Sun, 6 Oct 2024 14:56:08 +0800 Message-Id: <20241006065616.2563243-5-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Introduce skb drop reasons to the function vxlan_rcv(). Following new drop reasons are added: SKB_DROP_REASON_VXLAN_INVALID_HDR SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND SKB_DROP_REASON_IP_TUNNEL_ECN Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- v3: - modify vxlan_set_mac() and vxlan_remcsum() after this patch v2: - rename the drop reasons, as Ido advised. - document the drop reasons --- drivers/net/vxlan/vxlan_core.c | 26 ++++++++++++++++++++------ include/net/dropreason-core.h | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 0359c750d81e..4997a2c09c14 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1671,13 +1671,15 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) struct vxlan_metadata _md; struct vxlan_metadata *md = &_md; __be16 protocol = htons(ETH_P_TEB); + enum skb_drop_reason reason; bool raw_proto = false; void *oiph; __be32 vni = 0; int nh; /* Need UDP and VXLAN header to be present */ - if (!pskb_may_pull(skb, VXLAN_HLEN)) + reason = pskb_may_pull_reason(skb, VXLAN_HLEN); + if (reason) goto drop; unparsed = *vxlan_hdr(skb); @@ -1686,6 +1688,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) netdev_dbg(skb->dev, "invalid vxlan flags=%#x vni=%#x\n", ntohl(vxlan_hdr(skb)->vx_flags), ntohl(vxlan_hdr(skb)->vx_vni)); + reason = SKB_DROP_REASON_VXLAN_INVALID_HDR; /* Return non vxlan pkt */ goto drop; } @@ -1699,8 +1702,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) vni = vxlan_vni(vxlan_hdr(skb)->vx_vni); vxlan = vxlan_vs_find_vni(vs, skb->dev->ifindex, vni, &vninode); - if (!vxlan) + if (!vxlan) { + reason = SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND; goto drop; + } /* For backwards compatibility, only allow reserved fields to be * used by VXLAN extensions if explicitly requested. @@ -1713,8 +1718,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) } if (__iptunnel_pull_header(skb, VXLAN_HLEN, protocol, raw_proto, - !net_eq(vxlan->net, dev_net(vxlan->dev)))) + !net_eq(vxlan->net, dev_net(vxlan->dev)))) { + reason = SKB_DROP_REASON_NOMEM; goto drop; + } if (vs->flags & VXLAN_F_REMCSUM_RX) if (unlikely(!vxlan_remcsum(&unparsed, skb, vs->flags))) @@ -1728,8 +1735,10 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) tun_dst = udp_tun_rx_dst(skb, vxlan_get_sk_family(vs), flags, key32_to_tunnel_id(vni), sizeof(*md)); - if (!tun_dst) + if (!tun_dst) { + reason = SKB_DROP_REASON_NOMEM; goto drop; + } md = ip_tunnel_info_opts(&tun_dst->u.tun_info); @@ -1753,6 +1762,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) * is more robust and provides a little more security in * adding extensions to VXLAN. */ + reason = SKB_DROP_REASON_VXLAN_INVALID_HDR; goto drop; } @@ -1773,7 +1783,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) skb_reset_network_header(skb); - if (!pskb_inet_may_pull(skb)) { + reason = pskb_inet_may_pull_reason(skb); + if (reason) { DEV_STATS_INC(vxlan->dev, rx_length_errors); DEV_STATS_INC(vxlan->dev, rx_errors); vxlan_vnifilter_count(vxlan, vni, vninode, @@ -1785,6 +1796,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) oiph = skb->head + nh; if (!vxlan_ecn_decapsulate(vs, oiph, skb)) { + reason = SKB_DROP_REASON_IP_TUNNEL_ECN; DEV_STATS_INC(vxlan->dev, rx_frame_errors); DEV_STATS_INC(vxlan->dev, rx_errors); vxlan_vnifilter_count(vxlan, vni, vninode, @@ -1799,6 +1811,7 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) dev_core_stats_rx_dropped_inc(vxlan->dev); vxlan_vnifilter_count(vxlan, vni, vninode, VXLAN_VNI_STATS_RX_DROPS, 0); + reason = SKB_DROP_REASON_DEV_READY; goto drop; } @@ -1811,8 +1824,9 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) return 0; drop: + reason = reason ?: SKB_DROP_REASON_NOT_SPECIFIED; /* Consume bad packet */ - kfree_skb(skb); + kfree_skb_reason(skb, reason); return 0; } diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 4748680e8c88..98259d2b3e92 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -92,6 +92,9 @@ FN(PACKET_SOCK_ERROR) \ FN(TC_CHAIN_NOTFOUND) \ FN(TC_RECLASSIFY_LOOP) \ + FN(VXLAN_INVALID_HDR) \ + FN(VXLAN_VNI_NOT_FOUND) \ + FN(IP_TUNNEL_ECN) \ FNe(MAX) /** @@ -418,6 +421,19 @@ enum skb_drop_reason { * iterations. */ SKB_DROP_REASON_TC_RECLASSIFY_LOOP, + /** + * @SKB_DROP_REASON_VXLAN_INVALID_HDR: VXLAN header is invalid. E.g.: + * 1) reserved fields are not zero + * 2) "I" flag is not set + */ + SKB_DROP_REASON_VXLAN_INVALID_HDR, + /** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */ + SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND, + /** + * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to + * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail. + */ + SKB_DROP_REASON_IP_TUNNEL_ECN, /** * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which * shouldn't be used as a real 'reason' - only for tracing code gen From patchwork Sun Oct 6 06:56:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823692 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 CFA7C16F8E9; Sun, 6 Oct 2024 06:57:17 +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=1728197840; cv=none; b=WhPg3dsV2A1oFAd1w1ONEyPwNvE7/a2GhcJd9riky4+Mzq8Nv36T9EDPh6jau4KBfAqG/YV0bGN933nZRl1a6kF/ldikTRzOtz4vy2xBAfw+2jpLSZQ94dsSqRLzxThbWIPITk7lAELZVATq6futYY/cqYj/6KZrL+Jm+Z2qR2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197840; c=relaxed/simple; bh=RqJB6ZWkDR9/PDVgtjzb6hIWH6sz0+ZXugXeLypicD8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c7JFsR7wXuHK6u41JRil7d2/q767fO5+In8+Bggsy1R35UuLWQ0+Fm62cQ9cf7kux9JoWgTWqDFJkN3IZ7I3esg2I8SNdHBx3gK4cWMi3n5DthepeJmX96rB2VvcWcRjT1CkWgASkRpiY4Y/mZw4JFccHufEWpejZ2lIhc+LYJM= 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=EIOr4SU6; 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="EIOr4SU6" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20b95359440so29185435ad.0; Sat, 05 Oct 2024 23:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197837; x=1728802637; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oYnO8bxbAcS5ofNqn2tjM8UFXYntoF7uV3soxSFaKsg=; b=EIOr4SU6j5xe7U4/ImC4V1MbdC9SeyLyTe5N/TNhApAW3pA0xj5YEhqvKudxeEDbKQ PozP3rgS0PQ8kd4whodw+oDPxeLDBAr/JWmaxNXni0lCabj11YIi0kn7fVg8eobeeGkb J7U3hIy1XtX9VtyNqok5mq7TzZZzIWAVDCZ2Yj4UVYiUy2JHz795erJUfNozazkGkIor OpntcsvZNEcIeDLF5L4cxM8iXFtk3EOXpEQU0F0zI9HoAEHYH5Au2ej6uWnQK/yd4Vez 2qzcq7yAXlajy3CMlONrgcS+7lEevd5cz9zmNSqkCnbMMRBcMxQqEMTvmOEpdTehGjZH 1LXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197837; x=1728802637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oYnO8bxbAcS5ofNqn2tjM8UFXYntoF7uV3soxSFaKsg=; b=COhjIYJrgym4F0NkJJR0JT7kHL/HrOa81w/ORZqoq8novaz3aF7FasbKnill5AMNRz C3Iu4XejzPaGqTBHKfM8FYJ7LC2bC1a3mXgnlLCtwRLVGHFJHcu5LhzsEGB2J2T/rT8f yufrRFYol/k7135oO6CPHR67q55t0Oiv5DPorhNfBq0tDBc2FZUQH/4FZ0lBxaljiWGe 1hWlEI2h88tBY5lnGsZOd9or/PPTQkQiC4wPgooAndjFkTZl51F6yGDEArvsrMCNsQV5 /KQ/gOpS1Fu21c2BH+SZpkGiN/NQBu8dfpV1uAlP0y1+/V1YqDFniKQ2rqE7xJWeT4jn 0QSA== X-Forwarded-Encrypted: i=1; AJvYcCWACOQmAc/K8UnGeWOtcyShRuV8UwzaWw/TtSdMgOGMjlaqyKOLl5NN2mWKWgJvlaWC0jR4wekbsAfABtk=@vger.kernel.org, AJvYcCX+c/cOI0Lge+YqXjHjUUqZ1gnssHDvXcRZXfo8aoZpwO/UnWB5fY3vKBoyqJJkIbBjf0MG5rpO@vger.kernel.org X-Gm-Message-State: AOJu0Yxq7fYv0AgCQELVoH80F3vxplflTL8Uu2nWYsRkkV/wnQcDAY8n zp17tLsuzpOYE1lKHZjPiBHx9G2qKM7oJx04NlY7RXoCJIqPzjEy X-Google-Smtp-Source: AGHT+IGhzl23QZe5oiIY68+Gwzi3jX3QaPRoRJc0QbTSwKKTcyFCMRzC6Xac2GYxHdfyuj8m1NjemQ== X-Received: by 2002:a17:903:11c7:b0:20b:aebb:e17c with SMTP id d9443c01a7336-20bfe04af0cmr114614775ad.36.1728197837164; Sat, 05 Oct 2024 23:57:17 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:57:16 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Kalesh AP Subject: [PATCH net-next v5 05/12] net: vxlan: make vxlan_remcsum() return drop reasons Date: Sun, 6 Oct 2024 14:56:09 +0800 Message-Id: <20241006065616.2563243-6-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Make vxlan_remcsum() support skb drop reasons by changing the return value type of it from bool to enum skb_drop_reason. The only drop reason in vxlan_remcsum() comes from pskb_may_pull_reason(), so we just return it. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman Reviewed-by: Kalesh AP --- v3: - add a empty newline before return, as Alexander advised - adjust the call of vxlan_remcsum() --- drivers/net/vxlan/vxlan_core.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 4997a2c09c14..34b44755f663 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1551,9 +1551,11 @@ static void vxlan_sock_release(struct vxlan_dev *vxlan) #endif } -static bool vxlan_remcsum(struct vxlanhdr *unparsed, - struct sk_buff *skb, u32 vxflags) +static enum skb_drop_reason vxlan_remcsum(struct vxlanhdr *unparsed, + struct sk_buff *skb, + u32 vxflags) { + enum skb_drop_reason reason; size_t start, offset; if (!(unparsed->vx_flags & VXLAN_HF_RCO) || skb->remcsum_offload) @@ -1562,15 +1564,17 @@ static bool vxlan_remcsum(struct vxlanhdr *unparsed, start = vxlan_rco_start(unparsed->vx_vni); offset = start + vxlan_rco_offset(unparsed->vx_vni); - if (!pskb_may_pull(skb, offset + sizeof(u16))) - return false; + reason = pskb_may_pull_reason(skb, offset + sizeof(u16)); + if (reason) + return reason; skb_remcsum_process(skb, (void *)(vxlan_hdr(skb) + 1), start, offset, !!(vxflags & VXLAN_F_REMCSUM_NOPARTIAL)); out: unparsed->vx_flags &= ~VXLAN_HF_RCO; unparsed->vx_vni &= VXLAN_VNI_MASK; - return true; + + return SKB_NOT_DROPPED_YET; } static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, @@ -1723,9 +1727,11 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) goto drop; } - if (vs->flags & VXLAN_F_REMCSUM_RX) - if (unlikely(!vxlan_remcsum(&unparsed, skb, vs->flags))) + if (vs->flags & VXLAN_F_REMCSUM_RX) { + reason = vxlan_remcsum(&unparsed, skb, vs->flags); + if (unlikely(reason)) goto drop; + } if (vxlan_collect_metadata(vs)) { IP_TUNNEL_DECLARE_FLAGS(flags) = { }; From patchwork Sun Oct 6 06:56:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823693 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 11E7A166F1B; Sun, 6 Oct 2024 06:57:25 +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=1728197847; cv=none; b=gLEP48Yy1t8SC99KfoHd6xbc1AnQD+uCnTqUbHUWa9I82SNJjs+3REcNJnCx4nmYwn4Dk+kQQDreYHISEtZrbyoelZp4E9snWhQjYctowSpo7OD6MzmTiCZN0TJGkAiTIpAbyreaFi3l4GVlq0qyT/VcvciUUfXMD3pgzbZdccc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197847; c=relaxed/simple; bh=0ZgJtJ+TjXiHcGPlxVYxhjDteuWSfgfQg0cBummbs2g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b/EsL4XOyT2fc64IfgEWYLAQYgXjMB7KZdG+POyegsu2dCYyh0LIYwDAXumTUny7NTg3Mq+hqkpccY5tGhoa5t6So2VPYJsLykDsodrV3kL9Dia1zOnvvlxTpW5RFa2qqotsl8aFV/64ONFz+Ityq2SepLeX7+yLurudnY9pkFU= 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=UcbczpAx; 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="UcbczpAx" Received: by mail-pl1-f194.google.com with SMTP id d9443c01a7336-20b0b2528d8so39461045ad.2; Sat, 05 Oct 2024 23:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197845; x=1728802645; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zDoqXpsFl8RNldAVAwpbrbVadRrwiVLnsOpDQV2p6FU=; b=UcbczpAxX7h++a1Y++ehiPj4iSPHdadeN3kR+yEW3MgPEoDlZSHAKgmeOZEkDowyfN kNd8agm5o5gEMBBU5pDItdIZfLJ4HYfQCP9gWhBWhNno64BNtRCMs4rnqGlkpXEOBr/P /47V5FvfDZmaFl/ZJoQtTdaDp4W3fXFvHlqC7u0vjH9jbyVQf+MCunHaWu2A1KEXPzvx pW5YyOncGWEW5a8S/Tebr7YvEso4LIRX36BDYJkn3XSpS5BG7IMqaAvO8qkmuLqNo+JR 3Dq2prrQenzGgA2eqRsCwfSD74BXRk1mnRtN1rQZb+R6GaXMdaKi+TU34Dk9Nx9biJqg 6oDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197845; x=1728802645; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zDoqXpsFl8RNldAVAwpbrbVadRrwiVLnsOpDQV2p6FU=; b=D7XxehJYZr+S9KVn9+Gmx/lqLi1nY4To0n8VbSCHjQzgMZZE77ceUEJBdbmsErJsDw hLZ1iXWr7hBqVty4qcF5HoOZByHSS+drBE0ucm96s7QUdR5GI/M5ZI7iMX/deVIs4sA5 0xiQj/PcnloFCo7jjGH6FraGtvSC5mMnn+jCrnfZire3HOhuha4JHo0zOMUmn7PzyZXw 1QI3tEb+rNgTm442DDAc0aBF9Q93imQgC7wqI9za9x5cXW7GhTqKWt3egyU0pRloCgqT vGCRetdbIepHB5a+1bFHFGLvilZ4/BEDxwvCEBpuhNw8UNKxRRhBTXW0+sUDvOrnt+g2 ycQA== X-Forwarded-Encrypted: i=1; AJvYcCU/JfIvi4LJ9NzGpJWAceXXXWlaQqDaBVMV6ScfzEGWap7lqpZrQ9yHbxcVjaiR3Ld5J9RXA145GN6uJ14=@vger.kernel.org, AJvYcCUfXBMKUENNEUAC86c+/gINbetqKRY46tvcsetsdguLHLXN75hKJ8SZ9wdmNThU+da/wH61ehoP@vger.kernel.org X-Gm-Message-State: AOJu0YyNqvWRj0JrJARE0Jg1l6Cz2wxtjrNtop3ryD6KNtQz5BSfId6D /yYycetei0uLpM0GK73GjCoEy0aE++TEFKFab8eeu5DOP0S+e7Mi X-Google-Smtp-Source: AGHT+IG2aloFo9TpQS72Qo/YAtPA2QYlWX24x6YVnSYqMWNLXgVKxuGK1VO0K+nG7GW82+cG1ehC0A== X-Received: by 2002:a17:902:d4ca:b0:1fa:9c04:946a with SMTP id d9443c01a7336-20bfdf64fcfmr117512235ad.1.1728197845380; Sat, 05 Oct 2024 23:57:25 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:57:24 -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 v5 06/12] net: vxlan: make vxlan_snoop() return drop reasons Date: Sun, 6 Oct 2024 14:56:10 +0800 Message-Id: <20241006065616.2563243-7-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Change the return type of vxlan_snoop() from bool to enum skb_drop_reason. In this commit, two drop reasons are introduced: SKB_DROP_REASON_MAC_INVALID_SOURCE SKB_DROP_REASON_VXLAN_ENTRY_EXISTS Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- v5: - rename SKB_DROP_REASON_VXLAN_INVALID_SMAC to SKB_DROP_REASON_MAC_INVALID_SOURCE in the commit log v4: - rename SKB_DROP_REASON_VXLAN_INVALID_SMAC to SKB_DROP_REASON_MAC_INVALID_SOURCE --- drivers/net/vxlan/vxlan_core.c | 17 +++++++++-------- include/net/dropreason-core.h | 9 +++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 34b44755f663..1a81a3957327 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1437,9 +1437,10 @@ static int vxlan_fdb_get(struct sk_buff *skb, * and Tunnel endpoint. * Return true if packet is bogus and should be dropped. */ -static bool vxlan_snoop(struct net_device *dev, - union vxlan_addr *src_ip, const u8 *src_mac, - u32 src_ifindex, __be32 vni) +static enum skb_drop_reason vxlan_snoop(struct net_device *dev, + union vxlan_addr *src_ip, + const u8 *src_mac, u32 src_ifindex, + __be32 vni) { struct vxlan_dev *vxlan = netdev_priv(dev); struct vxlan_fdb *f; @@ -1447,7 +1448,7 @@ static bool vxlan_snoop(struct net_device *dev, /* Ignore packets from invalid src-address */ if (!is_valid_ether_addr(src_mac)) - return true; + return SKB_DROP_REASON_MAC_INVALID_SOURCE; #if IS_ENABLED(CONFIG_IPV6) if (src_ip->sa.sa_family == AF_INET6 && @@ -1461,15 +1462,15 @@ static bool vxlan_snoop(struct net_device *dev, if (likely(vxlan_addr_equal(&rdst->remote_ip, src_ip) && rdst->remote_ifindex == ifindex)) - return false; + return SKB_NOT_DROPPED_YET; /* Don't migrate static entries, drop packets */ if (f->state & (NUD_PERMANENT | NUD_NOARP)) - return true; + return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS; /* Don't override an fdb with nexthop with a learnt entry */ if (rcu_access_pointer(f->nh)) - return true; + return SKB_DROP_REASON_VXLAN_ENTRY_EXISTS; if (net_ratelimit()) netdev_info(dev, @@ -1497,7 +1498,7 @@ static bool vxlan_snoop(struct net_device *dev, spin_unlock(&vxlan->hash_lock[hash_index]); } - return false; + return SKB_NOT_DROPPED_YET; } static bool __vxlan_sock_release_prep(struct vxlan_sock *vs) diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 98259d2b3e92..1cb8d7c953be 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -94,6 +94,8 @@ FN(TC_RECLASSIFY_LOOP) \ FN(VXLAN_INVALID_HDR) \ FN(VXLAN_VNI_NOT_FOUND) \ + FN(MAC_INVALID_SOURCE) \ + FN(VXLAN_ENTRY_EXISTS) \ FN(IP_TUNNEL_ECN) \ FNe(MAX) @@ -429,6 +431,13 @@ enum skb_drop_reason { SKB_DROP_REASON_VXLAN_INVALID_HDR, /** @SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND: no VXLAN device found for VNI */ SKB_DROP_REASON_VXLAN_VNI_NOT_FOUND, + /** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */ + SKB_DROP_REASON_MAC_INVALID_SOURCE, + /** + * @SKB_DROP_REASON_VXLAN_ENTRY_EXISTS: trying to migrate a static + * entry or an entry pointing to a nexthop. + */ + SKB_DROP_REASON_VXLAN_ENTRY_EXISTS, /** * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail. From patchwork Sun Oct 6 06:56:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823694 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 A92231662E8; Sun, 6 Oct 2024 06:57:32 +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=1728197854; cv=none; b=b1mOtmBJdO/lEjOuZ/nxH7pil97rtDquVAeH5WQIyjiyGV8GbPt+JNyelRrztLnfpL//bCjdjUcl1OkArZ/7TNsNb/x6SfbpiG5m7gGp1BZA+vi1oincIBQMWc2im/9BUVhiVkT4tE5a6eIkaFGk9eCKcxb6WEWt8fuaxvck/DU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197854; c=relaxed/simple; bh=4xIH7Aio0f4PBcaIE51Qch3dJo9N/MMWAobYuTWQmmc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Nt+6dgVXcpMMI2YPYpXaSsYQoM5RagO3ZddAj9RYU+4EqfGYIRmm0L7EeU6cVT/iAu3xHhiuIq7NqHfNxl8EAVipteEZFAmpwNE2YPadSW6ijyyXTGcO/zIwvc9Po9Ii/7fZgDD5oG8ZtYqVyu+LyHFkESGc+uyQqmovhQLuxlU= 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=IPEQ8p4e; 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="IPEQ8p4e" Received: by mail-pl1-f193.google.com with SMTP id d9443c01a7336-20bb39d97d1so29392325ad.2; Sat, 05 Oct 2024 23:57:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197852; x=1728802652; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mQoyYqReGxg6xit/tJWU0LNVGXnn5CuHq60bShXa6OE=; b=IPEQ8p4eoYgmiWe7LWVS2qLBeF589xgohMveeq3R4OQ3CpiwCp+kaXA3wAks+ijxUh kH10UrRPPhrR3YnBCj+SoRa06FVgxHhvFmL0zHldDCE2ROhxssCWD2WsY6HYy1E4TRZr k13CAxIagEXZ8+UC93UMYVniMsUph0WNB7hCVvQj45hAtnqLFGaYkhPuNN2o9BgW0+Yr 7ZOOf15q9+HTiXtuSry/cYyZWmmkd2L2/Vjhr+FosnQG2Uxo9QxnPwXrFxVsTksHU/Sx f29lbeQ12zELstPcJhMihI7pnXcIy8BwrCN0E0gcE3do2DVNydNDoBmrLj31iUT5QLdW GKtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197852; x=1728802652; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mQoyYqReGxg6xit/tJWU0LNVGXnn5CuHq60bShXa6OE=; b=RW/jvr1mvZJ7nHHlcgzphJvoCCDgwjWJiIIqwoZbgY64tyfJs43zx4ZefF6rSnWYrB a4ZGaYOWJR0laydAfrkZwAThCIZzq9kW1DLJRXbQhWE/5S6BCtA1vMo+zLv7IHCw16Ep 1VYZMtMrmJCj5BEF9TiG/M3h+xLFLbCqi9XqWwHBlNmGmQkh4pUr/TLaLHjXP+7hJMm9 acey9TtkYt1poDNRVirkgA52K0DsQLFv6iigyxLfTed4J8QYIa1I8FCmTkl9A9ugtHP4 d6NfOZI+J5OCsfGXrKbHCeFzJw1e5dj4uuaEFjXFRcYgSbQsRqPYIOomSwzl3pIlpj6e 74SA== X-Forwarded-Encrypted: i=1; AJvYcCWgSdAwIM3Re2HWVtzsaTuB52HAJZIV1bDuUvZyqQcQ8DR+UfoOx6XOkEGZCkANcUaKmnQqFmgTx1PGWnU=@vger.kernel.org, AJvYcCWgXE01d+A4wzG9SbCZgCQa0ftCruk51CratDYouJxJIAuU0xGFzU1v2yQjm4A/7Q4PAvYHFjv9@vger.kernel.org X-Gm-Message-State: AOJu0Ywl69ZDP8wYd27hKq5+tfW0cpHkhPfD9zORpNw/8vNIdQfQF+Oz 1nqU2sjcQSJ7Hs/Ezqntee7v/aEaBpMHrJqu2r70O4icHwYsevZR X-Google-Smtp-Source: AGHT+IHZp64FJEgkxIjfb5hkwn93eyOxhXrd0JpIvjRjmLIKdf3Wrlpbxed7WIDkByJi9EMCr7yCWA== X-Received: by 2002:a17:903:181:b0:20c:2e3:7139 with SMTP id d9443c01a7336-20c02e37166mr88595595ad.24.1728197851942; Sat, 05 Oct 2024 23:57:31 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:57: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 v5 07/12] net: vxlan: make vxlan_set_mac() return drop reasons Date: Sun, 6 Oct 2024 14:56:11 +0800 Message-Id: <20241006065616.2563243-8-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Change the return type of vxlan_set_mac() from bool to enum skb_drop_reason. In this commit, the drop reason "SKB_DROP_REASON_LOCAL_MAC" is introduced for the case that the source mac of the packet is a local mac. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- v5: - modify the document of SKB_DROP_REASON_LOCAL_MAC v3: - adjust the call of vxlan_set_mac() - add SKB_DROP_REASON_LOCAL_MAC --- drivers/net/vxlan/vxlan_core.c | 19 ++++++++++--------- include/net/dropreason-core.h | 6 ++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 1a81a3957327..41191a28252a 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1609,9 +1609,9 @@ static void vxlan_parse_gbp_hdr(struct vxlanhdr *unparsed, unparsed->vx_flags &= ~VXLAN_GBP_USED_BITS; } -static bool vxlan_set_mac(struct vxlan_dev *vxlan, - struct vxlan_sock *vs, - struct sk_buff *skb, __be32 vni) +static enum skb_drop_reason vxlan_set_mac(struct vxlan_dev *vxlan, + struct vxlan_sock *vs, + struct sk_buff *skb, __be32 vni) { union vxlan_addr saddr; u32 ifindex = skb->dev->ifindex; @@ -1622,7 +1622,7 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan, /* Ignore packet loops (and multicast echo) */ if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr)) - return false; + return SKB_DROP_REASON_LOCAL_MAC; /* Get address from the outer IP header */ if (vxlan_get_sk_family(vs) == AF_INET) { @@ -1635,11 +1635,11 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan, #endif } - if ((vxlan->cfg.flags & VXLAN_F_LEARN) && - vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, ifindex, vni)) - return false; + if (!(vxlan->cfg.flags & VXLAN_F_LEARN)) + return SKB_NOT_DROPPED_YET; - return true; + return vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, + ifindex, vni); } static bool vxlan_ecn_decapsulate(struct vxlan_sock *vs, void *oiph, @@ -1774,7 +1774,8 @@ static int vxlan_rcv(struct sock *sk, struct sk_buff *skb) } if (!raw_proto) { - if (!vxlan_set_mac(vxlan, vs, skb, vni)) + reason = vxlan_set_mac(vxlan, vs, skb, vni); + if (reason) goto drop; } else { skb_reset_mac_header(skb); diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index 1cb8d7c953be..fbf92d442c1b 100644 --- a/include/net/dropreason-core.h +++ b/include/net/dropreason-core.h @@ -97,6 +97,7 @@ FN(MAC_INVALID_SOURCE) \ FN(VXLAN_ENTRY_EXISTS) \ FN(IP_TUNNEL_ECN) \ + FN(LOCAL_MAC) \ FNe(MAX) /** @@ -443,6 +444,11 @@ enum skb_drop_reason { * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail. */ SKB_DROP_REASON_IP_TUNNEL_ECN, + /** + * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to + * the MAC address of the local netdev. + */ + SKB_DROP_REASON_LOCAL_MAC, /** * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which * shouldn't be used as a real 'reason' - only for tracing code gen From patchwork Sun Oct 6 06:56:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823695 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06C481714A9; Sun, 6 Oct 2024 06:57:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197861; cv=none; b=P77ggtjkbsz5aab8gyZRQo19jDXIJalwyc8BTln/SJpK2buG3YogHXHBuf5PWJTIPs5rmt05lQzuBG0gVtzJlzFtxWA7cuD/NXqL7SPBRSPzaKGFUctgxBW0yZZNFRYN6U2tge+g9B15BpHLBYJiG6VR88A1DZSMdZQ5gMSO2QM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197861; c=relaxed/simple; bh=ujpeecq6Ku1eQ+HNfJbhwy7VJNkiDsWGKEoWWfvU/Hw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QcBh5xR1ALJMoslD8lv5pHP/w+Bl/mSf3HlMaboYuXqvwRhL9YkEaWCnQrJtg+XS6dgWYrjMfosCv7BED53rjGCy2zPiccE4zEWD4pJJteSpPL4uTiFPyF8GBYGV18XaWZ7Va3PTfd41XmtdyR7GXPU9cfXZh26Vc6SuKoPKaF4= 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=ecEXfm0L; arc=none smtp.client-ip=209.85.215.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ecEXfm0L" Received: by mail-pg1-f193.google.com with SMTP id 41be03b00d2f7-7163489149eso3029781a12.1; Sat, 05 Oct 2024 23:57:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197859; x=1728802659; 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=0bAbTH4w6YKghRfLGkeXQEpG0Ld8teD6Vf5NXy7dGPs=; b=ecEXfm0Ltddk8W09t4hlqqK/3ccpwRN89LO7h9ww/emXfoH1TePIRf08ch9f4IpV2G SoiriuvZhoMvuDh5+101teC2pihgRZgMbdb28Oip7WxzBKxWZ/DAlSI6BTELKqMNN7hn oGJ6TZQApr7MC0D4WmaVfBmxmgw+2iaXPfETwMdmeKbl+ENC/eNOzI0YWuUt+s7f3E5W gYte4Umswcy1QYQ0lDwTtA7pyS2sDO1kttDyn0V8abmkBMVm7UIZ+LjXA98Bx53EK8vi goyTi9r/rSiegBMCBH483/ZBKbae8V+UA6jWWFC4V/SgeuHquiHelimpoSthqDxCXCl+ zT/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197859; x=1728802659; 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=0bAbTH4w6YKghRfLGkeXQEpG0Ld8teD6Vf5NXy7dGPs=; b=iDCk1AiR+Pjc94t8bg+i/C7uyjKTbsBUh/yLpzTYuqcR11Et8Q6UsXMEQcGDSazPHi eWi4JQ9IQgoseIp0W+g2J8MAXrlSNHCKgNP2eEIq0Kg8sMwgUY1rEyBx1wGkWYE0Fmwj Am2A4vHbEKe/uKqXMYfUt1upILN+ftFBv5gr9y1h5efkRJHyFBkcT6F5cco1EIh5X4qF UVcB5/3070ucl/J7Nq7hVWQ28VGiWa6N880x+Yk7LG3YEdLN8w6VeibifOULsU9thxjz ojXemHH2UHuagvDAeCeA1zJJ0xQzEN7bO27019LzTTC0z1W0DicXykHKfL9jbH6ccw2v H5Dw== X-Forwarded-Encrypted: i=1; AJvYcCWPdaj4S7vPoINQUDnSZKjkNkNIp+ZjKB6pcw1NGMlv+FykycLYSSRGi2X5Kq3olbHO41W2zLdhwqx55Jg=@vger.kernel.org, AJvYcCWnuOdGg7yjlVUBFTQhxF/WRvufrhghchaOhr28Ivkljqp8r2U0awxokkt7s5Q6YTyodADoQzLF@vger.kernel.org X-Gm-Message-State: AOJu0Yy1UCmYIgH4EyBA6Gwcaa6LcGulnrgPfxgVr8pFHwYDI93ccgKo Tzu8XcVFwSCTWvEFTHzHtw6qRp6lXsDeQeFgnoz6A7iHfz35j4SS X-Google-Smtp-Source: AGHT+IH1Ox+K2vHP8nFXzXw0QCiDhOcMNq+9qZlLSXdzdW9b3hdDzBWJDiZv48lYw6z21h70HAkYyg== X-Received: by 2002:a17:902:e551:b0:20b:4875:2c51 with SMTP id d9443c01a7336-20bfe024d5cmr137922685ad.27.1728197859311; Sat, 05 Oct 2024 23:57:39 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:57:38 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v5 08/12] net: vxlan: use kfree_skb_reason() in vxlan_xmit() Date: Sun, 6 Oct 2024 14:56:12 +0800 Message-Id: <20241006065616.2563243-9-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb() with kfree_skb_reason() in vxlan_xmit(). Following new skb drop reasons are introduced for vxlan: /* no remote found for xmit */ SKB_DROP_REASON_VXLAN_NO_REMOTE /* packet without necessary metatdata reached a device is in "eternal" * mode. */ SKB_DROP_REASON_TUNNEL_TXINFO Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- v5: - modify the document for SKB_DROP_REASON_TUNNEL_TXINFO v2: - move the drop reason "TXINFO" from vxlan to core - rename VXLAN_DROP_REMOTE to VXLAN_DROP_NO_REMOTE --- drivers/net/vxlan/vxlan_core.c | 6 +++--- include/net/dropreason-core.h | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 41191a28252a..b677ec901807 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2730,7 +2730,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) if (info && info->mode & IP_TUNNEL_INFO_TX) vxlan_xmit_one(skb, dev, vni, NULL, false); else - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_TUNNEL_TXINFO); return NETDEV_TX_OK; } } @@ -2793,7 +2793,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) dev_core_stats_tx_dropped_inc(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE); return NETDEV_TX_OK; } } @@ -2816,7 +2816,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev) if (fdst) vxlan_xmit_one(skb, dev, vni, fdst, did_rsc); else - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_NO_REMOTE); } return NETDEV_TX_OK; diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h index fbf92d442c1b..0a2407e7e93f 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,17 @@ enum skb_drop_reason { * entry or an entry pointing to a nexthop. */ SKB_DROP_REASON_VXLAN_ENTRY_EXISTS, + /** @SKB_DROP_REASON_VXLAN_NO_REMOTE: no remote found for xmit */ + SKB_DROP_REASON_VXLAN_NO_REMOTE, /** * @SKB_DROP_REASON_IP_TUNNEL_ECN: skb is dropped according to * RFC 6040 4.2, see __INET_ECN_decapsulate() for detail. */ SKB_DROP_REASON_IP_TUNNEL_ECN, + /** @SKB_DROP_REASON_TUNNEL_TXINFO: packet without necessary metatdata + * reached a device is in "eternal" mode. + */ + SKB_DROP_REASON_TUNNEL_TXINFO, /** * @SKB_DROP_REASON_LOCAL_MAC: the source MAC address is equal to * the MAC address of the local netdev. From patchwork Sun Oct 6 06:56:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 13823696 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F80216D4E8; Sun, 6 Oct 2024 06:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197870; cv=none; b=gXFoUBsXcyHk8oV/U2Ew7nJHvnc/4ouEf5fI4KIAOc+kqBiIqws5qHiaXMyzpnZGdevzj07xsnTIHzjUuZs81niAj4KAFp+R+X078H5M+fxuJ7+WI307i3bO8QslC7NFvxQgRodsIbvIE55YD9B7a5cTvpb+SrQy/hPS6uV2/Zc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197870; c=relaxed/simple; bh=ZX6rpV2p4NCjpSh/ZKSJ+9hBSNtbI+i1jkrQAXbqfxM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tT8ZHoUy3VjH0EwOAbJijwAXrk6p9ossY5kEC1gpGh2F2W1zpkmr4Nc6ePkATVj77zFjoqT9/FnMN/TJE8YHnfU58DE8iKypxsZIhQr4FmDNJHdnA9MX3hjlX5Pi5/MFieOMxAQa0GoHcE991O7rddKuaIJx7LyPsTbOuXkXjNg= 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=Tq8FSqES; arc=none smtp.client-ip=209.85.215.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tq8FSqES" Received: by mail-pg1-f195.google.com with SMTP id 41be03b00d2f7-7e9fdad5af8so387425a12.3; Sat, 05 Oct 2024 23:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197868; x=1728802668; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fbb7WoMAUR4wBk7UiHJwsRsFkglFtN6iutr69JSzLxM=; b=Tq8FSqESNhDt8k6TPSC+RioBpB3N2mxqR2gZvmwiehe/gq/0IQ+wqThIuJdJbMGVjV kVelZ3AraK3hNl5VP6CKcx/9g6N8A46aaozQuLqxMdMznAz1AJC0NrQdXNYSn8JVM1/y gW9TUg6NeYg9H2XdTjKHmbTxB0yMUSWjQcO1vI+1S1kkikSZn7CPz7e2PdLp+CVX0qwt JybeLzSNlKCoO1g/W3oLLkFezmbeJU5ci7Ngxp8l7I1DMBz9N9MEk5Cdc7Ywzn5y+tzC UeHMPj+SOVFebNvTFBdEkL8F9OyonCCqFNeRU3z8CdR0yYiSZHcydfL6SC+XcfcqP6uh LTDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197868; x=1728802668; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fbb7WoMAUR4wBk7UiHJwsRsFkglFtN6iutr69JSzLxM=; b=Jso9jCIjTcowoZHaazu8HZDnN7KYVB5s/4XIt3skqBv+C4T5WMufBGqn8RxJQWvDEH iOIndC5C+B8c/GexGnThnSMWdDu2MoVoucjFHHpu5qEDbX5qyOZZfqB03/dIsXUStFaU xdrLpGiQY27RmnSvsKO4ZKtMn13Qo0y/C2JxtwUoua0gIwmr0RRtJxQT36t/XQhhvt9V Yt+s9ODoINUKfyj9zsMc4GIjG3jDRFRmCDseAGt2Qww0d4f4tnDWTCahg+DgUyCysxyl myTv7w0PuLtfk4hQH5mDDcmGY3JJhwJhZGSxG0HLWTQ9XESyHRPMOFBfX/eX3xkP9DL4 fZ/A== X-Forwarded-Encrypted: i=1; AJvYcCWWUCtCeii+AtObL+bbd+k72if8Xlmd33Wx17JHgBbbnigqDu5DRLTuYkLBliLQ7wc4qnqKouM1DYq/nHE=@vger.kernel.org, AJvYcCX6kKwHxLcqm/4q4hyKwtSoqr1V8KiSnhlbMINoscLjuOy0UDE6x+V8nQeo2Dy23P6lM+wntlzC@vger.kernel.org X-Gm-Message-State: AOJu0YyJyoQqYgH4y1x/wvBWc4W/1xToloRvy9JTAgXEyG/EDsPrMMiB 6s7ImCYh75Zye8xYjd5CEz6G7LTepejhRymejTWKfHb6/p/qLrtr X-Google-Smtp-Source: AGHT+IH/4CPkp5sJFNk+kzSowYbzr1jK4IfSOz7gEMXrzQJVKLMO5H9EdxmPhvZOkOT2pLu/z82oTw== X-Received: by 2002:a17:902:e88f:b0:20b:7bcb:5c5a with SMTP id d9443c01a7336-20bfe060515mr125561455ad.16.1728197868570; Sat, 05 Oct 2024 23:57:48 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.57.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:57:48 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v5 09/12] net: vxlan: add drop reasons support to vxlan_xmit_one() Date: Sun, 6 Oct 2024 14:56:13 +0800 Message-Id: <20241006065616.2563243-10-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb/dev_kfree_skb with kfree_skb_reason in vxlan_xmit_one. No drop reasons are introduced in this commit. The only concern of mine is replacing dev_kfree_skb with kfree_skb_reason. The dev_kfree_skb is equal to consume_skb, and I'm not sure if we can change it to kfree_skb here. In my option, the skb is "dropped" here, isn't it? Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- drivers/net/vxlan/vxlan_core.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index b677ec901807..508693fa4fd9 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2374,13 +2374,16 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, bool use_cache; bool udp_sum = false; bool xnet = !net_eq(vxlan->net, dev_net(vxlan->dev)); + enum skb_drop_reason reason; bool no_eth_encap; __be32 vni = 0; no_eth_encap = flags & VXLAN_F_GPE && skb->protocol != htons(ETH_P_TEB); - if (skb_vlan_inet_prepare(skb, no_eth_encap)) + reason = skb_vlan_inet_prepare(skb, no_eth_encap); + if (reason) goto drop; + reason = SKB_DROP_REASON_NOT_SPECIFIED; old_iph = ip_hdr(skb); info = skb_tunnel_info(skb); @@ -2484,6 +2487,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, tos, use_cache ? dst_cache : NULL); if (IS_ERR(rt)) { err = PTR_ERR(rt); + reason = SKB_DROP_REASON_IP_OUTNOROUTES; goto tx_error; } @@ -2535,8 +2539,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ttl = ttl ? : ip4_dst_hoplimit(&rt->dst); err = vxlan_build_skb(skb, ndst, sizeof(struct iphdr), vni, md, flags, udp_sum); - if (err < 0) + if (err < 0) { + reason = SKB_DROP_REASON_NOMEM; goto tx_error; + } udp_tunnel_xmit_skb(rt, sock4->sock->sk, skb, saddr, pkey->u.ipv4.dst, tos, ttl, df, @@ -2556,6 +2562,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, if (IS_ERR(ndst)) { err = PTR_ERR(ndst); ndst = NULL; + reason = SKB_DROP_REASON_IP_OUTNOROUTES; goto tx_error; } @@ -2596,8 +2603,10 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, skb_scrub_packet(skb, xnet); err = vxlan_build_skb(skb, ndst, sizeof(struct ipv6hdr), vni, md, flags, udp_sum); - if (err < 0) + if (err < 0) { + reason = SKB_DROP_REASON_NOMEM; goto tx_error; + } udp_tunnel6_xmit_skb(ndst, sock6->sock->sk, skb, dev, &saddr, &pkey->u.ipv6.dst, tos, ttl, @@ -2612,7 +2621,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, drop: dev_core_stats_tx_dropped_inc(dev); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_DROPS, 0); - dev_kfree_skb(skb); + kfree_skb_reason(skb, reason); return; tx_error: @@ -2624,7 +2633,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, dst_release(ndst); DEV_STATS_INC(dev, tx_errors); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_ERRORS, 0); - kfree_skb(skb); + kfree_skb_reason(skb, reason); } static void vxlan_xmit_nh(struct sk_buff *skb, struct net_device *dev, From patchwork Sun Oct 6 06:56: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: 13823697 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 1D4231EB36; Sun, 6 Oct 2024 06:57:54 +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=1728197877; cv=none; b=tyu6vJ1HYnjKm7gX+CjFQ6QVSBLStbUprJ8hEsU6ZxW+jkPL9xwRxQODEz9h8eT+PjuH3mWAVxT1EFAoCI8cKHaArqh2r++tMV1uIY8RyosazNrwbNoD8Za+59BVRPy43uaKKQEK0mev3FnTs4wDE3/bFpVIxqjJOb4gObsl72E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197877; c=relaxed/simple; bh=YBE7Gm/eB2TlKhxoUuPSI1O81VwH7aGArvM+el/K8oQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J+XXvmzqyiNgzbAB0HtnkSVYEAM8PU9sa4aT8PtFENQymCg+5ZnNRVPFVgCcKCfm/D//MHdDm7GdaPzdQKz0Yay5kU/A659qgsZs6ZzSYu/h8RmxFx+4xHZ53isKBpXgyb+WCdbeN5+WmIrwfQVlJvwp68VlrxdtjyrraUNZCg0= 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=WWase6wG; 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="WWase6wG" Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-20b58f2e1f4so22917685ad.2; Sat, 05 Oct 2024 23:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197874; x=1728802674; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VUrRZI6iM2TdSh5ZMNy/fS83zTOTT53JwP3p/9CnIm0=; b=WWase6wG+zrmBQZ2ctfbFN62xdCRS84ryNK6FsmmLBPDB1qHYY/WFRXN1CqsUBu7qk 1WpUNlSJNVSWK1dLlXHCevQpJMUgj4gbDdMzZxwoWeWabeIFAY0wJdKSPSQbZKV0/HH6 giDZolQfuHV/H4GoFEK6kr0HzRBF9rcOi6EwF9Qady5c+WtmDT7/BwxLqijpgd+YDrGM e613HTuqD5/ODfnDidGSrPYMnRoS6s+3+0840sthxVLps8fDQNzV7HJnMYE5cOtE9BoK YrWWZEM4HNfHvPQEjbOIzq0JunEiHQBJyJlyyJWEXy8DNGPvZmEz/kkmEJ+rRlfWk2db Ecbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197874; x=1728802674; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VUrRZI6iM2TdSh5ZMNy/fS83zTOTT53JwP3p/9CnIm0=; b=Gw8HEmeUQhOI096kGAd2FtNqiaKS5FOYiNvMH5bBTc9qQyg3OXwo6YSmAaB8I78wq7 Eva6JgA3ygAhyDgiBxnH9twlOeeB8xhPLeXRTUszdngXUlM61yTXnWqXH328r2zZGm1A 1SgIXwqfGMRIOM40k4wgtl1XYV8iJn6PrXiY4u1wS+lzvOLannI0+PM4xlaHD1InbyTz fbk3U94ndHc839gX5Sw6ZKBHKjGqqjnB0GnTRbrA+XH4l+FIfstoO3XWRAT/R88Ue772 eivn9qIQo1Tnxch6g/SeKxQhYdXlyWoh7w6N71Oyh7XuvzFbkCgirvLh5KQkL69T4d20 UK6g== X-Forwarded-Encrypted: i=1; AJvYcCVuluToP8tX4HwaxDNelVRbTYQj0H1WMcbv1xO/CxsuXlAXChNXcdR1DGRyGlYs5H22c0er+eyoHfoMwsA=@vger.kernel.org, AJvYcCWWAVvfhNrMKH+SRvkHDfNqdPm7XG645KSv4TlykuvPgxJ9ykSNupKjwygTcTQGZiifYY4yHZOJ@vger.kernel.org X-Gm-Message-State: AOJu0YxXAKZd9J2kIhTgJ+g11uWU01XUy+7oDPWO6kSO9ysS19cCF6mG 0zDc1lLy36q9GXK3Sug8+pMxMd2/L+UcgtkbWnMZtcXpKoA4dZHH X-Google-Smtp-Source: AGHT+IHFWCumIHgc11KXUc6Nu3PPfqOmTx28qcmiKH7nGDeP4D5XmucA6wZ7v9cbFVE1kcmyI0hFqQ== X-Received: by 2002:a17:903:2307:b0:20b:75ce:cfb6 with SMTP id d9443c01a7336-20bfe023d1cmr156580815ad.6.1728197874426; Sat, 05 Oct 2024 23:57:54 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:57: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 v5 10/12] net: vxlan: use kfree_skb_reason() in vxlan_mdb_xmit() Date: Sun, 6 Oct 2024 14:56:14 +0800 Message-Id: <20241006065616.2563243-11-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-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 Sun Oct 6 06:56: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: 13823698 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 26AF41EB36; Sun, 6 Oct 2024 06:58: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=1728197883; cv=none; b=Tu41ULwLkJq8l82FhAzowmb4Erbhg/fY0wG1HvAIudLvbavnsq1OTESAGQ39OsVZkrpxqsU0ZVQh8BAb5p1ZG41EjzIR053r+2rV0SJL/jbD/YCPOHhuuG960c4FSJdgS13ehWUMgOyJR/If7TYLNs7P/FB/LABZmFFYvYiVosk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197883; c=relaxed/simple; bh=dKbZM7+rvKdCAftLsIqRMrR/jd8BPaE4KCzu53bpfvM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MgMQb4Y/B+DBCY1n+HWDHVXKu1E1NMHo+Rm6LijyhjfcuEL7DnmiFGC94AfasCnd/H+rZ0Sesfae3vadWtKwavt9PJvsd0WH5pSPSt4WcNLc2K2H8FAmTMEDy2y7X5/rrE8eTSdI50FdPh2AidkIjgBoPb8WJBmLb+XBaunSIE0= 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=mmKHhRnb; 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="mmKHhRnb" Received: by mail-pl1-f195.google.com with SMTP id d9443c01a7336-20b7eb9e81eso40353855ad.2; Sat, 05 Oct 2024 23:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197881; x=1728802681; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qwQKLkW+/qRHGLn4gTua8kQBWJmQk8KcS+aTLWa1XwA=; b=mmKHhRnbppEjbB/Rtkgbsx5F1GIrjzFhOkyoLRKfcrckLrjZxRMlXeXyHKfzOJVI5R ya13Gw3Gi2SGD89apdqiGczHh4+qn6UbA66t+/BduSmRwQTQwirycahHvsa/LR24uHs2 4Em7C90vY5jPmZQhxFIzEA5UIf91M2MF03zfx2d3cZWHvfLppjblw2++S91O5fCWKRGG meHOO3/Fjl0nTuOs4c/fPeCUnQc55MAoXaXO2ama0BKtHKMVMdesPoSByXub02XiewCV SSF3+dL/k3uPrTZ2W4qpWxceVK/Z5kBkbQRIodOPX0mTVuQHM3UCfiAzKfElTZQ9JDlu Lskw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197881; x=1728802681; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qwQKLkW+/qRHGLn4gTua8kQBWJmQk8KcS+aTLWa1XwA=; b=aYUoC3I5A9TiyQIcIBG137JQ9IRSOClpgHkZzOQhM9CEOvs2Qth7BweGoq8rOOW5Es AAWwSOLwIfvnOIRGuLqL/ZgmSC8sqRed2aQs7K9UYANBjaUK212yVLIj80qZUlrjGwWn Bfp6i7TUPsDMZuZztixI4ioAbraOdAWTqdI23BYq7fNkvONS1wsXtEe++2mJLBIAoE6H xAGr2m2e5LdrV0I2M2tYs5/mSwy7tx5rzeBKXXO9wsve/+Gso3C2KgKF/QuCWlRgohpZ iLHeggHRYHUUDuK2Fck9jrDEZLh8IWvREVSw3iKWKX/jQAFN/12ycAyEb+vaqzzVnItD 1NcA== X-Forwarded-Encrypted: i=1; AJvYcCWFCD0HpsQzr05zuPF3RgPrtOULsczCkmB+sDJGII+xKO+KybDpoqwkqfHahbRQrW/H7/9yR6hk@vger.kernel.org, AJvYcCXDUr2iWz6YeGY3YhYhuluTIpvQMhXhGbQ0pQT1r/4o8iVRHnjCpkwVcLIgvtBbZtrXo0VxWfJusnjAh+M=@vger.kernel.org X-Gm-Message-State: AOJu0YwU7iN22em2CyYtDgXnN9XkQPfbgemdlFOiA8XWByaARccC8cRe xLjM71E2rqL6jrYDFBsATPjRUyBiid0E42HAfir1nCxuhTyGkdfc X-Google-Smtp-Source: AGHT+IEfC8ROF4RbEcTIyUxsKlI8U1ld6f3g9Q0X45WL5SD8P+lfFDocjmki6uJYpIN4UeSd7MEnIw== X-Received: by 2002:a17:902:f651:b0:20b:9b35:c62d with SMTP id d9443c01a7336-20bff194c27mr115722935ad.59.1728197881433; Sat, 05 Oct 2024 23:58:01 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:58:01 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH net-next v5 11/12] net: vxlan: use kfree_skb_reason() in vxlan_encap_bypass() Date: Sun, 6 Oct 2024 14:56:15 +0800 Message-Id: <20241006065616.2563243-12-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb with kfree_skb_reason in vxlan_encap_bypass, and no new skb drop reason is added in this commit. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman --- drivers/net/vxlan/vxlan_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 508693fa4fd9..da4de19d0331 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2290,7 +2290,7 @@ static void vxlan_encap_bypass(struct sk_buff *skb, struct vxlan_dev *src_vxlan, rcu_read_lock(); dev = skb->dev; if (unlikely(!(dev->flags & IFF_UP))) { - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_DEV_READY); goto drop; } From patchwork Sun Oct 6 06:56: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: 13823699 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 57E2D166F34; Sun, 6 Oct 2024 06:58:09 +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=1728197890; cv=none; b=FTk7AjWMNcmAdQQkLXAx90pj0s2SJ4zfQJMSQCFon4MuLcCGD/ARG0Gsnd27KeQPEDWH62lkWUAwP1T6HC2A96bUZKFddrGwmqwjfU0yGzlw6HBjBSUgLzHHHE6zXTWiMrRdCc50fR/VfK9N3qeYbKm7mbmMa2fRPZO0uBcH96E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728197890; c=relaxed/simple; bh=R8vmG0u3lFl9fsXKHPJv8VqmdcKKDyrNnQXHw0Dmp2U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iJk9TTud4PzkrR2m1fLMLQJ76dqtK5IaOozT4W2Hqggn5zGXeT3gE0xp01d2+rTeFHEtR3s5nt3y4S3SH3y9yu+pjMC+72IF+wpvYtwQ9CdqbJhHd8XmEP++mRerl0GoSJRWnyGqG22zL4Wju3eo64y5SnFtWHYLv20iULlHDtU= 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=RlLXcs7z; 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="RlLXcs7z" Received: by mail-pl1-f196.google.com with SMTP id d9443c01a7336-20b8be13cb1so36788035ad.1; Sat, 05 Oct 2024 23:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728197889; x=1728802689; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KyNsEi0JeRXi6J1a9d2wdU47n7lnZVibMGfNyAtDMsk=; b=RlLXcs7zSqq16XUxgkaXFPYbt/1n2MydCS1RwnXY69FZkgFEOiw5SqYs0fdgGYueer STmJNVGlqDdn+SCGlo6QOtsK7lG4dIcJ2Ls7lwgh5VozRxNI/9Dx2wHUywYH1IHuPjXy S6gIX135QwTy5a/nfL5WZ2lWFH19h74/+iLSGFU4HKE5fxLBJM2NJ5mFadUYiB6U0iIM GgFQJFkspT6MLAhSdqpU3g1bfIlQUc0qDES3EAcDGx0qt2tF1DQ+8hAHeajuSn5PpjHN /S2bPIANQBrpeEyo2LFyKgakh0Cg78zRB5GhJ0Y1yj7Awskk8ODVRQGEDhlQg3nD474f a9WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728197889; x=1728802689; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KyNsEi0JeRXi6J1a9d2wdU47n7lnZVibMGfNyAtDMsk=; b=KuIQe/IVFqFIsrNV2QbDvKhoP9PuwkA+mWkOaKWBePR7IP2VuEuBpwdgPZcA6HC2wN Rc75hy3+Ov+w40PKt5/0HWtT7FlC3cOGJXyaAx2jBdWKfpyf7jCZN3TMqRbPqACh669o Vt5Ik22NP5WmjTYH4OwrKvy1bdVrFHmNfpt2LwHtZhu4rMgCnwLoPKiy+VyQuEi8m2rQ e84oAa8NoRTOK+KczWQUJh0lhl0Pxg+2y/yVeZxdW+VYbnhcuXDswuppw2T9WlnbKrGE NgcL+hvgxV70ZFlYyq5Sdm8Lg9vqgktwyNfcSJ9TCKjf9/sUmBcS2VxUjPWamQ6jLZW3 VAfw== X-Forwarded-Encrypted: i=1; AJvYcCVgQ1/BrXil23i+qC79tp2lBdcCECcZovB/uyHC90WIZ+3+Ft3OlhHuF4Wv8nvCc7LQBeOjlWo9JjQcnpU=@vger.kernel.org, AJvYcCWdqHsukdx+kT0s9V8DQSnkf7i04OHY0oKTjU+KBLoYV6cKU6krAuT+fpDLLA2QTvV+jM+r8Zh0@vger.kernel.org X-Gm-Message-State: AOJu0Yym7z4nqxVHuOz479R176xTcm9njnDrX/AVgI5qkR9oaxdh9f8b qG1HJi/P1dGi6YFk9VBIPim9DMCM0z3Lc205pD2PMWag5iLrwVIG X-Google-Smtp-Source: AGHT+IHx42K0WqJ7EvcJSGjOcyT5M9GQpn0waDeAp3xdXSAlH9kCkGHV8u7YOUh7HcgCxMClRPiyXQ== X-Received: by 2002:a17:902:7446:b0:205:4885:235e with SMTP id d9443c01a7336-20bff04b26bmr98164725ad.39.1728197888703; Sat, 05 Oct 2024 23:58:08 -0700 (PDT) Received: from localhost.localdomain ([43.129.25.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c138af813sm21749865ad.9.2024.10.05.23.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 23:58:08 -0700 (PDT) From: Menglong Dong X-Google-Original-From: Menglong Dong To: idosch@nvidia.com, kuba@kernel.org, aleksander.lobakin@intel.com, horms@kernel.org Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, dsahern@kernel.org, dongml2@chinatelecom.cn, amcohen@nvidia.com, gnault@redhat.com, bpoirier@nvidia.com, b.galvani@gmail.com, razor@blackwall.org, petrm@nvidia.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Kalesh AP Subject: [PATCH net-next v5 12/12] net: vxlan: use kfree_skb_reason() in encap_bypass_if_local() Date: Sun, 6 Oct 2024 14:56:16 +0800 Message-Id: <20241006065616.2563243-13-dongml2@chinatelecom.cn> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241006065616.2563243-1-dongml2@chinatelecom.cn> References: <20241006065616.2563243-1-dongml2@chinatelecom.cn> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Replace kfree_skb() with kfree_skb_reason() in encap_bypass_if_local, and no new skb drop reason is added in this commit. Signed-off-by: Menglong Dong Reviewed-by: Simon Horman Reviewed-by: Kalesh AP --- drivers/net/vxlan/vxlan_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index da4de19d0331..f7e94bb8e30e 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2341,7 +2341,7 @@ static int encap_bypass_if_local(struct sk_buff *skb, struct net_device *dev, DEV_STATS_INC(dev, tx_errors); vxlan_vnifilter_count(vxlan, vni, NULL, VXLAN_VNI_STATS_TX_ERRORS, 0); - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_VXLAN_INVALID_HDR); return -ENOENT; }