Commit f674cbd6 authored by Pavel Emelyanov's avatar Pavel Emelyanov

unix: Collect packets via cinfo engine

Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 508cb933
...@@ -76,6 +76,8 @@ ...@@ -76,6 +76,8 @@
#include "seccomp.h" #include "seccomp.h"
#include "bitmap.h" #include "bitmap.h"
#include "fault-injection.h" #include "fault-injection.h"
#include "sk-queue.h"
#include "parasite-syscall.h" #include "parasite-syscall.h"
#include "protobuf.h" #include "protobuf.h"
...@@ -178,6 +180,7 @@ static struct collect_image_info *cinfos[] = { ...@@ -178,6 +180,7 @@ static struct collect_image_info *cinfos[] = {
&ext_file_cinfo, &ext_file_cinfo,
&timerfd_cinfo, &timerfd_cinfo,
&file_locks_cinfo, &file_locks_cinfo,
&sk_queues_cinfo,
}; };
struct post_prepare_cb { struct post_prepare_cb {
...@@ -242,8 +245,6 @@ static int root_prepare_shared(void) ...@@ -242,8 +245,6 @@ static int root_prepare_shared(void)
return -1; return -1;
if (collect_fifo()) if (collect_fifo())
return -1; return -1;
if (collect_unix_sockets())
return -1;
if (tty_verify_active_pairs()) if (tty_verify_active_pairs())
return -1; return -1;
......
#ifndef __CR_SK_QUEUE_H__ #ifndef __CR_SK_QUEUE_H__
#define __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 dump_sk_queue(int sock_fd, int sock_id);
extern int restore_sk_queue(int fd, unsigned int peer_id); extern int restore_sk_queue(int fd, unsigned int peer_id);
......
...@@ -38,7 +38,6 @@ struct ns_id; ...@@ -38,7 +38,6 @@ struct ns_id;
extern int collect_sockets(struct ns_id *); extern int collect_sockets(struct ns_id *);
extern int collect_inet_sockets(void); 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 fix_external_unix_sockets(void); extern int fix_external_unix_sockets(void);
extern struct collect_image_info netlink_sk_cinfo; extern struct collect_image_info netlink_sk_cinfo;
......
...@@ -33,43 +33,29 @@ struct sk_packet { ...@@ -33,43 +33,29 @@ struct sk_packet {
static LIST_HEAD(packets_list); 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; struct sk_packet *pkt = obj;
int ret;
struct cr_img *img;
pr_info("Trying to read socket queues image\n");
img = open_image(CR_FD_SK_QUEUES, O_RSTR);
if (!img)
return -1;
while (1) { pkt->entry = pb_msg(msg, SkPacketEntry);
ret = -1; pkt->img_off = lseek(img_raw_fd(img), 0, SEEK_CUR);
pkt = xmalloc(sizeof(*pkt)); /*
if (!pkt) { * NOTE: packet must be added to the tail. Otherwise sequence
pr_err("Failed to allocate packet header\n"); * will be broken.
break; */
} list_add_tail(&pkt->list, &packets_list);
ret = pb_read_one_eof(img, &pkt->entry, PB_SK_QUEUES); lseek(img_raw_fd(img), pkt->entry->length, SEEK_CUR);
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) int dump_sk_queue(int sock_fd, int sock_id)
{ {
SkPacketEntry pe = SK_PACKET_ENTRY__INIT; SkPacketEntry pe = SK_PACKET_ENTRY__INIT;
......
...@@ -1330,11 +1330,6 @@ struct collect_image_info unix_sk_cinfo = { ...@@ -1330,11 +1330,6 @@ struct collect_image_info unix_sk_cinfo = {
.flags = COLLECT_SHARED, .flags = COLLECT_SHARED,
}; };
int collect_unix_sockets(void)
{
return read_sk_queues();
}
static int resolve_unix_peers(void *unused) static int resolve_unix_peers(void *unused)
{ {
struct unix_sk_info *ui, *peer; struct unix_sk_info *ui, *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