Skip to content

Commit 7ada19d

Browse files
committed
interfaces: deal with PPP device nodes
Some mwexecf() sanity on the side and notes for further work. PR: https://forum.opnsense.org/index.php?topic=25599.0
1 parent 19d89e0 commit 7ada19d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/etc/inc/interfaces.inc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,8 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
23772377
interface_virtual_create($realhwif);
23782378

23792379
$ifconfig_details = legacy_interfaces_details();
2380-
if (empty($ifconfig_details[$realhwif])) {
2380+
if ((strpos($realhwif, '/') === false && empty($ifconfig_details[$realhwif])) ||
2381+
(strpos($realhwif, '/') === 0 && !file_exists($realhwif))) {
23812382
log_error(sprintf('Unable to configure non-existent interface %s (%s)', $interface, $realhwif));
23822383
return;
23832384
}
@@ -2387,7 +2388,9 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
23872388
flush();
23882389
}
23892390

2390-
/* XXX mpd5 $realif(v6) does not exist at this point in time */
2391+
/* XXX mpd5 $realif(v6) may not exist at this point in time */
2392+
/* XXX mpd5 $realhwif may be a device node path */
2393+
23912394
if (!file_exists('/var/run/booting') && substr($realif, 0, 4) != 'ovpn') {
23922395
interfaces_addresses_flush($realif, 4, $ifconfig_details);
23932396
interfaces_addresses_flush($realifv6, 6, $ifconfig_details);
@@ -2410,7 +2413,7 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
24102413
* spoof the MAC again which cycles the link again...
24112414
*/
24122415
if (!empty($wancfg['spoofmac']) && strcasecmp($wancfg['spoofmac'], get_interface_mac($realhwif))) {
2413-
mwexecf('/sbin/ifconfig %s link %s', array($realhwif, $wancfg['spoofmac']));
2416+
mwexecf('/sbin/ifconfig %s link %s', [$realhwif, $wancfg['spoofmac']]);
24142417
}
24152418

24162419
/* only try to set media properties when requested */
@@ -2433,11 +2436,13 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
24332436
}
24342437

24352438
/* set p(ermanent)-promiscuous mode required for e.g. VLAN MAC spoofing */
2436-
if (in_array('ppromisc', $ifconfig_details[$realhwif]['flags']) !== !empty($wancfg['promisc'])) {
2437-
mwexec("/sbin/ifconfig " . $realhwif . " " . (empty($wancfg['promisc']) ? "-" : "") . "promisc");
2439+
if (in_array('ppromisc', $ifconfig_details[$realhwif]['flags'] ?? []) !== !empty($wancfg['promisc'])) {
2440+
mwexecf('/sbin/ifconfig %s %spromisc', [$realhwif, empty($wancfg['promisc']) ? '-' : '']);
24382441
}
24392442

24402443
/* apply interface hardware settings (tso, lro, ..) */
2444+
/* XXX pass down $ifconfig_details */
2445+
/* XXX maybe spoofmac, media and promisc can live here too? */
24412446
configure_interface_hardware($realhwif);
24422447

24432448
switch ($wancfg['ipaddr']) {

0 commit comments

Comments
 (0)