mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-25 11:04:35 +00:00
unix: Collect packets via cinfo engine
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
parent
508cb93374
commit
f674cbd60f
5 changed files with 22 additions and 41 deletions
|
|
@ -76,6 +76,8 @@
|
|||
#include "seccomp.h"
|
||||
#include "bitmap.h"
|
||||
#include "fault-injection.h"
|
||||
#include "sk-queue.h"
|
||||
|
||||
#include "parasite-syscall.h"
|
||||
|
||||
#include "protobuf.h"
|
||||
|
|
@ -178,6 +180,7 @@ static struct collect_image_info *cinfos[] = {
|
|||
&ext_file_cinfo,
|
||||
&timerfd_cinfo,
|
||||
&file_locks_cinfo,
|
||||
&sk_queues_cinfo,
|
||||
};
|
||||
|
||||
struct post_prepare_cb {
|
||||
|
|
@ -242,8 +245,6 @@ static int root_prepare_shared(void)
|
|||
return -1;
|
||||
if (collect_fifo())
|
||||
return -1;
|
||||
if (collect_unix_sockets())
|
||||
return -1;
|
||||
|
||||
if (tty_verify_active_pairs())
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __CR_SK_QUEUE_H__
|
||||
#define __CR_SK_QUEUE_H__
|
||||
|
||||
extern int read_sk_queues(void);
|
||||
extern struct collect_image_info sk_queues_cinfo;
|
||||
extern int dump_sk_queue(int sock_fd, int sock_id);
|
||||
extern int restore_sk_queue(int fd, unsigned int peer_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ struct ns_id;
|
|||
extern int collect_sockets(struct ns_id *);
|
||||
extern int collect_inet_sockets(void);
|
||||
extern struct collect_image_info unix_sk_cinfo;
|
||||
extern int collect_unix_sockets(void);
|
||||
extern int fix_external_unix_sockets(void);
|
||||
|
||||
extern struct collect_image_info netlink_sk_cinfo;
|
||||
|
|
|
|||
|
|
@ -33,43 +33,29 @@ struct sk_packet {
|
|||
|
||||
static LIST_HEAD(packets_list);
|
||||
|
||||
int read_sk_queues(void)
|
||||
static int collect_one_packet(void *obj, ProtobufCMessage *msg, struct cr_img *img)
|
||||
{
|
||||
struct sk_packet *pkt;
|
||||
int ret;
|
||||
struct cr_img *img;
|
||||
struct sk_packet *pkt = obj;
|
||||
|
||||
pr_info("Trying to read socket queues image\n");
|
||||
pkt->entry = pb_msg(msg, SkPacketEntry);
|
||||
pkt->img_off = lseek(img_raw_fd(img), 0, SEEK_CUR);
|
||||
/*
|
||||
* NOTE: packet must be added to the tail. Otherwise sequence
|
||||
* will be broken.
|
||||
*/
|
||||
list_add_tail(&pkt->list, &packets_list);
|
||||
lseek(img_raw_fd(img), pkt->entry->length, SEEK_CUR);
|
||||
|
||||
img = open_image(CR_FD_SK_QUEUES, O_RSTR);
|
||||
if (!img)
|
||||
return -1;
|
||||
|
||||
while (1) {
|
||||
ret = -1;
|
||||
pkt = xmalloc(sizeof(*pkt));
|
||||
if (!pkt) {
|
||||
pr_err("Failed to allocate packet header\n");
|
||||
break;
|
||||
}
|
||||
ret = pb_read_one_eof(img, &pkt->entry, PB_SK_QUEUES);
|
||||
if (ret <= 0)
|
||||
break;
|
||||
|
||||
pkt->img_off = lseek(img_raw_fd(img), 0, SEEK_CUR);
|
||||
/*
|
||||
* NOTE: packet must be added to the tail. Otherwise sequence
|
||||
* will be broken.
|
||||
*/
|
||||
list_add_tail(&pkt->list, &packets_list);
|
||||
lseek(img_raw_fd(img), pkt->entry->length, SEEK_CUR);
|
||||
}
|
||||
close_image(img);
|
||||
xfree(pkt);
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct collect_image_info sk_queues_cinfo = {
|
||||
.fd_type = CR_FD_SK_QUEUES,
|
||||
.pb_type = PB_SK_QUEUES,
|
||||
.priv_size = sizeof(struct sk_packet),
|
||||
.collect = collect_one_packet,
|
||||
};
|
||||
|
||||
int dump_sk_queue(int sock_fd, int sock_id)
|
||||
{
|
||||
SkPacketEntry pe = SK_PACKET_ENTRY__INIT;
|
||||
|
|
|
|||
|
|
@ -1330,11 +1330,6 @@ struct collect_image_info unix_sk_cinfo = {
|
|||
.flags = COLLECT_SHARED,
|
||||
};
|
||||
|
||||
int collect_unix_sockets(void)
|
||||
{
|
||||
return read_sk_queues();
|
||||
}
|
||||
|
||||
static int resolve_unix_peers(void *unused)
|
||||
{
|
||||
struct unix_sk_info *ui, *peer;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue