* Question on 2.2.18 and setting a device to PROMISC.
@ 2001-01-15 0:06 Ben Greear
0 siblings, 0 replies; only message in thread
From: Ben Greear @ 2001-01-15 0:06 UTC (permalink / raw)
To: netdev@oss.sgi.com, linux-kernel
This code works in 2.4.0: (The important part is the dev_set_promiscuity()
method.)
int vlan_dev_set_mac_address(struct net_device *dev, void* addr_struct_p) {
int i;
struct sockaddr *addr = (struct sockaddr*)(addr_struct_p);
if (netif_running(dev)) {
return -EBUSY;
}
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
printk("%s: Setting MAC address to ", dev->name);
for (i = 0; i < 6; i++) {
printk(" %2.2x", dev->dev_addr[i]);
}
printk(".\n");
if (memcmp(dev->vlan_dev->real_dev->dev_addr, dev->dev_addr, dev->addr_len) != 0) {
if (dev->vlan_dev->real_dev->flags & IFF_PROMISC) {
/* Already promiscious...leave it alone. */
printk("VLAN (%s): Good, underlying device (%s) is already promiscious.\n",
dev->name, dev->vlan_dev->real_dev->name);
}
else {
printk("VLAN (%s): Setting underlying device (%s) to promiscious mode.\n",
dev->name, dev->vlan_dev->real_dev->name);
dev_set_promiscuity(dev->vlan_dev->real_dev, 1);
}
}
else {
printk("VLAN (%s): Underlying device (%s) has same MAC, not checking promiscious mode.\n",
dev->name, dev->vlan_dev->real_dev->name);
}
return 0;
}
But this code in the 2.2.18 kernel does not work. Specifically,
the dev_set_promiscuity method fails to actually make the interface
promiscious. Anyone know why?
int vlan_dev_set_mac_address(struct device *dev, void* addr_struct_p) {
int i;
struct sockaddr *addr = (struct sockaddr*)(addr_struct_p);
if (dev->start) {
return -EBUSY;
}
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
printk("%s: Setting MAC address to ", dev->name);
for (i = 0; i < 6; i++) {
printk(" %2.2x", dev->dev_addr[i]);
}
printk(".\n");
if (memcmp(dev->vlan_dev->real_dev->dev_addr, dev->dev_addr, dev->addr_len) != 0) {
if (dev->vlan_dev->real_dev->flags & IFF_PROMISC) {
/* Already promiscious...leave it alone. */
printk("VLAN (%s): Good, underlying device (%s) is already promiscious.\n",
dev->name, dev->vlan_dev->real_dev->name);
}
else {
printk("VLAN (%s): Setting underlying device (%s) to promiscious mode.\n",
dev->name, dev->vlan_dev->real_dev->name);
dev_set_promiscuity(dev->vlan_dev->real_dev, 1);
}
}
else {
printk("VLAN (%s): Underlying device (%s) has same MAC, not checking promiscious mode.\n",
dev->name, dev->vlan_dev->real_dev->name);
}
return 0;
}
--
Ben Greear (greearb@candelatech.com) http://www.candelatech.com
Author of ScryMUD: scry.wanfear.com 4444 (Released under GPL)
http://scry.wanfear.com http://scry.wanfear.com/~greear
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-01-14 23:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-01-15 0:06 Question on 2.2.18 and setting a device to PROMISC Ben Greear
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.