login
Header Space

 
 

[PATCH][IPROUTE2] Support device movement between network namespaces

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Stephen Hemminger <shemminger@...>
Cc: Daniel Lezcano <dlezcano@...>, <netdev@...>
Date: Thursday, April 24, 2008 - 11:15 am

Hi Stephen,

I don't know if anyone has already sent you this patch for iproute2 to
enable movement of network devices between network namespaces. 
(Daniel Lezcano is the original author). 

It applies on iproute2-2.6.25.

Benjamin


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

The syntax is: 
ip link DEVICE netns PID

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

---
 ip/iplink.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: iproute2-2.6.25/ip/iplink.c
===================================================================
--- iproute2-2.6.25.orig/ip/iplink.c
+++ iproute2-2.6.25/ip/iplink.c
@@ -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, 
 	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, 
 			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;

-- 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH][IPROUTE2] Support device movement between network na..., Benjamin Thery, (Thu Apr 24, 11:15 am)
speck-geostationary