[ewg] [PATCH] rdma_cm: Fix bugzilla 726 - rdma_bind_addr() fails on ib aliases (eg ib0:0) under Redhat 4

Moni Shoua monis at Voltaire.COM
Thu Dec 25 04:17:48 PST 2008


This fix is not to rdma_cm but to its backport.

The approach I took to solve the problem is as in suggestion #1 in the bug
report - use the same xxx_ip_dev_find() as the one used in 1.1
Besides RHEL4, I applied the fix to SLES10 as well.
There is no need to fix for RHEL5.
Other backports were not checked.

Reported-by: Philippe Bernadat <philippe.bernadat at hp.com>
Debugged-by: Philippe Bernadat <philippe.bernadat at hp.com>
Signed-off-by: Moni Shoua <monis at voltaire.com>
---
 kernel_addons/backport/2.6.16_sles10/include/linux/inetdevice.h     |   22 ++++++----
 kernel_addons/backport/2.6.16_sles10_sp1/include/linux/inetdevice.h |   22 ++++++----
 kernel_addons/backport/2.6.16_sles10_sp2/include/linux/inetdevice.h |   22 ++++++----
 kernel_addons/backport/2.6.9_U4/include/linux/inetdevice.h          |   22 ++++++----
 kernel_addons/backport/2.6.9_U5/include/linux/inetdevice.h          |   22 ++++++----
 kernel_addons/backport/2.6.9_U6/include/linux/inetdevice.h          |   22 ++++++----
 kernel_addons/backport/2.6.9_U7/include/linux/inetdevice.h          |   22 ++++++----
 7 files changed, 105 insertions(+), 49 deletions(-)

