summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1998-10-13 21:57:33 +0200
committerMartin Mares <mj@ucw.cz>1998-10-13 21:57:33 +0200
commitc93214d442644c9667d69f904d57aef6b4ddd47e (patch)
treeb58421542c2e9a5af3a3dd0da41170b280f57950
parentfdf33cde1cd14a2a0215d6d459489e258fe20789 (diff)
downloadbird-c93214d442644c9667d69f904d57aef6b4ddd47e.tar
bird-c93214d442644c9667d69f904d57aef6b4ddd47e.zip
o There are cases when SIOCGIFINDEX is defined, but it doesn't work. When
this happens, don't reject the whole interface, just mark it as index 0. o Removed Pavel's comment about EFAULT and SIGSEGV. EFAULT is a valid return code for cases where the buffer is too small. o Commented out the smart interface list size logic temporarily as it seems Linux 2.0 SIOCGIFCONF doesn't react to ifc_req==NULL sanely. Replaced it by exponential stepping.
-rw-r--r--TODO2
-rw-r--r--sysdep/unix/sync-if.c18
2 files changed, 13 insertions, 7 deletions
diff --git a/TODO b/TODO
index 6d58cd1..f7f336d 100644
--- a/TODO
+++ b/TODO
@@ -2,6 +2,8 @@ Core
~~~~
* router id
+- use -freg-struct-return ?
+
- fake multipath?
- config file: symbolic constants?
- counters (according to SNMP MIB?)
diff --git a/sysdep/unix/sync-if.c b/sysdep/unix/sync-if.c
index 44f93f5..4478c10 100644
--- a/sysdep/unix/sync-if.c
+++ b/sysdep/unix/sync-if.c
@@ -115,8 +115,9 @@ scan_ifs(struct ifreq *r, int cnt)
#ifdef SIOCGIFINDEX
if (ioctl(if_scan_sock, SIOCGIFINDEX, r) < 0)
- { err = "SIOCGIFINDEX"; goto faulty; }
- i.index = r->ifr_ifindex;
+ DBG("SIOCGIFINDEX failed: %m\n");
+ else
+ i.index = r->ifr_ifindex;
#endif
if_update(&i);
@@ -128,7 +129,7 @@ static void
scan_if(timer *t)
{
struct ifconf ic;
- static int last_ifbuf_size;
+ static int last_ifbuf_size = 4*sizeof(struct ifreq);
int res;
DBG("Scanning interfaces...\n");
@@ -140,7 +141,7 @@ scan_if(timer *t)
ic.ifc_ifcu.ifcu_req = r;
ic.ifc_len = last_ifbuf_size;
res = ioctl(if_scan_sock, SIOCGIFCONF, &ic);
- if (res < 0 && errno != EFAULT) /* FIXME: I would sigsegv you if I were kernel at this point */
+ if (res < 0 && errno != EFAULT)
die("SIOCCGIFCONF: %m");
if (res < last_ifbuf_size)
{
@@ -148,18 +149,21 @@ scan_if(timer *t)
break;
}
}
- ic.ifc_ifcu.ifcu_req = NULL;
+#ifdef CLEAN_WAY_WORKING_ONLY_ON_LINUX_2_1 /* FIXME */
+ ic.ifc_req = NULL;
ic.ifc_len = 999999999;
if (ioctl(if_scan_sock, SIOCGIFCONF, &ic) < 0)
die("SIOCIFCONF: %m");
- if (ic.ifc_len > 100*1024)
- die("Buf size MUCH too big: %d\n", ic.ifc_len);
ic.ifc_len += sizeof(struct ifreq);
if (last_ifbuf_size < ic.ifc_len)
{
last_ifbuf_size = ic.ifc_len;
DBG("Increased ifconf buffer size to %d\n", last_ifbuf_size);
}
+#else
+ last_ifbuf_size *= 2;
+ DBG("Increased ifconf buffer size to %d\n", last_ifbuf_size);
+#endif
}
}