From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Jiri Benc <jbenc@redhat.com>
Cc: vadim4j@gmail.com, netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] ip: Simplify executing ip cmd within namespace
Date: Thu, 11 Dec 2014 16:36:17 -0200 [thread overview]
Message-ID: <5489E421.4020003@gmail.com> (raw)
In-Reply-To: <20141211190846.1e25e7fa@griffin>
On 11-12-2014 16:08, Jiri Benc wrote:
> On Thu, 11 Dec 2014 15:33:34 -0200, Marcelo Ricardo Leitner wrote:
>> In that case, it would be interesting to also accelerate the original use
>> case, no? So all usages we currently have will benefit from this speed up
>> without a change.
>>
>> if (command to be executed == myself)
>> switch namespace, continue without fork/exec..
>
> It's never good idea to do such tricks behind the user's back. This
> particular case could easily break for users wanting to execute a
> different ip binary (for whatever reason).
Then the if() above wouldn't match. That if means to check
/proc/self/exe against the result of the path expansion. If that fails,
continue with the normal path. If it matches, it is the same binary, and
no need to re-exec itself.
> All programs should do what they are told to do, not try to outsmart
> the user.
It's not outsmarting, it's just not being dumb and doing it the proper
way. Bash itself does this twist a lot. If you just type 'echo hi', it
won't execute /bin/echo but use a built-in version. But if you write
"/bin/echo hi", it will use /bin/echo..
We could use the same idea. "ip netns exec ip" -> ellipse it and avoid
the fork/exec. But if it's cmd != "ip", execute it..
Now consider other applications that are user of this command. They will
have to implement something like:
if (this ip command has --netns argument) {
cmd="ip --netns ..."
} else {
cmd="ip netns exec ..."
}
which is ugly and inconvenient.
Marcelo
prev parent reply other threads:[~2014-12-11 18:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-10 22:56 [PATCH iproute2] ip: Simplify executing ip cmd within namespace Vadim Kochan
2014-12-11 10:58 ` Nicolas Dichtel
2014-12-11 10:57 ` vadim4j
2014-12-11 12:50 ` Nicolas Dichtel
2014-12-11 13:02 ` vadim4j
2014-12-11 16:09 ` Jiri Benc
2014-12-11 16:33 ` vadim4j
2014-12-11 17:33 ` Marcelo Ricardo Leitner
2014-12-11 18:08 ` Jiri Benc
2014-12-11 18:36 ` Marcelo Ricardo Leitner [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=5489E421.4020003@gmail.com \
--to=marcelo.leitner@gmail.com \
--cc=jbenc@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=vadim4j@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).