diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2013-12-04 04:16:09 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2013-12-09 14:28:32 (GMT) |
commit | 8b87ae55161f402c07aa8464d8d6164d46aa84d5 (patch) | |
tree | 166c28f587167972687b1935dd6131ead992365e /lib | |
parent | b50a36bf34e7452377ab9bbb4d1873b68c65bf72 (diff) | |
download | libnl-8b87ae55161f402c07aa8464d8d6164d46aa84d5.zip libnl-8b87ae55161f402c07aa8464d8d6164d46aa84d5.tar.gz libnl-8b87ae55161f402c07aa8464d8d6164d46aa84d5.tar.bz2 |
fix rtnl_link_info_parse() and rtnl_link_fill_info()
So that the veth peer could be parsed correctly.
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/route/link.c | 30 |
1 files 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; |