diff options
author | 2020-11-12 13:31:19 +0000 | |
---|---|---|
committer | 2020-11-12 13:31:19 +0000 | |
commit | 2362e6a47775512ed958a0f646ebf28f77abf9d3 (patch) | |
tree | 6a15c441c1542749090b4a1f6f0bb1aa1e85f36b /sys/dev/usb | |
parent | FDT-based I2C drivers should not use OF_* API in the match code, since (diff) | |
download | wireguard-openbsd-2362e6a47775512ed958a0f646ebf28f77abf9d3.tar.xz wireguard-openbsd-2362e6a47775512ed958a0f646ebf28f77abf9d3.zip |
Don't enable port or link until all crypto keys are installed by
async task(s).
Makes dhclient(8) much happier.
Suggestions and ok stsp@, jmatthew@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/if_urtwn.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/sys/dev/usb/if_urtwn.c b/sys/dev/usb/if_urtwn.c index 3ffaead61d1..4693ad37dca 100644 --- a/sys/dev/usb/if_urtwn.c +++ b/sys/dev/usb/if_urtwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_urtwn.c,v 1.94 2020/11/10 11:19:37 stsp Exp $ */ +/* $OpenBSD: if_urtwn.c,v 1.95 2020/11/12 13:31:19 krw Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> @@ -216,6 +216,7 @@ struct urtwn_softc { #define sc_txtap sc_txtapu.th int sc_txtap_len; #endif + int sc_key_tasks; }; #ifdef URTWN_DEBUG @@ -1044,7 +1045,9 @@ urtwn_set_key(struct ieee80211com *ic, struct ieee80211_node *ni, cmd.key = *k; cmd.ni = ni; urtwn_do_async(sc, urtwn_set_key_cb, &cmd, sizeof(cmd)); - return (0); + sc->sc_key_tasks++; + + return (EBUSY); } void @@ -1053,7 +1056,20 @@ urtwn_set_key_cb(struct urtwn_softc *sc, void *arg) struct ieee80211com *ic = &sc->sc_sc.sc_ic; struct urtwn_cmd_key *cmd = arg; - rtwn_set_key(ic, cmd->ni, &cmd->key); + sc->sc_key_tasks--; + + if (rtwn_set_key(ic, cmd->ni, &cmd->key) == 0) { + if (sc->sc_key_tasks == 0) { + DPRINTF(("marking port %s valid\n", + ether_sprintf(cmd->ni->ni_macaddr))); + cmd->ni->ni_port_valid = 1; + ieee80211_set_link_state(ic, LINK_STATE_UP); + } + } else { + IEEE80211_SEND_MGMT(ic, cmd->ni, IEEE80211_FC0_SUBTYPE_DEAUTH, + IEEE80211_REASON_AUTH_LEAVE); + ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); + } } void |