netdev
[Top] [All Lists]

Question on 2.2.18 and setting a device to PROMISC.

To: "netdev@xxxxxxxxxxx" <netdev@xxxxxxxxxxx>, linux-kernel <linux-kernel@xxxxxxxxxxxxxxx>
Subject: Question on 2.2.18 and setting a device to PROMISC.
From: Ben Greear <greearb@xxxxxxxxxxxxxxx>
Date: Sun, 14 Jan 2001 17:06:00 -0700
Organization: Candela Technologies
Sender: owner-netdev@xxxxxxxxxxx
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@xxxxxxxxxxxxxxx)  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 Thread] Current Thread [Next in Thread>
  • Question on 2.2.18 and setting a device to PROMISC., Ben Greear <=