Commit 01e88d1c authored by Pavel Emelyanov's avatar Pavel Emelyanov

rpc: Add ability to specify veth pairs (--veth-pair option)

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 72bf807c
......@@ -22,6 +22,7 @@
#include "cr-service-const.h"
#include "sd-daemon.h"
#include "page-xfer.h"
#include "net.h"
unsigned int service_sk_ino = -1;
......@@ -159,6 +160,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
socklen_t ids_len = sizeof(struct ucred);
char images_dir_path[PATH_MAX];
char work_dir_path[PATH_MAX];
int i;
if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) {
pr_perror("Can't get socket options");
......@@ -265,6 +267,11 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
list_add(&script->node, &opts.scripts);
}
for (i = 0; i < req->n_veths; i++) {
if (veth_pair_add(req->veths[i]->if_in, req->veths[i]->if_out))
return -1;
}
return 0;
}
......
......@@ -230,20 +230,15 @@ int main(int argc, char *argv[])
break;
case 47:
{
struct veth_pair *n;
char *aux;
n = xmalloc(sizeof(*n));
if (n == NULL)
return 1;
n->outside = strchr(optarg, '=');
if (n->outside == NULL) {
xfree(n);
aux = strchr(optarg, '=');
if (aux == NULL)
goto bad_arg;
}
*n->outside++ = '\0';
n->inside = optarg;
list_add(&n->node, &opts.veth_pairs);
*aux = '\0';
if (veth_pair_add(optarg, aux + 1))
return 1;
}
break;
case 49:
......
......@@ -24,4 +24,6 @@ extern int write_netdev_img(NetDeviceEntry *nde, struct cr_fdset *fds);
extern int read_ns_sys_file(char *path, char *buf, int len);
extern int restore_link_parms(NetDeviceEntry *nde, int nlsk);
extern int veth_pair_add(char *in, char *out);
#endif /* __CR_NET_H__ */
......@@ -605,4 +605,19 @@ void network_unlock(void)
run_scripts("network-unlock");
}
int veth_pair_add(char *in, char *out)
{
struct veth_pair *n;
n = xmalloc(sizeof(*n));
if (n == NULL)
return -1;
n->inside = in;
n->outside = out;
list_add(&n->node, &opts.veth_pairs);
pr_debug("Added %s:%s veth map\n", in, out);
return 0;
}
struct ns_desc net_ns_desc = NS_DESC_ENTRY(CLONE_NEWNET, "net");
......@@ -4,6 +4,11 @@ message criu_page_server_info {
optional int32 pid = 3;
}
message criu_veth_pair {
required string if_in = 1;
required string if_out = 2;
};
message criu_opts {
required int32 images_dir_fd = 1;
optional int32 pid = 2; /* if not set on dump, will dump requesting process */
......@@ -27,6 +32,7 @@ message criu_opts {
optional int32 work_dir_fd = 16;
optional bool link_remap = 17;
repeated criu_veth_pair veths = 18;
}
message criu_dump_resp {
......
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