Re: Bug in the RTM_SETLINK kernel API for setting MAC address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> > Note that the payload with the MAC address has to be
> > "struct sockaddr" (or equivalent) and the length of that payload is
> > the equivalent of "sizeof(sa_family) + mac_address_size".
> 
> It should just be the MAC address, that's why the kernel side
> is coded the way it is.

I couldn't find any documentation about the API, so I wasn't sure
whether it is actually suppose to be the MAC address or "sockaddr".

In fact, earlier version of our userland code was assuming it
is just the MAC address, until we found that it doesn't work on
recent kernels.

> Where does this sockaddr come from?

The set_mac_address() functions for each network device driver make
that assumption:

static int set_mac_address(struct net_device *dev, void *p)
{
        int i;
        struct sockaddr *addr = p;

> I don't see how it could work with the sockaddr there in
> 2.6.17, as 2.6.17 makes the same exact length check:
> 
> 		if (ida[IFLA_ADDRESS - 1]->rta_len != RTA_LENGTH(dev->addr_len))
> 			goto out;

Note that in my example rta_len was tweaked to match the MAC address
size, but the the payload itself and the netlink message nlmsg_len
actually match the sockaddr alignment.

The real mismatch is that ida[IFLA_ADDRESS - 1] is (as you say)
suppose to be a MAC address, but the set_mac_address() functions
for each device assume that the RTA_DATA(ida[IFLA_ADDRESS - 1])
payload is a sockaddr.

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

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux