A few days ago I posted the mail below. Problem:

:   ip6tnl0
:     ^
:     !
split into <ip><6tnl0> by the current code in Interface_Scan_Init().

One immediate comment was that my fix (below) would break some
interface names e.g:

    o   eth2:3
    o   eth3.4

This is true, but it's in fact true for the current algorithm as well
and in the Linux case we're all saved by the fact that /proc/net/dev
does not provide other than the "base name" e.g. eth2 & eth3.

Or at least I thought so. However, it's possible to play games like

    Linux# ip link set ip6tnl0  name ip6tnl0:23
    Linux# ip link set ip6tnl0  name ip6tnl0.24

and then the entire name shows up in /proc/net/dev. Now, what is the
"if_name part" and what is the "if_unit part" in those exemples?

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 and only do

    ./agent/mibgroup/mibII/interfaces.c

    Interface_Scan_Init(void)
    {
    ...
        /*
         * set name and interface# :
         */
        nnew->if_name = (char *) strdup(ifname);
        nnew->if_unit = strdup("");
    ...
    }

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

        Gunnar Lindberg


Reference only.

>From [EMAIL PROTECTED]  Fri May 27 10:15:51 2005
>Date: Fri, 27 May 2005 10:15:50 +0200 (MEST)
>From: Gunnar Lindberg <[EMAIL PROTECTED]>
>Message-Id: <[EMAIL PROTECTED]>
>To: [email protected]
>Subject: Linux 2.6 IPv6 interface "ip6tnl0"

>Hope this posting is OK although I'm not on this list.

>With Linux 2.6 IPv6 came a tunnel interface, "ip6tnl0".

>It breaks the code that extracts interface #, since that algorithm
>stops at the first digit and takes the rest as #, i.e. <ip><6tnl0>.

>I think the "diff -c" below is an appropriate fix.

>       Gunnar Lindberg

>*** ./agent/mibgroup/mibII/interfaces.c.ORIG   Mon Jan  3 16:51:32 2005
>--- ./agent/mibgroup/mibII/interfaces.c        Fri May 27 06:04:06 2005
>***************
>*** 1574,1581 ****
>--- 1574,1597 ----
>           * set name and interface# : 
>           */
>          nnew->if_name = (char *) strdup(ifname);
>+ #ifdef       notdef
>+      /* this fails for e.g. "ip6tnl0"                        */
>          for (ptr = nnew->if_name; *ptr && (*ptr < '0' || *ptr > '9');
>               ptr++);
>+ #endif       /* notdef */
>+ 
>+      ptr = nnew->if_name;
>+      /* start from end of string                             */
>+      while (*ptr)
>+          ptr++;
>+      /* trailing digits are interface #                      */
>+      while (ptr != nnew->if_name)
>+      {
>+          ptr--;
>+          if (*ptr < '0' || *ptr > '9')
>+              break;
>+      }
>+      ptr++;
>          nnew->if_unit = strdup(*ptr ? ptr : "");
>          *ptr = 0;
>  



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to