[CRIU] [PATCH v7 7/9] unix: Add support of ghost sockets

Andrey Vagin avagin at virtuozzo.com
Tue Jun 5 01:31:03 MSK 2018


On Mon, Jun 04, 2018 at 11:18:56PM +0300, Cyrill Gorcunov wrote:
> On Mon, Jun 04, 2018 at 12:52:20PM -0700, Andrey Vagin wrote:
> > > +
> > > +			snprintf(path, sizeof(path), UNIX_GHOST_FMT, ui->name);
> > > +			if (rename(ui->name, path)) {
> > > +				ret = -errno;
> > > +				pr_perror("ghost: Can't rename id %#x ino %d addr %s -> %s\n",
> > > +					  ui->ue->id, ui->ue->ino, ui->name, path);
> > > +				return ret;
> > > +			}
> > > +			ui->flags |= USK_GHOST_RENAMED;
> > 
> > Why do we use a global flag for this? Why we can't rename this file
> > back after bind()?
> 
> Because once we have it renamed we exit out of this routine and
> start restoring file permissions on this socket, iow, there gonna
> be more manipulations on this address later.
> 
> > > +	pr_debug("ghost: Resolving addresses\n");
> > > +
> > > +	list_for_each_entry(ui, &unix_ghost_addr, ghost_node) {
> > > +		pr_debug("ghost: id %#x type %s state %s ino %d peer %d address %s\n",
> > > +			 ui->ue->id, socket_type_name(ui->ue->type),
> > > +			 tcp_state_name(ui->ue->state),
> > > +			 ui->ue->ino, ui->peer ? ui->peer->ue->ino : 0,
> > > +			 ui->name);
> > > +
> > > +		/*
> > > +		 * Drop any existing trash on the FS and mark the
> > > +		 * peer as a ghost one, so we will put it into
> > > +		 * fdstore to be able to connect into it even
> > > +		 * when the address is removed from the FS.
> > > +		 */
> > > +		unlink_sk(ui);
> > 
> > Hm. If a socket is a ghost one, we don't know an owner of a socket file
> > on a file system, so we don't have rights to delete it, do we?
> 
> We always do that, been cleaning any existing socket appeared on
> the file system after the checkpoint. Actually there should not
> be any file. But to be fair I don't remember the details why
> we start removing any existing trash in firs place, been too
> long ago.

I don't understand why there is any special case for ghost sockets.


More information about the CRIU mailing list