Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
f984fdf6
Commit
f984fdf6
authored
Dec 07, 2015
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inc: reapply the cache removal now that filter reloads swiftly
PR:
https://github.com/opnsense/core/issues/451
parent
5639e441
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
185 deletions
+61
-185
filter.inc
src/etc/inc/filter.inc
+1
-10
gwlb.inc
src/etc/inc/gwlb.inc
+6
-7
interfaces.inc
src/etc/inc/interfaces.inc
+50
-163
pfsense-utils.inc
src/etc/inc/pfsense-utils.inc
+3
-2
rc.newwanip
src/etc/rc.newwanip
+1
-1
carp_status.php
src/www/carp_status.php
+0
-2
No files found.
src/etc/inc/filter.inc
View file @
f984fdf6
...
...
@@ -169,9 +169,6 @@ function filter_configure_sync()
filter_pflog_start
();
update_filter_reload_status
(
gettext
(
"Initializing"
),
true
);
/* invalidate interface cache */
get_interface_arr
(
true
);
/* Get interface list to work with. */
if
(
file_exists
(
"/var/run/booting"
))
{
echo
gettext
(
"Configuring firewall"
);
...
...
@@ -864,13 +861,7 @@ function filter_get_direct_networks_list(&$FilterIflist, $returnsubnetsonly = tr
function
filter_generate_optcfg_array
()
{
global
$config
,
$FilterIflist
;
// Nasty hack to avoid unkown status of $FilterIflist, every piece of code using $FilterIflist should use
// this function to retrieve it's content.
if
(
isset
(
$FilterIflist
)
&&
is_array
(
$FilterIflist
)
&&
count
(
$FilterIflist
)
>
0
)
{
return
$FilterIflist
;
}
global
$config
;
$FilterIflist
=
array
();
...
...
src/etc/inc/gwlb.inc
View file @
f984fdf6
...
...
@@ -168,7 +168,7 @@ EOD;
* the if block. So using $gateway['ipprotocol'] is the better option.
*/
if
(
$gateway
[
'ipprotocol'
]
==
"inet"
)
{
// This is an IPv4 gateway...
$gwifip
=
find_interface_ip
(
$gateway
[
'interface'
]
,
true
);
$gwifip
=
find_interface_ip
(
$gateway
[
'interface'
]);
if
(
!
is_ipaddrv4
(
$gwifip
))
continue
;
//Skip this target
...
...
@@ -188,9 +188,9 @@ EOD;
if
(
$gateway
[
'monitor'
]
==
$gateway
[
'gateway'
])
{
/* link locals really need a different src ip */
if
(
is_linklocal
(
$gateway
[
'gateway'
]))
{
$gwifip
=
find_interface_ipv6_ll
(
$gateway
[
'interface'
]
,
true
);
$gwifip
=
find_interface_ipv6_ll
(
$gateway
[
'interface'
]);
}
else
{
$gwifip
=
find_interface_ipv6
(
$gateway
[
'interface'
]
,
true
);
$gwifip
=
find_interface_ipv6
(
$gateway
[
'interface'
]);
}
}
else
{
/* 'monitor' has been set, so makes sure it has precedence over
...
...
@@ -198,14 +198,14 @@ EOD;
* is a local link and 'monitor' is global routable then the
* ICMP6 response would not find its way back home...
*/
$gwifip
=
find_interface_ipv6
(
$gateway
[
'interface'
]
,
true
);
$gwifip
=
find_interface_ipv6
(
$gateway
[
'interface'
]);
if
(
is_linklocal
(
$gateway
[
'monitor'
]))
{
if
(
!
strstr
(
$gateway
[
'monitor'
],
'%'
))
{
$gateway
[
'monitor'
]
.=
"%
{
$gateway
[
'interface'
]
}
"
;
}
}
else
{
// Monitor is a routable address, so use a routable address for the "src" part
$gwifip
=
find_interface_ipv6
(
$gateway
[
'interface'
]
,
true
);
$gwifip
=
find_interface_ipv6
(
$gateway
[
'interface'
]);
}
}
...
...
@@ -431,8 +431,7 @@ function return_gateways_array($disabled = false, $localhost = false, $inactive
$found_defaultv4
=
0
;
$found_defaultv6
=
0
;
// Ensure the interface cache is up to date first
$interfaces
=
get_interface_arr
(
true
);
$interfaces
=
legacy_interface_listget
();
$interfaces_v4
=
array
();
$interfaces_v6
=
array
();
...
...
src/etc/inc/interfaces.inc
View file @
f984fdf6
...
...
@@ -97,21 +97,6 @@ function interfaces_bring_up($interface)
legacy_interface_flags
(
$interface
,
'up'
);
}
/*
* Return the interface array
*/
function
get_interface_arr
(
$flush
=
false
)
{
global
$interface_arr_cache
;
/* If the cache doesn't exist, build it */
if
(
!
isset
(
$interface_arr_cache
)
or
$flush
)
{
$interface_arr_cache
=
legacy_interface_listget
();
}
return
$interface_arr_cache
;
}
function
interface_override_flags
()
{
global
$config
;
...
...
@@ -126,24 +111,14 @@ function interface_override_flags()
);
}
function
does_interface_exist
(
$interface
,
$flush
=
true
)
function
does_interface_exist
(
$interface
)
{
global
$config
;
if
(
!
$interface
)
{
return
false
;
}
$ints
=
get_interface_arr
(
$flush
);
if
(
$ints
==
null
)
{
return
false
;
}
if
(
!
in_array
(
$interface
,
$ints
))
{
$ints
=
legacy_interface_listget
();
if
(
empty
(
$interface
)
||
$ints
==
null
||
!
in_array
(
$interface
,
$ints
))
{
return
false
;
}
else
{
return
true
;
}
return
true
;
}
...
...
@@ -310,9 +285,6 @@ function interface_vlan_configure(&$vlan)
interfaces_bring_up
(
$vlanif
);
/* invalidate interface cache */
get_interface_arr
(
true
);
/* XXX: ermal -- for now leave it here at the moment it does not hurt. */
interfaces_bring_up
(
$if
);
...
...
@@ -366,9 +338,6 @@ function interface_qinq_configure(&$vlan, $fd = NULL) {
fwrite
(
$fd
,
"connect
{
$qinqif
}
:
{
$vlanif
}
qinq: upper nomatch
\n
"
);
}
/* invalidate interface cache */
get_interface_arr
(
true
);
if
(
!
stristr
(
$qinqif
,
"_vlan"
))
mwexec
(
"/sbin/ifconfig
{
$qinqif
}
promisc
\n
"
);
...
...
@@ -434,9 +403,6 @@ function interface_qinq2_configure(&$qinq, $fd, $macaddr) {
fwrite
(
$fd
,
"msg
{
$if
}
h
{
$tag
}
: setifname
\"
{
$vlanif
}
\"\n
"
);
fwrite
(
$fd
,
"msg
{
$if
}
h
{
$tag
}
: set
{
$macaddr
}
\n
"
);
/* invalidate interface cache */
get_interface_arr
(
true
);
return
$vlanif
;
}
...
...
@@ -2873,8 +2839,6 @@ function interface_vlan_adapt_mtu($vlanifs, $mtu) {
function
interface_configure
(
$interface
=
'wan'
,
$reloadall
=
false
,
$linkupevent
=
false
)
{
global
$config
;
global
$interface_sn_arr_cache
,
$interface_ip_arr_cache
;
global
$interface_snv6_arr_cache
,
$interface_ipv6_arr_cache
;
$wancfg
=
$config
[
'interfaces'
][
$interface
];
...
...
@@ -2989,13 +2953,6 @@ function interface_configure($interface = 'wan', $reloadall = false, $linkupeven
legacy_interface_flags
(
$realhwif
,
interface_override_flags
());
}
/* invalidate interface/ip/sn cache */
get_interface_arr
(
true
);
unset
(
$interface_ip_arr_cache
[
$realif
]);
unset
(
$interface_sn_arr_cache
[
$realif
]);
unset
(
$interface_ipv6_arr_cache
[
$realif
]);
unset
(
$interface_snv6_arr_cache
[
$realif
]);
$tunnelif
=
substr
(
$realif
,
0
,
3
);
switch
(
$wancfg
[
'ipaddr'
])
{
case
'dhcp'
:
...
...
@@ -3194,8 +3151,6 @@ function interface_track6_configure($interface = 'lan', $wancfg, $linkupevent =
function
interface_track6_6rd_configure
(
$interface
=
'lan'
,
$lancfg
)
{
global
$config
;
global
$interface_ipv6_arr_cache
;
global
$interface_snv6_arr_cache
;
if
(
!
is_array
(
$lancfg
))
return
;
...
...
@@ -3245,8 +3200,6 @@ function interface_track6_6rd_configure($interface = 'lan', $lancfg)
$oip
=
find_interface_ipv6
(
$lanif
);
if
(
is_ipaddrv6
(
$oip
))
mwexec
(
"/sbin/ifconfig
{
$lanif
}
inet6
{
$oip
}
delete"
);
unset
(
$interface_ipv6_arr_cache
[
$lanif
]);
unset
(
$interface_snv6_arr_cache
[
$lanif
]);
log_error
(
"rd6
{
$interface
}
with ipv6 address
{
$rd6lan
}
based on
{
$lancfg
[
'track6-interface'
]
}
ipv4
{
$ip4address
}
"
);
mwexec
(
"/sbin/ifconfig
{
$lanif
}
inet6
{
$rd6lan
}
prefixlen 64"
);
...
...
@@ -3256,8 +3209,6 @@ function interface_track6_6rd_configure($interface = 'lan', $lancfg)
function
interface_track6_6to4_configure
(
$interface
=
'lan'
,
$lancfg
)
{
global
$config
;
global
$interface_ipv6_arr_cache
;
global
$interface_snv6_arr_cache
;
if
(
!
is_array
(
$lancfg
))
return
;
...
...
@@ -3303,8 +3254,6 @@ function interface_track6_6to4_configure($interface = 'lan', $lancfg)
$oip
=
find_interface_ipv6
(
$lanif
);
if
(
is_ipaddrv6
(
$oip
))
mwexec
(
"/sbin/ifconfig
{
$lanif
}
inet6
{
$oip
}
delete"
);
unset
(
$interface_ipv6_arr_cache
[
$lanif
]);
unset
(
$interface_snv6_arr_cache
[
$lanif
]);
log_error
(
"sixto4
{
$interface
}
with ipv6 address
{
$sixto4lan
}
based on
{
$lancfg
[
'track6-interface'
]
}
ipv4
{
$ip4address
}
"
);
mwexec
(
"/sbin/ifconfig
{
$lanif
}
inet6
{
$sixto4lan
}
prefixlen 64"
);
...
...
@@ -4540,133 +4489,71 @@ function link_interface_to_gif($interface)
/*
* find_interface_ip($interface): return the interface ip (first found)
*/
function
find_interface_ip
(
$interface
,
$flush
=
false
)
{
global
$interface_ip_arr_cache
;
if
(
!
isset
(
$interface_ip_arr_cache
)
||
!
is_array
(
$interface_ip_arr_cache
))
{
$interface_ip_arr_cache
=
array
()
;
}
$interface
=
str_replace
(
"
\n
"
,
""
,
$interface
);
if
(
!
does_interface_exist
(
$interface
))
return
;
/* Setup IP cache */
if
(
!
isset
(
$interface_ip_arr_cache
[
$interface
])
or
$flush
)
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'ipaddr'
]))
{
$interface_ip_arr_cache
[
$interface
]
=
$ifinfo
[
'ipaddr'
];
}
else
{
return
null
;
function
find_interface_ip
(
$interface
)
{
$interface
=
trim
(
$interface
);
if
(
does_interface_exist
(
$interface
))
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'ipaddr'
]))
{
return
$ifinfo
[
'ipaddr'
];
}
}
}
return
$interface_ip_arr_cache
[
$interface
];
return
null
;
}
/*
* find_interface_ipv6($interface): return the interface ip (first found)
*/
function
find_interface_ipv6
(
$interface
,
$flush
=
false
)
{
global
$interface_ipv6_arr_cache
;
global
$config
;
if
(
!
isset
(
$interface_ipv6_arr_cache
)
||
!
is_array
(
$interface_ipv6_arr_cache
))
{
$interface_ipv6_arr_cache
=
array
();
}
$interface
=
trim
(
$interface
);
$interface
=
get_real_interface
(
$interface
);
if
(
!
does_interface_exist
(
$interface
))
return
;
/* Setup IP cache */
if
(
!
isset
(
$interface_ipv6_arr_cache
[
$interface
])
or
$flush
)
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'ipaddr6'
]))
{
$interface_ipv6_arr_cache
[
$interface
]
=
$ifinfo
[
'ipaddr6'
];
}
else
{
return
null
;
function
find_interface_ipv6
(
$interface
)
{
// a bit obscure, why should this be different then find_interface_ip?
$interface
=
get_real_interface
(
trim
(
$interface
));
if
(
does_interface_exist
(
$interface
))
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'ipaddr6'
]))
{
return
$ifinfo
[
'ipaddr6'
];
}
}
}
return
$interface_ipv6_arr_cache
[
$interface
];
return
null
;
}
/*
* find_interface_ipv6_ll($interface): return the interface ipv6 link local (first found)
*/
function
find_interface_ipv6_ll
(
$interface
,
$flush
=
false
)
{
global
$interface_llv6_arr_cache
;
global
$config
;
$interface
=
str_replace
(
"
\n
"
,
""
,
$interface
);
if
(
!
does_interface_exist
(
$interface
))
return
;
/* Setup IP cache */
if
(
!
isset
(
$interface_llv6_arr_cache
[
$interface
])
or
$flush
)
{
$ifinfo
=
pfSense_getall_interface_addresses
(
$interface
);
foreach
(
$ifinfo
as
$line
)
{
if
(
strstr
(
$line
,
":"
))
{
$parts
=
explode
(
"/"
,
$line
);
if
(
is_linklocal
(
$parts
[
0
]))
{
$ifinfo
[
'linklocal'
]
=
$parts
[
0
];
function
find_interface_ipv6_ll
(
$interface
)
{
$interface
=
trim
(
$interface
);
if
(
does_interface_exist
(
$interface
))
{
$ifinfo
=
pfSense_getall_interface_addresses
(
$interface
);
foreach
(
$ifinfo
as
$line
)
{
if
(
strstr
(
$line
,
":"
))
{
$parts
=
explode
(
"/"
,
$line
);
if
(
is_linklocal
(
$parts
[
0
]))
{
return
$parts
[
0
];
}
}
}
}
}
$interface_llv6_arr_cache
[
$interface
]
=
$ifinfo
[
'linklocal'
];
}
return
$interface_llv6_arr_cache
[
$interface
];
return
null
;
}
function
find_interface_subnet
(
$interface
,
$flush
=
false
)
{
global
$interface_sn_arr_cache
;
if
(
!
isset
(
$interface_sn_arr_cache
)
||
!
is_array
(
$interface_sn_arr_cache
)){
$interface_sn_arr_cache
=
array
();
}
$interface
=
str_replace
(
"
\n
"
,
""
,
$interface
);
if
(
does_interface_exist
(
$interface
)
==
false
)
return
;
if
(
!
isset
(
$interface_sn_arr_cache
[
$interface
][
'subnetbits'
])
||
$flush
)
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'subnetbits'
]))
{
$interface_sn_arr_cache
[
$interface
]
=
$ifinfo
[
'subnetbits'
];
}
else
{
return
null
;
function
find_interface_subnet
(
$interface
)
{
$interface
=
trim
(
$interface
);
if
(
does_interface_exist
(
$interface
))
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'subnetbits'
]))
{
return
$ifinfo
[
'subnetbits'
];
}
}
}
return
$interface_sn_arr_cache
[
$interface
];
return
null
;
}
function
find_interface_subnetv6
(
$interface
,
$flush
=
false
)
{
global
$interface_snv6_arr_cache
;
if
(
!
isset
(
$interface_snv6_arr_cache
)
||
!
is_array
(
$interface_snv6_arr_cache
))
{
$interface_snv6_arr_cache
=
array
();
}
$interface
=
str_replace
(
"
\n
"
,
""
,
$interface
);
if
(
does_interface_exist
(
$interface
)
==
false
)
return
;
if
(
!
isset
(
$interface_snv6_arr_cache
[
$interface
][
'subnetbits6'
])
||
$flush
)
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'subnetbits6'
]))
{
$interface_snv6_arr_cache
[
$interface
]
=
$ifinfo
[
'subnetbits6'
];
}
else
{
return
null
;
function
find_interface_subnetv6
(
$interface
)
{
$interface
=
trim
(
$interface
);
if
(
does_interface_exist
(
$interface
))
{
$ifinfo
=
pfSense_get_interface_addresses
(
$interface
);
if
(
isset
(
$ifinfo
[
'subnetbits6'
]))
{
return
$ifinfo
[
'subnetbits6'
];
}
}
}
return
$interface_snv6_arr_cache
[
$interface
];
return
null
;
}
function
ip_in_interface_alias_subnet
(
$interface
,
$ipalias
)
{
...
...
src/etc/inc/pfsense-utils.inc
View file @
f984fdf6
...
...
@@ -136,10 +136,11 @@ function setup_polling()
function
setup_microcode
()
{
/* if list */
$ifs
=
get_interface_arr
();
$ifs
=
legacy_interface_listget
();
foreach
(
$ifs
as
$if
)
foreach
(
$ifs
as
$if
)
{
enable_hardware_offloading
(
$if
);
}
}
/****f* legacy/get_carp_status
...
...
src/etc/rc.newwanip
View file @
f984fdf6
...
...
@@ -76,7 +76,7 @@ if (is_array($config['interfaces'][$interface]) && !isset($config['interfaces'][
if
(
empty
(
$argument
))
{
$curwanip
=
get_interface_ip
();
}
else
{
$curwanip
=
find_interface_ip
(
$interface_real
,
true
);
$curwanip
=
find_interface_ip
(
$interface_real
);
if
(
empty
(
$curwanip
))
{
$curwanip
=
get_interface_ip
(
$interface
);
}
...
...
src/www/carp_status.php
View file @
f984fdf6
...
...
@@ -51,9 +51,7 @@ function interfaces_carp_set_maintenancemode($carp_maintenancemode)
}
unset
(
$interface_arr_cache
);
unset
(
$carp_interface_count_cache
);
unset
(
$interface_ip_arr_cache
);
$status
=
get_carp_status
();
if
(
$_POST
[
'carp_maintenancemode'
]
<>
""
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment