[lustre-devel] [PATCH 06/20] lnet: add iface index to struct lnet_inetdev

James Simmons <[email protected]>
Newsgroups org.lustre.lists.lustre-devel
Message-ID <[email protected]>
From: Mr NeilBrown <[email protected]>

When getting list of interfaces, get the index as well, as this can be
useful and avoid search the list of interfaces again to find it.

WC-bug-id: https://jira.whamcloud.com/browse/LU-10391
Lustre-commit: 860182ee6e84d391a ("LU-10391 lnet: add iface index to struct lnet_inetdev")
Signed-off-by: Mr NeilBrown <[email protected]>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/48569
Reviewed-by: jsimmons <[email protected]>
Reviewed-by: Serguei Smirnov <[email protected]>
Reviewed-by: Frank Sehr <[email protected]>
Reviewed-by: Oleg Drokin <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
 include/linux/lnet/lib-lnet.h    | 1 +
 net/lnet/klnds/socklnd/socklnd.c | 2 +-
 net/lnet/lnet/config.c           | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/lnet/lib-lnet.h b/include/linux/lnet/lib-lnet.h
index a95919e69802..eb48d2900172 100644
--- a/include/linux/lnet/lib-lnet.h
+++ b/include/linux/lnet/lib-lnet.h
@@ -826,6 +826,7 @@ struct lnet_inetdev {
 	u32	li_flags;
 	u32	li_ipaddr;
 	u32	li_netmask;
+	u32	li_index;
 	char	li_name[IFNAMSIZ];
 };
 
diff --git a/net/lnet/klnds/socklnd/socklnd.c b/net/lnet/klnds/socklnd/socklnd.c
index 2b08501133dc..69cb738796e7 100644
--- a/net/lnet/klnds/socklnd/socklnd.c
+++ b/net/lnet/klnds/socklnd/socklnd.c
@@ -2522,11 +2522,11 @@ ksocknal_startup(struct lnet_ni *ni)
 	}
 
 	ni->ni_dev_cpt = ifaces[i].li_cpt;
+	ksi->ksni_index = ifaces[i].li_index;
 	sa = (void *)&ksi->ksni_addr;
 	memset(sa, 0, sizeof(*sa));
 	sa->sin_family = AF_INET;
 	sa->sin_addr.s_addr = htonl(ifaces[i].li_ipaddr);
-	ksi->ksni_index = ksocknal_ip2index((struct sockaddr *)sa, ni);
 	ksi->ksni_netmask = ifaces[i].li_netmask;
 	strlcpy(ksi->ksni_name, ifaces[i].li_name, sizeof(ksi->ksni_name));
 
diff --git a/net/lnet/lnet/config.c b/net/lnet/lnet/config.c
index da3d20e5bebb..083a9a29697f 100644
--- a/net/lnet/lnet/config.c
+++ b/net/lnet/lnet/config.c
@@ -1538,6 +1538,7 @@ int lnet_inet_enumerate(struct lnet_inetdev **dev_list, struct net *ns)
 
 			ifaces[nip].li_cpt = cpt;
 			ifaces[nip].li_flags = flags;
+			ifaces[nip].li_index = dev->ifindex;
 			ifaces[nip].li_ipaddr = ntohl(ifa->ifa_local);
 			ifaces[nip].li_netmask = ntohl(ifa->ifa_mask);
 			strlcpy(ifaces[nip].li_name, ifa->ifa_label,
-- 
2.27.0

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.