mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
protobuf: Convert sk_opts_entry to PB format
This patch prepares the ground for further patches. sk_opts_entry get converted to PB format but not yet used anywhere in code. Also a few additional pb_ helpers are added. Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
2383c398c4
commit
eb0f81bc6f
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "protobuf.h"
|
||||
#include "../protobuf/sk-opts.pb-c.h"
|
||||
|
||||
struct fdinfo_list_entry;
|
||||
struct sk_opts_entry;
|
||||
struct cr_options;
|
||||
@@ -27,6 +30,10 @@ extern int dump_socket_opts(int sk, struct sk_opts_entry *soe);
|
||||
extern int restore_socket_opts(int sk, struct sk_opts_entry *soe);
|
||||
extern void show_socket_opts(struct sk_opts_entry *soe);
|
||||
|
||||
extern int pb_restore_socket_opts(int sk, SkOptsEntry *soe);
|
||||
extern int pb_dump_socket_opts(int sk, SkOptsEntry *soe);
|
||||
extern void pb_show_socket_opts(SkOptsEntry *soe);
|
||||
|
||||
extern int sk_collect_one(int ino, int family, struct socket_desc *d);
|
||||
extern int collect_sockets(void);
|
||||
extern int collect_inet_sockets(void);
|
||||
|
@@ -39,6 +39,7 @@ PROTO_FILES += pipe-data.proto
|
||||
PROTO_FILES += sa.proto
|
||||
PROTO_FILES += itimer.proto
|
||||
PROTO_FILES += mm.proto
|
||||
PROTO_FILES += sk-opts.proto
|
||||
|
||||
HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
|
||||
SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
|
||||
|
9
protobuf/sk-opts.proto
Normal file
9
protobuf/sk-opts.proto
Normal file
@@ -0,0 +1,9 @@
|
||||
message sk_opts_entry {
|
||||
required uint32 so_sndbuf = 1;
|
||||
required uint32 so_rcvbuf = 2;
|
||||
|
||||
required uint64 so_snd_tmo_sec = 3;
|
||||
required uint64 so_snd_tmo_usec = 4;
|
||||
required uint64 so_rcv_tmo_sec = 5;
|
||||
required uint64 so_rcv_tmo_usec = 6;
|
||||
}
|
50
sockets.c
50
sockets.c
@@ -63,6 +63,25 @@ static int do_restore_opt(int sk, int name, void *val, int len)
|
||||
|
||||
#define restore_opt(s, n, f) do_restore_opt(s, n, f, sizeof(*f))
|
||||
|
||||
int pb_restore_socket_opts(int sk, SkOptsEntry *soe)
|
||||
{
|
||||
int ret = 0;
|
||||
struct timeval tv;
|
||||
|
||||
ret |= restore_opt(sk, SO_SNDBUFFORCE, &soe->so_sndbuf);
|
||||
ret |= restore_opt(sk, SO_RCVBUFFORCE, &soe->so_rcvbuf);
|
||||
|
||||
tv.tv_sec = soe->so_snd_tmo_sec;
|
||||
tv.tv_usec = soe->so_snd_tmo_usec;
|
||||
ret |= restore_opt(sk, SO_SNDTIMEO, &tv);
|
||||
|
||||
tv.tv_sec = soe->so_rcv_tmo_sec;
|
||||
tv.tv_usec = soe->so_rcv_tmo_usec;
|
||||
ret |= restore_opt(sk, SO_RCVTIMEO, &tv);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int restore_socket_opts(int sk, struct sk_opts_entry *soe)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -107,6 +126,25 @@ int dump_socket_opts(int sk, struct sk_opts_entry *soe)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int pb_dump_socket_opts(int sk, SkOptsEntry *soe)
|
||||
{
|
||||
int ret = 0;
|
||||
struct timeval tv;
|
||||
|
||||
ret |= dump_opt(sk, SO_SNDBUF, &soe->so_sndbuf);
|
||||
ret |= dump_opt(sk, SO_RCVBUF, &soe->so_rcvbuf);
|
||||
|
||||
ret |= dump_opt(sk, SO_SNDTIMEO, &tv);
|
||||
soe->so_snd_tmo_sec = tv.tv_sec;
|
||||
soe->so_snd_tmo_usec = tv.tv_usec;
|
||||
|
||||
ret |= dump_opt(sk, SO_RCVTIMEO, &tv);
|
||||
soe->so_rcv_tmo_sec = tv.tv_sec;
|
||||
soe->so_rcv_tmo_usec = tv.tv_usec;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
|
||||
{
|
||||
int family;
|
||||
@@ -385,3 +423,15 @@ void show_socket_opts(struct sk_opts_entry *soe)
|
||||
|
||||
pr_msg("\n");
|
||||
}
|
||||
|
||||
void pb_show_socket_opts(SkOptsEntry *soe)
|
||||
{
|
||||
pr_msg("\t");
|
||||
|
||||
pr_msg("sndbuf: %u ", soe->so_sndbuf);
|
||||
pr_msg("rcvbuf: %u ", soe->so_rcvbuf);
|
||||
pr_msg("sndtmo: %lu.%lu ", soe->so_snd_tmo_sec, soe->so_snd_tmo_usec);
|
||||
pr_msg("rcvtmo: %lu.%lu ", soe->so_rcv_tmo_sec, soe->so_rcv_tmo_usec);
|
||||
|
||||
pr_msg("\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user