[CRIU] [PATCH cr 02/10] net: add ability to use tcp_repair_off from a restorer code

Andrey Vagin avagin at openvz.org
Thu Sep 13 09:10:22 EDT 2012


Use sys_setsockopt and declare a function in a header as "static inline"

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/sk-inet.h |   17 ++++++++++++++++-
 sk-tcp.c          |   15 ---------------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/sk-inet.h b/include/sk-inet.h
index a081769..0fe550c 100644
--- a/include/sk-inet.h
+++ b/include/sk-inet.h
@@ -1,10 +1,18 @@
 #ifndef __CR_SK_INET_H__
 #define __CR_SK_INET_H__
 
+#include <netinet/tcp.h>
+
 #include "protobuf.h"
 #include "../protobuf/sk-inet.pb-c.h"
 
 #define INET_ADDR_LEN		40
+#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
 
 struct inet_sk_desc {
 	struct socket_desc	sd;
@@ -33,7 +41,14 @@ struct inet_sk_info {
 int inet_bind(int sk, struct inet_sk_info *);
 int inet_connect(int sk, struct inet_sk_info *);
 
-void tcp_repair_off(int sk);
+static inline void tcp_repair_off(int fd)
+{
+	int aux = 0;
+
+	if (sys_setsockopt(fd, SOL_TCP, TCP_REPAIR, &aux, sizeof(aux)) < 0)
+		pr_perror("Failed to turn off repair mode on socket");
+}
+
 void tcp_unlock_all(void);
 void tcp_locked_conn_add(struct inet_sk_info *);
 void tcp_unlock_connections(void);
diff --git a/sk-tcp.c b/sk-tcp.c
index 7f0e262..4a9cf73 100644
--- a/sk-tcp.c
+++ b/sk-tcp.c
@@ -19,12 +19,6 @@
 #include "protobuf.h"
 #include "protobuf/tcp-stream.pb-c.h"
 
-#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
-
 struct tcp_repair_opt {
 	u32	opt_code;
 	u32	opt_val;
@@ -36,7 +30,6 @@ enum {
 	TCP_SEND_QUEUE,
 	TCP_QUEUES_NR,
 };
-#endif
 
 #ifndef TCPOPT_SACK_PERM
 #define TCPOPT_SACK_PERM TCPOPT_SACK_PERMITTED
@@ -55,14 +48,6 @@ static int tcp_repair_on(int fd)
 	return ret;
 }
 
-void tcp_repair_off(int fd)
-{
-	int aux = 0;
-
-	if (setsockopt(fd, SOL_TCP, TCP_REPAIR, &aux, sizeof(aux)) < 0)
-		pr_perror("Failed to turn off repair mode on socket");
-}
-
 static void tcp_unlock_one(struct inet_sk_desc *sk);
 static int tcp_repair_establised(int fd, struct inet_sk_desc *sk)
 {
-- 
1.7.1



More information about the CRIU mailing list