Commit 7f82ae11 authored by Pavel Emelyanov's avatar Pavel Emelyanov

sockets: Prepare for dumping/restoring/showing socket options

Those sitting on the SOL_SOCKET level are common to different
socket families and will be handled in a generic code.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7b7e86c9
......@@ -168,6 +168,9 @@ struct pipe_data_entry {
#define USK_EXTERN (1 << 0)
struct sk_opts_entry {
};
struct unix_sk_entry {
u32 id;
u8 type;
......@@ -179,6 +182,7 @@ struct unix_sk_entry {
u32 backlog;
u32 peer;
fown_t fown;
struct sk_opts_entry opts;
u8 name[0];
} __packed;
......@@ -195,6 +199,7 @@ struct inet_sk_entry {
fown_t fown;
u32 src_addr[4];
u32 dst_addr[4];
struct sk_opts_entry opts;
} __packed;
struct tcp_stream_entry {
......
......@@ -9,6 +9,10 @@ struct cr_fdset;
struct fd_parms;
extern int dump_socket(struct fd_parms *p, int lfd,
const struct cr_fdset *cr_fdset);
struct sk_opts_entry;
extern int dump_socket_opts(int sk, struct sk_opts_entry *);
extern int restore_socket_opts(int sk, struct sk_opts_entry *);
extern void show_socket_opts(struct sk_opts_entry *);
struct fdinfo_list_entry;
struct file_desc;
......
......@@ -134,6 +134,9 @@ int dump_one_inet(struct socket_desc *_sk, struct fd_parms *p,
show_one_inet_img("Dumped", &ie);
sk->sd.already_dumped = 1;
if (dump_socket_opts(lfd, &ie.opts))
goto err;
if (tcp_connection(sk))
return dump_one_tcp(lfd, sk);
......@@ -277,6 +280,9 @@ done:
if (rst_file_params(sk, &ii->ie.fown, ii->ie.flags))
goto err;
if (restore_socket_opts(sk, &ii->ie.opts))
return -1;
return sk;
err:
......@@ -377,6 +383,8 @@ void show_inetsk(int fd, struct cr_options *o)
ie.id, skfamily2s(ie.family), sktype2s(ie.type), skproto2s(ie.proto),
skstate2s(ie.state), src_addr, ie.src_port, dst_addr, ie.dst_port, ie.flags);
pr_msg("\t"), show_fown_cont(&ie.fown), pr_msg("\n");
show_socket_opts(&ie.opts);
}
out:
......
......@@ -191,6 +191,9 @@ int dump_one_unix(const struct socket_desc *_sk, struct fd_parms *p,
ue.id, ue.peer);
}
if (dump_socket_opts(lfd, &ue.opts))
goto err;
if (write_img(fdset_fd(glob_fdset, CR_FD_UNIXSK), &ue))
goto err;
if (write_img_buf(fdset_fd(glob_fdset, CR_FD_UNIXSK), sk->name, ue.namelen))
......@@ -452,6 +455,8 @@ void show_unixsk(int fd, struct cr_options *o)
} else
pr_msg("\n");
pr_msg("\t"), show_fown_cont(&ue.fown), pr_msg("\n");
show_socket_opts(&ue.opts);
}
out:
pr_img_tail(CR_FD_UNIXSK);
......@@ -520,6 +525,9 @@ try_again:
if (rst_file_params(fle->fe.fd, &ui->ue.fown, ui->ue.flags))
return -1;
if (restore_socket_opts(fle->fe.fd, &ui->ue.opts))
return -1;
cj = cj->next;
}
......@@ -628,6 +636,9 @@ static int open_unixsk_pair_slave(struct unix_sk_info *ui)
if (rst_file_params(sk, &ui->ue.fown, ui->ue.flags))
return -1;
if (restore_socket_opts(sk, &ui->ue.opts))
return -1;
return sk;
}
......@@ -656,6 +667,10 @@ static int open_unixsk_standalone(struct unix_sk_info *ui)
if (rst_file_params(sk, &ui->ue.fown, ui->ue.flags))
return -1;
if (restore_socket_opts(sk, &ui->ue.opts))
return -1;
} else if (ui->peer) {
pr_info("\tWill connect %#x to %#x later\n", ui->ue.id, ui->ue.peer);
if (schedule_conn_job(ui))
......
......@@ -66,6 +66,16 @@ int sk_collect_one(int ino, int family, struct socket_desc *d)
return 0;
}
int restore_socket_opts(int sk, struct sk_opts_entry *soe)
{
return 0;
}
int dump_socket_opts(int sk, struct sk_opts_entry *soe)
{
return 0;
}
int dump_socket(struct fd_parms *p, int lfd, const struct cr_fdset *cr_fdset)
{
struct socket_desc *sk;
......@@ -327,3 +337,6 @@ char *skstate2s(u32 state)
return unknown(state);
}
void show_socket_opts(struct sk_opts_entry *soe)
{
}
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