[04/15] inet: raw -- Fetch socket type and check for being raw in can_dump_ipproto

Submitted by Cyrill Gorcunov on Sept. 13, 2018, 7:57 p.m.

Details

Message ID 20180913195758.30566-5-gorcunov@gmail.com
State Accepted
Series "net: Add support for raw inet sockets"
Headers show

Commit Message

Cyrill Gorcunov Sept. 13, 2018, 7:57 p.m.
Don't allow to proceed dumping since we don't support
raw sockets restore yet.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/sk-inet.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-inet.c b/criu/sk-inet.c
index a5a092bc732a..c0adc168bb01 100644
--- a/criu/sk-inet.c
+++ b/criu/sk-inet.c
@@ -102,8 +102,14 @@  static void show_one_inet_img(const char *act, const InetSkEntry *e)
 		e->state, src_addr);
 }
 
-static int can_dump_ipproto(int ino, int proto)
+static int can_dump_ipproto(int ino, int proto, int type)
 {
+	/* Raw sockets may have any protocol inside */
+	if (type == SOCK_RAW) {
+		pr_err("Unsupported raw socket %x\n", ino);
+		return 0;
+	}
+
 	/* Make sure it's a proto we support */
 	switch (proto) {
 	case IPPROTO_IP:
@@ -331,14 +337,17 @@  static int do_dump_one_inet_fd(int lfd, u32 id, const struct fd_parms *p, int fa
 	InetSkEntry ie = INET_SK_ENTRY__INIT;
 	IpOptsEntry ipopts = IP_OPTS_ENTRY__INIT;
 	SkOptsEntry skopts = SK_OPTS_ENTRY__INIT;
-	int ret = -1, err = -1, proto, aux;
+	int ret = -1, err = -1, proto, aux, type;
 
 	ret = do_dump_opt(lfd, SOL_SOCKET, SO_PROTOCOL,
 					&proto, sizeof(proto));
 	if (ret)
 		goto err;
 
-	if (!can_dump_ipproto(p->stat.st_ino, proto))
+	if (do_dump_opt(lfd, SOL_SOCKET, SO_TYPE, &type, sizeof(type)))
+		goto err;
+
+	if (!can_dump_ipproto(p->stat.st_ino, proto, type))
 		goto err;
 
 	sk = (struct inet_sk_desc *)lookup_socket(p->stat.st_ino, family, proto);