From 8b87ae55161f402c07aa8464d8d6164d46aa84d5 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Tue, 3 Dec 2013 20:16:09 -0800 Subject: fix rtnl_link_info_parse() and rtnl_link_fill_info() So that the veth peer could be parsed correctly. Signed-off-by: Cong Wang Signed-off-by: Thomas Graf --- lib/route/link.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/route/link.c b/lib/route/link.c index 6c99e22..4bcf615 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -458,6 +458,16 @@ int rtnl_link_info_parse(struct rtnl_link *link, struct nlattr **tb) link->ce_mask |= LINK_ATTR_IFALIAS; } + if (tb[IFLA_NET_NS_FD]) { + link->l_ns_fd = nla_get_u32(tb[IFLA_NET_NS_FD]); + link->ce_mask |= LINK_ATTR_NS_FD; + } + + if (tb[IFLA_NET_NS_PID]) { + link->l_ns_pid = nla_get_u32(tb[IFLA_NET_NS_PID]); + link->ce_mask |= LINK_ATTR_NS_PID; + } + return 0; } @@ -612,16 +622,6 @@ static int link_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who, link->ce_mask |= LINK_ATTR_GROUP; } - if (tb[IFLA_NET_NS_FD]) { - link->l_ns_fd = nla_get_u32(tb[IFLA_NET_NS_FD]); - link->ce_mask |= LINK_ATTR_NS_FD; - } - - if (tb[IFLA_NET_NS_FD]) { - link->l_ns_pid = nla_get_u32(tb[IFLA_NET_NS_PID]); - link->ce_mask |= LINK_ATTR_NS_PID; - } - if (tb[IFLA_PHYS_PORT_ID]) { link->l_phys_port_id = nl_data_alloc_attr(tb[IFLA_PHYS_PORT_ID]); if (link->l_phys_port_id == NULL) { @@ -1287,8 +1287,11 @@ int rtnl_link_fill_info(struct nl_msg *msg, struct rtnl_link *link) if (link->ce_mask & LINK_ATTR_NUM_RX_QUEUES) NLA_PUT_U32(msg, IFLA_NUM_RX_QUEUES, link->l_num_rx_queues); - if (link->ce_mask & LINK_ATTR_GROUP) - NLA_PUT_U32(msg, IFLA_GROUP, link->l_group); + if (link->ce_mask & LINK_ATTR_NS_FD) + NLA_PUT_U32(msg, IFLA_NET_NS_FD, link->l_ns_fd); + + if (link->ce_mask & LINK_ATTR_NS_PID) + NLA_PUT_U32(msg, IFLA_NET_NS_PID, link->l_ns_pid); return 0; @@ -1312,6 +1315,9 @@ static int build_link_msg(int cmd, struct ifinfomsg *hdr, if (rtnl_link_fill_info(msg, link)) goto nla_put_failure; + if (link->ce_mask & LINK_ATTR_GROUP) + NLA_PUT_U32(msg, IFLA_GROUP, link->l_group); + if (link->ce_mask & LINK_ATTR_LINKINFO) { struct nlattr *info; -- cgit v0.12