| Summary: | ifconfig fails if interfaces are being created during it's execution | ||
|---|---|---|---|
| Product: | Base System | Reporter: | ari.suutari |
| Component: | bin | Assignee: | Doug Ambrisko <ambrisko> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.8-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
Responsible Changed From-To: freebsd-bugs->ambrisko I've seen this local so I'm going to take it. I think I have a fix to work around the race condition by retrying a few times. State Changed From-To: open->closed Fixed this bug in -current. |
ifconfig fails with 'actual retrieval of interface table' when interfaces are being dynamically created at same time when ifconfig executes. This can happen for example when using vtund server, which receives multiple connections during startup (which causes multiple tun devices to be created and ifconfigured at same time). Fix: I think that ifconfig should check if sysctl call for interface table returns an error code which means that buffer size was too small and perform call again until buffer is large enough. I think this should fix it. We've seen this locally on 4.9. We are testing this. Fixed in ifconfig and route for -current. They both had similar issues.--U0LrIOQoscQNWAcUhBoodheeHLShN6IEvgpyX97LmydXhK7H Content-Type: text/plain; name="file.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="file.diff" Index: sbin/ifconfig/ifconfig.c =================================================================== RCS file: /usr/local/cvsroot/freebsd/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.51.2.19 diff -u -r1.51.2.19 ifconfig.c --- sbin/ifconfig/ifconfig.c 28 Jan 2003 11:02:56 -0000 1.51.2.19 +++ sbin/ifconfig/ifconfig.c 17 Mar 2004 21:56:43 -0000 @@ -427,7 +427,7 @@ { int c; int all, namesonly, downonly, uponly; - int foundit = 0, need_nl = 0; + int foundit = 0, need_nl = 0, count = 0; const struct afswtch *afp = 0; int addrcount; struct if_msghdr *ifm, *nextifm; @@ -551,6 +551,7 @@ afp = NULL; /* not a family, NULL */ } +retry: mib[0] = CTL_NET; mib[1] = PF_ROUTE; mib[2] = 0; @@ -566,8 +567,14 @@ errx(1, "iflist-sysctl-estimate"); if ((buf = malloc(needed)) == NULL) errx(1, "malloc"); - if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) + if (sysctl(mib, 6, buf, &needed, NULL, 0) < 0) { + if (errno == 12 && count++ < 10) { + warnx("Routing table grew, retrying"); + sleep(1); + goto retry; + } errx(1, "actual retrieval of interface table"); + } lim = buf + needed; next = buf; How-To-Repeat: Run a program that creates network interfaces at same time when you use ifconfig.