Commit 70f8e78e authored by David S. Miller's avatar David S. Miller

[RTNETLINK]: Fix IFLA_ADDRESS handling.

The ->set_mac_address handlers expect a pointer to a
sockaddr which contains the MAC address, whereas
IFLA_ADDRESS provides just the MAC address itself.

So whip up a sockaddr to wrap around the netlink
attribute for the ->set_mac_address call.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1b2a7205
...@@ -394,6 +394,9 @@ static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) ...@@ -394,6 +394,9 @@ static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
} }
if (ida[IFLA_ADDRESS - 1]) { if (ida[IFLA_ADDRESS - 1]) {
struct sockaddr *sa;
int len;
if (!dev->set_mac_address) { if (!dev->set_mac_address) {
err = -EOPNOTSUPP; err = -EOPNOTSUPP;
goto out; goto out;
...@@ -405,7 +408,17 @@ static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) ...@@ -405,7 +408,17 @@ static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
if (ida[IFLA_ADDRESS - 1]->rta_len != RTA_LENGTH(dev->addr_len)) if (ida[IFLA_ADDRESS - 1]->rta_len != RTA_LENGTH(dev->addr_len))
goto out; goto out;
err = dev->set_mac_address(dev, RTA_DATA(ida[IFLA_ADDRESS - 1])); len = sizeof(sa_family_t) + dev->addr_len;
sa = kmalloc(len, GFP_KERNEL);
if (!sa) {
err = -ENOMEM;
goto out;
}
sa->sa_family = dev->type;
memcpy(sa->sa_data, RTA_DATA(ida[IFLA_ADDRESS - 1]),
dev->addr_len);
err = dev->set_mac_address(dev, sa);
kfree(sa);
if (err) if (err)
goto out; goto out;
send_addr_notify = 1; send_addr_notify = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment