X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Frtnetlink-link.c;h=1c12562c5af7437cc24d32ec46b49e719b96854a;hb=003ce655b7116d18c86a74c50391e54990346931;hp=d14f0e3c4c3c923bb7de57946619a3bf8b4368d9;hpb=90a6637d5e7f5f83e3370e05b3716a24fc093fc7;p=sliver-openvswitch.git diff --git a/lib/rtnetlink-link.c b/lib/rtnetlink-link.c index d14f0e3c4..1c12562c5 100644 --- a/lib/rtnetlink-link.c +++ b/lib/rtnetlink-link.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,9 +46,10 @@ rtnetlink_link_parse(struct ofpbuf *buf, [IFLA_IFNAME] = { .type = NL_A_STRING, .optional = false }, [IFLA_MASTER] = { .type = NL_A_U32, .optional = true }, [IFLA_MTU] = { .type = NL_A_U32, .optional = true }, + [IFLA_ADDRESS] = { .type = NL_A_UNSPEC, .optional = true }, }; - static struct nlattr *attrs[ARRAY_SIZE(policy)]; + struct nlattr *attrs[ARRAY_SIZE(policy)]; parsed = nl_policy_parse(buf, NLMSG_HDRLEN + sizeof(struct ifinfomsg), policy, attrs, ARRAY_SIZE(policy)); @@ -57,9 +58,8 @@ rtnetlink_link_parse(struct ofpbuf *buf, const struct nlmsghdr *nlmsg; const struct ifinfomsg *ifinfo; - nlmsg = buf->data; - ifinfo = ((const struct ifinfomsg *) - ((const char *) buf->data + NLMSG_HDRLEN)); + nlmsg = ofpbuf_data(buf); + ifinfo = ofpbuf_at(buf, NLMSG_HDRLEN, sizeof *ifinfo); change->nlmsg_type = nlmsg->nlmsg_type; change->ifi_index = ifinfo->ifi_index; @@ -72,6 +72,12 @@ rtnetlink_link_parse(struct ofpbuf *buf, ? nl_attr_get_u32(attrs[IFLA_MTU]) : 0); + if (attrs[IFLA_ADDRESS] && + nl_attr_get_size(attrs[IFLA_ADDRESS]) == ETH_ALEN) { + memcpy(change->addr, nl_attr_get(attrs[IFLA_ADDRESS]), ETH_ALEN); + } else { + memset(change->addr, 0, ETH_ALEN); + } } return parsed;