Skip to content

Commit

Permalink
interfaces: deal with PPP device nodes
Browse files Browse the repository at this point in the history
Some mwexecf() sanity on the side and notes for further work.

PR: https://forum.opnsense.org/index.php?topic=25599.0
  • Loading branch information
fichtner committed Nov 23, 2021
1 parent 19d89e0 commit 7ada19d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/etc/inc/interfaces.inc
Expand Up @@ -2377,7 +2377,8 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
interface_virtual_create($realhwif);

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

/* XXX mpd5 $realif(v6) does not exist at this point in time */
/* XXX mpd5 $realif(v6) may not exist at this point in time */
/* XXX mpd5 $realhwif may be a device node path */

if (!file_exists('/var/run/booting') && substr($realif, 0, 4) != 'ovpn') {
interfaces_addresses_flush($realif, 4, $ifconfig_details);
interfaces_addresses_flush($realifv6, 6, $ifconfig_details);
Expand All @@ -2410,7 +2413,7 @@ function interface_configure($verbose = false, $interface = 'wan', $reload = fal
* spoof the MAC again which cycles the link again...
*/
if (!empty($wancfg['spoofmac']) && strcasecmp($wancfg['spoofmac'], get_interface_mac($realhwif))) {
mwexecf('/sbin/ifconfig %s link %s', array($realhwif, $wancfg['spoofmac']));
mwexecf('/sbin/ifconfig %s link %s', [$realhwif, $wancfg['spoofmac']]);
}

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

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

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

switch ($wancfg['ipaddr']) {
Expand Down

0 comments on commit 7ada19d

Please sign in to comment.