Commit eb0f81bc authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

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: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2383c398
...@@ -7,6 +7,9 @@ ...@@ -7,6 +7,9 @@
#include "types.h" #include "types.h"
#include "protobuf.h"
#include "../protobuf/sk-opts.pb-c.h"
struct fdinfo_list_entry; struct fdinfo_list_entry;
struct sk_opts_entry; struct sk_opts_entry;
struct cr_options; struct cr_options;
...@@ -27,6 +30,10 @@ extern int dump_socket_opts(int sk, struct sk_opts_entry *soe); ...@@ -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 int restore_socket_opts(int sk, struct sk_opts_entry *soe);
extern void show_socket_opts(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 sk_collect_one(int ino, int family, struct socket_desc *d);
extern int collect_sockets(void); extern int collect_sockets(void);
extern int collect_inet_sockets(void); extern int collect_inet_sockets(void);
......
...@@ -39,6 +39,7 @@ PROTO_FILES += pipe-data.proto ...@@ -39,6 +39,7 @@ PROTO_FILES += pipe-data.proto
PROTO_FILES += sa.proto PROTO_FILES += sa.proto
PROTO_FILES += itimer.proto PROTO_FILES += itimer.proto
PROTO_FILES += mm.proto PROTO_FILES += mm.proto
PROTO_FILES += sk-opts.proto
HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES)) HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES)) SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
......
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;
}
...@@ -63,6 +63,25 @@ static int do_restore_opt(int sk, int name, void *val, int len) ...@@ -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)) #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 restore_socket_opts(int sk, struct sk_opts_entry *soe)
{ {
int ret = 0; int ret = 0;
...@@ -107,6 +126,25 @@ int dump_socket_opts(int sk, struct sk_opts_entry *soe) ...@@ -107,6 +126,25 @@ int dump_socket_opts(int sk, struct sk_opts_entry *soe)
return ret; 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 dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
{ {
int family; int family;
...@@ -385,3 +423,15 @@ void show_socket_opts(struct sk_opts_entry *soe) ...@@ -385,3 +423,15 @@ void show_socket_opts(struct sk_opts_entry *soe)
pr_msg("\n"); 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");
}
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