Hi!
I have read a bit NetSNMP sources and I think I have found some
interesting bits to answer myself.
> BTW, why is there a lookup before each action? I mean, the workflow is:
> var_atEntry lookups the entry and sets write_method.
> write_arp is called with action == RESERVE1
> var_atEntry lookups the entry and sets write_method.
> write_arp is called with action == RESERVE2
> var_atEntry lookups the entry and sets write_method.
> write_arp is called with action == ACTION
> var_atEntry lookups the entry and sets write_method.
> write_arp is called with action == COMMIT
> var_atEntry lookups the entry and sets write_method.
> write_arp is called with action == FREE
> The workflow could be more efficient with:
> var_atEntry lookups the entry and sets write_method.
> write_arp is called with action == RESERVE1
> write_arp is called with action == RESERVE2
> write_arp is called with action == ACTION
> write_arp is called with action == COMMIT
> write_arp is called with action == FREE
In fact, the real workflow is the last one, except there is no FREE (the
FREE action is called only when an error occurs in RESERVE1 and
RESERVE2). So, I am happy here: lookup only happens once.
> This is a bit odd for me. Let's suppose that I use:
> snmpset ifAdminStatus.5 = up ifAdminStatus.6 = up
> Since I suppose that before each phase (RESERVE1, RESERVE2, etc), we go
> into var_ifEntry, then admin_status is set correctly each time. However,
> oldadmin_status seems inaccurate to me. ACTION will be executed for
> column 5 first then for column 6 and the only value of oldadmin_status
> we have saved would be the second one, right?
Therefore, this is even worst here. admin_status get overwritten since
it is only correct in RESERVE1. Therefore, if I do:
snmpset ifAdminStatus.5 = up ifAdminStatus.6 = down
both interfaces will get down because in ACTION, admin_status is set to
the value that we want. This means up when going into ACTION for row 5,
then down when going into ACTION for row 6. In COMMIT, admin_status
would then be down for both rows 5 and 6.
I still need to check, but I think there is a bug here.
> Another question: what is the best way to pass an object to the
> write_method? For example, if I need some expensive processing to find
> an object, I would like to not redo it in write_method. Since,
> write_method is always immediatly called after the var_* method, I could
> put a pointer to my object in some global variable. Is there a cleaner
> way? For example, using the statP pointer (I don't need the current
> value)?
>From the source code, I can safely use this statP pointer. It is put
into some cache system that get retrieved through phases and is only
used as a parameter of the write_method. I could then do something like
this in findVar method:
obj = locate_object();
if mode == SET {
*write_method = my_write_method;
return obj;
}
case (vp->magic) {
....
}
Unfortunately, I don't think that I have necessary information in
findVar method to know that I am currently in SET method. This is a pity
because it would have been a nice way to pass my object to the write
method and netsnmp would have kept for me this object through different
invocations of the write method (through the statP parameter). If I use
a global variable and if the write method can be used to modify several
instances of my object, I need to organize my objects into a dictionary
or an array.
Any insight on this would be greatly appreciated.
--
No fortunes found
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users