PacketFence - BTS - PacketFence
View Issue Details
0000897PacketFenceerror-handlingpublic2010-01-22 09:542015-02-13 15:35
obilodeau 
 
normalminorsometimes
closedopen 
 
 
0000897: improved SNMP validation
There are a lot of places in the code with stuff like that:

    return (
            defined($result)
            && exists( $result->{"$OID_vmVlan.$ifIndex"})
            && ( $result->{"$OID_vmVlan.$ifIndex"} ne 'noSuchInstance' )
           )

We should do validation of these type of cases. Since validation will be similar, I think we would need an error wrapper in SNMP.pm and use that to validate SNMP's answers. Logger would then need to complain about the caller to the error handler and not the error wrapper itself (to know what sub in what module exactly caused the problem). I know this is doable in log4perl.
No tags attached.
Issue History
2010-01-22 09:54obilodeauNew Issue
2010-01-22 09:55obilodeauStatusnew => assigned
2010-01-22 09:55obilodeauAssigned To => obilodeau
2010-02-09 11:42obilodeauNote Added: 0001465
2010-04-15 17:43obilodeauProjectPacketFence 1.9 => PacketFence
2011-01-18 11:43obilodeauTarget Version => trunk
2011-03-18 10:26obilodeauNote Added: 0001948
2012-10-19 14:29fgaudreaultAssigned Toobilodeau =>
2012-10-19 14:29fgaudreaultTarget Versiondevel => general
2015-02-13 15:35lmunroNote Added: 0003760
2015-02-13 15:35lmunroStatusassigned => closed

Notes
(0001465)
obilodeau   
2010-02-09 11:42   
Just did one isolated case that I could test. I added noSuchObject to the below test in isLearntTrapsEnabled sub:

    return (
        exists( $result->{"$OID_cmnMacAddrLearntEnable.$ifIndex"} )
            && ( $result->{"$OID_cmnMacAddrLearntEnable.$ifIndex"} ne 'noSuchInstance' )
            && ( $result->{"$OID_cmnMacAddrLearntEnable.$ifIndex"} ne 'noSuchObject' )
            && ( $result->{"$OID_cmnMacAddrLearntEnable.$ifIndex"} == 1 )
    );

committed in branch 1.9 with revno: 951bcc89a66e3caf1e7d0381ed62912111bb69d4
(0001948)
obilodeau   
2011-03-18 10:26   
here's a good way to do it

    # if $result is defined, it works we can return $TRUE
    return $TRUE if (defined($result));

    # otherwise report failure
    $logger->warn("setting VLAN failed with " . $this->{_sessionWrite}->error());
    return;
}
(0003760)
lmunro   
2015-02-13 15:35   
No longer relevant.