]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
iproute2: add support for IFLA_NET_NS_PID in ip link
authorBenjamin Thery <benjamin.thery@bull.net>
Fri, 20 Jun 2008 09:07:35 +0000 (11:07 +0200)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Mon, 23 Jun 2008 16:10:47 +0000 (09:10 -0700)
Hi Stephen,

I resend you this patch once more. This time I updated the documentation
too (may be that was the reason why you didn't take it before?).

Please tell me if there are other things missing in this patch
It applies on iproute2 git tree.

Regards,
Benjamin

Description:
------------

This patch adds support for the IFLA_NET_NS_PID type. It is used to
move network devices between network namespaces.

The syntax is:
ip link set DEVICE netns PID

PID is the pid of a process in the target network namespace.

(Daniel Lezcano is the original author).

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
doc/ip-cref.tex
ip/iplink.c
man/man8/ip.8

index cc0e07d3812094eda6037c540eeec230a4f176b9..bb4eb7831ec9f5ac72f12958f8524b08953ef1d0 100644 (file)
@@ -294,6 +294,10 @@ broadcast address will break networking.
 Do not use it, if you do not understand what this operation really does.
 \end{NB}
 
+\item \verb|netns PID|
+
+--- move the device to the network namespace associated with the process PID.
+
 \end{itemize}
 
 \vskip 1mm
index 95801a6cab813a5c631341e2ca81ca37e86405a6..c70c84ad479ab4f3c49928c0f1cef001791ce08a 100644 (file)
@@ -49,6 +49,7 @@ void iplink_usage(void)
        fprintf(stderr, "                            name NEWNAME |\n");
        fprintf(stderr, "                            address LLADDR | broadcast LLADDR |\n");
        fprintf(stderr, "                            mtu MTU }\n");
+       fprintf(stderr, "                            netns PID }\n");
        fprintf(stderr, "       ip link show [ DEVICE ]\n");
        exit(-1);
 }
@@ -156,6 +157,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
        char abuf[32];
        int qlen = -1;
        int mtu = -1;
+       int netns = -1;
 
        ret = argc;
 
@@ -197,6 +199,13 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
                        if (get_integer(&mtu, *argv, 0))
                                invarg("Invalid \"mtu\" value\n", *argv);
                        addattr_l(&req->n, sizeof(*req), IFLA_MTU, &mtu, 4);
+                } else if (strcmp(*argv, "netns") == 0) {
+                        NEXT_ARG();
+                        if (netns != -1)
+                                duparg("netns", *argv);
+                        if (get_integer(&netns, *argv, 0))
+                                invarg("Invalid \"netns\" value\n", *argv);
+                        addattr_l(&req->n, sizeof(*req), IFLA_NET_NS_PID, &netns, 4);
                } else if (strcmp(*argv, "multicast") == 0) {
                        NEXT_ARG();
                        req->i.ifi_change |= IFF_MULTICAST;
index da314f39845a499b6152843a291b4c004c01e13f..2097317c8ee5737709931ce4c9fdd2f0cea5a3ec 100644 (file)
@@ -50,7 +50,10 @@ ip \- show / manipulate routing, devices, policy routing and tunnels
 .IR LLADDR " |"
 .br
 .B  mtu
-.IR MTU " }"
+.IR MTU " |"
+.br
+.B  netns
+.IR PID " }"
 
 .ti -8
 .B ip link show
@@ -873,6 +876,11 @@ change the link layer broadcast address or the peer address when
 the interface is
 .IR "POINTOPOINT" .
 
+.TP
+.BI netns " PID"
+move the device to the network namespace associated with the process
+.IR "PID" .
+
 .PP
 .B Warning:
 If multiple parameter changes are requested,