From 26090443666d3ceab2f75d88550efeb67cd0461b Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 30 May 2009 19:57:31 +0000 Subject: [PATCH] o assert TDMA_MAXSLOTS is 2 so noone tries to blindly increase it o add safety belt in vdetach for failed state block allocation o fix dynamic change to tdma config; ERESTART may not result in kicking the state machine so we need to explicitly mark the beacon for update Sponsored by: --- sys/net80211/ieee80211_tdma.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/sys/net80211/ieee80211_tdma.c b/sys/net80211/ieee80211_tdma.c index 8747b4e9cd18..43f32f7fd987 100644 --- a/sys/net80211/ieee80211_tdma.c +++ b/sys/net80211/ieee80211_tdma.c @@ -104,6 +104,11 @@ __FBSDID("$FreeBSD$"); /* XXX probably should set a max */ #define TDMA_BINTVAL_VALID(_bintval) (1 <= (_bintval)) +/* + * This code is not prepared to handle more than 2 slots. + */ +CTASSERT(TDMA_MAXSLOTS == 2); + static void tdma_vdetach(struct ieee80211vap *vap); static int tdma_newstate(struct ieee80211vap *, enum ieee80211_state, int); static void tdma_beacon_miss(struct ieee80211vap *vap); @@ -187,8 +192,13 @@ tdma_vdetach(struct ieee80211vap *vap) { struct ieee80211_tdma_state *ts = vap->iv_tdma; + if (ts == NULL) { + /* NB: should not have touched any ic state */ + return; + } ts->tdma_opdetach(vap); free(vap->iv_tdma, M_80211_VAP); + vap->iv_tdma = NULL; setackpolicy(vap->iv_ic, 0); /* enable ACK's */ } @@ -764,7 +774,7 @@ tdma_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) return EINVAL; if (ireq->i_val != ts->tdma_slot) { ts->tdma_slot = ireq->i_val; - return ERESTART; + goto restart; } break; case IEEE80211_IOC_TDMA_SLOTCNT: @@ -772,7 +782,7 @@ tdma_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) return EINVAL; if (ireq->i_val != ts->tdma_slotcnt) { ts->tdma_slotcnt = ireq->i_val; - return ERESTART; + goto restart; } break; case IEEE80211_IOC_TDMA_SLOTLEN: @@ -786,7 +796,7 @@ tdma_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) return EINVAL; if (ireq->i_val != ts->tdma_slotlen) { ts->tdma_slotlen = ireq->i_val; - return ERESTART; + goto restart; } break; case IEEE80211_IOC_TDMA_BINTERVAL: @@ -794,12 +804,15 @@ tdma_ioctl_set80211(struct ieee80211vap *vap, struct ieee80211req *ireq) return EINVAL; if (ireq->i_val != ts->tdma_bintval) { ts->tdma_bintval = ireq->i_val; - return ERESTART; + goto restart; } break; default: return ENOSYS; } return 0; +restart: + ieee80211_beacon_notify(vap, IEEE80211_BEACON_TDMA); + return ERESTART; } IEEE80211_IOCTL_SET(tdma, tdma_ioctl_set80211);