patch-2.3.47 linux/net/core/dev_mcast.c
Next file: linux/net/core/profile.c
Previous file: linux/net/core/dev.c
Back to the patch index
Back to the overall index
- Lines: 174
- Date:
Thu Feb 17 09:18:47 2000
- Orig file:
v2.3.46/linux/net/core/dev_mcast.c
- Orig date:
Mon Nov 1 13:56:27 1999
diff -u --recursive --new-file v2.3.46/linux/net/core/dev_mcast.c linux/net/core/dev_mcast.c
@@ -71,17 +71,20 @@
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 @@
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 @@
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 @@
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 @@
}
}
- 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 @@
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 @@
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 @@
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 @@
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
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)