mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 01:51:51 +00:00
sk-inet: handle the IP_FREEBIND option (v2)
v2: set has_freebind Signed-off-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
c2ad6f3a68
commit
c9a61a205f
@ -2,6 +2,10 @@ import "opts.proto";
|
||||
import "fown.proto";
|
||||
import "sk-opts.proto";
|
||||
|
||||
message ip_opts_entry {
|
||||
optional bool freebind = 1;
|
||||
}
|
||||
|
||||
message inet_sk_entry {
|
||||
/*
|
||||
* We have two IDs here -- id and ino. The first one
|
||||
@ -28,4 +32,5 @@ message inet_sk_entry {
|
||||
required fown_entry fown = 13;
|
||||
required sk_opts_entry opts = 14;
|
||||
optional bool v6only = 15;
|
||||
optional ip_opts_entry ip_opts = 16;
|
||||
}
|
||||
|
26
sk-inet.c
26
sk-inet.c
@ -230,10 +230,20 @@ err:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int dump_ip_opts(int sk, IpOptsEntry *ioe)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
ret |= dump_opt(sk, SOL_IP, IP_FREEBIND, &ioe->freebind);
|
||||
ioe->has_freebind = ioe->freebind;
|
||||
|
||||
return ret;
|
||||
}
|
||||
static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int family)
|
||||
{
|
||||
struct inet_sk_desc *sk;
|
||||
InetSkEntry ie = INET_SK_ENTRY__INIT;
|
||||
IpOptsEntry ipopts = IP_OPTS_ENTRY__INIT;
|
||||
SkOptsEntry skopts = SK_OPTS_ENTRY__INIT;
|
||||
int ret = -1, err = -1, proto;
|
||||
|
||||
@ -272,6 +282,7 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
|
||||
|
||||
ie.fown = (FownEntry *)&p->fown;
|
||||
ie.opts = &skopts;
|
||||
ie.ip_opts = &ipopts;
|
||||
|
||||
ie.n_src_addr = PB_ALEN_INET;
|
||||
ie.n_dst_addr = PB_ALEN_INET;
|
||||
@ -298,6 +309,9 @@ static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
|
||||
memcpy(ie.src_addr, sk->src_addr, pb_repeated_size(&ie, src_addr));
|
||||
memcpy(ie.dst_addr, sk->dst_addr, pb_repeated_size(&ie, dst_addr));
|
||||
|
||||
if (dump_ip_opts(lfd, &ipopts))
|
||||
goto err;
|
||||
|
||||
if (dump_socket_opts(lfd, &skopts))
|
||||
goto err;
|
||||
|
||||
@ -477,6 +491,15 @@ static int post_open_inet_sk(struct file_desc *d, int sk)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int restore_ip_opts(int sk, IpOptsEntry *ioe)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (ioe->has_freebind)
|
||||
ret |= restore_opt(sk, SOL_IP, IP_FREEBIND, &ioe->freebind);
|
||||
|
||||
return ret;
|
||||
}
|
||||
static int open_inet_sk(struct file_desc *d)
|
||||
{
|
||||
struct inet_sk_info *ii;
|
||||
@ -565,6 +588,9 @@ done:
|
||||
if (rst_file_params(sk, ie->fown, ie->flags))
|
||||
goto err;
|
||||
|
||||
if (ie->ip_opts && restore_ip_opts(sk, ie->ip_opts))
|
||||
goto err;
|
||||
|
||||
if (restore_socket_opts(sk, ie->opts))
|
||||
goto err;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user