Commit 3b288ca3 authored by Pavel Emelyanov's avatar Pavel Emelyanov

unix: Run peer resolving via post_cb engine

With autofs patches we've merged a small engine that allows
to queue random routine for post-prepare execution. Re-use
this for unix sockets' interconneting routine.

Also this is a tiny optimization -- when we don't have unix
sockets to interconnect we don't make extra list walk.
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 46408840
...@@ -274,10 +274,6 @@ static int root_prepare_shared(void) ...@@ -274,10 +274,6 @@ static int root_prepare_shared(void)
if (ret) if (ret)
goto err; goto err;
ret = resolve_unix_peers();
if (ret)
goto err;
ret = prepare_restorer_blob(); ret = prepare_restorer_blob();
if (ret) if (ret)
goto err; goto err;
......
...@@ -40,7 +40,6 @@ extern int collect_inet_sockets(void); ...@@ -40,7 +40,6 @@ extern int collect_inet_sockets(void);
extern struct collect_image_info unix_sk_cinfo; extern struct collect_image_info unix_sk_cinfo;
extern int collect_unix_sockets(void); extern int collect_unix_sockets(void);
extern int fix_external_unix_sockets(void); extern int fix_external_unix_sockets(void);
extern int resolve_unix_peers(void);
extern struct collect_image_info netlink_sk_cinfo; extern struct collect_image_info netlink_sk_cinfo;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "plugin.h" #include "plugin.h"
#include "namespaces.h" #include "namespaces.h"
#include "pstree.h" #include "pstree.h"
#include "crtools.h"
#include "protobuf.h" #include "protobuf.h"
#include "images/sk-unix.pb-c.h" #include "images/sk-unix.pb-c.h"
...@@ -1281,13 +1282,22 @@ static void unlink_stale(struct unix_sk_info *ui) ...@@ -1281,13 +1282,22 @@ static void unlink_stale(struct unix_sk_info *ui)
revert_unix_sk_cwd(&cwd_fd); revert_unix_sk_cwd(&cwd_fd);
} }
static int resolve_unix_peers(void *unused);
static int collect_one_unixsk(void *o, ProtobufCMessage *base) static int collect_one_unixsk(void *o, ProtobufCMessage *base)
{ {
struct unix_sk_info *ui = o; struct unix_sk_info *ui = o;
static bool post_queued = false;
ui->ue = pb_msg(base, UnixSkEntry); ui->ue = pb_msg(base, UnixSkEntry);
ui->name_dir = (void *)ui->ue->name_dir; ui->name_dir = (void *)ui->ue->name_dir;
if (ui->ue->peer && !post_queued) {
post_queued = true;
if (add_post_prepare_cb(resolve_unix_peers, NULL))
return -1;
}
if (ui->ue->name.len) { if (ui->ue->name.len) {
if (ui->ue->name.len > UNIX_PATH_MAX) { if (ui->ue->name.len > UNIX_PATH_MAX) {
pr_err("Bad unix name len %d\n", (int)ui->ue->name.len); pr_err("Bad unix name len %d\n", (int)ui->ue->name.len);
...@@ -1325,7 +1335,7 @@ int collect_unix_sockets(void) ...@@ -1325,7 +1335,7 @@ int collect_unix_sockets(void)
return read_sk_queues(); return read_sk_queues();
} }
int resolve_unix_peers(void) static int resolve_unix_peers(void *unused)
{ {
struct unix_sk_info *ui, *peer; struct unix_sk_info *ui, *peer;
struct fdinfo_list_entry *fle, *fle_peer; struct fdinfo_list_entry *fle, *fle_peer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment