Merge pull request #3439 from pblasquez/bad_ifname

Added bad ifName and ifAlias regex matching
This commit is contained in:
Neil Lathwood
2016-04-30 02:00:13 +01:00
2 changed files with 28 additions and 0 deletions
+2
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
+26
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']);
@@ -895,6 +897,30 @@ function is_port_valid($port, $device) {
}
}
}
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'];
if( is_array($config['os'][$device['os']]['bad_iftype']) ) {