提交 b596d6c1 编写于 作者: L Laine Stump 提交者: Laine Stump

util: allow sending mac addr to virNetNewLink without ifindex

Although until now, any use of the extra_args argument (a pointer to a
struct containing extra attributes to add the the RTM_NEWLINK message)
would always have the ifindex and mac set, so the code could assume it
was safe to add both to the message if extra_args != NULL. There is
now a use for setting a MAC address in the RTM_NEWLINK without setting
the ifindex, so we should check each of these separately.
Signed-off-by: NLaine Stump <laine@redhat.com>
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
上级 0de541bf
...@@ -541,9 +541,14 @@ virNetlinkNewLink(const char *ifname, ...@@ -541,9 +541,14 @@ virNetlinkNewLink(const char *ifname,
NETLINK_MSG_NEST_END(nl_msg, linkinfo); NETLINK_MSG_NEST_END(nl_msg, linkinfo);
if (extra_args) { if (extra_args) {
NETLINK_MSG_PUT(nl_msg, IFLA_LINK, if (extra_args->ifindex) {
NETLINK_MSG_PUT(nl_msg, IFLA_LINK,
sizeof(uint32_t), extra_args->ifindex); sizeof(uint32_t), extra_args->ifindex);
NETLINK_MSG_PUT(nl_msg, IFLA_ADDRESS, VIR_MAC_BUFLEN, extra_args->mac); }
if (extra_args->mac) {
NETLINK_MSG_PUT(nl_msg, IFLA_ADDRESS,
VIR_MAC_BUFLEN, extra_args->mac);
}
} }
if (virNetlinkCommand(nl_msg, &resp, &buflen, 0, 0, NETLINK_ROUTE, 0) < 0) if (virNetlinkCommand(nl_msg, &resp, &buflen, 0, 0, NETLINK_ROUTE, 0) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册