[CRIU] [PATCH 1/2] sk-inet: handle the IP_FREEBIND option (v2)
Pavel Emelyanov
xemul at parallels.com
Mon Nov 23 00:46:50 PST 2015
On 11/20/2015 11:28 PM, Andrew Vagin wrote:
> On Thu, Nov 19, 2015 at 05:48:21PM +0300, Andrey Vagin wrote:
>> From: Andrew Vagin <avagin at virtuozzo.com>
>>
>> v2: set has_freebind
>> Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
>> ---
>> protobuf/sk-inet.proto | 5 +++++
>> sk-inet.c | 26 ++++++++++++++++++++++++++
>> 2 files changed, 31 insertions(+)
>>
>> diff --git a/protobuf/sk-inet.proto b/protobuf/sk-inet.proto
>> index bd8f074..ad49928 100644
>> --- a/protobuf/sk-inet.proto
>> +++ b/protobuf/sk-inet.proto
>> @@ -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;
>> }
>> diff --git a/sk-inet.c b/sk-inet.c
>> index c06a0b2..65f103d 100644
>> --- a/sk-inet.c
>> +++ b/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_SOCKET, SO_PRIORITY, &ioe->freebind);
>
> Ooops. s/SOL_SOCKET, SO_PRIORITY/SOL_IP, IP_FREEBIND/
Fixed and applied, thanks.
More information about the CRIU
mailing list