Skip to content

Commit abf7841

Browse files
Fix podman install issue and add required dependent packages (microsoft#15043)
Co-authored-by: jslobodzian <joslobo@microsoft.com>
1 parent cd6c832 commit abf7841

14 files changed

Lines changed: 517 additions & 144 deletions

File tree

LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSES-AND-NOTICES/SPECS/data/licenses.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
"cpufrequtils",
148148
"cpuid",
149149
"criu",
150+
"crun",
150151
"crypto-policies",
151152
"cryptsetup",
152153
"cscope",
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
From 22fdffbdde9476b27988b3ee0a4013a4453784c9 Mon Sep 17 00:00:00 2001
2+
From: Andrei Vagin <avagin@gmail.com>
3+
Date: Mon, 21 Apr 2025 06:33:41 +0000
4+
Subject: [PATCH] net: nftables: avoid restore failure if the CRIU nft table
5+
already exist
6+
7+
CRIU locks the network during restore in an "empty" network namespace.
8+
However, "empty" in this context means CRIU isn't restoring the
9+
namespace. This network namespace can be the same namespace where
10+
processes have been dumped and so the network is already locked in it.
11+
12+
Fixes #2650
13+
14+
Signed-off-by: Andrei Vagin <avagin@gmail.com>
15+
---
16+
criu/cr-restore.c | 2 +-
17+
criu/include/net.h | 2 +-
18+
criu/net.c | 30 +++++++++++++++++-------------
19+
3 files changed, 19 insertions(+), 15 deletions(-)
20+
21+
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
22+
index 583b446e0b..30932f60a2 100644
23+
--- a/criu/cr-restore.c
24+
+++ b/criu/cr-restore.c
25+
@@ -2119,7 +2119,7 @@ static int restore_root_task(struct pstree_item *init)
26+
* the '--empty-ns net' mode no iptables C/R is done and we
27+
* need to return these rules by hands.
28+
*/
29+
- ret = network_lock_internal();
30+
+ ret = network_lock_internal(/* restore = */ true);
31+
if (ret)
32+
goto out_kill;
33+
}
34+
diff --git a/criu/include/net.h b/criu/include/net.h
35+
index 5e8a848620..7c5ede21e1 100644
36+
--- a/criu/include/net.h
37+
+++ b/criu/include/net.h
38+
@@ -31,7 +31,7 @@ extern int collect_net_namespaces(bool for_dump);
39+
40+
extern int network_lock(void);
41+
extern void network_unlock(void);
42+
-extern int network_lock_internal(void);
43+
+extern int network_lock_internal(bool restore);
44+
45+
extern struct ns_desc net_ns_desc;
46+
47+
diff --git a/criu/net.c b/criu/net.c
48+
index ee46f1c495..300df480b0 100644
49+
--- a/criu/net.c
50+
+++ b/criu/net.c
51+
@@ -3206,12 +3206,12 @@ static inline FILE *redirect_nftables_output(struct nft_ctx *nft)
52+
}
53+
#endif
54+
55+
-static inline int nftables_lock_network_internal(void)
56+
+static inline int nftables_lock_network_internal(bool restore)
57+
{
58+
#if defined(CONFIG_HAS_NFTABLES_LIB_API_0) || defined(CONFIG_HAS_NFTABLES_LIB_API_1)
59+
cleanup_file FILE *fp = NULL;
60+
struct nft_ctx *nft;
61+
- int ret = 0;
62+
+ int ret = 0, exit_code = -1;
63+
char table[32];
64+
char buf[128];
65+
66+
@@ -3224,11 +3224,16 @@ static inline int nftables_lock_network_internal(void)
67+
68+
fp = redirect_nftables_output(nft);
69+
if (!fp)
70+
- goto out;
71+
+ goto err2;
72+
73+
snprintf(buf, sizeof(buf), "create table %s", table);
74+
- if (NFT_RUN_CMD(nft, buf))
75+
+ ret = NFT_RUN_CMD(nft, buf);
76+
+ if (ret) {
77+
+ /* The network has been locked on dump. */
78+
+ if (restore && errno == EEXIST)
79+
+ return 0;
80+
goto err2;
81+
+ }
82+
83+
snprintf(buf, sizeof(buf), "add chain %s output { type filter hook output priority 0; policy drop; }", table);
84+
if (NFT_RUN_CMD(nft, buf))
85+
@@ -3246,17 +3251,16 @@ static inline int nftables_lock_network_internal(void)
86+
if (NFT_RUN_CMD(nft, buf))
87+
goto err1;
88+
89+
- goto out;
90+
-
91+
+ exit_code = 0;
92+
+out:
93+
+ nft_ctx_free(nft);
94+
+ return exit_code;
95+
err1:
96+
snprintf(buf, sizeof(buf), "delete table %s", table);
97+
NFT_RUN_CMD(nft, buf);
98+
err2:
99+
- ret = -1;
100+
pr_err("Locking network failed using nftables\n");
101+
-out:
102+
- nft_ctx_free(nft);
103+
- return ret;
104+
+ goto out;
105+
#else
106+
pr_err("CRIU was built without libnftables support\n");
107+
return -1;
108+
@@ -3288,7 +3292,7 @@ static int iptables_network_lock_internal(void)
109+
return ret;
110+
}
111+
112+
-int network_lock_internal(void)
113+
+int network_lock_internal(bool restore)
114+
{
115+
int ret = 0, nsret;
116+
117+
@@ -3301,7 +3305,7 @@ int network_lock_internal(void)
118+
if (opts.network_lock_method == NETWORK_LOCK_IPTABLES)
119+
ret = iptables_network_lock_internal();
120+
else if (opts.network_lock_method == NETWORK_LOCK_NFTABLES)
121+
- ret = nftables_lock_network_internal();
122+
+ ret = nftables_lock_network_internal(restore);
123+
124+
if (restore_ns(nsret, &net_ns_desc))
125+
ret = -1;
126+
@@ -3427,7 +3431,7 @@ int network_lock(void)
127+
if (run_scripts(ACT_NET_LOCK))
128+
return -1;
129+
130+
- return network_lock_internal();
131+
+ return network_lock_internal(false);
132+
}
133+
134+
void network_unlock(void)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"Signatures": {
3-
"criu-3.15.tar.bz2": "447cc1f350da94d190bcfda753695bf34ce91eee969df8263fcc33d08990a025",
3+
"criu-4.1.1.tar.gz": "a5338fe696395843543e6e09c85ccaf36614bf172c26fe8506191b7b930d2dae",
44
"criu-tmpfiles.conf": "d40c7153756d170c4d68ac57598236a011c177ac41a1125813f8b2e16dc15c1a"
55
}
6-
}
6+
}

0 commit comments

Comments
 (0)