summaryrefslogtreecommitdiffstats
path: root/net/core/dev_mcast.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-02-24 00:12:35 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-02-24 00:12:35 +0000
commit482368b1a8e45430672c58c9a42e7d2004367126 (patch)
treece2a1a567d4d62dee7c2e71a46a99cf72cf1d606 /net/core/dev_mcast.c
parente4d0251c6f56ab2e191afb70f80f382793e23f74 (diff)
Merge with 2.3.47. Guys, this is buggy as shit. You've been warned.
Diffstat (limited to 'net/core/dev_mcast.c')
-rw-r--r--net/core/dev_mcast.c81
1 files changed, 43 insertions, 38 deletions
diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c
index 2facf1bc1..0dcedb142 100644
--- a/net/core/dev_mcast.c
+++ b/net/core/dev_mcast.c
@@ -71,17 +71,20 @@ static rwlock_t dev_mc_lock = RW_LOCK_UNLOCKED;
void dev_mc_upload(struct net_device *dev)
{
/* Don't do anything till we up the interface
- [dev_open will call this function so the list will
- stay sane] */
+ * [dev_open will call this function so the list will
+ * stay sane]
+ */
- if(!(dev->flags&IFF_UP))
+ if (!(dev->flags&IFF_UP))
return;
/*
- * Devices with no set multicast don't get set
+ * Devices with no set multicast or which have been
+ * detached don't get set.
*/
- if(dev->set_multicast_list==NULL)
+ if (dev->set_multicast_list == NULL ||
+ !netif_device_present(dev))
return;
read_lock_bh(&dev_mc_lock);
@@ -103,19 +106,20 @@ int dev_mc_delete(struct net_device *dev, void *addr, int alen, int glbl)
struct dev_mc_list *dmi, **dmip;
write_lock_bh(&dev_mc_lock);
- for (dmip=&dev->mc_list; (dmi=*dmip)!=NULL; dmip=&dmi->next) {
+ for (dmip = &dev->mc_list; (dmi = *dmip) != NULL; dmip = &dmi->next) {
/*
* Find the entry we want to delete. The device could
* have variable length entries so check these too.
*/
- if (memcmp(dmi->dmi_addr,addr,dmi->dmi_addrlen)==0 && alen==dmi->dmi_addrlen) {
+ if (memcmp(dmi->dmi_addr, addr, dmi->dmi_addrlen) == 0 &&
+ alen == dmi->dmi_addrlen) {
if (glbl) {
int old_glbl = dmi->dmi_gusers;
dmi->dmi_gusers = 0;
if (old_glbl == 0)
break;
}
- if(--dmi->dmi_users)
+ if (--dmi->dmi_users)
goto done;
/*
@@ -125,7 +129,7 @@ int dev_mc_delete(struct net_device *dev, void *addr, int alen, int glbl)
dev->mc_count--;
write_unlock_bh(&dev_mc_lock);
- kfree_s(dmi,sizeof(*dmi));
+ kfree_s(dmi, sizeof(*dmi));
/*
* We have altered the list, so the card
@@ -153,8 +157,9 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
dmi1 = (struct dev_mc_list *)kmalloc(sizeof(*dmi), GFP_ATOMIC);
write_lock_bh(&dev_mc_lock);
- for(dmi=dev->mc_list; dmi!=NULL; dmi=dmi->next) {
- if (memcmp(dmi->dmi_addr,addr,dmi->dmi_addrlen)==0 && dmi->dmi_addrlen==alen) {
+ for (dmi = dev->mc_list; dmi != NULL; dmi = dmi->next) {
+ if (memcmp(dmi->dmi_addr, addr, dmi->dmi_addrlen) == 0 &&
+ dmi->dmi_addrlen == alen) {
if (glbl) {
int old_glbl = dmi->dmi_gusers;
dmi->dmi_gusers = 1;
@@ -166,16 +171,16 @@ int dev_mc_add(struct net_device *dev, void *addr, int alen, int glbl)
}
}
- if ((dmi=dmi1)==NULL) {
+ if ((dmi = dmi1) == NULL) {
write_unlock_bh(&dev_mc_lock);
return -ENOMEM;
}
memcpy(dmi->dmi_addr, addr, alen);
- dmi->dmi_addrlen=alen;
- dmi->next=dev->mc_list;
- dmi->dmi_users=1;
- dmi->dmi_gusers=glbl ? 1 : 0;
- dev->mc_list=dmi;
+ dmi->dmi_addrlen = alen;
+ dmi->next = dev->mc_list;
+ dmi->dmi_users = 1;
+ dmi->dmi_gusers = glbl ? 1 : 0;
+ dev->mc_list = dmi;
dev->mc_count++;
write_unlock_bh(&dev_mc_lock);
dev_mc_upload(dev);
@@ -195,14 +200,14 @@ done:
void dev_mc_discard(struct net_device *dev)
{
write_lock_bh(&dev_mc_lock);
- while (dev->mc_list!=NULL) {
- struct dev_mc_list *tmp=dev->mc_list;
- dev->mc_list=tmp->next;
+ while (dev->mc_list != NULL) {
+ struct dev_mc_list *tmp = dev->mc_list;
+ dev->mc_list = tmp->next;
if (tmp->dmi_users > tmp->dmi_gusers)
printk("dev_mc_discard: multicast leakage! dmi_users=%d\n", tmp->dmi_users);
- kfree_s(tmp,sizeof(*tmp));
+ kfree_s(tmp, sizeof(*tmp));
}
- dev->mc_count=0;
+ dev->mc_count = 0;
write_unlock_bh(&dev_mc_lock);
}
@@ -210,9 +215,9 @@ void dev_mc_discard(struct net_device *dev)
static int dev_mc_read_proc(char *buffer, char **start, off_t offset,
int length, int *eof, void *data)
{
- off_t pos=0, begin=0;
+ off_t pos = 0, begin = 0;
struct dev_mc_list *m;
- int len=0;
+ int len = 0;
struct net_device *dev;
read_lock(&dev_base_lock);
@@ -221,20 +226,20 @@ static int dev_mc_read_proc(char *buffer, char **start, off_t offset,
for (m = dev->mc_list; m; m = m->next) {
int i;
- len += sprintf(buffer+len,"%-4d %-15s %-5d %-5d ", dev->ifindex, dev->name,
- m->dmi_users, m->dmi_gusers);
+ len += sprintf(buffer+len,"%-4d %-15s %-5d %-5d ", dev->ifindex,
+ dev->name, m->dmi_users, m->dmi_gusers);
- for (i=0; i<m->dmi_addrlen; i++)
+ for (i = 0; i < m->dmi_addrlen; i++)
len += sprintf(buffer+len, "%02x", m->dmi_addr[i]);
- len+=sprintf(buffer+len, "\n");
+ len += sprintf(buffer+len, "\n");
- pos=begin+len;
+ pos = begin + len;
if (pos < offset) {
- len=0;
- begin=pos;
+ len = 0;
+ begin = pos;
}
- if (pos > offset+length) {
+ if (pos > offset + length) {
read_unlock_bh(&dev_mc_lock);
goto done;
}
@@ -245,12 +250,12 @@ static int dev_mc_read_proc(char *buffer, char **start, off_t offset,
done:
read_unlock(&dev_base_lock);
- *start=buffer+(offset-begin);
- len-=(offset-begin);
- if(len>length)
- len=length;
- if(len<0)
- len=0;
+ *start = buffer + (offset - begin);
+ len -= (offset - begin);
+ if (len > length)
+ len = length;
+ if (len < 0)
+ len = 0;
return len;
}
#endif