Skip to content

Commit 3986035

Browse files
committed
tunspace: bring interfaces up later to prevent log spam
Bird, OLSR and Babel spam syslog if the wireguard interface doesn't have its private key configured yet. Prevent this by bringing the interface up later, once it's fully configured. Socket error on ts_wg0: Required key not available
1 parent 6dcd701 commit 3986035

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/tunspace/tunspace.uc

+12-4
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,10 @@ function create_wg_interface(nsid, ifname, ifcfg, netns) {
171171
return false;
172172
}
173173

174-
// set mtu and bring the interface up
174+
// set mtu. interface will be brought up later when it's fully configured.
175175
if (0 != shell_command("ip link set "+ifname+" mtu "+ifcfg.mtu)) {
176176
return false;
177177
}
178-
if (0 != shell_command("ip link set up "+ifname)) {
179-
return false;
180-
}
181178

182179
// configure wireguard
183180
wg_request(wg.const.WG_CMD_SET_DEVICE, wg.const.NLM_F_REQUEST, {
@@ -232,6 +229,11 @@ function wg_replace_endpoint(ifname, cfg, next) {
232229
let srvcfg = cfg.wireguard_servers[next];
233230
let certopt = srvcfg.insecure_cert ? "--no-check-certificate" : "";
234231

232+
// bring interface down to prevent OLSR and Babel from spamming syslog.
233+
if (0 != shell_command("ip link set down "+ifname)) {
234+
return false;
235+
}
236+
235237
// generate a fresh private key
236238
let randfd = fs.open("/dev/random");
237239
let privkey = randfd.read(32);
@@ -347,6 +349,12 @@ function wg_replace_endpoint(ifname, cfg, next) {
347349
log("WG_CMD_SET_DEVICE failed: "+err);
348350
return false;
349351
}
352+
353+
// bring interface up, it's fully configured now
354+
if (0 != shell_command("ip link set up "+ifname)) {
355+
return false;
356+
}
357+
350358
return true;
351359
}
352360

0 commit comments

Comments
 (0)