diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2013-12-04 04:16:08 (GMT) |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2013-12-09 14:28:33 (GMT) |
commit | aa1c5628fd67631894b91bfb339a912a39a24994 (patch) | |
tree | 71b61a97a6c79fdbfe8a1e56682f8b9a12c44aa7 /lib/route | |
parent | 8b87ae55161f402c07aa8464d8d6164d46aa84d5 (diff) | |
download | libnl-aa1c5628fd67631894b91bfb339a912a39a24994.zip libnl-aa1c5628fd67631894b91bfb339a912a39a24994.tar.gz libnl-aa1c5628fd67631894b91bfb339a912a39a24994.tar.bz2 |
add a parameter to rtnl_link_veth_add()
Usually the peer of a veth device is moved to a new netns
after creation, so add a pid parameter to rtnl_link_veth_add().
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'lib/route')
-rw-r--r-- | lib/route/link/veth.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/route/link/veth.c b/lib/route/link/veth.c index dba1294..d5c1926 100644 --- a/lib/route/link/veth.c +++ b/lib/route/link/veth.c @@ -236,15 +236,17 @@ int rtnl_link_is_veth(struct rtnl_link *link) * @arg sock netlink socket * @arg name name of the veth device or NULL * @arg peer_name name of its peer or NULL + * @arg pid pid of the process in the new netns * - * Creates a new veth device pair in the kernel. If no name is + * Creates a new veth device pair in the kernel and move the peer + * to the network namespace where the process is. If no name is * provided, the kernel will automatically pick a name of the * form "veth%d" (e.g. veth0, veth1, etc.) * * @return 0 on success or a negative error code */ int rtnl_link_veth_add(struct nl_sock *sock, const char *name, - const char *peer_name) + const char *peer_name, pid_t pid) { struct rtnl_link *link, *peer; int err = -NLE_NOMEM; @@ -258,6 +260,7 @@ int rtnl_link_veth_add(struct nl_sock *sock, const char *name, rtnl_link_set_name(peer, peer_name); } + rtnl_link_set_ns_pid(peer, pid); err = rtnl_link_add(sock, link, NLM_F_CREATE); rtnl_link_put(peer); |