Notes |
|
(0001836)
|
fgaudreault
|
2011-01-27 13:28
|
|
Did a patch for it, to be validated/tested. |
|
|
|
Reproduced issue with test cases in t/vlan.t. Two cases where the code bombs:
- not an array
- empty array
trying the patch
|
|
|
|
the patch doesn't respect the desired behavior. A zero uplink list should return 1 and with the patch it'll return 0.
# Failed test 'avoid empty array warning (issue \0000832)'
# in vlan.t at line 112.
# got: '0'
# expected: '1'
not ok 10 - avoid empty array warning (issue \0000832)
# Failed test 'Zero uplinks'
# in vlan.t at line 119.
# got: '0'
# expected: '1'
not ok 11 - Zero uplinks
# Failed test 'getUpLinks not supported return 0'
# in vlan.t at line 126.
# got: '1'
# expected: '0'
not ok 12 - getUpLinks not supported return 0
ok 13 - do we act on uplink?
# Looks like you failed 3 tests of 14.
|
|
|
|
fixed it. Here's the patch:
#
# old_revision [c29f24c5813973df2563988671ab3e279c219927]
#
# patch "pf/lib/pf/vlan.pm"
# from [ba5ea5b5334a6a05b0234f7039666c40ecc9de22]
# to [db0fbb6caa31e08eaa05674fd61d4e27fbacb061]
#
============================================================
--- pf/lib/pf/vlan.pm ba5ea5b5334a6a05b0234f7039666c40ecc9de22
+++ pf/lib/pf/vlan.pm db0fbb6caa31e08eaa05674fd61d4e27fbacb061
@@ -106,7 +106,7 @@ sub doWeActOnThisTrap {
if ( ( $ifType == $SNMP::ETHERNET_CSMACD ) || ( $ifType == $SNMP::GIGABIT_ETHERNET ) ) {
my @upLinks = $switch->getUpLinks();
# TODO: need to validate for empty array here to avoid warning
- if ( $upLinks[0] == -1 ) {
+ if ( @upLinks && $upLinks[0] == -1 ) {
$logger->warn("Can't determine Uplinks for the switch -> do nothing");
} else {
if ( grep( { $_ == $ifIndex } @upLinks ) == 0 ) {
Test results:
ok 10 - avoid empty array warning (issue \0000832)
ok 11 - Zero uplinks
ok 12 - getUpLinks not supported return 0
ok 13 - do we act on uplink?
ok 14 - no warnings
|
|
|
|
|