public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: "netdev@oss.sgi.com" <netdev@oss.sgi.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Question on 2.2.18 and setting a device to PROMISC.
Date: Sun, 14 Jan 2001 17:06:00 -0700	[thread overview]
Message-ID: <3A623EE8.644A572D@candelatech.com> (raw)

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/

                 reply	other threads:[~2001-01-14 23:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3A623EE8.644A572D@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox