netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, dsahern@gmail.com
Subject: [patch iproute2] devlink: load ifname map on demand from ifname_map_rev_lookup() as well
Date: Wed,  9 Nov 2022 13:48:51 +0100	[thread overview]
Message-ID: <20221109124851.975716-1-jiri@resnulli.us> (raw)

From: Jiri Pirko <jiri@nvidia.com>

Commit 5cddbb274eab ("devlink: load port-ifname map on demand") changed
the ifname map to be loaded on demand from ifname_map_lookup(). However,
it didn't put this on-demand loading into ifname_map_rev_lookup() which
causes ifname_map_rev_lookup() to return -ENOENT all the time.

Fix this by triggering on-demand ifname map load
from ifname_map_rev_lookup() as well.

Fixes: 5cddbb274eab ("devlink: load port-ifname map on demand")
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 devlink/devlink.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 8aefa101b2f8..150b4e63ead1 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -838,6 +838,23 @@ static int ifname_map_load(struct dl *dl)
 	return 0;
 }
 
+static int ifname_map_check_load(struct dl *dl)
+{
+	int err;
+
+	if (dl->map_loaded)
+		return 0;
+
+	err = ifname_map_load(dl);
+	if (err) {
+		pr_err("Failed to create index map\n");
+		return err;
+	}
+	dl->map_loaded = true;
+	return 0;
+}
+
+
 static int ifname_map_lookup(struct dl *dl, const char *ifname,
 			     char **p_bus_name, char **p_dev_name,
 			     uint32_t *p_port_index)
@@ -845,14 +862,10 @@ static int ifname_map_lookup(struct dl *dl, const char *ifname,
 	struct ifname_map *ifname_map;
 	int err;
 
-	if (!dl->map_loaded) {
-		err = ifname_map_load(dl);
-		if (err) {
-			pr_err("Failed to create index map\n");
-			return err;
-		}
-		dl->map_loaded = true;
-	}
+	err = ifname_map_check_load(dl);
+	if (err)
+		return err;
+
 	list_for_each_entry(ifname_map, &dl->ifname_map_list, list) {
 		if (strcmp(ifname, ifname_map->ifname) == 0) {
 			*p_bus_name = ifname_map->bus_name;
@@ -870,6 +883,12 @@ static int ifname_map_rev_lookup(struct dl *dl, const char *bus_name,
 {
 	struct ifname_map *ifname_map;
 
+	int err;
+
+	err = ifname_map_check_load(dl);
+	if (err)
+		return err;
+
 	list_for_each_entry(ifname_map, &dl->ifname_map_list, list) {
 		if (strcmp(bus_name, ifname_map->bus_name) == 0 &&
 		    strcmp(dev_name, ifname_map->dev_name) == 0 &&
-- 
2.37.3


             reply	other threads:[~2022-11-09 12:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 12:48 Jiri Pirko [this message]
2022-11-21  8:52 ` [patch iproute2] devlink: load ifname map on demand from ifname_map_rev_lookup() as well Jiri Pirko
2022-11-21 18:34   ` Stephen Hemminger
2022-11-22 12:37     ` Jiri Pirko
2022-11-24  8:28     ` Jiri Pirko
2022-11-25  4:02       ` David Ahern
2022-11-25  8:21         ` Jiri Pirko
2022-11-25 18:58       ` Stephen Hemminger
2022-11-28  9:07         ` Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221109124851.975716-1-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).