A disabling repair mode drops SO_REUSEADDR.
We can set SO_REUSEADDR after disabling repair mode, but
a small race window exists in this case.
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
All sockets are created with SO_REUSEADDR, it's needed for restoring.
E.g.: A listen socket is created after a connected socket. Both of them
are binded to one port.
So SO_REUSEADDR should be restored, when all sockets on a port were created.
This code creates a structure for each port of one type of sockets
and accounts a number of sockets, which are not restored yet.
Sockets have a hook post_open(), in which it waits when all sockets for
a defined port would be created and then it will restore SO_REUSEADDR.
struct port contains a type (udp, tcp, etc) and a port number.
It doesn't contain family or addr, because it's extra loads of logic,
which doesn't bring a significant profits.
v2: fix according with comments from Pavel
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We hash socket with inode and family, but search only by inode. Well,
yes, family should match, since all sockets are in one sockfs in kernel,
but let's make sure _we_ did things right by checking the family as well.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v4:
1) Only address specificator ('A') left
New custom specificators:
'A': output as socket address
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Most part of services (ssh, httpd, ...) create two separate sockets
one for ipv4 and one for ipv6. If IPV6_V6ONLY isn't dumped, bind() returns
EADDRINUSE
v2: use do_dump_opt and initialize yes = 1
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Now crtools checks address, but it may be zero. For example,
a listen socket is bound to zero address to accept connections
from any addresses.
v2: add a comment about zero port
Signed-off-by: Andrey Vagin <avagin@openvz.org>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
It doesn't makemuch sense in pulling this further. The generic genid generation seems to
be enough for eny file type.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We use repeated u32 field for IPv* address. For ipv4 there's 1 element
in it, for ipv6 -- 4. Validate these sizes in image and check that
sockaddr_in* elements sizes match.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Let's carry only on uint_32 for IPv4 address.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
On restore we typically read an image and put the entries into
some hash/list/whatever to work on them later. It's handy to have
a generic routine for doing so.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This aptch replaces BUG_ON's by return of error code.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The pb_read thing is no longer a macros. This will allow to
factor out objects collecting on restore.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Since we've BUG_ON(1) here so this is
not a problem, but lets make compiler happy.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This types specifies a strict set of what is hidden behind
the fd. Thus these numbers should be in the description of
the fdinfo message.
Plus protobuf makes shure nothing else will be there.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We've switched to SkOptsEntry, no need to carry this
obsolete one.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
We are ready to use FownEntry everywhere,
so drop fown_t type and clean up source code.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
v2:
- Use do_dump_opt in dump_socket to not call
lookup_socket redundantly
v3:
- use getsockopt to check that unconnected
socket has no peername and it's not listening
- do test only socket protocol since family and
type will be called in dump_one_inet_fd.
v4:
- Move proto tests to can_dump_inet_sk
- Use SOL_TCP/TCP_INFO to gather info about tcp sockets
v5:
- hash unconnected sockets to run BUG_ON(already-dumped) logic
- no default value for sk->wqlen, use zero from xzalloc
- drop bogus xfree on error
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Use fdtype_ops facility to c/r inet sockets.
v2:
- Use BUG_ON if socket is attempted to be dumped
several times
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
The task is not complete - this is just a part of what have to be done. I.e.
looks like a lot of excessive deps can be fixed.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Those sitting on the SOL_SOCKET level are common to different
socket families and will be handled in a generic code.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This saves some space on dynamic file_desc and makes file_desc_ops
looks closer to fdinfo_ops used on dump.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
When dump finished with error we should unlock all locked
previously connections.
When restoring we should collect connctions and unlock them
all at the end.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
First of all -- to make crtools dump/restore established tcp sockets
you have to specify the --tcp-established options. By doing so you
inform crtools that
a) you know, that after dump there will be a netfilter rules blocking
the dumped connections
b) you guarantee, that before restore this netfilter block is still
there
What else this patch does is simple -- collects establised sockets and
calls the dump/restore tcp function (now empty) where appropriate.
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>