Skip to content

Commit

Permalink
tunspace: bring interfaces up later to prevent log spam
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pktpls committed Jan 16, 2025
1 parent 6dcd701 commit 3986035
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/tunspace/tunspace.uc
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,10 @@ function create_wg_interface(nsid, ifname, ifcfg, netns) {
return false;
}

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

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

// bring interface down to prevent OLSR and Babel from spamming syslog.
if (0 != shell_command("ip link set down "+ifname)) {
return false;
}

// generate a fresh private key
let randfd = fs.open("/dev/random");
let privkey = randfd.read(32);
Expand Down Expand Up @@ -347,6 +349,12 @@ function wg_replace_endpoint(ifname, cfg, next) {
log("WG_CMD_SET_DEVICE failed: "+err);
return false;
}

// bring interface up, it's fully configured now
if (0 != shell_command("ip link set up "+ifname)) {
return false;
}

return true;
}

Expand Down

0 comments on commit 3986035

Please sign in to comment.