328-mac80211-let-unused-MPP-table-entries-timeout.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. From: Henning Rogge <hrogge@gmail.com>
  2. Date: Wed, 3 Feb 2016 13:58:37 +0100
  3. Subject: [PATCH] mac80211: let unused MPP table entries timeout
  4. Remember the last time when a mpp table entry is used for
  5. rx or tx and remove them after MESH_PATH_EXPIRE time.
  6. Acked-by: Bob Copeland <me@bobcopeland.com>
  7. Signed-off-by: Henning Rogge <henning.rogge@fkie.fraunhofer.de>
  8. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  9. ---
  10. --- a/net/mac80211/mesh_pathtbl.c
  11. +++ b/net/mac80211/mesh_pathtbl.c
  12. @@ -942,6 +942,46 @@ enddel:
  13. }
  14. /**
  15. + * mpp_path_del - delete a mesh proxy path from the table
  16. + *
  17. + * @addr: addr address (ETH_ALEN length)
  18. + * @sdata: local subif
  19. + *
  20. + * Returns: 0 if successful
  21. + */
  22. +static int mpp_path_del(struct ieee80211_sub_if_data *sdata, const u8 *addr)
  23. +{
  24. + struct mesh_table *tbl;
  25. + struct mesh_path *mpath;
  26. + struct mpath_node *node;
  27. + struct hlist_head *bucket;
  28. + int hash_idx;
  29. + int err = 0;
  30. +
  31. + read_lock_bh(&pathtbl_resize_lock);
  32. + tbl = resize_dereference_mpp_paths();
  33. + hash_idx = mesh_table_hash(addr, sdata, tbl);
  34. + bucket = &tbl->hash_buckets[hash_idx];
  35. +
  36. + spin_lock(&tbl->hashwlock[hash_idx]);
  37. + hlist_for_each_entry(node, bucket, list) {
  38. + mpath = node->mpath;
  39. + if (mpath->sdata == sdata &&
  40. + ether_addr_equal(addr, mpath->dst)) {
  41. + __mesh_path_del(tbl, node);
  42. + goto enddel;
  43. + }
  44. + }
  45. +
  46. + err = -ENXIO;
  47. +enddel:
  48. + mesh_paths_generation++;
  49. + spin_unlock(&tbl->hashwlock[hash_idx]);
  50. + read_unlock_bh(&pathtbl_resize_lock);
  51. + return err;
  52. +}
  53. +
  54. +/**
  55. * mesh_path_tx_pending - sends pending frames in a mesh path queue
  56. *
  57. * @mpath: mesh path to activate
  58. @@ -1157,6 +1197,17 @@ void mesh_path_expire(struct ieee80211_s
  59. time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE))
  60. mesh_path_del(mpath->sdata, mpath->dst);
  61. }
  62. +
  63. + tbl = rcu_dereference(mpp_paths);
  64. + for_each_mesh_entry(tbl, node, i) {
  65. + if (node->mpath->sdata != sdata)
  66. + continue;
  67. + mpath = node->mpath;
  68. + if ((!(mpath->flags & MESH_PATH_FIXED)) &&
  69. + time_after(jiffies, mpath->exp_time + MESH_PATH_EXPIRE))
  70. + mpp_path_del(mpath->sdata, mpath->dst);
  71. + }
  72. +
  73. rcu_read_unlock();
  74. }
  75. --- a/net/mac80211/rx.c
  76. +++ b/net/mac80211/rx.c
  77. @@ -2291,6 +2291,7 @@ ieee80211_rx_h_mesh_fwding(struct ieee80
  78. spin_lock_bh(&mppath->state_lock);
  79. if (!ether_addr_equal(mppath->mpp, mpp_addr))
  80. memcpy(mppath->mpp, mpp_addr, ETH_ALEN);
  81. + mppath->exp_time = jiffies;
  82. spin_unlock_bh(&mppath->state_lock);
  83. }
  84. rcu_read_unlock();
  85. --- a/net/mac80211/tx.c
  86. +++ b/net/mac80211/tx.c
  87. @@ -2171,8 +2171,11 @@ static struct sk_buff *ieee80211_build_h
  88. mpp_lookup = true;
  89. }
  90. - if (mpp_lookup)
  91. + if (mpp_lookup) {
  92. mppath = mpp_path_lookup(sdata, skb->data);
  93. + if (mppath)
  94. + mppath->exp_time = jiffies;
  95. + }
  96. if (mppath && mpath)
  97. mesh_path_del(mpath->sdata, mpath->dst);