[CRIU] [PATCH 2/4] unix: link a socket to its peer
Andrew Vagin
avagin at parallels.com
Wed Dec 4 01:54:49 PST 2013
On Mon, Dec 02, 2013 at 02:26:47PM +0400, Pavel Emelyanov wrote:
> On 11/30/2013 09:43 PM, Andrey Vagin wrote:
> > We are going to add callback-s for dumping external sockets.
> > All external sockets are added into unix_list, but for dumping we need
> > to know all peers.
> >
> > And one more thing is that a socket is not closed before its peer is
> > not be dumped. We are going to transfer the socket decriptor in the
> > callback.
> >
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> > sk-unix.c | 29 +++++++++++++++++++++++------
> > 1 file changed, 23 insertions(+), 6 deletions(-)
> >
...
> > @@ -197,9 +199,18 @@ static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
> > * It can be external socket, so we defer dumping
> > * until all sockets the program owns are processed.
> > */
> > - if (!peer->sd.already_dumped && list_empty(&peer->list)) {
> > - show_one_unix("Add a peer", peer);
> > - list_add_tail(&peer->list, &unix_sockets);
> > + if (!peer->sd.already_dumped) {
> > + if (list_empty(&peer->list)) {
> > + show_one_unix("Add a peer", peer);
> > + list_add_tail(&peer->list, &unix_sockets);
> > + }
> > +
> > + list_add(&sk->peer_node, &peer->peer_list);
> > + sk->fd = dup(lfd);
> > + if (sk->fd < 0) {
> > + pr_perror("Unable to dup(%d)", lfd);
> > + goto err;
> > + }
> > }
> >
> > if ((ue.type != SOCK_DGRAM) && (
> > @@ -284,6 +295,9 @@ dump:
> > list_del_init(&sk->list);
Delete sk from unix_sockets
> > sk->sd.already_dumped = 1;
> >
> > + list_for_each_entry(peer, &sk->peer_list, peer_node)
>
> Remove from list?
For what? sk was deleted from unix_sockets
>
> > + close_safe(&peer->fd);
> > +
> > return 0;
> >
> > err:
> > @@ -311,6 +325,9 @@ static int unix_collect_one(const struct unix_diag_msg *m,
> > d->state = m->udiag_state;
> > INIT_LIST_HEAD(&d->list);
> >
> > + INIT_LIST_HEAD(&d->peer_list);
> > + d->fd = -1;
> > +
> > if (tb[UNIX_DIAG_SHUTDOWN])
> > d->shutdown = *(u8 *)RTA_DATA(tb[UNIX_DIAG_SHUTDOWN]);
> > else
> >
>
>
More information about the CRIU
mailing list