Added bad ifName and ifAlias regex matching

Allow user to ignore interfaces based on regex matching of ifName and
ifAlias values
This commit is contained in:
pblasquez
2016-04-28 15:36:13 -07:00
parent 0e33d20724
commit ba48567f19
2 changed files with 28 additions and 0 deletions

View File

@@ -400,6 +400,8 @@ by continuing the array.
`bad_if` is matched against the ifDescr value.
`bad_iftype` is matched against the ifType value.
`bad_if_regexp` is matched against the ifDescr value as a regular expression.
`bad_ifname_regexp` is matched against the ifName value as a regular expression.
`bad_ifalias_regexp` is matched against the ifAlias value as a regular expression.
#### Interfaces to be rewritten

View File

@@ -873,6 +873,8 @@ function is_port_valid($port, $device) {
else {
$valid = 1;
$if = strtolower($port['ifDescr']);
$ifname = strtolower($port['ifName']);
$ifalias = strtolower($port['ifAlias']);
$fringe = $config['bad_if'];
if( is_array($config['os'][$device['os']]['bad_if']) ) {
$fringe = array_merge($config['bad_if'],$config['os'][$device['os']]['bad_if']);
@@ -894,6 +896,30 @@ function is_port_valid($port, $device) {
d_echo("ignored : $bi : ".$if);
}
}
}
if (is_array($config['bad_ifname_regexp'])) {
$fringe = $config['bad_ifname_regexp'];
if( is_array($config['os'][$device['os']]['bad_ifname_regexp']) ) {
$fringe = array_merge($config['bad_ifname_regexp'],$config['os'][$device['os']]['bad_ifname_regexp']);
}
foreach ($fringe as $bi) {
if (preg_match($bi ."i", $ifname)) {
$valid = 0;
d_echo("ignored : $bi : ".$ifname);
}
}
}
if (is_array($config['bad_ifalias_regexp'])) {
$fringe = $config['bad_ifalias_regexp'];
if( is_array($config['os'][$device['os']]['bad_ifalias_regexp']) ) {
$fringe = array_merge($config['bad_ifalias_regexp'],$config['os'][$device['os']]['bad_ifalias_regexp']);
}
foreach ($fringe as $bi) {
if (preg_match($bi ."i", $ifalias)) {
$valid = 0;
d_echo("ignored : $bi : ".$ifalias);
}
}
}
if (is_array($config['bad_iftype'])) {
$fringe = $config['bad_iftype'];