summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2011-11-23 09:03:24 +0000
committerRoy Marples <roy@marples.name>2011-11-23 09:03:24 +0000
commit126abb55cf19c543fe414e23bb26c71b43513d8f (patch)
treef2b23877d8252d81933095ab3176603176a56e55 /dhcpcd.c
parent499225e43fdd093c6bc0c9f37ffb25cd5af97cb1 (diff)
downloaddhcpcd-126abb55cf19c543fe414e23bb26c71b43513d8f.tar.xz
Respect each kernel message on carrier change instead of checking carrier
after receiving the message as it's possible for the kernel to react faster than dhcpcd.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 97ad6c6e..80aa04ad 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -871,8 +871,8 @@ configure_interface(struct interface *iface, int argc, char **argv)
configure_interface1(iface);
}
-static void
-handle_carrier(const char *ifname)
+void
+handle_carrier(int action, int flags, const char *ifname)
{
struct interface *iface;
int carrier;
@@ -882,9 +882,19 @@ handle_carrier(const char *ifname)
for (iface = ifaces; iface; iface = iface->next)
if (strcmp(iface->name, ifname) == 0)
break;
- if (!iface || !(iface->state->options->options & DHCPCD_LINK))
+ if (!iface) {
+ if (options & DHCPCD_LINK)
+ handle_interface(1, ifname);
+ return;
+ }
+ if (!(iface->state->options->options & DHCPCD_LINK))
return;
- carrier = carrier_status(iface);
+ if (action == 0)
+ carrier = carrier_status(iface);
+ else {
+ carrier = action == 1 ? 1 : 0;
+ iface->flags = flags;
+ }
if (carrier == -1)
syslog(LOG_ERR, "%s: carrier_status: %m", ifname);
else if (carrier == 0 || !(iface->flags & IFF_RUNNING)) {
@@ -1127,7 +1137,7 @@ start_interface(void *arg)
uint32_t l;
int nolease;
- handle_carrier(iface->name);
+ handle_carrier(0, 0, iface->name);
if (iface->carrier == LINK_DOWN) {
syslog(LOG_INFO, "%s: waiting for carrier", iface->name);
return;
@@ -1255,9 +1265,6 @@ handle_interface(int action, const char *ifname)
if (ifp != NULL)
stop_interface(ifp);
return;
- } else if (action == 0) {
- handle_carrier(ifname);
- return;
}
/* If running off an interface list, check it's in it. */
@@ -2030,7 +2037,7 @@ main(int argc, char **argv)
ts.tv_nsec = 0;
nanosleep(&ts, NULL);
for (iface = ifaces; iface; iface = iface->next) {
- handle_carrier(iface->name);
+ handle_carrier(0, 0, iface->name);
if (iface->carrier != LINK_DOWN) {
opt = 1;
break;