Sorry to followup to my own posting, but I've done some "research on
(pre)historic code" :-).

But, maybe I should begin with a proper bug report:

    net-snmp-5.2.1 (& net-snmp-5.1 & obviously "historic")
    Linux Kernel 2.6.10
    IPv6
    interface "ip6tnl0"

    linux# ifconfig ip6tnl0   Link encap:UNSPEC  HWaddr 00-00 ...

    linux# grep ip6tnl0 /proc/net/dev
        ip6tnl0:       0       0         ...

    snmpwalk "interfaces.ifTable.ifEntry.ifDescr" does not show it.

    However, snmpwalk "ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex"
    returns index numbers as if "ip6tnl0" was there; "off by one".

    See details of both snmpwalk at then end of this posting.

Now, to "(pre)historic code":

cmu-snmp2.1.2/agent/snmp_vars.c
-rw-r--r--   1 lindberg  119879 Feb  5  1996 ./agent/snmp_vars.c

  2128  #ifdef sunV3
  2133  int Interface_Scan_Next(Index, Name, Retifnet)
   ...
  2142          while (ifnetaddr) {
  2143              /*
  2144               *      Get the "ifnet" structure and extract the device 
name
  2145               */
  2146              klookup((int)ifnetaddr, (char *)&ifnet, sizeof ifnet);
  2147              klookup((int)ifnet.if_name, (char *)saveName, 16);
  2148              if (strcmp(saveName, "ip") == 0) {
  2149                  ifnetaddr = ifnet.if_next;
  2150                  continue;
  2151              }

So, that test has been around for a while - 1996 "#ifdef sunV3" later
updated to "#if defined(sunV3) || defined(linux)". An "educated guess"
would be that this piece of code *might* have been needed in "sunV3"
and that it was kept with "linux" since "it did no harm".

Now I'm at 0.10c: Let's just delete the piece of code above and then
modify the rest to do entirely without (ifnet *)->if_unit.

I plan to supply "diff -c" soon. Would you prefer that to:

    1)  Delete the old code completely.

    2)  Keep the old code inline but between
        #ifdef  OLD_if_unit
        #endif  /* OLD_if_unit */

            Gunnar Lindberg



>From [EMAIL PROTECTED]  Fri Jun  3 17:28:17 2005
>From: Gunnar Lindberg <[EMAIL PROTECTED]>
>Message-Id: <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Fwd: Linux 2.6 IPv6 interface "ip6tnl0"
>Cc: [email protected]
>In-Reply-To: <[EMAIL PROTECTED]>
>Date: Fri, 3 Jun 2005 17:26:58 +0200 (MEST)

>Hm, there is one piece of code which is likely to depend on whether
>or not you split the interface name into x->if_name & x->if_unit:

