Handle cases when SIOCGIFINDEX is defined, but doesn't work (new glibc

with 2.0 kernels).
This commit is contained in:
Martin Mares 1999-12-16 13:23:32 +00:00
parent 3f996d46df
commit e693ddff87
2 changed files with 6 additions and 8 deletions

2
TODO
View file

@ -17,8 +17,6 @@ Core
- netlink: import Linux route attributes to our rta's, so that they can be filtered? - netlink: import Linux route attributes to our rta's, so that they can be filtered?
- iface: SIOCGIFINDEX exists on glibc systems, but it doesn't work on 2.0.x kernels!
- socket: Use IP_RECVERR for BGP TCP sockets? - socket: Use IP_RECVERR for BGP TCP sockets?
- config: executable config files - config: executable config files

View file

@ -36,11 +36,11 @@ scan_ifs(struct ifreq *r, int cnt)
unsigned fl; unsigned fl;
ip_addr netmask; ip_addr netmask;
int l; int l;
int sec = 0;
if_start_update(); if_start_update();
for (cnt /= sizeof(struct ifreq); cnt; cnt--, r++) for (cnt /= sizeof(struct ifreq); cnt; cnt--, r++)
{ {
int sec = 0;
bzero(&i, sizeof(i)); bzero(&i, sizeof(i));
bzero(&a, sizeof(a)); bzero(&a, sizeof(a));
DBG("%s\n", r->ifr_name); DBG("%s\n", r->ifr_name);
@ -136,11 +136,12 @@ scan_ifs(struct ifreq *r, int cnt)
i.mtu = r->ifr_mtu; i.mtu = r->ifr_mtu;
#ifdef SIOCGIFINDEX #ifdef SIOCGIFINDEX
if (ioctl(if_scan_sock, SIOCGIFINDEX, r) < 0) if (ioctl(if_scan_sock, SIOCGIFINDEX, r) >= 0)
DBG("SIOCGIFINDEX failed: %m\n");
else
i.index = r->ifr_ifindex; i.index = r->ifr_ifindex;
#else else if (errno != -EINVAL)
DBG("SIOCGIFINDEX failed: %m\n");
else /* defined, but not supported by the kernel */
#endif
/* /*
* The kernel doesn't give us real ifindices, but we still need them * The kernel doesn't give us real ifindices, but we still need them
* at least for OSPF unnumbered links. So let's make them up ourselves. * at least for OSPF unnumbered links. So let's make them up ourselves.
@ -152,7 +153,6 @@ scan_ifs(struct ifreq *r, int cnt)
static int if_index_counter = 1; static int if_index_counter = 1;
i.index = if_index_counter++; i.index = if_index_counter++;
} }
#endif
pi = NULL; pi = NULL;
if (sec) if (sec)