diff --git a/protobuf/sk-inet.proto b/protobuf/sk-inet.proto index bd8f0742a..ad49928dd 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 c06a0b2a2..46ec7d6b5 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_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;