diff --git a/kernel_addons/backport/2.6.16_sles10/include/linux/inetdevice.h b/kernel_addons/backport/2.6.16_sles10/include/linux/inetdevice.h
index 4ef1826..c2fefbc 100644
--- a/kernel_addons/backport/2.6.16_sles10/include/linux/inetdevice.h
+++ b/kernel_addons/backport/2.6.16_sles10/include/linux/inetdevice.h
@@ -7,16 +7,24 @@
 static inline struct net_device *xxx_ip_dev_find(u32 addr)
 {
 	struct net_device *dev;
-	u32 ip;
+	struct in_ifaddr **ifap;
+	struct in_ifaddr *ifa;
+	struct in_device *in_dev;
 
 	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev; dev = dev->next) {
-		ip = inet_select_addr(dev, 0, RT_SCOPE_HOST);
-		if (ip == addr) {
-			dev_hold(dev);
-			break;
+	for (dev = dev_base; dev; dev = dev->next)
+		if ((in_dev = in_dev_get(dev))) {
+			for (ifap = &in_dev->ifa_list; (ifa = *ifap);
+			     ifap = &ifa->ifa_next) {
+				if (addr == ifa->ifa_address) {
+					dev_hold(dev);
+					in_dev_put(in_dev);
+					goto found;
+				}
+			}
+			in_dev_put(in_dev);
 		}
-	}
+found:
 	read_unlock(&dev_base_lock);
 
 	return dev;
diff --git a/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/inetdevice.h b/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/inetdevice.h
index 4ef1826..c2fefbc 100644
--- a/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/inetdevice.h
+++ b/kernel_addons/backport/2.6.16_sles10_sp1/include/linux/inetdevice.h
@@ -7,16 +7,24 @@
 static inline struct net_device *xxx_ip_dev_find(u32 addr)
 {
 	struct net_device *dev;
-	u32 ip;
+	struct in_ifaddr **ifap;
+	struct in_ifaddr *ifa;
+	struct in_device *in_dev;
 
 	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev; dev = dev->next) {
-		ip = inet_select_addr(dev, 0, RT_SCOPE_HOST);
-		if (ip == addr) {
-			dev_hold(dev);
-			break;
+	for (dev = dev_base; dev; dev = dev->next)
+		if ((in_dev = in_dev_get(dev))) {
+			for (ifap = &in_dev->ifa_list; (ifa = *ifap);
+			     ifap = &ifa->ifa_next) {
+				if (addr == ifa->ifa_address) {
+					dev_hold(dev);
+					in_dev_put(in_dev);
+					goto found;
+				}
+			}
+			in_dev_put(in_dev);
 		}
-	}
+found:
 	read_unlock(&dev_base_lock);
 
 	return dev;
diff --git a/kernel_addons/backport/2.6.16_sles10_sp2/include/linux/inetdevice.h b/kernel_addons/backport/2.6.16_sles10_sp2/include/linux/inetdevice.h
index 4ef1826..c2fefbc 100644
--- a/kernel_addons/backport/2.6.16_sles10_sp2/include/linux/inetdevice.h
+++ b/kernel_addons/backport/2.6.16_sles10_sp2/include/linux/inetdevice.h
@@ -7,16 +7,24 @@
 static inline struct net_device *xxx_ip_dev_find(u32 addr)
 {
 	struct net_device *dev;
-	u32 ip;
+	struct in_ifaddr **ifap;
+	struct in_ifaddr *ifa;
+	struct in_device *in_dev;
 
 	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev; dev = dev->next) {
-		ip = inet_select_addr(dev, 0, RT_SCOPE_HOST);
-		if (ip == addr) {
-			dev_hold(dev);
-			break;
+	for (dev = dev_base; dev; dev = dev->next)
+		if ((in_dev = in_dev_get(dev))) {
+			for (ifap = &in_dev->ifa_list; (ifa = *ifap);
+			     ifap = &ifa->ifa_next) {
+				if (addr == ifa->ifa_address) {
+					dev_hold(dev);
+					in_dev_put(in_dev);
+					goto found;
+				}
+			}
+			in_dev_put(in_dev);
 		}
-	}
+found:
 	read_unlock(&dev_base_lock);
 
 	return dev;
diff --git a/kernel_addons/backport/2.6.9_U4/include/linux/inetdevice.h b/kernel_addons/backport/2.6.9_U4/include/linux/inetdevice.h
index b50002b..fa70310 100644
--- a/kernel_addons/backport/2.6.9_U4/include/linux/inetdevice.h
+++ b/kernel_addons/backport/2.6.9_U4/include/linux/inetdevice.h
@@ -9,16 +9,24 @@
 static inline struct net_device *xxx_ip_dev_find(u32 addr)
 {
 	struct net_device *dev;
-	u32 ip;
+	struct in_ifaddr **ifap;
+	struct in_ifaddr *ifa;
+	struct in_device *in_dev;
 
 	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev; dev = dev->next) {
-		ip = inet_select_addr(dev, 0, RT_SCOPE_HOST);
-		if (ip == addr) {
-			dev_hold(dev);
-			break;
+	for (dev = dev_base; dev; dev = dev->next)
+		if ((in_dev = in_dev_get(dev))) {
+			for (ifap = &in_dev->ifa_list; (ifa = *ifap);
+			     ifap = &ifa->ifa_next) {
+				if (addr == ifa->ifa_address) {
+					dev_hold(dev);
+					in_dev_put(in_dev);
+					goto found;
+				}
+			}
+			in_dev_put(in_dev);
 		}
-	}
+found:
 	read_unlock(&dev_base_lock);
 
 	return dev;
diff --git a/kernel_addons/backport/2.6.9_U5/include/linux/inetdevice.h b/kernel_addons/backport/2.6.9_U5/include/linux/inetdevice.h
index b50002b..fa70310 100644
--- a/kernel_addons/backport/2.6.9_U5/include/linux/inetdevice.h
+++ b/kernel_addons/backport/2.6.9_U5/include/linux/inetdevice.h
@@ -9,16 +9,24 @@
 static inline struct net_device *xxx_ip_dev_find(u32 addr)
 {
 	struct net_device *dev;
-	u32 ip;
+	struct in_ifaddr **ifap;
+	struct in_ifaddr *ifa;
+	struct in_device *in_dev;
 
 	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev; dev = dev->next) {
-		ip = inet_select_addr(dev, 0, RT_SCOPE_HOST);
-		if (ip == addr) {
-			dev_hold(dev);
-			break;
+	for (dev = dev_base; dev; dev = dev->next)
+		if ((in_dev = in_dev_get(dev))) {
+			for (ifap = &in_dev->ifa_list; (ifa = *ifap);
+			     ifap = &ifa->ifa_next) {
+				if (addr == ifa->ifa_address) {
+					dev_hold(dev);
+					in_dev_put(in_dev);
+					goto found;
+				}
+			}
+			in_dev_put(in_dev);
 		}
-	}
+found:
 	read_unlock(&dev_base_lock);
 
 	return dev;
diff --git a/kernel_addons/backport/2.6.9_U6/include/linux/inetdevice.h b/kernel_addons/backport/2.6.9_U6/include/linux/inetdevice.h
index b50002b..fa70310 100644
--- a/kernel_addons/backport/2.6.9_U6/include/linux/inetdevice.h
+++ b/kernel_addons/backport/2.6.9_U6/include/linux/inetdevice.h
@@ -9,16 +9,24 @@
 static inline struct net_device *xxx_ip_dev_find(u32 addr)
 {
 	struct net_device *dev;
-	u32 ip;
+	struct in_ifaddr **ifap;
+	struct in_ifaddr *ifa;
+	struct in_device *in_dev;
 
 	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev; dev = dev->next) {
-		ip = inet_select_addr(dev, 0, RT_SCOPE_HOST);
-		if (ip == addr) {
-			dev_hold(dev);
-			break;
+	for (dev = dev_base; dev; dev = dev->next)
+		if ((in_dev = in_dev_get(dev))) {
+			for (ifap = &in_dev->ifa_list; (ifa = *ifap);
+			     ifap = &ifa->ifa_next) {
+				if (addr == ifa->ifa_address) {
+					dev_hold(dev);
+					in_dev_put(in_dev);
+					goto found;
+				}
+			}
+			in_dev_put(in_dev);
 		}
-	}
+found:
 	read_unlock(&dev_base_lock);
 
 	return dev;
diff --git a/kernel_addons/backport/2.6.9_U7/include/linux/inetdevice.h b/kernel_addons/backport/2.6.9_U7/include/linux/inetdevice.h
index b50002b..fa70310 100644
--- a/kernel_addons/backport/2.6.9_U7/include/linux/inetdevice.h
+++ b/kernel_addons/backport/2.6.9_U7/include/linux/inetdevice.h
@@ -9,16 +9,24 @@
 static inline struct net_device *xxx_ip_dev_find(u32 addr)
 {
 	struct net_device *dev;
-	u32 ip;
+	struct in_ifaddr **ifap;
+	struct in_ifaddr *ifa;
+	struct in_device *in_dev;
 
 	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev; dev = dev->next) {
-		ip = inet_select_addr(dev, 0, RT_SCOPE_HOST);
-		if (ip == addr) {
-			dev_hold(dev);
-			break;
+	for (dev = dev_base; dev; dev = dev->next)
+		if ((in_dev = in_dev_get(dev))) {
+			for (ifap = &in_dev->ifa_list; (ifa = *ifap);
+			     ifap = &ifa->ifa_next) {
+				if (addr == ifa->ifa_address) {
+					dev_hold(dev);
+					in_dev_put(in_dev);
+					goto found;
+				}
+			}
+			in_dev_put(in_dev);
 		}
-	}
+found:
 	read_unlock(&dev_base_lock);
 
 	return dev;



More information about the ewg mailing list