Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added bad ifName and ifAlias regex matching #3439

Merged
merged 4 commits into from
Apr 30, 2016
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/Support/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 26 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,8 @@ function is_port_valid($port, $device) {
else {
$valid = 1;
$if = strtolower($port['ifDescr']);
$ifname = strtolower($port['ifName']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the space formatting here. 4 spaces for indentation.

your other PRs had the same but I only noticed at the end :(

$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']);
Expand All @@ -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'];
Expand Down