353-mac80211-mesh-drop-redundant-rcu_read_lock-unlock-ca.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. From: Felix Fietkau <nbd@nbd.name>
  2. Date: Sat, 16 Mar 2019 17:43:58 +0100
  3. Subject: [PATCH] mac80211: mesh: drop redundant rcu_read_lock/unlock calls
  4. The callers of these functions are all within RCU locked sections
  5. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  6. ---
  7. --- a/net/mac80211/mesh_hwmp.c
  8. +++ b/net/mac80211/mesh_hwmp.c
  9. @@ -1115,16 +1115,13 @@ int mesh_nexthop_resolve(struct ieee8021
  10. struct mesh_path *mpath;
  11. struct sk_buff *skb_to_free = NULL;
  12. u8 *target_addr = hdr->addr3;
  13. - int err = 0;
  14. /* Nulls are only sent to peers for PS and should be pre-addressed */
  15. if (ieee80211_is_qos_nullfunc(hdr->frame_control))
  16. return 0;
  17. - rcu_read_lock();
  18. - err = mesh_nexthop_lookup(sdata, skb);
  19. - if (!err)
  20. - goto endlookup;
  21. + if (!mesh_nexthop_lookup(sdata, skb))
  22. + return 0;
  23. /* no nexthop found, start resolving */
  24. mpath = mesh_path_lookup(sdata, target_addr);
  25. @@ -1132,8 +1129,7 @@ int mesh_nexthop_resolve(struct ieee8021
  26. mpath = mesh_path_add(sdata, target_addr);
  27. if (IS_ERR(mpath)) {
  28. mesh_path_discard_frame(sdata, skb);
  29. - err = PTR_ERR(mpath);
  30. - goto endlookup;
  31. + return PTR_ERR(mpath);
  32. }
  33. }
  34. @@ -1147,13 +1143,10 @@ int mesh_nexthop_resolve(struct ieee8021
  35. info->flags |= IEEE80211_TX_INTFL_NEED_TXPROCESSING;
  36. ieee80211_set_qos_hdr(sdata, skb);
  37. skb_queue_tail(&mpath->frame_queue, skb);
  38. - err = -ENOENT;
  39. if (skb_to_free)
  40. mesh_path_discard_frame(sdata, skb_to_free);
  41. -endlookup:
  42. - rcu_read_unlock();
  43. - return err;
  44. + return -ENOENT;
  45. }
  46. /**
  47. @@ -1173,13 +1166,10 @@ int mesh_nexthop_lookup(struct ieee80211
  48. struct sta_info *next_hop;
  49. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  50. u8 *target_addr = hdr->addr3;
  51. - int err = -ENOENT;
  52. - rcu_read_lock();
  53. mpath = mesh_path_lookup(sdata, target_addr);
  54. -
  55. if (!mpath || !(mpath->flags & MESH_PATH_ACTIVE))
  56. - goto endlookup;
  57. + return -ENOENT;
  58. if (time_after(jiffies,
  59. mpath->exp_time -
  60. @@ -1194,12 +1184,10 @@ int mesh_nexthop_lookup(struct ieee80211
  61. memcpy(hdr->addr1, next_hop->sta.addr, ETH_ALEN);
  62. memcpy(hdr->addr2, sdata->vif.addr, ETH_ALEN);
  63. ieee80211_mps_set_frame_flags(sdata, next_hop, hdr);
  64. - err = 0;
  65. + return 0;
  66. }
  67. -endlookup:
  68. - rcu_read_unlock();
  69. - return err;
  70. + return -ENOENT;
  71. }
  72. void mesh_path_timer(struct timer_list *t)
  73. --- a/net/mac80211/mesh_pathtbl.c
  74. +++ b/net/mac80211/mesh_pathtbl.c
  75. @@ -219,7 +219,7 @@ static struct mesh_path *mpath_lookup(st
  76. {
  77. struct mesh_path *mpath;
  78. - mpath = rhashtable_lookup_fast(&tbl->rhead, dst, mesh_rht_params);
  79. + mpath = rhashtable_lookup(&tbl->rhead, dst, mesh_rht_params);
  80. if (mpath && mpath_expired(mpath)) {
  81. spin_lock_bh(&mpath->state_lock);