Skip to contentSkip to conversation

infiniband: convert to use netdev_for_each_mc_addr

PATCH Applied Jiri Pirko 6 participants 15 messages Feb 24, 2010 – Mar 2, 2010 8 messages not in the archive

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 infiniband: convert to use netdev_for_each_mc_addr

Due to the loop complexicity in nes_nic.c, I'm using char* to copy mc addresses to it.

---
 drivers/infiniband/hw/nes/nes_nic.c            |   85 ++++++++++++++----------
 drivers/infiniband/ulp/ipoib/ipoib_multicast.c |    8 +--
 2 files changed, 51 insertions(+), 42 deletions(-)
drivers/infiniband/hw/nes/nes_nic.c +49 -36
index c04f8fc..9384f5d 100644
@@ -810,6 +810,20 @@ static int nes_netdev_set_mac_address(struct net_device *netdev, void *p)
 }
 
 
+static void set_allmulti(struct nes_device *nesdev, u32 nic_active_bit)
+{
+	u32 nic_active;
+
+	nic_active = nes_read_indexed(nesdev, NES_IDX_NIC_MULTICAST_ALL);
+	nic_active |= nic_active_bit;
+	nes_write_indexed(nesdev, NES_IDX_NIC_MULTICAST_ALL, nic_active);
+	nic_active = nes_read_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL);
+	nic_active &= ~nic_active_bit;
+	nes_write_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL, nic_active);
+}
+
+#define get_addr(addrs, index) ((addrs) + (index) * ETH_ALEN)
+
 /**
  * nes_netdev_set_multicast_list
  */
@@ -818,7 +832,6 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 	struct nes_vnic *nesvnic = netdev_priv(netdev);
 	struct nes_device *nesdev = nesvnic->nesdev;
 	struct nes_adapter *nesadapter = nesvnic->nesdev->nesadapter;
-	struct dev_mc_list *multicast_addr;
 	u32 nic_active_bit;
 	u32 nic_active;
 	u32 perfect_filter_register_address;
@@ -831,6 +844,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 					nics_per_function, 4);
 	u8 max_pft_entries_avaiable = NES_PFT_SIZE - pft_entries_preallocated;
 	unsigned long flags;
+	int mc_count = netdev_mc_count(netdev);
 
 	spin_lock_irqsave(&nesadapter->resource_lock, flags);
 	nic_active_bit = 1 << nesvnic->nic_index;
@@ -845,12 +859,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 		mc_all_on = 1;
 	} else if ((netdev->flags & IFF_ALLMULTI) ||
 			   (nesvnic->nic_index > 3)) {
-		nic_active = nes_read_indexed(nesdev, NES_IDX_NIC_MULTICAST_ALL);
-		nic_active |= nic_active_bit;
-		nes_write_indexed(nesdev, NES_IDX_NIC_MULTICAST_ALL, nic_active);
-		nic_active = nes_read_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL);
-		nic_active &= ~nic_active_bit;
-		nes_write_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL, nic_active);
+		set_allmulti(nesdev, nic_active_bit);
 		mc_all_on = 1;
 	} else {
 		nic_active = nes_read_indexed(nesdev, NES_IDX_NIC_MULTICAST_ALL);
@@ -862,19 +871,30 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 	}
 
 	nes_debug(NES_DBG_NIC_RX, "Number of MC entries = %d, Promiscous = %d, All Multicast = %d.\n",
-		  netdev_mc_count(netdev), !!(netdev->flags & IFF_PROMISC),
+		  mc_count, !!(netdev->flags & IFF_PROMISC),
 		  !!(netdev->flags & IFF_ALLMULTI));
 	if (!mc_all_on) {
-		multicast_addr = netdev->mc_list;
+		char *addrs;
+		int i;
+		struct dev_mc_list *mcaddr;
+
+		addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
+		if (!addrs) {
+			set_allmulti(nesdev, nic_active_bit);
+			goto unlock;
+		}
+		i = 0;
+		netdev_for_each_mc_addr(mcaddr, netdev)
+			memcpy(get_addr(addrs, i++),
+			       mcaddr->dmi_addr, ETH_ALEN);
+
 		perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW +
 						pft_entries_preallocated * 0x8;
-		for (mc_index = 0; mc_index < max_pft_entries_avaiable;
-		mc_index++) {
-			while (multicast_addr && nesvnic->mcrq_mcast_filter &&
+		for (i = 0, mc_index = 0; mc_index < max_pft_entries_avaiable;
+		     mc_index++) {
+			while (i < mc_count && nesvnic->mcrq_mcast_filter &&
 			((mc_nic_index = nesvnic->mcrq_mcast_filter(nesvnic,
-					multicast_addr->dmi_addr)) == 0)) {
-				multicast_addr = multicast_addr->next;
-			}
+					get_addr(addrs, i++))) == 0));
 			if (mc_nic_index < 0)
 				mc_nic_index = nesvnic->nic_index;
 			while (nesadapter->pft_mcast_map[mc_index] < 16 &&
@@ -890,17 +910,19 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 			}
 			if (mc_index >= max_pft_entries_avaiable)
 				break;
