fprintf(stderr, "Usage: ip netns list\n");
fprintf(stderr, " ip netns add NAME\n");
fprintf(stderr, " ip netns delete NAME\n");
- fprintf(stderr, " ip netns identify PID\n");
+ fprintf(stderr, " ip netns identify [PID]\n");
fprintf(stderr, " ip netns pids NAME\n");
fprintf(stderr, " ip netns exec NAME cmd ...\n");
fprintf(stderr, " ip netns monitor\n");
struct dirent *entry;
if (argc < 1) {
- fprintf(stderr, "No pid specified\n");
- return -1;
- }
- if (argc > 1) {
+ pidstr = "self";
+ } else if (argc > 1) {
fprintf(stderr, "extra arguments specified\n");
return -1;
- }
- pidstr = argv[0];
-
- if (!is_pid(pidstr)) {
- fprintf(stderr, "Specified string '%s' is not a pid\n",
- pidstr);
- return -1;
+ } else {
+ pidstr = argv[0];
+ if (!is_pid(pidstr)) {
+ fprintf(stderr, "Specified string '%s' is not a pid\n",
+ pidstr);
+ return -1;
+ }
}
snprintf(net_path, sizeof(net_path), "/proc/%s/ns/net", pidstr);
.ti -8
.BR "ip netns identify"
-.I PID
+.RI "[ " PID " ]"
.ti -8
.BR "ip netns pids"
the mount point is in use in another mount namespace.
.TP
-.B ip netns identify PID - Report network namespaces names for process
+.B ip netns identify [PID] - Report network namespaces names for process
.sp
This command walks through /var/run/netns and finds all the network
-namespace names for network namespace of the specified process.
+namespace names for network namespace of the specified process, if PID is
+not specified then the current process will be used.
.TP
.B ip netns pids NAME - Report processes in the named network namespace