From bc84c36587d5c025baf81f0eb9a8d8024aae36a3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 27 Mar 2020 12:45:49 +0100 Subject: [rebootcontrol] Fix indirect subnet to subnet WOL The query for getting clients that can reach a client in another subnet was broken in that it didn't check for actual reachability from src to dst. Then the wrong array key was accessed when trying to wake clients via this method. --- modules-available/rebootcontrol/inc/rebootcontrol.inc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php index 4e21deee..abbef0c9 100644 --- a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php +++ b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php @@ -434,7 +434,7 @@ class RebootControl } } if (!$ok && !empty($subnet['iclients'])) { - $ok = self::wakeGroup('across subnets', $tasks, $errors, $subnet['dclients'], $subnet['indirect'], $subnet['end']); + $ok = self::wakeGroup('across subnets', $tasks, $errors, $subnet['iclients'], $subnet['indirect'], $subnet['end']); } if (!$ok) { $errors .= "I'm all out of ideas.\n"; @@ -486,7 +486,7 @@ class RebootControl { if (isset($subnet['dclients'])) return; - $cutoff = time() - 302; + $cutoff = time() - 320; // Get clients from same subnet first $subnet['dclients'] = Database::queryAll("SELECT machineuuid, clientip FROM machine WHERE state IN ('IDLE', 'OCCUPIED') AND INET_ATON(clientip) BETWEEN :start AND :end AND lastseen > :cutoff @@ -497,7 +497,7 @@ class RebootControl return; // If none, get clients from other subnets known to be able to reach this one $subnet['iclients'] = Database::queryAll("SELECT m.machineuuid, m.clientip FROM reboot_subnet_x_subnet sxs - INNER JOIN reboot_subnet s ON (s.subnetid = sxs.srcid AND sxs.dstid = :subnetid) + INNER JOIN reboot_subnet s ON (s.subnetid = sxs.srcid AND sxs.dstid = :subnetid AND sxs.reachable = 1) INNER JOIN machine m ON (INET_ATON(m.clientip) BETWEEN s.start AND s.end AND state IN ('IDLE', 'OCCUPIED') AND m.lastseen > :cutoff) LIMIT 20", ['subnetid' => $subnet['subnetid'], 'cutoff' => $cutoff]); shuffle($subnet['iclients']); -- cgit v1.2.3-55-g7522