Skip to contentSkip to conversation

devlink: load ifname map on demand from ifname_map_rev_lookup() as well

PATCH Applied Jiri Pirko 2 participants 2 messages Nov 25, 2022

Subsystems (2)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 devlink: load ifname map on demand from ifname_map_rev_lookup() as well

From: Jiri Pirko <[email protected]>

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")
---
 devlink/devlink.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)
devlink/devlink.c +27 -8
index 8aefa101b2f8..150b4e63ead1 100644
@@ -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 &&
Signature · 1 line
2.37.3
#1 lore raw
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Quoted 8 lines · On Fri, 25 Nov 2022 10:12:51 +0100 you wrote:

From: Jiri Pirko <[email protected]>

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.

[...]

Here is the summary with links:
- [iproute2-main,REPOST] devlink: load ifname map on demand from ifname_map_rev_lookup() as well

    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=63d84b1fc98d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html