Skip to content

Commit

Permalink
interfaces: require PPP interface to be in up state (#7692)
Browse files Browse the repository at this point in the history
Otherwise the check will "approve" an interface that is not yet up, and subsequent
calls to fetch the gateway of that interface might fail if issued to quickly thereafter.

(cherry picked from commit 62a09bf)
(cherry picked from commit 7c9b97a)
(cherry picked from commit 4b77d13)
(cherry picked from commit 10aa787)
  • Loading branch information
nscheer authored and fichtner committed Aug 14, 2024
1 parent 2d070cc commit 0920914
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/etc/inc/interfaces.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,9 @@ EOD;
@unlink('/var/spool/lock/LCK..' . basename($port));
}

/* precaution for post-start 'up' check */
legacy_interface_flags($ifcfg['if'], 'down', false);

/* fire up mpd */
mwexecf(
'/usr/local/sbin/mpd5 -b -d /var/etc -f %s -p %s -s ppp %s',
Expand All @@ -1248,17 +1251,21 @@ EOD;
/* appease netgraph by setting the correct node name */
shell_safe('/usr/sbin/daemon -f /usr/local/opnsense/scripts/interfaces/ppp-rename.sh %s %s %s', [$interface, $ifcfg['if'], $ppp['type']]);

/* wait for up to 10 seconds for the interface to appear (ppp(oe)) */
/* wait for functional device */
$max = 20;
$i = 0;
while ($i < 10) {
exec("/sbin/ifconfig " . escapeshellarg($ppp['if']) . " 2>&1", $out, $ret);
if ($ret == 0) {
while ($i < $max) {
sleep(1);
if (does_interface_exist($ifcfg['if'], 'up')) {
break;
}
sleep(1);
$i++;
}

if ($i >= $max) {
log_msg("interface_ppps_configure() waiting threshold exceeded - device {$ifcfg['if']} is still not up", LOG_WARNING);
}

switch ($ppp['type']) {
case 'pppoe':
/* automatically change MAC address if parent interface changes */
Expand Down

0 comments on commit 0920914

Please sign in to comment.