Re: Question concerning ifconfig

From: Bernd Eckenfels (ecki-news2002-06@lina.inka.de)
Date: Fri Jul 05 2002 - 12:33:25 EST


Bloch, Jack <Jack.Bloch@icn.siemens.com> wrote:
> ifconfig ifp0 hw ether A2:A5:A5:01:00:00

I get also EBUSY on 0x8924 aka SIOCSIFHWADDR.

Looking into the kernel:

core/dev.c
                case SIOCSIFHWADDR:
                        if (dev->set_mac_address == NULL)
                                return -EOPNOTSUPP;
                        if (ifr->ifr_hwaddr.sa_family!=dev->type)
                                return -EINVAL;
                        if (!netif_device_present(dev))
                                return -ENODEV;
                        err = dev->set_mac_address(dev, &ifr->ifr_hwaddr);
                        if (!err)
                                notifier_call_chain(&netdev_chain, NETDEV_CHANGE
                        return err;

It looks to me that set_mac_address() of the device is doing that. For my
card it is the generic one in net_init.c which is doing:

static int eth_mac_addr(struct net_device *dev, void *p)
{
        struct sockaddr *addr=p;
        if (netif_running(dev))
                return -EBUSY;
        memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
        return 0;
}

So, as long as your interface is up, you are not allowed to change the
address.

I will add that to the man page.

Greetings
Bernd
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jul 07 2002 - 22:00:15 EST