[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-netdev
Subject: Question on 2.2.18 and setting a device to PROMISC.
From: Ben Greear <greearb () candelatech ! com>
Date: 2001-01-14 23:02:48
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic