On 11/13/09 2:22 PM, Dave Shield wrote:
> 2009/11/13 Mike Bowie<[email protected]>:
>    
>> Looking at agent/mibgroup/mibII/ip.c @ 850 onwards, the "Loaded IP Group
>> (sysctl)" message is only called if IPFORWARDING and IPDEFAULTTTL are
>> missed and ret_value is greater than or equal to zero; unless I'm
>> missing something.
>>      
> The 'ip_load' routine actually serves two seperate roles.
>
> One is to load the contents of an internal cache, used for
> most of the the IP statistics (but excluding ipForwarding and
> ipDefaultTTL).   This is done automatically by the cache
> handler, before the IP handler is ever called.
>     In this case, the 'magic' parameter is zero - because
> the cache helper doesn't typically use this parameter.
>
> That's the normal mode of operation for the cache loading
> method.   And that's the debug message that you are
> currently seeing.
>
> But in the case of ip_load, this is pressed into service for
> a second role - to handle the two "special case" variables
> (ipForwarding and ipDefaultTTL).   It's that one case which
> we are looking at at the moment.
>
> As I say, my suspicion is that the ipForwarding sysctl
> call is failing, when ip_load is being called for the second
> time.  But it's sensible to check this for certain.
>
>
>    
>> My debug shows that ret_value in this case is zero.  I'm using:
>> char msg[20];
>> sprintf(msg, "ret_value: %d\n", ret_value);
>> DEBUGMSGTL(("mibII/ip", msg));
>>      
> Where exactly is this code fragment?
> What does the full 'ip_load' routine look like?
>
> Dave
>    
This appears to have fallen off the group thread a message or so back... 
if anyone might have suggestions, I'm all ears.  (Or eyes, depending on 
how you look at it.)

This is what I have in ip.c from 840 on
int
ip_load(netsnmp_cache *cache, void *vmagic)
{
     long            ret_value = 0;
     int             i;
     static int      sname[4] = { CTL_NET, PF_INET, IPPROTO_IP, 0 };
     size_t          len;
     int             magic = (int) vmagic;

     char init_msg[60];
     sprintf(init_msg, "%d|%d|%d\n", magic, IPFORWARDING, IPDEFAULTTTL);
     DEBUGMSGTL(("mibII/ip", init_msg));

     switch (magic) {
     case IPFORWARDING:
         DEBUGMSGTL(("mibII/ip", "IPFORWARDING\n"));
         len = sizeof i;
         sname[3] = IPCTL_FORWARDING;
         if (sysctl(sname, 4, &i, &len, 0, 0) < 0) {
             DEBUGMSGTL(("mibII/ip", "sysctl ret -1\n"));
             return -1;
         } else
             return (i ? 1 /* GATEWAY */
                       : 2 /* HOST    */ );

     case IPDEFAULTTTL:
         DEBUGMSGTL(("mibII/ip", "IPDEFAULTTTL\n"));
         len = sizeof i;
         sname[3] = IPCTL_DEFTTL;
         if (sysctl(sname, 4, &i, &len, 0, 0) < 0)
             return -1;
         else
             return i;

     default:
         DEBUGMSGTL(("mibII/ip", "default\n"));
         len = sizeof(ipstat);
         sname[3] = IPCTL_STATS;
         ret_value = sysctl(sname, 4, &ipstat, &len, 0, 0);

         if ( ret_value < 0 ) {
             DEBUGMSGTL(("mibII/ip", "Failed to load IP Group (sysctl)\n"));
         } else {
             DEBUGMSGTL(("mibII/ip", "Loaded IP Group (sysctl)\n"));
         }
         char ret_msg[20];
         sprintf(ret_msg, "ret_value: %d\n", ret_value);
         DEBUGMSGTL(("mibII/ip", ret_msg));
         return ret_value;
     }
}

Querying IP-MIB::ipForwarding.0 results in
$ snmpd -f -Le -DmibII/ip -c /usr/pkg/etc/snmpd.conf
registered debug token mibII/ip, 1
mibII/ip: Initialising IP group
nlist err: neither ipstat nor _ipstat found.
nlist err: neither tcpstat nor _tcpstat found.
nlist err: neither icmpstat nor _icmpstat found.
nlist err: neither udpstat nor _udpstat found.
NET-SNMP version 5.4.2.1
Connection from UDP: [172.16.4.253]:59018->[0.0.0.0]
mibII/ip: 0|1|2
mibII/ip: default
mibII/ip: Loaded IP Group (sysctl)
mibII/ip: ret_value: 0
mibII/ip: Handler - mode GET
mibII/ip: oid: IP-MIB::ipForwarding.0
truncating integer value > 32 bits

As I understand it, ip_load is only being called once... otherwise I'd 
expect to see the "init_msg" value output twice.

Any suggestions are most welcome. ;-)

Cheers,

Mike.

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to