]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
fix rtnl_link_info_parse() and rtnl_link_fill_info()
authorCong Wang <xiyou.wangcong@gmail.com>
Wed, 4 Dec 2013 04:16:09 +0000 (20:16 -0800)
committerThomas Graf <tgraf@suug.ch>
Mon, 9 Dec 2013 14:28:32 +0000 (15:28 +0100)
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>
lib/route/link.c

index 6c99e22e015c094d86375e4c95c57d45693a9c1a..4bcf61546330a91ff8e0f9e21dd96a5d252419a3 100644 (file)
@@ -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;