Commit 655ffee2 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

wireless: convert to use netdev_for_each_mc_addr

also added missed locking in rndis_wlan.c
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9675478b
...@@ -319,15 +319,18 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd, ...@@ -319,15 +319,18 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
{ {
int i = nr_addrs; int i = nr_addrs;
struct dev_mc_list *mc_list; struct dev_mc_list *mc_list;
int cnt;
if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST)) if ((dev->flags & (IFF_UP|IFF_MULTICAST)) != (IFF_UP|IFF_MULTICAST))
return nr_addrs; return nr_addrs;
netif_addr_lock_bh(dev); netif_addr_lock_bh(dev);
for (mc_list = dev->mc_list; mc_list; mc_list = mc_list->next) { cnt = netdev_mc_count(dev);
netdev_for_each_mc_addr(mc_list, dev) {
if (mac_in_list(cmd->maclist, nr_addrs, mc_list->dmi_addr)) { if (mac_in_list(cmd->maclist, nr_addrs, mc_list->dmi_addr)) {
lbs_deb_net("mcast address %s:%pM skipped\n", dev->name, lbs_deb_net("mcast address %s:%pM skipped\n", dev->name,
mc_list->dmi_addr); mc_list->dmi_addr);
cnt--;
continue; continue;
} }
...@@ -337,9 +340,10 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd, ...@@ -337,9 +340,10 @@ static int lbs_add_mcast_addrs(struct cmd_ds_mac_multicast_adr *cmd,
lbs_deb_net("mcast address %s:%pM added to filter\n", dev->name, lbs_deb_net("mcast address %s:%pM added to filter\n", dev->name,
mc_list->dmi_addr); mc_list->dmi_addr);
i++; i++;
cnt--;
} }
netif_addr_unlock_bh(dev); netif_addr_unlock_bh(dev);
if (mc_list) if (cnt)
return -EOVERFLOW; return -EOVERFLOW;
return i; return i;
......
...@@ -1028,7 +1028,7 @@ int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx) ...@@ -1028,7 +1028,7 @@ int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx)
} }
int __orinoco_hw_set_multicast_list(struct orinoco_private *priv, int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
struct dev_addr_list *mc_list, struct net_device *dev,
int mc_count, int promisc) int mc_count, int promisc)
{ {
hermes_t *hw = &priv->hw; hermes_t *hw = &priv->hw;
...@@ -1049,24 +1049,16 @@ int __orinoco_hw_set_multicast_list(struct orinoco_private *priv, ...@@ -1049,24 +1049,16 @@ int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
* group address if either we want to multicast, or if we were * group address if either we want to multicast, or if we were
* multicasting and want to stop */ * multicasting and want to stop */
if (!promisc && (mc_count || priv->mc_count)) { if (!promisc && (mc_count || priv->mc_count)) {
struct dev_mc_list *p = mc_list; struct dev_mc_list *p;
struct hermes_multicast mclist; struct hermes_multicast mclist;
int i; int i = 0;
for (i = 0; i < mc_count; i++) { netdev_for_each_mc_addr(p, dev) {
/* paranoia: is list shorter than mc_count? */ if (i == mc_count)
BUG_ON(!p); break;
/* paranoia: bad address size in list? */ memcpy(mclist.addr[i++], p->dmi_addr, ETH_ALEN);
BUG_ON(p->dmi_addrlen != ETH_ALEN);
memcpy(mclist.addr[i], p->dmi_addr, ETH_ALEN);
p = p->next;
} }
if (p)
printk(KERN_WARNING "%s: Multicast list is "
"longer than mc_count\n", priv->ndev->name);
err = hermes_write_ltv(hw, USER_BAP, err = hermes_write_ltv(hw, USER_BAP,
HERMES_RID_CNFGROUPADDRESSES, HERMES_RID_CNFGROUPADDRESSES,
HERMES_BYTES_TO_RECLEN(mc_count * ETH_ALEN), HERMES_BYTES_TO_RECLEN(mc_count * ETH_ALEN),
......
...@@ -43,7 +43,7 @@ int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx, ...@@ -43,7 +43,7 @@ int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx,
u8 *tsc, size_t tsc_len); u8 *tsc, size_t tsc_len);
int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx); int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx);
int __orinoco_hw_set_multicast_list(struct orinoco_private *priv, int __orinoco_hw_set_multicast_list(struct orinoco_private *priv,
struct dev_addr_list *mc_list, struct net_device *dev,
int mc_count, int promisc); int mc_count, int promisc);
int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, int orinoco_hw_get_essid(struct orinoco_private *priv, int *active,
char buf[IW_ESSID_MAX_SIZE+1]); char buf[IW_ESSID_MAX_SIZE+1]);
......
...@@ -1676,8 +1676,7 @@ __orinoco_set_multicast_list(struct net_device *dev) ...@@ -1676,8 +1676,7 @@ __orinoco_set_multicast_list(struct net_device *dev)
mc_count = netdev_mc_count(dev); mc_count = netdev_mc_count(dev);
} }
err = __orinoco_hw_set_multicast_list(priv, dev->mc_list, mc_count, err = __orinoco_hw_set_multicast_list(priv, dev, mc_count, promisc);
promisc);
return err; return err;
} }
......
...@@ -1871,10 +1871,8 @@ static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, ...@@ -1871,10 +1871,8 @@ static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value,
/*===========================================================================*/ /*===========================================================================*/
static void ray_update_multi_list(struct net_device *dev, int all) static void ray_update_multi_list(struct net_device *dev, int all)
{ {
struct dev_mc_list *dmi, **dmip;
int ccsindex; int ccsindex;
struct ccs __iomem *pccs; struct ccs __iomem *pccs;
int i = 0;
ray_dev_t *local = netdev_priv(dev); ray_dev_t *local = netdev_priv(dev);
struct pcmcia_device *link = local->finder; struct pcmcia_device *link = local->finder;
void __iomem *p = local->sram + HOST_TO_ECF_BASE; void __iomem *p = local->sram + HOST_TO_ECF_BASE;
...@@ -1895,9 +1893,11 @@ static void ray_update_multi_list(struct net_device *dev, int all) ...@@ -1895,9 +1893,11 @@ static void ray_update_multi_list(struct net_device *dev, int all)
writeb(0xff, &pccs->var); writeb(0xff, &pccs->var);
local->num_multi = 0xff; local->num_multi = 0xff;
} else { } else {
struct dev_mc_list *dmi;
int i = 0;
/* Copy the kernel's list of MC addresses to card */ /* Copy the kernel's list of MC addresses to card */
for (dmip = &dev->mc_list; (dmi = *dmip) != NULL; netdev_for_each_mc_addr(dmi, dev) {
dmip = &dmi->next) {
memcpy_toio(p, dmi->dmi_addr, ETH_ALEN); memcpy_toio(p, dmi->dmi_addr, ETH_ALEN);
dev_dbg(&link->dev, dev_dbg(&link->dev,
"ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n", "ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n",
......
...@@ -1502,6 +1502,7 @@ static void set_multicast_list(struct usbnet *usbdev) ...@@ -1502,6 +1502,7 @@ static void set_multicast_list(struct usbnet *usbdev)
filter = RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_BROADCAST; filter = RNDIS_PACKET_TYPE_DIRECTED | RNDIS_PACKET_TYPE_BROADCAST;
netif_addr_lock_bh(usbdev->net);
if (usbdev->net->flags & IFF_PROMISC) { if (usbdev->net->flags & IFF_PROMISC) {
filter |= RNDIS_PACKET_TYPE_PROMISCUOUS | filter |= RNDIS_PACKET_TYPE_PROMISCUOUS |
RNDIS_PACKET_TYPE_ALL_LOCAL; RNDIS_PACKET_TYPE_ALL_LOCAL;
...@@ -1515,16 +1516,15 @@ static void set_multicast_list(struct usbnet *usbdev) ...@@ -1515,16 +1516,15 @@ static void set_multicast_list(struct usbnet *usbdev)
netdev_warn(usbdev->net, netdev_warn(usbdev->net,
"couldn't alloc %d bytes of memory\n", "couldn't alloc %d bytes of memory\n",
size * ETH_ALEN); size * ETH_ALEN);
netif_addr_unlock_bh(usbdev->net);
return; return;
} }
mclist = usbdev->net->mc_list; i = 0;
for (i = 0; i < size && mclist; mclist = mclist->next) { netdev_for_each_mc_addr(mclist, usbdev->net) {
if (mclist->dmi_addrlen != ETH_ALEN) if (i == size)
continue; break;
memcpy(buf + i++ * ETH_ALEN, mclist->dmi_addr, ETH_ALEN);
memcpy(buf + i * ETH_ALEN, mclist->dmi_addr, ETH_ALEN);
i++;
} }
ret = rndis_set_oid(usbdev, OID_802_3_MULTICAST_LIST, buf, ret = rndis_set_oid(usbdev, OID_802_3_MULTICAST_LIST, buf,
...@@ -1539,6 +1539,7 @@ static void set_multicast_list(struct usbnet *usbdev) ...@@ -1539,6 +1539,7 @@ static void set_multicast_list(struct usbnet *usbdev)
kfree(buf); kfree(buf);
} }
netif_addr_unlock_bh(usbdev->net);
ret = rndis_set_oid(usbdev, OID_GEN_CURRENT_PACKET_FILTER, &filter, ret = rndis_set_oid(usbdev, OID_GEN_CURRENT_PACKET_FILTER, &filter,
sizeof(filter)); sizeof(filter));
......
...@@ -875,17 +875,16 @@ static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev) ...@@ -875,17 +875,16 @@ static struct iw_statistics *zd1201_get_wireless_stats(struct net_device *dev)
static void zd1201_set_multicast(struct net_device *dev) static void zd1201_set_multicast(struct net_device *dev)
{ {
struct zd1201 *zd = netdev_priv(dev); struct zd1201 *zd = netdev_priv(dev);
struct dev_mc_list *mc = dev->mc_list; struct dev_mc_list *mc;
unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI]; unsigned char reqbuf[ETH_ALEN*ZD1201_MAXMULTI];
int i; int i;
if (netdev_mc_count(dev) > ZD1201_MAXMULTI) if (netdev_mc_count(dev) > ZD1201_MAXMULTI)
return; return;
for (i=0; i<netdev_mc_count(dev); i++) { i = 0;
memcpy(reqbuf+i*ETH_ALEN, mc->dmi_addr, ETH_ALEN); netdev_for_each_mc_addr(mc, dev)
mc = mc->next; memcpy(reqbuf + i++ * ETH_ALEN, mc->dmi_addr, ETH_ALEN);
}
zd1201_setconfig(zd, ZD1201_RID_CNFGROUPADDRESS, reqbuf, zd1201_setconfig(zd, ZD1201_RID_CNFGROUPADDRESS, reqbuf,
netdev_mc_count(dev) * ETH_ALEN, 0); netdev_mc_count(dev) * ETH_ALEN, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment