Skip to contentSkip to conversation

libnfnetlink list of interfaces

DISCUSSION Kuzin Andrey 2 participants 2 messages Oct 3, 2009 – Oct 5, 2009 netfilter

lore
Share & tools
lore
#0 lore raw

I use nlif_index2name() to get interfaces list in my programm. After uptime 44 days and many reconnections by vtund i can't get tun/tap interfaces numbers.

For example output of iftest (example in nfnetlink library):

root@banana:/tmp/tgz/libnfnetlink-1.0.0/utils# ./iftest
index (1) is lo (RUNNING)
index (2) is eth0 (RUNNING)
index (3) is eth1 (RUNNING)
index (4) is eth2 (NOT RUNNING)
index (5) is eth3 (RUNNING)
index (6) is teql0 (NOT RUNNING)
index (7) is tunl0 (NOT RUNNING)
index (8) is gre0 (NOT RUNNING)
index (9) is eth0.11 (RUNNING)
index (10) is eth0.14 (RUNNING)
index (11) is eth0.15 (RUNNING)
index (12) is eth0.2 (RUNNING)
index (13) is eth0.5 (RUNNING)

Output by ifconfig:

eth0      Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth0:1    Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth0:2    Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth0:3    Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth1      Link encap:Ethernet  HWaddr 00:22:15:39:a3:34
eth2      Link encap:Ethernet  HWaddr 00:22:15:39:a3:35
eth3      Link encap:Ethernet  HWaddr 00:22:15:39:a3:36
eth0.2    Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth0.5    Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth0.11   Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth0.14   Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth0.14:1 Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
eth0.15   Link encap:Ethernet  HWaddr 00:22:15:39:a3:33
lo        Link encap:Local Loopback
tun1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
tun2      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00

In iftest.c we have:

      for (i=0; i<64; i++) {
            char name[IFNAMSIZ];
            unsigned int flags;

            if (nlif_index2name(h, i, name) == -1)
                  continue;
            if (nlif_get_ifflags(h, i, &flags) == -1)
                  continue;
            printf("index (%d) is %s (%s)\n", i, name,
                  flags & IFF_RUNNING ? "RUNNING" : "NOT RUNNING");
      }

Only 64 interfaces numbers checked. It mean that tun ifaces have number greater than 64.

I think libnfnetlink need better way to get list of interfaces, better than stupid checking random number by nlif_index2name.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Kuzin Andrey - [email protected]
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

#1 lore raw

Hi,

Quoted 5 lines · Kuzin Andrey

I use nlif_index2name() to get interfaces list in my programm. After uptime 44 days and many reconnections by vtund i can't get tun/tap interfaces numbers.

For example output of iftest (example in nfnetlink library):

As mentionned in its name, iftest is for testing. It is not supposed to do the complete job.

Quoted 5 lines
root@banana:/tmp/tgz/libnfnetlink-1.0.0/utils# ./iftest
index (1) is lo (RUNNING)
index (2) is eth0 (RUNNING)
index (3) is eth1 (RUNNING)

....

Quoted 13 lines

In iftest.c we have:

      for (i=0; i<64; i++) {
            char name[IFNAMSIZ];
            unsigned int flags;

            if (nlif_index2name(h, i, name) == -1)
                  continue;
            if (nlif_get_ifflags(h, i, &flags) == -1)
                  continue;
            printf("index (%d) is %s (%s)\n", i, name,
                  flags & IFF_RUNNING ? "RUNNING" : "NOT RUNNING");
      }
Quoted 2 lines

Only 64 interfaces numbers checked. It mean that tun ifaces have number greater than 64.

Yes, see previous remark.

Quoted 3 lines

I think libnfnetlink need better way to get list of interfaces, better than stupid checking random number by nlif_index2name.

What do you mean here ?

BR,

Signature · 9 lines
Eric Leblond <[email protected]>
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/
EdenWall: http://www.edenwall.com/

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html