-			if (multicast_addr) {
+			if (i < mc_count) {
+				char *addr = get_addr(addrs, i++);
+
 				nes_debug(NES_DBG_NIC_RX, "Assigning MC Address %pM to register 0x%04X nic_idx=%d\n",
-					  multicast_addr->dmi_addr,
+					  addr,
 					  perfect_filter_register_address+(mc_index * 8),
 					  mc_nic_index);
-				macaddr_high  = ((u16)multicast_addr->dmi_addr[0]) << 8;
-				macaddr_high += (u16)multicast_addr->dmi_addr[1];
-				macaddr_low   = ((u32)multicast_addr->dmi_addr[2]) << 24;
-				macaddr_low  += ((u32)multicast_addr->dmi_addr[3]) << 16;
-				macaddr_low  += ((u32)multicast_addr->dmi_addr[4]) << 8;
-				macaddr_low  += (u32)multicast_addr->dmi_addr[5];
+				macaddr_high  = ((u16) addr[0]) << 8;
+				macaddr_high += (u16) addr[1];
+				macaddr_low   = ((u32) addr[2]) << 24;
+				macaddr_low  += ((u32) addr[3]) << 16;
+				macaddr_low  += ((u32) addr[4]) << 8;
+				macaddr_low  += (u32) addr[5];
 				nes_write_indexed(nesdev,
 						perfect_filter_register_address+(mc_index * 8),
 						macaddr_low);
@@ -908,7 +930,6 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 						perfect_filter_register_address+4+(mc_index * 8),
 						(u32)macaddr_high | NES_MAC_ADDR_VALID |
 						((((u32)(1<<mc_nic_index)) << 16)));
-				multicast_addr = multicast_addr->next;
 				nesadapter->pft_mcast_map[mc_index] =
 							nesvnic->nic_index;
 			} else {
@@ -920,21 +941,13 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 				nesadapter->pft_mcast_map[mc_index] = 255;
 			}
 		}
+		kfree(addrs);
 		/* PFT is not large enough */
-		if (multicast_addr && multicast_addr->next) {
-			nic_active = nes_read_indexed(nesdev,
-						NES_IDX_NIC_MULTICAST_ALL);
-			nic_active |= nic_active_bit;
-			nes_write_indexed(nesdev, NES_IDX_NIC_MULTICAST_ALL,
-								nic_active);
-			nic_active = nes_read_indexed(nesdev,
-						NES_IDX_NIC_UNICAST_ALL);
-			nic_active &= ~nic_active_bit;
-			nes_write_indexed(nesdev, NES_IDX_NIC_UNICAST_ALL,
-								nic_active);
-		}
+		if (i < mc_count)
+			set_allmulti(nesdev, nic_active_bit);
 	}
 
