Hi, John
On 2009-1-21, at 15:00, John Fremlin wrote:
> Hello Chun Tian,
>
> I think that the check to see when to terminate the snmpwalk was wrong
> in the version of snmp we were using. The snmpwalk terminates quite
> arbitrarily.
>
> First, the way of comparing oids with oid-< was very, very, very
> wrong.
>
>> (oid->= (oid ".1") (oid ".1.0"))
> T
>> (oid->= (oid ".1.1") (oid ".1.0"))
> T
Maybe I shouldn't use these confused function names, but that's what
the original Lisp-SNMP project called.
I don't think your patch on oid compare would work, because what I
want to do in snmp-walk in definitely NOT to check which oid is "big".
[Theorem 1] The OID as a number list which appears in a "GetNext PDU"
chain will ALWAYS get bigger and bigger. That's just what the SNMP
protocol defined on GetNextPDU.
For example, when I walk the "system" node (1.3.6.1.2.1.1), snmp-walk
function will call snmp-get-next manytimes and get following OID list:
system (1.3.6.1.2.1.1)
sysDescr.0 (1.3.6.1.2.1.1.1.0)
sysObjectID.0 (1.3.6.1.2.1.1.2.0)
...
sysORUpTime.1 (1.3.6.1.2.1.1.9.1.4.1)
sysORUpTime.2 (1.3.6.1.2.1.1.9.1.4.2)
...
sysORUpTime.9 (1.3.6.1.2.1.1.9.1.4.9)
Next OID on my Linux box is:
ifNumber.0 (1.3.6.1.2.1.2.1.0)
See, the OID number will always get bigger, if I use your OID->= to
test the terminal, I won't happy:
ASN.1 35 > (oid->= (oid "ifNumber.0") (oid "system"))
T
ASN.1 36 > (oid->= (oid "sysDescr.0") (oid "system"))
T
Both result is T, but I should continue walk when I met "sysDescr.0",
and terminate on "ifNumber.0".
Use my version, see:
ASN.1 40 > (oid->= (oid "ifNumber.0") (oid "system"))
T
ASN.1 41 > (oid->= (oid "sysDescr.0") (oid "system"))
NIL
That will work:)
Actually, what I really done here is clearly mentioned in function OID-
<'s documentation:
(defun oid-< (oid-1 oid-2)
"test if oid-1 is oid-2's child"
...)
Use my version, I can detect:
1) "sysDescr.0" is "system"'s child (oid number list longer, and their
start parts is the same)
2) "ifNumber.0" is NOT "system"'s child.
So, What's your opinion?
>
>
>
> Here is a fixed version for asn.1/object-id.lisp
>
> ;; return -1 if a < b
> ;; return 0 if a == b
> ;; return 1 if a > b
> (defun number-list-cmp (a b)
> (declare (optimize speed))
> (loop for i = a then (cdr i)
> for j = b then (cdr j)
> for x = (car i)
> for y = (car j)
> do
> (unless x (return (if y -1 0)))
> (unless y (return 1))
> (let ((s (signum (- x y))))
> (unless (zerop s)
> (return s)))))
>
>
> (defun oid-cmp (oid-1 oid-2)
> (number-list-cmp (oid-number-list oid-1)
> (oid-number-list oid-2)))
>
> (defun oid-< (oid-1 oid-2)
> (= -1 (oid-cmp oid-1 oid-2)))
>
> (defun oid->= (oid-1 oid-2)
> (not (oid-< oid-1 oid-2)))
>
>
> Second the termination test
>
> (if (or (some #'oid->= new-vars base-vars)
> (member (smi :end-of-mibview) new-values
> :test #'ber-equal))
>
> Is rather strange.
>
> One would always expect the new-vars to be > than the current-vars >=
> base-vars.
>
>
> Third, the termination test does not handle broken Windows 2k boxen
> that
> return no value for some OIDs. For example,
>
> .iso.org.dod.internet.private.enterprises.77.1.4.1.0 = NIL
> SNMPv2-MIB::sysDescr.0 = STRING: Hardware: x86 Family 15 Model 2
> Stepping 9 AT/AT COMPATIBLE - Software: Windows 2000 Version 5.0
> (Build 2195 Uniprocessor Free)
>
> $ snmpgetnext -c public -v 2c 192.51.54.4 .1.3.6.1.4.1.77.1.4.1.0
> Error in packet.
> Reason: (genError) A general failure occured
> Failed object: SNMPv2-SMI::enterprises.77.1.4.1.0
>
>
> This is a much better termination test that allows the walk to
> continue
> much longer.
>
> (defun snmp-walk-finished (new-vars new-values current-vars)
> (or
> (every 'not new-values)
> (some #'oid->= current-vars new-vars)
> ; two tests for broken agent; maybe we should emit an error here?
>
> (member (smi :end-of-mibview) new-values :test #'ber-equal)
> ))
>
> It is not a complete termination test compared to snmpwalk, which
> includes these two things:
>
> (vars->type != SNMP_NOSUCHOBJECT) &&
> (vars->type != SNMP_NOSUCHINSTANCE)) {
>
> Am I confused?
--
Chun Tian (binghe)
NetEase.com, Inc.
P. R. China
|