[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251028033812.2043964-2-kuniyu@google.com>
Date: Tue, 28 Oct 2025 03:36:56 +0000
From: Kuniyuki Iwashima <kuniyu@...gle.com>
To: "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>
Cc: Simon Horman <horms@...nel.org>, Kuniyuki Iwashima <kuniyu@...gle.com>,
Kuniyuki Iwashima <kuni1840@...il.com>, netdev@...r.kernel.org
Subject: [PATCH v1 net-next 01/13] mpls: Return early in mpls_label_ok().
When mpls_label_ok() returns false, it does not need to update *index.
Let's remove is_ok and return early.
Signed-off-by: Kuniyuki Iwashima <kuniyu@...gle.com>
---
net/mpls/af_mpls.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 25c88cba5c48..e3533d85d372 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -940,24 +940,23 @@ static int mpls_nh_build_multi(struct mpls_route_config *cfg,
static bool mpls_label_ok(struct net *net, unsigned int *index,
struct netlink_ext_ack *extack)
{
- bool is_ok = true;
-
/* Reserved labels may not be set */
if (*index < MPLS_LABEL_FIRST_UNRESERVED) {
NL_SET_ERR_MSG(extack,
"Invalid label - must be MPLS_LABEL_FIRST_UNRESERVED or higher");
- is_ok = false;
+ return false;
}
/* The full 20 bit range may not be supported. */
- if (is_ok && *index >= net->mpls.platform_labels) {
+ if (*index >= net->mpls.platform_labels) {
NL_SET_ERR_MSG(extack,
"Label >= configured maximum in platform_labels");
- is_ok = false;
+ return false;
}
*index = array_index_nospec(*index, net->mpls.platform_labels);
- return is_ok;
+
+ return true;
}
static int mpls_route_add(struct mpls_route_config *cfg,
--
2.51.1.838.g19442a804e-goog
Powered by blists - more mailing lists