From: Serge Hallyn <serge.hallyn@ubuntu.com>
To: "chenhanxiao@cn.fujitsu.com" <chenhanxiao@cn.fujitsu.com>
Cc: "Richard Weinberger (richard@nod.at)" <richard@nod.at>,
"containers@lists.linux-foundation.org"
<containers@lists.linux-foundation.org>,
"Oleg Nesterov (oleg@redhat.com)" <oleg@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Eric W. Biederman (ebiederm@xmission.com)"
<ebiederm@xmission.com>,
"Vasily Kulikov (segoon@openwall.com)" <segoon@openwall.com>
Subject: Re: [RFC]Pid conversion between pid namespace
Date: Fri, 25 Jul 2014 17:34:43 +0000 [thread overview]
Message-ID: <20140725173443.GH31507@ubuntumail> (raw)
In-Reply-To: <5871495633F38949900D2BF2DC04883E569892@G08CNEXMBPEKD02.g08.fujitsu.local>
Quoting chenhanxiao@cn.fujitsu.com (chenhanxiao@cn.fujitsu.com):
> Hi,
>
> > -----Original Message-----
> > From: Serge Hallyn [mailto:serge.hallyn@ubuntu.com]
> > Sent: Tuesday, July 15, 2014 12:16 PM
> > To: Chen, Hanxiao/陈 晗霄
> > Subject: Re: [RFC]Pid conversion between pid namespace
> > > A-2) syscall pid_t getnspid(pid_t query_pid, pid_t observer_pid)
> > > pros:
> > > - ns procfs free, easy to use.
> > > We could get rid of mounted ns procfs.
> > >
> > > cons:
> > > - may find multiple results in nested ns.
> > > We wished the new API could tell us the exact answer.
> > > But if getnspid return more than one results will bring trouble to admins,
> >
> > (See below for more, but) the question being posed to getnspid has precisely
> > one answer.
> >
> > > they had to make another decision.
> > > Or we marked the deepest level for translation as prerequisite.
> > >
> > > -based on current pidns, no reference ns.
> >
> > Hm, no. The intent here was that
> >
> > observer_pid would be in current ns
> > query_pid would be in observer_pid's ns.
> >
> > So this would be ideal for "I got a pid in a logfile created by rsyslog in
> > a nested contaner, what is the logged pid in my pidns."
> >
> > Taking a set of tasks (like a container with nesting) and bulding a tree
> > of all pids shouldn't be too difficult either. Start with the init pid,
> > call getnspid($pid, $init_pid) for every $pid in the container; to figure
> > out whether any $pid is itself a nested init_pid, we can compare the
> > /proc/$$/ns/pid, as well as look at getnspid($pid, $pid).
> I'm a little confused in this section:
>
> Ex:
> init_pid_ns ns1 ns2
> t1 2
> t2 `- 3 1
> t3 `- 4 `- 5 1
> t4 `-6 `-8 `-9
> t5 `-10 `-9 `-10
>
> For getnspid($pid, $init_pid),
> Does init_pid means container's init_pid such as 3 for t2?
Right, if you're in init_pid_ns and making the query, then
you'd pass 3.
> In nested containers, does this syscall work as:
> getnspid(9, 4) -> (6, 8, 9)
No, assuming the querying task is in init_pid_ns,
getnspid(9, 4) would return 6.
4 is the observer pid given in the querier's own pidns, so
it refers to t3. 9 is the pid being queried, in the oberver's
pidns, so it revers to t4. The result is, the pid in our own
pidns.
Does that help clarify at all? I'm not sure whether the problem is that
I didn't explain well enough from the start, or whether this just shows
that the API is one only its mother could love :)
-serge
next prev parent reply other threads:[~2014-07-25 17:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-03 12:18 chenhanxiao
2014-07-04 5:34 ` Yasunori Goto
2014-07-09 10:34 ` chenhanxiao
2014-07-15 4:16 ` Serge Hallyn
2014-07-21 10:47 ` chenhanxiao
2014-07-25 17:34 ` Serge Hallyn [this message]
2014-07-28 8:14 ` Hu Tao
2014-07-28 13:24 ` Serge Hallyn
2014-07-25 10:01 ` chenhanxiao
2014-08-04 22:20 ` Serge Hallyn
2014-08-07 10:03 ` chenhanxiao
2014-08-07 16:11 ` Serge Hallyn
2014-08-08 9:30 ` chenhanxiao
2014-08-28 13:49 ` Serge E. Hallyn
2014-08-29 9:59 ` chenhanxiao
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=20140725173443.GH31507@ubuntumail \
--to=serge.hallyn@ubuntu.com \
--cc=chenhanxiao@cn.fujitsu.com \
--cc=containers@lists.linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=richard@nod.at \
--cc=segoon@openwall.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
all inboxes | Powered by JetHome®