+unlock:
 	spin_unlock_irqrestore(&nesadapter->resource_lock, flags);
 }
 
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +2 -6
index 8763c1e..19eba3c 100644
@@ -767,11 +767,8 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
 	}
 }
 
-static int ipoib_mcast_addr_is_valid(const u8 *addr, unsigned int addrlen,
-				     const u8 *broadcast)
+static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
 {
-	if (addrlen != INFINIBAND_ALEN)
-		return 0;
 	/* reserved QPN, prefix, scope */
 	if (memcmp(addr, broadcast, 6))
 		return 0;
@@ -811,11 +808,10 @@ void ipoib_mcast_restart_task(struct work_struct *work)
 		clear_bit(IPOIB_MCAST_FLAG_FOUND, &mcast->flags);
 
 	/* Mark all of the entries that are found or don't exist */
-	for (mclist = dev->mc_list; mclist; mclist = mclist->next) {
+	netdev_for_each_mc_addr(mclist, dev) {
 		union ib_gid mgid;
 
 		if (!ipoib_mcast_addr_is_valid(mclist->dmi_addr,
-					       mclist->dmi_addrlen,
 					       dev->broadcast))
 			continue;
 
Signature · 6 lines
1.6.6

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20100224151108.GD2663-YzwxZg+R7evMbnheQZGK0N5OCZ2W11yPFxja6HXR22MAvxtiuMwx3w@public.gmane.org

#2 lore raw

Hi Jiri,

I am having trouble applying your patch. It is erroring out on hunk #5. Current nes_nic.c does not have this line:

drivers/infiniband/hw/nes/nes_nic.c static void nes_netdev_set_multicast_list(struct net_device *netdev) · line 865

Quoted 1 line
drivers/infiniband/hw/nes/nes_nic.c +0 -1
-		  netdev_mc_count(netdev), !!(netdev->flags & IFF_PROMISC),

Did I miss an old patch?

Chien

For reference:

Quoted 4 lines
drivers/infiniband/hw/nest/nes_nic.c renamed from drivers/infiniband/hw/nes/nes_nic.c +0 -0
index c04f8fc..9384f5d 100644

[...]

Quoted 29 lines
drivers/infiniband/hw/nest/nes_nic.c renamed from drivers/infiniband/hw/nes/nes_nic.c +16 -5
@@ -862,19 +871,30 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 	}
 
 	nes_debug(NES_DBG_NIC_RX, "Number of MC entries = %d, Promiscous = %d, All Multicast = %d.\n",
-		  netdev_mc_count(netdev), !!(netdev->flags & IFF_PROMISC),
+		  mc_count, !!(netdev->flags & IFF_PROMISC),
 		  !!(netdev->flags & IFF_ALLMULTI));
 	if (!mc_all_on) {
-		multicast_addr = netdev->mc_list;
+		char *addrs;
+		int i;
+		struct dev_mc_list *mcaddr;
+
+		addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
+		if (!addrs) {
+			set_allmulti(nesdev, nic_active_bit);
+			goto unlock;
+		}
+		i = 0;
+		netdev_for_each_mc_addr(mcaddr, netdev)
+			memcpy(get_addr(addrs, i++),
+			       mcaddr->dmi_addr, ETH_ALEN);
+
 		perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW +
 						pft_entries_preallocated * 0x8;
-		for (mc_index = 0; mc_index < max_pft_entries_avaiable;
-		mc_index++) {
-			while (multicast_addr && nesvnic->mcrq_mcast_filter &&
+		for (i = 0, mc_index = 0; mc_index < max_pft_entries_avaiable;

drivers/infiniband/hw/nest/nes_nic.c static void nes_netdev_set_multicast_list(struct net_device *netdev) · line 900

Quoted 10 lines
drivers/infiniband/hw/nest/nes_nic.c renamed from drivers/infiniband/hw/nes/nes_nic.c +3 -3
+		     mc_index++) {
+			while (i < mc_count && nesvnic->mcrq_mcast_filter &&
 			((mc_nic_index = nesvnic->mcrq_mcast_filter(nesvnic,
-					multicast_addr->dmi_addr)) == 0)) {
-				multicast_addr = multicast_addr->next;
-			}
+					get_addr(addrs, i++))) == 0));
 			if (mc_nic_index < 0)
 				mc_nic_index = nesvnic->nic_index;
 			while (nesadapter->pft_mcast_map[mc_index] < 16 &&

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 603F8A3875DCE940BA37B49D0A6EA0AE842606EE-uLM7Qlg6Mbekrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org

author
#4 lore raw
Quoted 6 lines · Wed, Feb 24, 2010 at 08:46:24PM CET, chien.tin.tung-ral2JQCrhuEAvxtiuMwx3w@publ…

Hi Jiri,

I am having trouble applying your patch. It is erroring out on hunk #5. Current nes_nic.c does not have this line:

drivers/infiniband/hw/nes/nes_nic.c static void nes_netdev_set_multicast_list(struct net_device *netdev) · line 865

Quoted 1 line
drivers/infiniband/hw/nes/nes_nic.c +0 -1
-		  netdev_mc_count(netdev), !!(netdev->flags & IFF_PROMISC),

This is present in current net-next tree.

Jirka

Quoted 43 lines

Did I miss an old patch?

Chien

For reference:

Quoted 4 lines
drivers/infiniband/hw/nest/nes_nic.c renamed from drivers/infiniband/hw/nes/nes_nic.c +0 -0
index c04f8fc..9384f5d 100644

[...]

Quoted 31 lines
drivers/infiniband/hw/nest/nes_nic.c renamed from drivers/infiniband/hw/nes/nes_nic.c +18 -5
@@ -862,19 +871,30 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 	}
 
 	nes_debug(NES_DBG_NIC_RX, "Number of MC entries = %d, Promiscous = %d, All Multicast = %d.\n",
-		  netdev_mc_count(netdev), !!(netdev->flags & IFF_PROMISC),
+		  mc_count, !!(netdev->flags & IFF_PROMISC),
 		  !!(netdev->flags & IFF_ALLMULTI));
 	if (!mc_all_on) {
-		multicast_addr = netdev->mc_list;
+		char *addrs;
+		int i;
+		struct dev_mc_list *mcaddr;
+
+		addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
+		if (!addrs) {
+			set_allmulti(nesdev, nic_active_bit);
+			goto unlock;
+		}
+		i = 0;
+		netdev_for_each_mc_addr(mcaddr, netdev)
+			memcpy(get_addr(addrs, i++),
+			       mcaddr->dmi_addr, ETH_ALEN);
+
 		perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW +
 						pft_entries_preallocated * 0x8;
-		for (mc_index = 0; mc_index < max_pft_entries_avaiable;
-		mc_index++) {
-			while (multicast_addr && nesvnic->mcrq_mcast_filter &&
+		for (i = 0, mc_index = 0; mc_index < max_pft_entries_avaiable;
+		     mc_index++) {
+			while (i < mc_count && nesvnic->mcrq_mcast_filter &&
Quoted 8 lines

drivers/infiniband/hw/nest/nes_nic.c static void nes_netdev_set_multicast_list(struct net_device *netdev) · line 900

Quoted 8 lines
drivers/infiniband/hw/nest/nes_nic.c renamed from drivers/infiniband/hw/nes/nes_nic.c +1 -3
 			((mc_nic_index = nesvnic->mcrq_mcast_filter(nesvnic,
-					multicast_addr->dmi_addr)) == 0)) {
-				multicast_addr = multicast_addr->next;
-			}
+					get_addr(addrs, i++))) == 0));
 			if (mc_nic_index < 0)
 				mc_nic_index = nesvnic->nic_index;
 			while (nesadapter->pft_mcast_map[mc_index] < 16 &&

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw
In reply to a message not in the archive

drivers/infiniband/ulp/ipoib/ipoib_multicast.c void ipoib_mcast_dev_flush(struct net_device *dev) · line 771

Quoted 9 lines · Jiri Pirko
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +1 -4
@@ -767,11 +767,8 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
-static int ipoib_mcast_addr_is_valid(const u8 *addr, unsigned int addrlen,
-				     const u8 *broadcast)
+static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
 {
-	if (addrlen != INFINIBAND_ALEN)
-		return 0;

This check was added by commit 5e47596b "IPoIB: Check multicast address format", may I ask what is the reason for removing it now?

Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4B862E07.7020002-hKgKHo2Ms0FWk0Htik3J/[email protected]

author
#7 lore raw
Quoted 12 lines · Thu, Feb 25, 2010 at 09:00:07AM CET, ogerlitz-smomgflXvOZWk0Htik3J/[email protected]…

drivers/infiniband/ulp/ipoib/ipoib_multicast.c void ipoib_mcast_dev_flush(struct net_device *dev) · line 771

Quoted 9 lines · Jiri Pirko
drivers/infiniband/ulp/ipoib/ipoib_multicast.c +1 -4
@@ -767,11 +767,8 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
-static int ipoib_mcast_addr_is_valid(const u8 *addr, unsigned int addrlen,
-				     const u8 *broadcast)
+static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
 {
-	if (addrlen != INFINIBAND_ALEN)
-		return 0;

This check was added by commit 5e47596b "IPoIB: Check multicast address format", may I ask what is the reason for removing it now?

Yes, at this very moment the check is not needless but it will be in a brief future. dev_mc_add will look very similar like dev_unicast_add. But ok. Here's patch adding the check in dev_mc_add right now to correct this state. Thanks Or.

Subject: [net-next-2.6 PATCH] net: add addr len check to dev_mc_add

net/core/dev_mcast.c +2 -0
index 9e2fa39..fd91569 100644
@@ -96,6 +96,8 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
 	int err;
 
 	netif_addr_lock_bh(dev);
+	if (alen != dev->addr_len)
+		return -EINVAL;
 	err = __dev_addr_add(&dev->mc_list, &dev->mc_count, addr, alen, glbl);
 	if (!err)
 		__dev_set_rx_mode(dev);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20100225084915.GA3171-YzwxZg+R7et1/[email protected]

#10 lore raw
Quoted 13 lines · Jiri Pirko
Quoted 11 lines · Thu, Feb 25, 2010 at 09:00:07AM CET, ogerlitz-smomgflXvOZWk0Htik3J/[email protected]…

Review void ipoib_mcast_dev_flush(struct net_device *dev) · line 771

Quoted 8 lines · Jiri Pirko

+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c

(quoted diff) +1 -4
@@ -767,11 +767,8 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
-static int ipoib_mcast_addr_is_valid(const u8 *addr, unsigned int addrlen,
-				     const u8 *broadcast)
+static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
 {
-	if (addrlen != INFINIBAND_ALEN)
-		return 0;

This check was added by commit 5e47596b "IPoIB: Check multicast address format", may I ask what is the reason for removing it now?

Quoted 3 lines

Yes, at this very moment the check is not needless but it will be in a brief future. dev_mc_add will look very similar like dev_unicast_add. But ok. Here's patch adding the check in dev_mc_add right now to correct this state. Thanks Or.

Is this enough?

The problem this statement is trying to solve had to do with bonding creating multicast addresess for ethernet rather than infiniband in some cases. This happens because bonding makes a device that switches from ethernet to infiniband during its lifetime. I'm not quite sure what kind of life cycle those addresses go through, but if they somehow stay on the mc_list then ipoib_mcast_addr_is_valid will still need to have the check.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20100227060146.GA13231-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

author
#12 lore raw
Quoted 20 lines · Sat, Feb 27, 2010 at 07:01:46AM CET, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn…
Quoted 13 lines · Jiri Pirko
Quoted 11 lines · Thu, Feb 25, 2010 at 09:00:07AM CET, ogerlitz-smomgflXvOZWk0Htik3J/[email protected]…

Review void ipoib_mcast_dev_flush(struct net_device *dev) · line 771

Quoted 8 lines · Jiri Pirko

+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c

(quoted diff) +1 -4
@@ -767,11 +767,8 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
-static int ipoib_mcast_addr_is_valid(const u8 *addr, unsigned int addrlen,
-				     const u8 *broadcast)
+static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
 {
-	if (addrlen != INFINIBAND_ALEN)
-		return 0;

This check was added by commit 5e47596b "IPoIB: Check multicast address format", may I ask what is the reason for removing it now?

Quoted 3 lines

Yes, at this very moment the check is not needless but it will be in a brief future. dev_mc_add will look very similar like dev_unicast_add. But ok. Here's patch adding the check in dev_mc_add right now to correct this state. Thanks Or.

Is this enough?

Quoted 8 lines

The problem this statement is trying to solve had to do with bonding creating multicast addresess for ethernet rather than infiniband in some cases. This happens because bonding makes a device that switches from ethernet to infiniband during its lifetime. I'm not quite sure what kind of life cycle those addresses go through, but if they somehow stay on the mc_list then ipoib_mcast_addr_is_valid will still need to have the check.

Ok I see your point now. But in this case, the length check should be in all drivers because if for example bonding device changes from infiniband back to eth, the addresses stored would be "cut" to 6 bytes and would make no sense.

I see two solutions:
1) check the length in all drivers to ensure correctness.
2) when bonding changes it's type, flush mc addresses and start over.

Second option looks nicer to me, but I might be missing something, thouths?

Thanks

Jirka

Quoted 1 line

Jason

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#13 lore raw

From: Jiri Pirko <[email protected]>
Date: Sat, 27 Feb 2010 11:38:37 +0100

Quoted 5 lines

I see two solutions:
1) check the length in all drivers to ensure correctness.
2) when bonding changes it's type, flush mc addresses and start over.

Second option looks nicer to me, but I might be missing something, thouths?

If bonding is causing this problem, perhaps we should make bonding go through a programmatic interface to do it's work so that the check can be done generically and in a place that will get caught during code changes and audits.

A message that is not in the archive (sent off-list or not yet received): 20100227103835.GA2862-YzwxZg+R7et1/[email protected]

#15 lore raw
Quoted 11 lines · Jiri Pirko
Quoted 7 lines

The problem this statement is trying to solve had to do with bonding creating multicast addresess for ethernet rather than infiniband in some cases. This happens because bonding makes a device that switches from ethernet to infiniband during its lifetime. I'm not quite sure what kind of life cycle those addresses go through, but if they somehow stay on the mc_list then ipoib_mcast_addr_is_valid will still need to have the check.

Ok I see your point now. But in this case, the length check should be in all drivers because if for example bonding device changes from infiniband back to eth, the addresses stored would be "cut" to 6 bytes and would make no sense.

Ideally, but the other wrinkle is due to other problems in the ipoib driver one bad multicast address blocks further addresses from being processed - effectively rendering the interface useless for multicast. Ethernet drivers will just subscribe to a bogus address, no real harm done.

I would prefer to see the check remain in ipoib until we can see through testing that it is no longer triggering.

Quoted 3 lines

2) when bonding changes it's type, flush mc addresses and start over.

Second option looks nicer to me, but I might be missing something, thouths?

There was a patch posted that tried to do something like what you are
describing:
From: Moni Shoua <monis-hKgKHo2Ms0F+cjeuK/[email protected]>
Subject: Re: [PATCH RESEND] bonding: remap muticast addresses without using dev_close() and dev_open()

Thanks,
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20100227184410.GB13231-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org

author
#17 lore raw
Quoted 14 lines · Sat, Feb 27, 2010 at 07:44:10PM CET, jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn…
Quoted 11 lines · Jiri Pirko
Quoted 7 lines

The problem this statement is trying to solve had to do with bonding creating multicast addresess for ethernet rather than infiniband in some cases. This happens because bonding makes a device that switches from ethernet to infiniband during its lifetime. I'm not quite sure what kind of life cycle those addresses go through, but if they somehow stay on the mc_list then ipoib_mcast_addr_is_valid will still need to have the check.

Ok I see your point now. But in this case, the length check should be in all drivers because if for example bonding device changes from infiniband back to eth, the addresses stored would be "cut" to 6 bytes and would make no sense.

Quoted 8 lines

Ideally, but the other wrinkle is due to other problems in the ipoib driver one bad multicast address blocks further addresses from being processed - effectively rendering the interface useless for multicast. Ethernet drivers will just subscribe to a bogus address, no real harm done.

I would prefer to see the check remain in ipoib until we can see through testing that it is no longer triggering.

Fair enough.

Subject: [net-next-2.6 PATCH] ipoib: returned back addrle check for mc addresses

Apparently bogus mc address can brake IPOIB multicast processing. Therefore returning the check for addrlen back until this is resolved in bonding (I don't see any other point from where mc address with non-dev->addr_len length can came from).

drivers/infiniband/ulp/ipoib/ipoib_multicast.c +5 -1
index 19eba3c..d41ea27 100644
@@ -767,8 +767,11 @@ void ipoib_mcast_dev_flush(struct net_device *dev)
 	}
 }
 
-static int ipoib_mcast_addr_is_valid(const u8 *addr, const u8 *broadcast)
+static int ipoib_mcast_addr_is_valid(const u8 *addr, unsigned int addrlen,
+				     const u8 *broadcast)
 {
+	if (addrlen != INFINIBAND_ALEN)
+		return 0;
 	/* reserved QPN, prefix, scope */
 	if (memcmp(addr, broadcast, 6))
 		return 0;
@@ -812,6 +815,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
 		union ib_gid mgid;
 
 		if (!ipoib_mcast_addr_is_valid(mclist->dmi_addr,
+					       mclist->dmi_addrlen,
 					       dev->broadcast))
 			continue;
 

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer Applied
#18 lore raw

From: Jiri Pirko <[email protected]>
Date: Sat, 27 Feb 2010 23:07:33 +0100

Quoted 8 lines

Subject: [net-next-2.6 PATCH] ipoib: returned back addrle check for mc addresses

Apparently bogus mc address can brake IPOIB multicast processing. Therefore returning the check for addrlen back until this is resolved in bonding (I don't see any other point from where mc address with non-dev->addr_len length can came from).

Applied.

#19 lore raw
In reply to a message not in the archive
Quoted 4 lines · Jason Gunthorpe
Quoted 1 line · Jiri Pirko

when bonding changes it's type, flush mc addresses and start over.

There was a patch posted that tried to do something like what you are describing

Indeed, Jason, commit 75c785 "bonding: remap muticast addresses without using dev_close() and dev_open()" from Moni Shoua <monis-smomgflXvOZWk0Htik3J/[email protected]> does exactly that, isn't it?

Or.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 4B8B7139.9050707-hKgKHo2Ms0FWk0Htik3J/[email protected]

author
#21 lore raw
Quoted 7 lines · Mon, Mar 01, 2010 at 08:48:09AM CET, ogerlitz-smomgflXvOZWk0Htik3J/[email protected]…
Quoted 4 lines · Jason Gunthorpe
Quoted 1 line · Jiri Pirko

when bonding changes it's type, flush mc addresses and start over.

There was a patch posted that tried to do something like what you are describing

Indeed, Jason, commit 75c785 "bonding: remap muticast addresses without using dev_close() and dev_open()" from Moni Shoua <monis-smomgflXvOZWk0Htik3J/[email protected]> does exactly that, isn't it?

This affects different mc_list.

Quoted 2 lines

Or.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#22 lore raw
In reply to a message not in the archive

From: Jiri Pirko <[email protected]>
Date: Wed, 24 Feb 2010 16:11:08 +0100

Quoted 4 lines

Due to the loop complexicity in nes_nic.c, I'm using char* to copy mc addresses to it.

Applied.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html