[SNMP4J] Issue with default context for SNMPv3

forum at friendlysnmp.org forum at friendlysnmp.org
Thu Jan 9 00:53:03 CET 2014


(updated wrong subject)

Frank,

My old versions before upgrade were snmp4j-1.11 and snmp4j-agent-1.4
My new versions are snmp4j-2.2.3 and snmp4j-agent-2.0.10a

The line numbers for code in question in 
org.snmp4j.agent.DefaultMOServer class:
=== snmp4j-agent-2.0.10a ===
271  public void register(ManagedObject mo, OctetString context)
272      throws DuplicateRegistrationException
273  {
274    if ((context == null) || (context.length() == 0)) {

=== snmp4j-agent-1.4 ===
282  public void register(ManagedObject mo, OctetString context)
283      throws DuplicateRegistrationException
284  {
285    if (context == null) {

Compare lines #274 and #285 for the above versions.
With default context (empty string) for the SNMPv3 the additional
verification in line #274 "(context.length() == 0)" breaks my agent.

It's possible that my BaseAgent implementation has bugs.
However, it was working with snmp4j-1.11/snmp4j-agent-1.4
and failed with snmp4j-2.2.3/snmp4j-agent-2.0.10a

The problem appears for registering managed objects for different 
contexts:
v2 and default (empty string) v3.

Thanks,
Mark

On 2013-12-28 04:28, Frank Fock wrote:
> Hi Mark,
> 
> You wrote that you upgraded SNMP4J but quoted SNMP4J-Agent
> code. Have updated SNMP4J-Agent as well? To which version?
> Why do you think that user (USM user?) contexts are related
> to the MOServer.register(..) method?
> (I would claim that they are not related)
> 
> Best regards,
> Frank
> 
> 
> Am 25.12.2013 22:15, schrieb forum at friendlysnmp.org:
>> Hi,
>> 
>> I upgraded my working application from SNMP4J v1.11 to v2.2.3...
>> There were some minor updates required in my code to use generics.
>> 
>> I discovered a serious problem in my code with SNMP4J v2.2.3:
>> empty default context for v3 user is not allowed any more
>> if there is a v2 user defined as well.
>> 
>> The problem is in a org.snmp4j.agent.DefaultMOServer class.
>> The method register(ManagedObject mo, OctetString context) in v2.2.3
>> makes following validation:
>>    if ((context == null) || (context.length() == 0)) {
>>    } else ...
>> 
>> The v1.11 implementation had
>>    if (context == null) {
>>    } else ...
>> 
>> The v2.2.3 validates default v3 empty context as v2 and
>> throws DuplicateRegistrationException if v2 user is present.
>> Am I missing something or this is a bug?
>> 
>> Thanks,
>> Mark
>> _______________________________________________
>> SNMP4J mailing list
>> SNMP4J at agentpp.org
>> http://lists.agentpp.org/mailman/listinfo/snmp4j




More information about the SNMP4J mailing list