[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5489E421.4020003@gmail.com>
Date: Thu, 11 Dec 2014 16:36:17 -0200
From: Marcelo Ricardo Leitner <marcelo.leitner@...il.com>
To: Jiri Benc <jbenc@...hat.com>
CC: vadim4j@...il.com, netdev@...r.kernel.org
Subject: Re: [PATCH iproute2] ip: Simplify executing ip cmd within namespace
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists