From: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
To: nicolas.dichtel@6wind.com,
Stephen Hemminger <stephen@networkplumber.org>
Cc: David Ahern <dsahern@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] iplink: fix fd leak when playing with netns
Date: Tue, 17 Sep 2024 21:04:30 +0200 [thread overview]
Message-ID: <e261cce8-bd41-4f7b-b035-2480fe0e36c5@orange.com> (raw)
In-Reply-To: <bfe6f4f8-b7a3-4ea1-886b-9929c7bf366f@6wind.com>
On 17/09/2024 17:17, Nicolas Dichtel wrote:
> Le 17/09/2024 à 17:11, Stephen Hemminger a écrit :
>> On Tue, 17 Sep 2024 08:51:58 +0200
>> Nicolas Dichtel <nicolas.dichtel@6wind.com> wrote:
>>
>>> The command 'ip link set foo netns mynetns' opens a file descriptor to fill
>>> the netlink attribute IFLA_NET_NS_FD. This file descriptor is never closed.
>>> When batch mode is used, the number of file descriptor may grow greatly and
>>> reach the maximum file descriptor number that can be opened.
>>>
>>> This fd can be closed only after the netlink answer. Let's pass a new
>>> argument to iplink_parse() to remember this fd and close it.
>>>
>>> Fixes: 0dc34c7713bb ("iproute2: Add processless network namespace support")
>>> Reported-by: Alexandre Ferrieux <alexandre.ferrieux@orange.com>
>>> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
>>> Tested-by: Alexandre Ferrieux <alexandre.ferrieux@orange.com>
>>> ---
>>
>> Maybe netns_fd should be a global variable rather than having to pass
>> to change all the unrelated function calls.
> I hesitated with this option. I don't have any strong opinion on this.
>
> Note that two variables are needed, because the link_util->parse_opt may call
> again iplink_parse().
>
> Another note that I forgot to mention: I didn't fix devlink which has the same
> problem. I was waiting for the conclusion of this fix first.
Another option would be to append "cleanup tasks" (a function pointer and a
single arg) to a global linked list; and call the chain at the end of the
execution of each single batch command. This allows for as many fds as are
needed, and other cleanups as well.
My $.02 ;)
prev parent reply other threads:[~2024-09-17 19:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-17 6:51 [PATCH iproute2] iplink: fix fd leak when playing with netns Nicolas Dichtel
2024-09-17 15:11 ` Stephen Hemminger
2024-09-17 15:17 ` Nicolas Dichtel
2024-09-17 19:04 ` Alexandre Ferrieux [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e261cce8-bd41-4f7b-b035-2480fe0e36c5@orange.com \
--to=alexandre.ferrieux@gmail.com \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.