PERFORCE change 137936 for review
Sam Leffler
sam at FreeBSD.org
Mon Mar 17 18:57:16 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=137936
Change 137936 by sam at sam_ebb on 2008/03/17 18:56:44
Defer state change on disassociate to avoid unnecessarily dropping
the lease; we set a timer on disassociate and if we re-associate
to the same ap then we just continue using the current lease; otherwise
we reboot the state machine as before.
May need to tweak the timer and/or fix other edge cases in the
dhcp state machine but I think link state change events should
handle other reasons to clock the state machine.
Affected files ...
.. //depot/projects/vap/sbin/dhclient/dhclient.c#4 edit
Differences ...
==== //depot/projects/vap/sbin/dhclient/dhclient.c#4 (text+ko) ====
@@ -176,8 +176,30 @@
return (NULL);
}
+
struct iaddr defaddr = { 4 };
+uint8_t curbssid[6];
+
+static void
+disassoc(void *arg)
+{
+ struct interface_info *ifi = arg;
+ /*
+ * Clear existing state.
+ */
+ if (ifi->client->active != NULL) {
+ script_init("EXPIRE", NULL);
+ script_write_params("old_",
+ ifi->client->active);
+ if (ifi->client->alias)
+ script_write_params("alias_",
+ ifi->client->alias);
+ script_go();
+ }
+ ifi->client->state = S_INIT;
+}
+
/* ARGSUSED */
void
routehandler(struct protocol *p)
@@ -187,6 +209,7 @@
struct if_msghdr *ifm;
struct ifa_msghdr *ifam;
struct if_announcemsghdr *ifan;
+ struct ieee80211_join_event *jev;
struct client_lease *l;
time_t t = time(NULL);
struct sockaddr *sa;
@@ -255,24 +278,28 @@
switch (ifan->ifan_what) {
case RTM_IEEE80211_ASSOC:
case RTM_IEEE80211_REASSOC:
+ cancel_timeout(disassoc, ifi);
+ jev = (struct ieee80211_join_event *) &ifan[1];
+ if (memcmp(curbssid, jev->iev_addr, 6))
+ disassoc(ifi);
state_reboot(ifi);
+ memcpy(curbssid, jev->iev_addr, 6);
break;
case RTM_IEEE80211_DISASSOC:
/*
- * Clear existing state; transition to the init
- * state and then wait for either a link down
- * notification or an associate event.
+ * Defer state change in case we are re-associating
+ * to the same ap after a deauth (e.g. due to being
+ * idle). We'll get an associate event and if we
+ * roamed we'll handle it (see above). Otherwise we'll
+ * eventually clear state. The only question is how
+ * long to wait before doing this. Give it 45 seconds
+ * as this should be plenty to scan multiple bands
+ * and complete a WPA handshake. If this event is a
+ * precursor to our being marked down or the interface
+ * going away that'll be handled by the link state
+ * change.
*/
- if (ifi->client->active != NULL) {
- script_init("EXPIRE", NULL);
- script_write_params("old_",
- ifi->client->active);
- if (ifi->client->alias)
- script_write_params("alias_",
- ifi->client->alias);
- script_go();
- }
- ifi->client->state = S_INIT;
+ add_timeout(t+45, disassoc, ifi);
break;
}
break;
More information about the p4-projects
mailing list