criu/criu/include/sk-inet.h
Pavel Tikhomirov ac78cbe770 log: remove all uses of %m specifier in pr_* functions
As our pr_* functions are complex and can call different system calls
inside before actual printing (e.g. gettimeofday for timestamps) actual
errno at the time of printing may be changed.

Let's just use %s + strerror(errno) instead of %m with pr_* functions to
be explicit that errno to string transformation happens before calling
anything else.

Note: tcp_repair_off is called from pie with no pr_perror defined due to
CR_NOGLIBC set and if I use errno variable there I get "Unexpected
undefined symbol: `__errno_location'. External symbol in PIE?", so it
seems there is no way to print errno there, so let's just skip it.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
2023-01-25 09:37:36 -08:00

104 lines
2.3 KiB
C

#ifndef __CR_SK_INET_H__
#define __CR_SK_INET_H__
#include <netinet/tcp.h>
#include "sockets.h"
#include "files.h"
#include "common/list.h"
#include "images/sk-inet.pb-c.h"
#define INET_ADDR_LEN 48 /* max of INET_ADDRSTRLEN and INET6_ADDRSTRLEN */
#ifndef TCP_REPAIR
#define TCP_REPAIR 19 /* TCP sock is under repair right now */
#define TCP_REPAIR_QUEUE 20
#define TCP_QUEUE_SEQ 21
#define TCP_REPAIR_OPTIONS 22
#endif
#ifndef IP_HDRINCL
#define IP_HDRINCL 3
#endif
#ifndef IP_NODEFRAG
#define IP_NODEFRAG 22
#endif
#ifndef IPV6_HDRINCL
#define IPV6_HDRINCL 36
#endif
struct inet_sk_desc {
struct socket_desc sd;
unsigned int type;
unsigned int src_port;
unsigned int dst_port;
unsigned int state;
unsigned int rqlen;
unsigned int wqlen; /* sent + unsent data */
unsigned int uwqlen; /* unsent data */
unsigned int src_addr[4];
unsigned int dst_addr[4];
unsigned short shutdown;
bool cork;
int rfd;
int cpt_reuseaddr;
struct list_head rlist;
void *priv;
};
struct inet_port;
struct inet_sk_info {
InetSkEntry *ie;
struct file_desc d;
struct inet_port *port;
struct list_head port_list;
/*
* This is an fd by which the socket is opened.
* It will be carried down to restorer code to
* repair-off the socket at the very end.
*/
int sk_fd;
struct list_head rlist;
};
extern int inet_bind(int sk, struct inet_sk_info *);
extern int inet_connect(int sk, struct inet_sk_info *);
#ifdef CR_NOGLIBC
#define setsockopt sys_setsockopt
#endif
static inline void tcp_repair_off(int fd)
{
int aux = 0, ret;
ret = setsockopt(fd, SOL_TCP, TCP_REPAIR, &aux, sizeof(aux));
if (ret < 0)
pr_err("Failed to turn off repair mode on socket\n");
}
extern void tcp_locked_conn_add(struct inet_sk_info *);
extern void rst_unlock_tcp_connections(void);
extern void cpt_unlock_tcp_connections(void);
extern int dump_one_tcp(int sk, struct inet_sk_desc *sd, SkOptsEntry *soe);
extern int restore_one_tcp(int sk, struct inet_sk_info *si);
#define SK_EST_PARAM "tcp-established"
#define SK_INFLIGHT_PARAM "skip-in-flight"
#define SK_CLOSE_PARAM "tcp-close"
struct task_restore_args;
int prepare_tcp_socks(struct task_restore_args *);
struct rst_tcp_sock {
int sk;
bool reuseaddr;
};
union libsoccr_addr;
int restore_sockaddr(union libsoccr_addr *sa, int family, u32 pb_port, u32 *pb_addr, u32 ifindex);
#endif /* __CR_SK_INET_H__ */