diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index e7d305cf2..1a653030c 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -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 diff --git a/includes/functions.php b/includes/functions.php index d7597c8ae..b1e58fac4 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -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']) ) {