[SNMP4J] [PATCH] Workaround for Net-SNMP < 5.4.1 64-bit agent bug
Frank Fock
fock at agentpp.com
Thu Nov 1 21:17:00 CET 2007
Hi Jeff,
I have noticed your patch and thought about how the
interoperability issue could be solved best.
Since the bug is on the NET-SNMP side, I do not
would like to spent any CPU cycles for a workaround
for this bug in SNMP4J.
Registering your own IpAddress subclass via the
smisynaxes.properties could be a clean solution.
You could name the class IpAddressNETSNMP64bitBugAware
and implement your patch there.
Let me know if you have any difficulties implementing/using
such a mechanism.
Best regards,
Frank
Jeff Gehlbach schrieb:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi!
>
> Replying to my own post, very bad form I know, but I've received no
> feedback on this patch.
>
> Frank, do you think this is something that could be integrated into a
> future release? In a perfect world we'd just tell everyone to use an
> agent that doesn't exhibit this bug, but the bug is widespread and not
> widely understood -- most users assume that the bug is in OpenNMS
> since they can walk the agent just fine using the Net-SNMP tools.
> This simple change to Snmp4J alleviates a LOT of heartburn. Having it
> in the official code base means that the OpenNMS project doesn't need
> to maintain a patched version of Snmp4J, and other projects that use
> Snmp4J will reap the benefits as well.
>
> Thanks for your consideration,
> - -jeff
>
>
> On 09Oct , 2007, at 8:59 AM, Jeff Gehlbach wrote:
>
>> Hi!
>>
>> I work on the OpenNMS project, which has for some time been using
>> SNMP4J as its default protocol implementation. Thank you for the
>> fabulous work on SNMP4J!
>>
>> I'm writing to propose a patch that works around a bounds-checking
>> bug in the Net-SNMP project's BER library that causes OpenNMS to fail
>> to discover any 64-bit host running a Net-SNMP snmpd older than
>> version 5.4.1. The BER bug in question causes IPv4 addresses to be
>> encoded as 64-bit values but marked in the PDU as being four bytes
>> long. When SNMP4J decodes a RESPONSE PDU containing such a value, it
>> correctly discards the variable in question. The upshot is that
>> OpenNMS cannot discover the interfaces on a node because it does not
>> get a valid picture of the node's ipAddrTable.
>>
>> The following patch, against Snmp4J 1.8.2, seems to effect a
>> workaround for this highly annoying and destructive agent bug. I
>> (and several others) have successfully discovered and managed hosts
>> exhibiting this agent bug by dropping in an SNMP4J JAR built from
>> sources with this patch applied. The addition of a property to
>> enable this workaround seemed the simplest and least intrusive route,
>> but I'm not married to the idea. Feedback is earnestly solicited!
>>
>> Thanks,
>> - -jeff
>>
>>
>> diff -ur snmp4j-1.8.2.orig/src/org/snmp4j/smi/IpAddress.java
>> snmp4j-1.8.2/src/org/snmp4j/smi/IpAddress.java
>> - --- snmp4j-1.8.2.orig/src/org/snmp4j/smi/IpAddress.java 2007-03-10
>> 21:59:12.000000000 -0500
>> +++ snmp4j-1.8.2/src/org/snmp4j/smi/IpAddress.java 2007-08-26
>> 19:07:26.000000000 -0400
>> @@ -150,9 +150,17 @@
>> type.getValue());
>> }
>> if (value.length != 4) {
>> - - throw new IOException("IpAddress encoding error, wrong
>> length: " +
>> + if ( (value.length == 8) &&
>> (System.getProperty("org.snmp4j.smi.bugCompat.netSnmpIpAddress8Bytes").equals("true"))
>> ) {
>> + byte[] tempValue = { 0,0,0,0 };
>> + for (int i = 0; i < 4; i++) {
>> + tempValue[i] = value[i];
>> + }
>> + value = tempValue;
>> + } else {
>> + throw new IOException("IpAddress encoding error, wrong
>> length: " +
>> value.length);
>> - - }
>> + }
>> + }
>> inetAddress = InetAddress.getByAddress(value);
>> }
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (Darwin)
>
> iD8DBQFHKjJuB3953+hexDoRAp27AKCNt83l7pBceZ/Jc/Yy1rN74lG+pgCdES6w
> BxNapYq6B/74mLm1BwfLljw=
> =Nbhz
> -----END PGP SIGNATURE-----
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
More information about the SNMP4J
mailing list