]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net/mac80211/mesh_plink: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Thu, 5 Oct 2017 17:39:10 +0000 (10:39 -0700)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 6 Oct 2017 09:47:52 +0000 (11:47 +0200)
In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. This requires adding a pointer back
to the sta_info since container_of() can't resolve the sta_info.

Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/mesh.h
net/mac80211/mesh_plink.c
net/mac80211/sta_info.c
net/mac80211/sta_info.h

index 7e5f271e3c30dbf960b78aecb87afeaff9d347c3..465b7853edc0b1c85a2145f2b248c81f86fb92eb 100644 (file)
@@ -275,6 +275,7 @@ void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
                           u8 *hw_addr, struct ieee802_11_elems *ie);
 bool mesh_peer_accepts_plinks(struct ieee802_11_elems *ie);
 u32 mesh_accept_plinks_update(struct ieee80211_sub_if_data *sdata);
+void mesh_plink_timer(struct timer_list *t);
 void mesh_plink_broken(struct sta_info *sta);
 u32 mesh_plink_deactivate(struct sta_info *sta);
 u32 mesh_plink_open(struct sta_info *sta);
index dc8e10f872070353f74aabbf00ca164325b30e86..e2d00cce3c17448f07d882d8d9cf9a98307aa661 100644 (file)
@@ -603,8 +603,9 @@ void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
        ieee80211_mbss_info_change_notify(sdata, changed);
 }
 
-static void mesh_plink_timer(unsigned long data)
+void mesh_plink_timer(struct timer_list *t)
 {
+       struct mesh_sta *mesh = from_timer(mesh, t, plink_timer);
        struct sta_info *sta;
        u16 reason = 0;
        struct ieee80211_sub_if_data *sdata;
@@ -616,7 +617,7 @@ static void mesh_plink_timer(unsigned long data)
         * del_timer_sync() this timer after having made sure
         * it cannot be readded (by deleting the plink.)
         */
-       sta = (struct sta_info *) data;
+       sta = mesh->plink_sta;
 
        if (sta->sdata->local->quiescing)
                return;
@@ -696,11 +697,8 @@ static void mesh_plink_timer(unsigned long data)
 
 static inline void mesh_plink_timer_set(struct sta_info *sta, u32 timeout)
 {
-       sta->mesh->plink_timer.expires = jiffies + msecs_to_jiffies(timeout);
-       sta->mesh->plink_timer.data = (unsigned long) sta;
-       sta->mesh->plink_timer.function = mesh_plink_timer;
        sta->mesh->plink_timeout = timeout;
-       add_timer(&sta->mesh->plink_timer);
+       mod_timer(&sta->mesh->plink_timer, jiffies + msecs_to_jiffies(timeout));
 }
 
 static bool llid_in_use(struct ieee80211_sub_if_data *sdata,
index ffcd25c4908cc4e97959649158956fe035cea452..9673e157bf8fd5be8f85277dfd41c0b46d634e17 100644 (file)
@@ -329,10 +329,12 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
                sta->mesh = kzalloc(sizeof(*sta->mesh), gfp);
                if (!sta->mesh)
                        goto free;
+               sta->mesh->plink_sta = sta;
                spin_lock_init(&sta->mesh->plink_lock);
                if (ieee80211_vif_is_mesh(&sdata->vif) &&
                    !sdata->u.mesh.user_mpm)
-                       init_timer(&sta->mesh->plink_timer);
+                       timer_setup(&sta->mesh->plink_timer, mesh_plink_timer,
+                                   0);
                sta->mesh->nonpeer_pm = NL80211_MESH_POWER_ACTIVE;
        }
 #endif
index a35c964f6217acd366f83f1a0fa291b731bb3cfe..5c54acd10562a66df8aa093b9352d097cadb17b9 100644 (file)
@@ -344,6 +344,7 @@ DECLARE_EWMA(mesh_fail_avg, 20, 8)
  * @plink_state: peer link state
  * @plink_timeout: timeout of peer link
  * @plink_timer: peer link watch timer
+ * @plink_sta: peer link watch timer's sta_info
  * @t_offset: timing offset relative to this host
  * @t_offset_setpoint: reference timing offset of this sta to be used when
  *     calculating clockdrift
@@ -356,6 +357,7 @@ DECLARE_EWMA(mesh_fail_avg, 20, 8)
  */
 struct mesh_sta {
        struct timer_list plink_timer;
+       struct sta_info *plink_sta;
 
        s64 t_offset;
        s64 t_offset_setpoint;