mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 00:54:41 +00:00
interfaces, performance. allow passing ifconfig details in get_interface_ip[v6] for https://github.com/opnsense/core/issues/3567
This commit is contained in:
parent
45b3d224a7
commit
aa25ecf2ad
@ -4003,19 +4003,19 @@ function ip_in_interface_alias_subnet($interface, $ipalias)
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_interface_ip($interface = 'wan')
|
||||
function get_interface_ip($interface = 'wan', $ifconfig_details = null)
|
||||
{
|
||||
/* XXX maybe we should make a proper lookup */
|
||||
if (strstr($interface, '_vip')) {
|
||||
return get_configured_carp_interface_list($interface);
|
||||
}
|
||||
|
||||
$realif = get_real_interface($interface);
|
||||
$realif = get_real_interface($interface, $ifconfig_details);
|
||||
|
||||
return find_interface_ip($realif);
|
||||
}
|
||||
|
||||
function get_interface_ipv6($interface = 'wan')
|
||||
function get_interface_ipv6($interface = 'wan', $ifconfig_details = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
@ -4027,7 +4027,7 @@ function get_interface_ipv6($interface = 'wan')
|
||||
$realif = get_real_interface($interface, 'inet6');
|
||||
|
||||
return isset($config['interfaces'][$interface]['dhcp6prefixonly']) ?
|
||||
find_interface_ipv6_ll($realif) : find_interface_ipv6($realif);
|
||||
find_interface_ipv6_ll($realif, $ifconfig_details) : find_interface_ipv6($realif, $ifconfig_details);
|
||||
}
|
||||
|
||||
/****f* interfaces/is_interface_wireless
|
||||
|
||||
@ -564,6 +564,7 @@ function dhcpd_dhcp4_configure($verbose = false)
|
||||
}
|
||||
|
||||
$custoptions = "";
|
||||
$ifconfig_details = legacy_interfaces_details();
|
||||
foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
|
||||
if (isset($dhcpifconf['numberoptions']['item'])) {
|
||||
foreach ($dhcpifconf['numberoptions']['item'] as $itemidx => $item) {
|
||||
@ -606,7 +607,7 @@ EOD;
|
||||
}
|
||||
|
||||
if (!empty($dhcpifconf['failover_peerip'])) {
|
||||
$intip = get_interface_ip($dhcpif);
|
||||
$intip = get_interface_ip($dhcpif, $ifconfig_details);
|
||||
/*
|
||||
* yep, failover peer is defined.
|
||||
* does it match up to a defined vip?
|
||||
@ -664,14 +665,14 @@ EOPP;
|
||||
}
|
||||
|
||||
$iflist = get_configured_interface_with_descr();
|
||||
$gwObject = new \OPNsense\Routing\Gateways(legacy_interfaces_details());
|
||||
$gwObject = new \OPNsense\Routing\Gateways($ifconfig_details);
|
||||
|
||||
foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf) {
|
||||
if (!isset($dhcpifconf['enable']) || !isset($iflist[$dhcpif])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list ($ifcfgip, $ifcfgsn) = explode('/', find_interface_network(get_real_interface($dhcpif), false));
|
||||
list ($ifcfgip, $ifcfgsn) = explode('/', find_interface_network(get_real_interface($dhcpif), false, $ifconfig_details));
|
||||
|
||||
$subnet = gen_subnet($ifcfgip, $ifcfgsn);
|
||||
$subnetmask = gen_subnet_mask($ifcfgsn);
|
||||
@ -1192,6 +1193,7 @@ function dhcpd_dhcp6_configure($verbose = false, $blacklist = array())
|
||||
}
|
||||
|
||||
$iflist = get_configured_interface_with_descr();
|
||||
$ifconfig_details = legacy_interfaces_details();
|
||||
$dhcpdv6cfg = config_read_array('dhcpdv6');
|
||||
|
||||
/* Only consider DNS servers with IPv6 addresses for the IPv6 DHCP server. */
|
||||
@ -1216,7 +1218,7 @@ function dhcpd_dhcp6_configure($verbose = false, $blacklist = array())
|
||||
continue;
|
||||
}
|
||||
if (!empty($config['interfaces'][$ifname]['track6-interface'])) {
|
||||
$ifcfgipv6 = get_interface_ipv6($ifname);
|
||||
$ifcfgipv6 = get_interface_ipv6($ifname, $ifconfig_details);
|
||||
if (!is_ipaddrv6($ifcfgipv6)) {
|
||||
continue;
|
||||
}
|
||||
@ -1370,8 +1372,8 @@ EOD;
|
||||
|
||||
$realif = get_real_interface($dhcpv6if, 'inet6');
|
||||
|
||||
$ifcfgipv6 = find_interface_ipv6($realif);
|
||||
$networkv6 = find_interface_networkv6($realif);
|
||||
$ifcfgipv6 = find_interface_ipv6($realif, $ifconfig_details);
|
||||
$networkv6 = find_interface_networkv6($realif, true, $ifconfig_details);
|
||||
|
||||
if (!is_ipaddrv6($ifcfgipv6) || !is_subnetv6($networkv6)) {
|
||||
log_error("Warning! dhcpd_dhcp6_configure() found no suitable IPv6 address on {$dhcpv6if}");
|
||||
@ -1585,14 +1587,15 @@ function dhcpd_dhcrelay4_configure($verbose = false)
|
||||
}
|
||||
|
||||
$iflist = get_configured_interface_with_descr();
|
||||
$a_gateways = (new \OPNsense\Routing\Gateways(legacy_interfaces_details()))->gatewaysIndexedByName(true);
|
||||
$ifconfig_details = legacy_interfaces_details();
|
||||
$a_gateways = (new \OPNsense\Routing\Gateways($ifconfig_details))->gatewaysIndexedByName(true);
|
||||
$dhcifaces = explode(",", $dhcrelaycfg['interface']);
|
||||
foreach ($dhcifaces as $dhcrelayif) {
|
||||
if (!isset($iflist[$dhcrelayif]) || link_interface_to_bridge($dhcrelayif)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_ipaddr(get_interface_ip($dhcrelayif))) {
|
||||
if (is_ipaddr(get_interface_ip($dhcrelayif, $ifconfig_details))) {
|
||||
$dhcrelayifs[] = get_real_interface($dhcrelayif);
|
||||
}
|
||||
}
|
||||
@ -1607,8 +1610,8 @@ function dhcpd_dhcrelay4_configure($verbose = false)
|
||||
|
||||
/* XXX runs multiple times because of server address loop :( */
|
||||
foreach (array_keys($iflist) as $ifname) {
|
||||
$realif = get_real_interface($ifname);
|
||||
$subnet = find_interface_network($realif);
|
||||
$realif = get_real_interface($ifname, $ifconfig_details);
|
||||
$subnet = find_interface_network($realif, true, $ifconfig_details);
|
||||
if (!is_subnetv4($subnet)) {
|
||||
continue;
|
||||
}
|
||||
@ -1705,14 +1708,15 @@ function dhcpd_dhcrelay6_configure($verbose = false)
|
||||
}
|
||||
|
||||
$iflist = get_configured_interface_with_descr();
|
||||
$a_gateways = (new \OPNsense\Routing\Gateways(legacy_interfaces_details()))->gatewaysIndexedByName(true);
|
||||
$ifconfig_details = legacy_interfaces_details();
|
||||
$a_gateways = (new \OPNsense\Routing\Gateways($ifconfig_details))->gatewaysIndexedByName(true);
|
||||
$dhcifaces = explode(",", $dhcrelaycfg['interface']);
|
||||
foreach ($dhcifaces as $dhcrelayif) {
|
||||
if (!isset($iflist[$dhcrelayif]) || link_interface_to_bridge($dhcrelayif)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_ipaddrv6(get_interface_ipv6($dhcrelayif))) {
|
||||
if (is_ipaddrv6(get_interface_ipv6($dhcrelayif, $ifconfig_details))) {
|
||||
$dhcrelayifs[] = get_real_interface($dhcrelayif);
|
||||
}
|
||||
}
|
||||
@ -1730,7 +1734,7 @@ function dhcpd_dhcrelay6_configure($verbose = false)
|
||||
/* XXX runs multiple times because of server address loop :( */
|
||||
foreach (array_keys($iflist) as $ifname) {
|
||||
$realif = get_real_interface($ifname, 'inet6');
|
||||
$subnet = find_interface_networkv6($realif);
|
||||
$subnet = find_interface_networkv6($realif, true, $ifconfig_details);
|
||||
if (!is_subnetv6($subnet)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user