[CRIU] [PATCH 07/21] soccr: add source and destination addresses to libsoccr_sk_data
Andrei Vagin
avagin at virtuozzo.com
Wed Nov 30 22:50:00 PST 2016
On Wed, Nov 30, 2016 at 12:13:40PM +0300, Pavel Emelyanov wrote:
> On 11/28/2016 10:27 PM, Andrei Vagin wrote:
> > From: Andrei Vagin <avagin at virtuozzo.com>
> >
> > These addresses will be used to restore half-closed sockets,
> > we will need to send a fake fin packet for that.
> >
> > And in the next patch connect() will be moved into soccr.
> >
> > Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
> > ---
> > criu/include/sk-inet.h | 10 ++++++++++
> > criu/sk-inet.c | 7 +------
> > criu/sk-tcp.c | 9 +++++++++
> > soccr/soccr.h | 10 ++++++++++
> > 4 files changed, 30 insertions(+), 6 deletions(-)
> >
> > diff --git a/criu/include/sk-inet.h b/criu/include/sk-inet.h
> > index a06a8ac..3ca27b4 100644
> > --- a/criu/include/sk-inet.h
> > +++ b/criu/include/sk-inet.h
> > @@ -1,6 +1,7 @@
> > #ifndef __CR_SK_INET_H__
> > #define __CR_SK_INET_H__
> >
> > +#include <netinet/in.h>
> > #include <netinet/tcp.h>
> >
> > #include "sockets.h"
> > @@ -85,4 +86,13 @@ struct rst_tcp_sock {
> > bool reuseaddr;
> > };
> >
> > +union sockaddr_inet {
> > + struct sockaddr addr;
> > + struct sockaddr_in v4;
> > + struct sockaddr_in6 v6;
> > +};
>
> Why not reuse the libsoccr_addr structure you've introduced in this patch?
I was not going to use libsoccr for non-tcp sockets.
>
> > +
> > +int restore_sockaddr(union sockaddr_inet *sa,
> > + int family, u32 pb_port, u32 *pb_addr, u32 ifindex);
> > +
> > #endif /* __CR_SK_INET_H__ */
> > diff --git a/criu/sk-inet.c b/criu/sk-inet.c
> > index 084eee7..30e7fa6 100644
> > --- a/criu/sk-inet.c
> > +++ b/criu/sk-inet.c
> > @@ -655,12 +655,7 @@ err:
> > return -1;
> > }
> >
> > -union sockaddr_inet {
> > - struct sockaddr_in v4;
> > - struct sockaddr_in6 v6;
> > -};
> > -
> > -static int restore_sockaddr(union sockaddr_inet *sa,
> > +int restore_sockaddr(union sockaddr_inet *sa,
> > int family, u32 pb_port, u32 *pb_addr, u32 ifindex)
> > {
> > BUILD_BUG_ON(sizeof(sa->v4.sin_addr.s_addr) > PB_ALEN_INET * sizeof(u32));
> > diff --git a/criu/sk-tcp.c b/criu/sk-tcp.c
> > index bd3b0da..d08a4c0 100644
> > --- a/criu/sk-tcp.c
> > +++ b/criu/sk-tcp.c
> > @@ -338,6 +338,15 @@ static int restore_tcp_conn_state(int sk, struct libsoccr_sk *socr, struct inet_
> > data.rcv_wup = tse->rcv_wup;
> > }
> >
> > + if (restore_sockaddr((union sockaddr_inet *) &data.src_addr,
> > + ii->ie->family, ii->ie->src_port,
> > + ii->ie->src_addr, 0) < 0)
> > + goto err_c;
> > + if (restore_sockaddr((union sockaddr_inet *) &data.dst_addr,
> > + ii->ie->family, ii->ie->dst_port,
> > + ii->ie->dst_addr, 0) < 0)
> > + goto err_c;
> > +
>
> I see no corresponding removals. Do we call restore_sockaddr() twice after this patch?
It is in the next patch.
>
> > (void)data;
> >
> > if (libsoccr_set_sk_data_unbound(socr, &data, sizeof(data)))
> > diff --git a/soccr/soccr.h b/soccr/soccr.h
> > index 4e272d5..8bd0377 100644
> > --- a/soccr/soccr.h
> > +++ b/soccr/soccr.h
> > @@ -1,6 +1,7 @@
> > #ifndef __LIBSOCCR_H__
> > #define __LIBSOCCR_H__
> > #include <linux/types.h>
> > +#include <netinet/in.h>
> > #include <stdint.h>
> >
> > #include "config.h"
> > @@ -57,6 +58,12 @@ void libsoccr_set_log(unsigned int level, void (*fn)(unsigned int level, const c
> > */
> > struct libsoccr_sk;
> >
> > +union libsoccr_addr {
> > + struct sockaddr_in sin;
> > + struct sockaddr_in6 sin6;
> > + struct sockaddr sa;
> > +};
> > +
> > /*
> > * Connection info that should be saved after fetching from the
> > * socket and given back into the library in two steps (see below).
> > @@ -80,6 +87,9 @@ struct libsoccr_sk_data {
> > __u32 max_window;
> > __u32 rcv_wnd;
> > __u32 rcv_wup;
> > +
> > + union libsoccr_addr src_addr;
> > + union libsoccr_addr dst_addr;
> > };
> >
> > /*
> >
>
More information about the CRIU
mailing list