From: David Ahern Drop the open coding of proc/pid/ns/net in favor of netns_get_fd_pid. Signed-off-by: David Ahern --- ip/iplink.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ip/iplink.c b/ip/iplink.c index eae51438..6c4586ee 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -650,19 +650,13 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) if (offload && name == dev) dev = NULL; } else if (strcmp(*argv, "netns") == 0) { - int pid; - NEXT_ARG(); if (netns != -1) duparg("netns", *argv); + /* try by name then by pid */ netns = netns_get_fd(*argv); - if (netns < 0 && get_integer(&pid, *argv, 0) == 0) { - char path[PATH_MAX]; - - snprintf(path, sizeof(path), "/proc/%d/ns/net", - pid); - netns = open(path, O_RDONLY); - } + if (netns < 0) + netns = netns_get_fd_pid(*argv); if (netns < 0) invarg("Invalid \"netns\" value\n", *argv); -- 2.50.1 (Apple Git-155)