#include <netlink/cache.h>
#include <netlink/addr.h>
#include <linux/if.h>
+#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
extern struct nl_data * rtnl_link_get_phys_port_id(struct rtnl_link *);
+extern void rtnl_link_set_ns_fd(struct rtnl_link *, int);
+extern int rtnl_link_get_ns_fd(struct rtnl_link *);
+extern void rtnl_link_set_ns_pid(struct rtnl_link *, pid_t);
+extern pid_t rtnl_link_get_ns_pid(struct rtnl_link *);
+
extern int rtnl_link_enslave_ifindex(struct nl_sock *, int, int);
extern int rtnl_link_enslave(struct nl_sock *, struct rtnl_link *,
struct rtnl_link *);
#define LINK_ATTR_PROTINFO (1 << 26)
#define LINK_ATTR_AF_SPEC (1 << 27)
#define LINK_ATTR_PHYS_PORT_ID (1 << 28)
+#define LINK_ATTR_NS_FD (1 << 29)
+#define LINK_ATTR_NS_PID (1 << 30)
static struct nl_cache_ops rtnl_link_ops;
static struct nl_object_ops link_obj_ops;
[IFLA_GROUP] = { .type = NLA_U32 },
[IFLA_CARRIER] = { .type = NLA_U8 },
[IFLA_PHYS_PORT_ID] = { .type = NLA_UNSPEC },
+ [IFLA_NET_NS_PID] = { .type = NLA_U32 },
+ [IFLA_NET_NS_FD] = { .type = NLA_U32 },
};
static struct nla_policy link_info_policy[IFLA_INFO_MAX+1] = {
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) {
return link->l_phys_port_id;
}
+void rtnl_link_set_ns_fd(struct rtnl_link *link, int fd)
+{
+ link->l_ns_fd = fd;
+ link->ce_mask |= LINK_ATTR_NS_FD;
+}
+
+int rtnl_link_get_ns_fd(struct rtnl_link *link)
+{
+ return link->l_ns_fd;
+}
+
+void rtnl_link_set_ns_pid(struct rtnl_link *link, pid_t pid)
+{
+ link->l_ns_pid = pid;
+ link->ce_mask |= LINK_ATTR_NS_PID;
+}
+
+pid_t rtnl_link_get_ns_pid(struct rtnl_link *link)
+{
+ return link->l_ns_pid;
+}
+
/** @} */
/**