lkml.org 
[lkml]   [2006]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: Bug in the RTM_SETLINK kernel API for setting MAC address
    Date
    From
    > > 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 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/

    \
     
     \ /
      Last update: 2006-08-08 07:35    [W:5.687 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site