* [PATCH iproute2] ipnetns: fix fd leak with 'ip netns set'
@ 2023-05-11 14:42 Nicolas Dichtel
2023-05-11 21:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Nicolas Dichtel @ 2023-05-11 14:42 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Ahern, netdev, Nicolas Dichtel
There is no reason to open this netns file. set_netnsid_from_name() uses
netns_get_fd() for this purpose and uses the returned fd.
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Fixes: d182ee1307c7 ("ipnetns: allow to get and set netns ids")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---
ip/ipnetns.c | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index 1203534914fe..9d996832aef8 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -967,9 +967,8 @@ int set_netnsid_from_name(const char *name, int nsid)
static int netns_set(int argc, char **argv)
{
- char netns_path[PATH_MAX];
const char *name;
- int netns, nsid;
+ int nsid;
if (argc < 1) {
fprintf(stderr, "No netns name specified\n");
@@ -988,14 +987,6 @@ static int netns_set(int argc, char **argv)
else if (nsid < 0)
invarg("\"netnsid\" value should be >= 0", argv[1]);
- snprintf(netns_path, sizeof(netns_path), "%s/%s", NETNS_RUN_DIR, name);
- netns = open(netns_path, O_RDONLY | O_CLOEXEC);
- if (netns < 0) {
- fprintf(stderr, "Cannot open network namespace \"%s\": %s\n",
- name, strerror(errno));
- return -1;
- }
-
return set_netnsid_from_name(name, nsid);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] ipnetns: fix fd leak with 'ip netns set'
2023-05-11 14:42 [PATCH iproute2] ipnetns: fix fd leak with 'ip netns set' Nicolas Dichtel
@ 2023-05-11 21:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-05-11 21:20 UTC (permalink / raw)
To: Nicolas Dichtel; +Cc: stephen, dsahern, netdev
Hello:
This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:
On Thu, 11 May 2023 16:42:24 +0200 you wrote:
> There is no reason to open this netns file. set_netnsid_from_name() uses
> netns_get_fd() for this purpose and uses the returned fd.
>
> Reported-by: Stephen Hemminger <stephen@networkplumber.org>
> Fixes: d182ee1307c7 ("ipnetns: allow to get and set netns ids")
> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>
> [...]
Here is the summary with links:
- [iproute2] ipnetns: fix fd leak with 'ip netns set'
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=465e87a89c13
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-11 21:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-11 14:42 [PATCH iproute2] ipnetns: fix fd leak with 'ip netns set' Nicolas Dichtel
2023-05-11 21:20 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.