[v4,04/15] unix: Link all sockets in unix_sockets list

Submitted by Kirill Tkhai on June 1, 2016, 4:02 p.m.

Details

Message ID 146479693020.23002.8203379324305834059.stgit@pro
State Rejected
Series "Support for packet's msg_name in receive queue of promiscous DGRAM sockets"
Headers show

Commit Message

Kirill Tkhai June 1, 2016, 4:02 p.m.
List "unix_sockets" is used to link external sockets.
Change this, to link all unix sockets there. To differ
really external sockets in fix_external_unix_sockets(),
we may check for socket's already_dumped value.

This may be useful to traverse over all unix sockets
in a namespace.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/sk-unix.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 3363cea..40cb9db 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -364,11 +364,7 @@  static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 		 * until all sockets the program owns are processed.
 		 */
 		if (!peer->sd.already_dumped) {
-			if (list_empty(&peer->list)) {
-				show_one_unix("Add a peer", peer);
-				list_add_tail(&peer->list, &unix_sockets);
-			}
-
+			show_one_unix("Add a peer", peer);
 			list_add(&sk->peer_node, &peer->peer_list);
 			sk->fd = dup(lfd);
 			if (sk->fd < 0) {
@@ -464,7 +460,6 @@  static int dump_one_unix_fd(int lfd, u32 id, const struct fd_parms *p)
 	if (list_empty(&sk->peer_node) && write_unix_entry(sk))
 		return -1;
 
-	list_del_init(&sk->list);
 	sk->sd.already_dumped = 1;
 
 	while (!list_empty(&sk->peer_list)) {
@@ -677,6 +672,7 @@  static int unix_collect_one(const struct unix_diag_msg *m,
 	}
 
 	sk_collect_one(m->udiag_ino, AF_UNIX, &d->sd);
+	list_add_tail(&d->list, &unix_sockets);
 	show_one_unix("Collected", d);
 
 	return 0;
@@ -757,9 +753,10 @@  int fix_external_unix_sockets(void)
 		FownEntry fown = FOWN_ENTRY__INIT;
 		SkOptsEntry skopts = SK_OPTS_ENTRY__INIT;
 
-		show_one_unix("Dumping extern", sk);
+		if (sk->sd.already_dumped)
+			continue;
 
-		BUG_ON(sk->sd.already_dumped);
+		show_one_unix("Dumping extern", sk);
 
 		fd_id_generate_special(NULL, &e.id);
 		e.ino		= sk->sd.ino;

Comments

Pavel Emelyanov June 9, 2016, 1:09 p.m.
1-4 applied
Pavel Emelyanov Nov. 23, 2016, 9:01 a.m.
On 06/01/2016 07:02 PM, Kirill Tkhai wrote:
> List "unix_sockets" is used to link external sockets.
> Change this, to link all unix sockets there. To differ
> really external sockets in fix_external_unix_sockets(),
> we may check for socket's already_dumped value.
> 
> This may be useful to traverse over all unix sockets
> in a namespace.
> 
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Heh :) This patch results in a weird effect. Look:

	# ./test/zdtm.py run -t zdtm/static/env00 -f h --keep-img always
	...
	# ls dump/zdtm/static/env00/39/1/
	...
	unixsk.img

The problem is that the amount of unix sockets involved in env00 test is zero,
but for some reason sk-unix.c decides to write into images one external unix sk
entry which is not referenced by anybody.

The patch id is c085d6af6d5, merged into 2.4.

-- Pavel
Pavel Emelyanov Nov. 30, 2016, 8:50 a.m.
Applied