Skip to content

Commit

Permalink
[netdrvr] Drivers should not set IFF_* flag themselves
Browse files Browse the repository at this point in the history
Some hardware set promisc when they are requested to set IFF_ALLMULTI flag.
It's ok, but if drivers set IFF_PROMISC flag when they set promisc,
it will broken upper layer handle for promisc and allmulti.
In addition, drivers can use their own hardware programming to make it.
So do not allow drivers to set IFF_* flags.

This is a general driver fix, so I didn't split it to pieces and send
to specific driver maintainers.

Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
  • Loading branch information
Wang Chen authored and Jeff Garzik committed Aug 7, 2008
1 parent fe41424 commit c16d118
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 57 deletions.
4 changes: 1 addition & 3 deletions drivers/net/3c523.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,10 +640,8 @@ static int init586(struct net_device *dev)
cfg_cmd->time_low = 0x00;
cfg_cmd->time_high = 0xf2;
cfg_cmd->promisc = 0;
if (dev->flags & (IFF_ALLMULTI | IFF_PROMISC)) {
if (dev->flags & (IFF_ALLMULTI | IFF_PROMISC))
cfg_cmd->promisc = 1;
dev->flags |= IFF_PROMISC;
}
cfg_cmd->carr_coll = 0x00;

p->scb->cbl_offset = make16(cfg_cmd);
Expand Down
9 changes: 3 additions & 6 deletions drivers/net/3c527.c
Original file line number Diff line number Diff line change
Expand Up @@ -1521,14 +1521,11 @@ static void do_mc32_set_multicast_list(struct net_device *dev, int retry)
struct mc32_local *lp = netdev_priv(dev);
u16 filt = (1<<2); /* Save Bad Packets, for stats purposes */