>./agent/mibgroup/mibII/interfaces.c
>   1733 #if defined(sunV3) || defined(linux)
>   1734 /*
>   1735  * **  4.2 BSD doesn't have ifaddr
>   1736  * **
>   1737  */
>   1738 int
>   1739 Interface_Scan_Next(short *Index,
>   1740                     char *Name,
>   1741                     struct ifnet *Retifnet, struct in_ifaddr *dummy)
>   1742 {
>   1743     struct ifnet    ifnet;
>   1744     register char  *cp;
>   1745 
>   1746     while (ifnetaddr) {
>   1747         /*
>   1748          *      Get the "ifnet" structure and extract the device name
>   1749          */
>   1750 #ifndef linux
>   1751         klookup((unsigned long) ifnetaddr, (char *) &ifnet, sizeof 
> ifnet        );
>   1752         klookup((unsigned long) ifnet.if_name, (char *) saveName,
>   1753                 sizeof saveName);
>   1754 #else
>   1755         ifnet = *ifnetaddr;
>   1756         strncpy(saveName, ifnet.if_name, sizeof(saveName));
>   1757 #endif
>-> 1758         if (strcmp(saveName, "ip") == 0) {
>-> 1759             ifnetaddr = ifnet.if_next;
>-> 1760             continue;
>   1761         }

>Now, I can read what it does and I do recognize the result (ip6tnl0
>simply disappears from SNMP, since it's split into <ip><6tnl0>, and
>the other interfaces then get their Index screwed up - "off by one")
>but I can't even guess what it's suppose to fix and who needs it.

>My 0.01c says "delete", but...

>Hopefully that's documented in CVS/RCS.

>       Gunnar

>>From [EMAIL PROTECTED]  Tue May 31 11:18:45 2005
>>Date: Tue, 31 May 2005 11:18:45 +0200 (MEST)
>>From: Gunnar Lindberg <[EMAIL PROTECTED]>
>>Message-Id: <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>Subject: Re: Fwd: Linux 2.6 IPv6 interface "ip6tnl0"
>>Cc: [email protected]
>>In-Reply-To: <[EMAIL PROTECTED]>

>>Ah, I see. if_type_from_name();

>>I'm not sure how much one should depend on how that code currently
>>is written , but as is - strncmp() - it will work just fine with
>>if_unit="" and if_name="eth2:3".

>>Otherwise, one could use a slightly more complicated split algorithm:

>>    o Backwards while ['0'-'9'] or ':' or '.'
>>    o save tail in if_unit    (0:23)
>>    o save head in if_name    (ip6tnl)

>>This will do for all my examples (eth2:3, eth3.4, ip6tnl0:23); for
>>all examples I can think of (which is likely not to be complete :-).

>>Are there more characters that should be considered part of if_unit?

>>      Gunnar

>>>From [EMAIL PROTECTED]  Tue May 31 10:46:22 2005
>>>Subject: Re: Fwd: Linux 2.6 IPv6 interface "ip6tnl0"
>>>From: Dave Shield <[EMAIL PROTECTED]>
>>>To: Gunnar Lindberg <[EMAIL PROTECTED]>
>>>Cc: [email protected]
>>>In-Reply-To: <[EMAIL PROTECTED]>
>>>References: <[EMAIL PROTECTED]>
>>>Organization: University of Liverpool, Computer Science
>>>Message-Id: <[EMAIL PROTECTED]>
>>>Date: Tue, 31 May 2005 09:47:33 +0100

>>>On Tue, 2005-05-31 at 09:13, Gunnar Lindberg wrote:

>>>> I guess you code writers can tell why (if) this is a bad idea, but
>>>> my 0.01c is to skip the if_unit stuff completely 

>>>> The only usage of if_unit I find is strncat() and string_append_int()
>>>> and both work well with the above.

>>>It's not the use of 'if_unit' that's important here - it's the
>>>use of 'if_name'.  This is used to attempt to identify the type
>>>and speed of the interface (search for 'if_type_from_name')

>>>I don't think it matters too much where the interface name
>>>is split into "base name" and "unit" - they should be spliced
>>>back together before being returned anyway.

>>>It's more a question of how this handles identifying the
>>>type of interface.

>>>Dave
>_______________________________________________
>Net-snmp-coders mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/net-snmp-coders


linux# ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 00:06:5B:38:BB:F3  
    inet addr:129.16.6.117  ...

other_host% snmpwalk interfaces.ifTable.ifEntry.ifDescr
interfaces.ifTable.ifEntry.ifDescr.1  = "lo" Hex: 6C 6F
interfaces.ifTable.ifEntry.ifDescr.2  = "dummy0"
interfaces.ifTable.ifEntry.ifDescr.3  = "tunl0"
interfaces.ifTable.ifEntry.ifDescr.4  = "gre0" Hex: 67 72 65 30
interfaces.ifTable.ifEntry.ifDescr.5  = "sit0" Hex: 73 69 74 30
interfaces.ifTable.ifEntry.ifDescr.6  = "eth0" Hex: 65 74 68 30
interfaces.ifTable.ifEntry.ifDescr.7  = "eth1" Hex: 65 74 68 31
interfaces.ifTable.ifEntry.ifDescr.8  = "eth2" Hex: 65 74 68 32
interfaces.ifTable.ifEntry.ifDescr.9  = "eth3" Hex: 65 74 68 33
interfaces.ifTable.ifEntry.ifDescr.10 = "eth4" Hex: 65 74 68 34
interfaces.ifTable.ifEntry.ifDescr.11 = "eth5" Hex: 65 74 68 35

no ip6tnl0 here, we now know why.

other_host% snmpwalk ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.127.0.0.1      = 1
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.129.16.244.5   = 2
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.129.16.6.117   = 7
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.129.16.245.1   = 8
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.129.16.245.129 = 8
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.129.16.245.193 = 8
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.129.16.245.65  = 8
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.129.16.247.1   = 9
ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.129.16.247.65  = 9

However, these Index numers are as if ip6tnl0 was there; in fact
they are correct, the ifDescr list is not.



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r 
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to