[1/2] tun: Add compatibility with old images

Submitted by Cyrill Gorcunov on Sept. 25, 2018, 12:44 p.m.

Details

Message ID 20180925124410.3294-2-gorcunov@gmail.com
State New
Series "tun: Fixup for old images and improve the test"
Headers show

Commit Message

Cyrill Gorcunov Sept. 25, 2018, 12:44 p.m.
From: Cyrill Gorcunov <gorcunov@virtuozzo.com>

Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 criu/tun.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/tun.c b/criu/tun.c
index b13148b0b912..6b3f3fb3ff42 100644
--- a/criu/tun.c
+++ b/criu/tun.c
@@ -139,8 +139,14 @@  static struct tun_link *find_tun_link(char *name, unsigned int ns_id)
 	struct tun_link *tl;
 
 	list_for_each_entry(tl, &tun_links, l) {
-		if (!strcmp(tl->name, name) &&
-		    tl->ns_id == ns_id)
+		if (strcmp(tl->name, name))
+			continue;
+		/*
+		 * Old images or kernel do not have SIOCGSKNS support,
+		 * and ns_id = 0, so then we can rely on names matching
+		 * only.
+		 */
+		if (ns_id == 0 || tl->ns_id == ns_id)
 			return tl;
 	}
 	return NULL;