if (dev->flags&IFF_PROMISC)
if ((dev->flags&IFF_PROMISC) ||
(dev->flags&IFF_ALLMULTI) ||
dev->mc_count > 10)
/* Enable promiscuous mode */
filt |= 1;
else if((dev->flags&IFF_ALLMULTI) || dev->mc_count > 10)
{
dev->flags|=IFF_PROMISC;
filt |= 1;
}
else if(dev->mc_count)
{
unsigned char block[62];
Expand Down
9 changes: 2 additions & 7 deletions drivers/net/atp.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,14 +854,9 @@ static void set_rx_mode_8002(struct net_device *dev)
struct net_local *lp = netdev_priv(dev);
long ioaddr = dev->base_addr;

if ( dev->mc_count > 0 || (dev->flags & (IFF_ALLMULTI|IFF_PROMISC))) {
/* We must make the kernel realise we had to move
* into promisc mode or we start all out war on
* the cable. - AC
*/
dev->flags|=IFF_PROMISC;
if (dev->mc_count > 0 || (dev->flags & (IFF_ALLMULTI|IFF_PROMISC)))
lp->addr_mode = CMR2h_PROMISC;
} else
else
lp->addr_mode = CMR2h_Normal;
write_reg_high(ioaddr, CMR2, lp->addr_mode);
}
Expand Down
7 changes: 0 additions & 7 deletions drivers/net/de620.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,6 @@ static void de620_set_multicast_list(struct net_device *dev)
{
if (dev->mc_count || dev->flags&(IFF_ALLMULTI|IFF_PROMISC))
{ /* Enable promiscuous mode */
/*
* We must make the kernel realise we had to move
* into promisc mode or we start all out war on
* the cable. - AC
*/
dev->flags|=IFF_PROMISC;

de620_set_register(dev, W_TCR, (TCR_DEF & ~RXPBM) | RXALL);
}
else
Expand Down
8 changes: 0 additions & 8 deletions drivers/net/eepro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1283,14 +1283,6 @@ set_multicast_list(struct net_device *dev)

if (dev->flags&(IFF_ALLMULTI|IFF_PROMISC) || dev->mc_count > 63)
{
/*
* We must make the kernel realise we had to move
* into promisc mode or we start all out war on
* the cable. If it was a promisc request the
* flag is already set. If not we assert it.
*/
dev->flags|=IFF_PROMISC;

eepro_sw2bank2(ioaddr); /* be CAREFUL, BANK 2 now */
mode = inb(ioaddr + REG2);
outb(mode | PRMSC_Mode, ioaddr + REG2);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/eth16i.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,6 @@ static void eth16i_multicast(struct net_device *dev)

if(dev->mc_count || dev->flags&(IFF_ALLMULTI|IFF_PROMISC))
{
dev->flags|=IFF_PROMISC; /* Must do this */
outb(3, ioaddr + RECEIVE_MODE_REG);
} else {
outb(2, ioaddr + RECEIVE_MODE_REG);
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/lp486e.c
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,6 @@ static void set_multicast_list(struct net_device *dev) {
return;
}
if (dev->mc_count == 0 && !(dev->flags & (IFF_PROMISC | IFF_ALLMULTI))) {
if (dev->flags & IFF_ALLMULTI)
dev->flags |= IFF_PROMISC;
lp->i596_config[8] &= ~0x01;
} else {
lp->i596_config[8] |= 0x01;
Expand Down
1 change: 0 additions & 1 deletion drivers/net/ni5010.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,6 @@ static void ni5010_set_multicast_list(struct net_device *dev)
PRINTK2((KERN_DEBUG "%s: entering set_multicast_list\n", dev->name));

if (dev->flags&IFF_PROMISC || dev->flags&IFF_ALLMULTI || dev->mc_list) {
dev->flags |= IFF_PROMISC;
outb(RMD_PROMISC, EDLC_RMODE); /* Enable promiscuous mode */
PRINTK((KERN_DEBUG "%s: Entering promiscuous mode\n", dev->name));
} else {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ni52.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ static int init586(struct net_device *dev)
if (num_addrs > len) {
printk(KERN_ERR "%s: switching to promisc. mode\n",
dev->name);
dev->flags |= IFF_PROMISC;
writeb(0x01, &cfg_cmd->promisc);
}
}
if (dev->flags & IFF_PROMISC)
Expand Down
7 changes: 2 additions & 5 deletions drivers/net/sun3_82586.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,11 @@ static int init586(struct net_device *dev)
int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
if(num_addrs > len) {
printk("%s: switching to promisc. mode\n",dev->name);
dev->flags|=IFF_PROMISC;
cfg_cmd->promisc = 1;
}
}
if(dev->flags&IFF_PROMISC)
{
cfg_cmd->promisc=1;
dev->flags|=IFF_PROMISC;
}
cfg_cmd->promisc = 1;
cfg_cmd->carr_coll = 0x00;

p->scb->cbl_offset = make16(cfg_cmd);
Expand Down
7 changes: 0 additions & 7 deletions drivers/net/wireless/orinoco.c
Original file line number Diff line number Diff line change
Expand Up @@ -1998,13 +1998,6 @@ __orinoco_set_multicast_list(struct net_device *dev)
else
priv->mc_count = mc_count;
}

/* Since we can set the promiscuous flag when it wasn't asked
for, make sure the net_device knows about it. */
if (priv->promiscuous)
dev->flags |= IFF_PROMISC;
else
dev->flags &= ~IFF_PROMISC;
}

/* This must be called from user context, without locks held - use
Expand Down
3 changes: 0 additions & 3 deletions drivers/net/wireless/wavelan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1409,9 +1409,6 @@ static void wavelan_set_multicast_list(struct net_device * dev)
lp->mc_count = 0;

wv_82586_reconfig(dev);

/* Tell the kernel that we are doing a really bad job. */
dev->flags |= IFF_PROMISC;
}
} else
/* Are there multicast addresses to send? */
Expand Down
6 changes: 0 additions & 6 deletions drivers/net/wireless/wavelan_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,9 +1412,6 @@ wavelan_set_multicast_list(struct net_device * dev)
lp->mc_count = 0;

wv_82593_reconfig(dev);

/* Tell the kernel that we are doing a really bad job... */
dev->flags |= IFF_PROMISC;
}
}
else
Expand All @@ -1433,9 +1430,6 @@ wavelan_set_multicast_list(struct net_device * dev)
lp->mc_count = 0;

wv_82593_reconfig(dev);

/* Tell the kernel that we are doing a really bad job... */
dev->flags |= IFF_ALLMULTI;
}
}
else
Expand Down

0 comments on commit c16d118

Please sign in to comment.