[CRIU] [PATCH RESEND v1 46/55] ns: Install transport fd socket in usernsd
Kirill Tkhai
ktkhai at virtuozzo.com
Fri Mar 24 08:16:15 PDT 2017
In next patches we will need a named socket in usernsd,
to send "set last pid" requests. Create transport socket
for that.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
criu/namespaces.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/criu/namespaces.c b/criu/namespaces.c
index 61e264f8..99f4379f 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -34,6 +34,7 @@
#include "common/scm.h"
#include "fdstore.h"
#include "proc_parse.h"
+#include "util-pie.h"
static struct ns_desc *ns_desc_array[] = {
&net_ns_desc,
@@ -1500,8 +1501,33 @@ static void unsc_msg_pid_fd(struct unsc_msg *um, pid_t *pid, int *fd)
static int usernsd(int sk)
{
+ struct sockaddr_un addr;
+ int transport_fd;
+ socklen_t len;
+
pr_info("uns: Daemon started\n");
+ transport_fd = socket(AF_UNIX, SOCK_DGRAM, 0);
+ if (transport_fd < 0) {
+ pr_perror("Can't create transport socket");
+ return -1;
+ }
+
+ addr.sun_family = AF_UNIX;
+ snprintf(addr.sun_path, UNIX_PATH_MAX, "x/criu-usernsd");
+ len = SUN_LEN(&addr);
+ *addr.sun_path = '\0';
+
+ if (bind(transport_fd, (struct sockaddr *)&addr, len) < 0) {
+ pr_perror("Can't bind transport sock");
+ return -1;
+ }
+
+ if (install_service_fd(TRANSPORT_FD_OFF, transport_fd) < 0) {
+ pr_perror("Can't install transport fd\n");
+ return -1;
+ }
+
while (1) {
struct unsc_msg um;
static char msg[MAX_UNSFD_MSG_SIZE];
More information about the CRIU
mailing list