mac80211: use skb_queue_walk() in mesh_path_assign_nexthop
PATCH 1/2 mac80211: use skb_queue_walk() in mesh_path_assign_nexthop
Since all we really want is just to iterate over all skbs, do just that and avoid (de)queueing to a clusmy tmpq.
Signed-off-by Thomas Pedersen <[email protected]>
--- net/mac80211/mesh_pathtbl.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
net/mac80211/mesh_pathtbl.c +1 -7
@@ -203,23 +203,17 @@ void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta) {struct sk_buff *skb;struct ieee80211_hdr *hdr; -struct sk_buff_head tmpq;unsigned long flags;rcu_assign_pointer (mpath->next_hop, sta); -__skb_queue_head_init (&tmpq); -spin_lock_irqsave (&mpath->frame_queue.lock, flags); - -while ((skb =__skb_dequeue (&mpath->frame_queue)) !=NULL ) { + skb_queue_walk(&mpath->frame_queue, skb) { hdr = (struct ieee80211_hdr *) skb->data;memcpy (hdr->addr1, sta->sta.addr,ETH_ALEN );memcpy (hdr->addr2, mpath->sdata->vif.addr,ETH_ALEN ); -__skb_queue_tail (&tmpq, skb); } -skb_queue_splice (&tmpq, &mpath->frame_queue);spin_unlock_irqrestore (&mpath->frame_queue.lock, flags); }
Signature · 1 line
1.7.5.4
PATCH 2/2 mac80211: clean up mpath_move_to_queue()
Use skb_queue_walk_safe instead, and fix a few issues:
- didn't free old skbs on moving
- didn't react to failed skb alloc
- needlessly held a local pointer to the destination frame queue
- didn't check destination queue length before adding skb
Signed-off-by Thomas Pedersen <[email protected]>
--- net/mac80211/mesh.h | 3 +++ net/mac80211/mesh_hwmp.c | 2 -- net/mac80211/mesh_pathtbl.c | 36 ++++++++++++++++++++---------------- 3 files changed, 23 insertions(+), 18 deletions(-)
net/mac80211/mesh.h +3 -0
@@ -215,6 +215,9 @@ struct mesh_rmc {/* Maximum number of paths per interface */ #define MESH_MAX_MPATHS 1024 +/* Number of frames buffered per destination for unresolved destinations */ +#define MESH_FRAME_QUEUE_LEN 10 +/* Public interfaces */ /* Various */ int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
net/mac80211/mesh_hwmp.c +0 -2
@@ -17,8 +17,6 @@#define MAX_METRIC 0xffffffff#define ARITH_SHIFT 8 -/* Number of frames buffered per destination for unresolved destinations */ -#define MESH_FRAME_QUEUE_LEN 10#define MAX_PREQ_QUEUE_LEN 64/* Destination only */
net/mac80211/mesh_pathtbl.c +20 -16
@@ -279,40 +279,44 @@ static void mesh_path_move_to_queue(struct mesh_path *gate_mpath, struct mesh_path *from_mpath, bool copy) { -struct sk_buff *skb, *cp_skb =NULL ; -struct sk_buff_head gateq, failq; +struct sk_buff *skb, *fskb, *tmp; +struct sk_buff_head failq;unsigned long flags; -int num_skbs;BUG_ON (gate_mpath == from_mpath);BUG_ON (!gate_mpath->next_hop); -__skb_queue_head_init (&gateq);__skb_queue_head_init (&failq);spin_lock_irqsave (&from_mpath->frame_queue.lock, flags);skb_queue_splice_init (&from_mpath->frame_queue, &failq);spin_unlock_irqrestore (&from_mpath->frame_queue.lock, flags); - num_skbs =skb_queue_len (&failq); - -while (num_skbs--) { - skb =__skb_dequeue (&failq); -if (copy) { - cp_skb =skb_copy (skb,GFP_ATOMIC ); -if (cp_skb) -__skb_queue_tail (&failq, cp_skb); + skb_queue_walk_safe(&failq, fskb, tmp) { +if (skb_queue_len (&gate_mpath->frame_queue) >= +MESH_FRAME_QUEUE_LEN ) { +/* XXX: the approach in mesh_hwmp.c is to pop an skb +* instead, which should we do here? */ +mpath_dbg (gate_mpath->sdata,"mpath queue full!\n" ); +break ; } + skb =skb_copy (fskb,GFP_ATOMIC ); +if (WARN_ON (!skb)) +break ; +prepare_for_gate (skb, gate_mpath->dst, gate_mpath); -__skb_queue_tail (&gateq, skb); +skb_queue_tail (&gate_mpath->frame_queue, skb); + +if (copy) +continue ; + +__skb_unlink (fskb, &failq); +kfree_skb (fskb); } -spin_lock_irqsave (&gate_mpath->frame_queue.lock, flags); -skb_queue_splice (&gateq, &gate_mpath->frame_queue);mpath_dbg (gate_mpath->sdata,"Mpath queue for gate %pM has %d frames\n" , gate_mpath->dst,skb_queue_len (&gate_mpath->frame_queue)); -spin_unlock_irqrestore (&gate_mpath->frame_queue.lock, flags);if (!copy)return ;
Signature · 1 line
1.7.5.4
Quoted 2 lines · Thomas Pedersen
Since all we really want is just to iterate over all skbs, do just that and avoid (de)queueing to a clusmy tmpq.
Applied both, thanks.
johannes