aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2009-11-17 07:34:04 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-11-18 17:09:18 -0500
commit15ff63653e507ec928a4a4386405a82446e096b1 (patch)
tree4e2ac0e39ab2142ae5115c4f1067e2962190e696
parentd84f323477260e773d5317ad7cbe50f76115cb47 (diff)
mac80211: use fixed broadcast address
The netdev broadcast address cannot change from all-ones so there's no need to use it; we can instead hard-code it. Since we already have an instance in tkip.c, which will be shared if it is marked static const, doing this reduces text size at no data/bss cost. The real motivation for this is, of course, the desire to get rid of almost all uses of netdevs in mac80211 so that auditing their use becomes easier. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--net/mac80211/mesh.c5
-rw-r--r--net/mac80211/mesh.h4
-rw-r--r--net/mac80211/mesh_hwmp.c20
-rw-r--r--net/mac80211/mesh_pathtbl.c3
-rw-r--r--net/mac80211/tkip.c4
-rw-r--r--net/mac80211/tx.c10
6 files changed, 27 insertions, 19 deletions
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index bbd56b087899..3a0683ba357b 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -394,8 +394,9 @@ void ieee80211_mesh_root_setup(struct ieee80211_if_mesh *ifmsh)
394 * 394 *
395 * Return the length of the 802.11 (does not include a mesh control header) 395 * Return the length of the 802.11 (does not include a mesh control header)
396 */ 396 */
397int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, char 397int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
398 *meshda, char *meshsa) { 398 const u8 *meshda, const u8 *meshsa)
399{
399 if (is_multicast_ether_addr(meshda)) { 400 if (is_multicast_ether_addr(meshda)) {
400 *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS); 401 *fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
401 /* DA TA SA */ 402 /* DA TA SA */
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h
index bd0e1cbb9a1e..31e102541869 100644
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -220,7 +220,7 @@ struct mesh_rmc {
220/* Public interfaces */ 220/* Public interfaces */
221/* Various */ 221/* Various */
222int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc, 222int ieee80211_fill_mesh_addresses(struct ieee80211_hdr *hdr, __le16 *fc,
223 char *da, char *sa); 223 const u8 *da, const u8 *sa);
224int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr, 224int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
225 struct ieee80211_sub_if_data *sdata, char *addr4, 225 struct ieee80211_sub_if_data *sdata, char *addr4,
226 char *addr5, char *addr6); 226 char *addr5, char *addr6);
@@ -284,7 +284,7 @@ u32 mesh_table_hash(u8 *addr, struct ieee80211_sub_if_data *sdata,
284 struct mesh_table *tbl); 284 struct mesh_table *tbl);
285/* Mesh paths */ 285/* Mesh paths */
286int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode, 286int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, __le16 target_rcode,
287 u8 *ra, struct ieee80211_sub_if_data *sdata); 287 const u8 *ra, struct ieee80211_sub_if_data *sdata);
288void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta); 288void mesh_path_assign_nexthop(struct mesh_path *mpath, struct sta_info *sta);
289void mesh_path_flush_pending(struct mesh_path *mpath); 289void mesh_path_flush_pending(struct mesh_path *mpath);
290void mesh_path_tx_pending(struct mesh_path *mpath); 290void mesh_path_tx_pending(struct mesh_path *mpath);
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 5c67e7b8790f..d93019874e41 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -101,10 +101,12 @@ enum mpath_frame_type {
101 MPATH_RANN 101 MPATH_RANN
102}; 102};
103 103
104static const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
105
104static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags, 106static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
105 u8 *orig_addr, __le32 orig_sn, u8 target_flags, u8 *target, 107 u8 *orig_addr, __le32 orig_sn, u8 target_flags, u8 *target,
106 __le32 target_sn, u8 *da, u8 hop_count, u8 ttl,__le32 lifetime, 108 __le32 target_sn, const u8 *da, u8 hop_count, u8 ttl,
107 __le32 metric, __le32 preq_id, 109 __le32 lifetime, __le32 metric, __le32 preq_id,
108 struct ieee80211_sub_if_data *sdata) 110 struct ieee80211_sub_if_data *sdata)
109{ 111{
110 struct ieee80211_local *local = sdata->local; 112 struct ieee80211_local *local = sdata->local;
@@ -198,8 +200,8 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
198 * @ra: node this frame is addressed to 200 * @ra: node this frame is addressed to
199 */ 201 */
200int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn, 202int mesh_path_error_tx(u8 ttl, u8 *target, __le32 target_sn,
201 __le16 target_rcode, u8 *ra, 203 __le16 target_rcode, const u8 *ra,
202 struct ieee80211_sub_if_data *sdata) 204 struct ieee80211_sub_if_data *sdata)
203{ 205{
204 struct ieee80211_local *local = sdata->local; 206 struct ieee80211_local *local = sdata->local;
205 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 207 struct sk_buff *skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
@@ -548,7 +550,7 @@ static void hwmp_preq_frame_process(struct ieee80211_sub_if_data *sdata,
548 hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1; 550 hopcount = PREQ_IE_HOPCOUNT(preq_elem) + 1;
549 mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr, 551 mesh_path_sel_frame_tx(MPATH_PREQ, flags, orig_addr,
550 cpu_to_le32(orig_sn), target_flags, target_addr, 552 cpu_to_le32(orig_sn), target_flags, target_addr,
551 cpu_to_le32(target_sn), sdata->dev->broadcast, 553 cpu_to_le32(target_sn), broadcast_addr,
552 hopcount, ttl, cpu_to_le32(lifetime), 554 hopcount, ttl, cpu_to_le32(lifetime),
553 cpu_to_le32(metric), cpu_to_le32(preq_id), 555 cpu_to_le32(metric), cpu_to_le32(preq_id),
554 sdata); 556 sdata);
@@ -660,7 +662,7 @@ static void hwmp_perr_frame_process(struct ieee80211_sub_if_data *sdata,
660 spin_unlock_bh(&mpath->state_lock); 662 spin_unlock_bh(&mpath->state_lock);
661 mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn), 663 mesh_path_error_tx(ttl, target_addr, cpu_to_le32(target_sn),
662 cpu_to_le16(target_rcode), 664 cpu_to_le16(target_rcode),
663 sdata->dev->broadcast, sdata); 665 broadcast_addr, sdata);
664 } else 666 } else
665 spin_unlock_bh(&mpath->state_lock); 667 spin_unlock_bh(&mpath->state_lock);
666 } 668 }
@@ -709,7 +711,7 @@ static void hwmp_rann_frame_process(struct ieee80211_sub_if_data *sdata,
709 if (mpath->sn < orig_sn) { 711 if (mpath->sn < orig_sn) {
710 mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr, 712 mesh_path_sel_frame_tx(MPATH_RANN, flags, orig_addr,
711 cpu_to_le32(orig_sn), 713 cpu_to_le32(orig_sn),
712 0, NULL, 0, sdata->dev->broadcast, 714 0, NULL, 0, broadcast_addr,
713 hopcount, ttl, 0, 715 hopcount, ttl, 0,
714 cpu_to_le32(metric + mpath->metric), 716 cpu_to_le32(metric + mpath->metric),
715 0, sdata); 717 0, sdata);
@@ -890,7 +892,7 @@ void mesh_path_start_discovery(struct ieee80211_sub_if_data *sdata)
890 spin_unlock_bh(&mpath->state_lock); 892 spin_unlock_bh(&mpath->state_lock);
891 mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr, 893 mesh_path_sel_frame_tx(MPATH_PREQ, 0, sdata->dev->dev_addr,
892 cpu_to_le32(ifmsh->sn), target_flags, mpath->dst, 894 cpu_to_le32(ifmsh->sn), target_flags, mpath->dst,
893 cpu_to_le32(mpath->sn), sdata->dev->broadcast, 0, 895 cpu_to_le32(mpath->sn), broadcast_addr, 0,
894 ttl, cpu_to_le32(lifetime), 0, 896 ttl, cpu_to_le32(lifetime), 0,
895 cpu_to_le32(ifmsh->preq_id++), sdata); 897 cpu_to_le32(ifmsh->preq_id++), sdata);
896 mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout); 898 mod_timer(&mpath->timer, jiffies + mpath->discovery_timeout);
@@ -1011,6 +1013,6 @@ mesh_path_tx_root_frame(struct ieee80211_sub_if_data *sdata)
1011 1013
1012 mesh_path_sel_frame_tx(MPATH_RANN, 0, sdata->dev->dev_addr, 1014 mesh_path_sel_frame_tx(MPATH_RANN, 0, sdata->dev->dev_addr,
1013 cpu_to_le32(++ifmsh->sn), 1015 cpu_to_le32(++ifmsh->sn),
1014 0, NULL, 0, sdata->dev->broadcast, 1016 0, NULL, 0, broadcast_addr,
1015 0, MESH_TTL, 0, 0, 0, sdata); 1017 0, MESH_TTL, 0, 0, 0, sdata);
1016} 1018}
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 5399e7a9ec6e..3fbabbf34ea5 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -449,6 +449,7 @@ err_path_alloc:
449 */ 449 */
450void mesh_plink_broken(struct sta_info *sta) 450void mesh_plink_broken(struct sta_info *sta)
451{ 451{
452 static const u8 bcast[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
452 struct mesh_path *mpath; 453 struct mesh_path *mpath;
453 struct mpath_node *node; 454 struct mpath_node *node;
454 struct hlist_node *p; 455 struct hlist_node *p;
@@ -468,7 +469,7 @@ void mesh_plink_broken(struct sta_info *sta)
468 mesh_path_error_tx(MESH_TTL, mpath->dst, 469 mesh_path_error_tx(MESH_TTL, mpath->dst,
469 cpu_to_le32(mpath->sn), 470 cpu_to_le32(mpath->sn),
470 PERR_RCODE_DEST_UNREACH, 471 PERR_RCODE_DEST_UNREACH,
471 sdata->dev->broadcast, sdata); 472 bcast, sdata);
472 } else 473 } else
473 spin_unlock_bh(&mpath->state_lock); 474 spin_unlock_bh(&mpath->state_lock);
474 } 475 }
diff --git a/net/mac80211/tkip.c b/net/mac80211/tkip.c
index 964b7faa7f17..4921d724b6c7 100644
--- a/net/mac80211/tkip.c
+++ b/net/mac80211/tkip.c
@@ -301,9 +301,9 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
301#endif 301#endif
302 if (key->local->ops->update_tkip_key && 302 if (key->local->ops->update_tkip_key &&
303 key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) { 303 key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) {
304 u8 bcast[ETH_ALEN] = 304 static const u8 bcast[ETH_ALEN] =
305 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; 305 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
306 u8 *sta_addr = key->sta->sta.addr; 306 const u8 *sta_addr = key->sta->sta.addr;
307 307
308 if (is_multicast_ether_addr(ra)) 308 if (is_multicast_ether_addr(ra))
309 sta_addr = bcast; 309 sta_addr = bcast;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 375cecc837a1..3466e1f7fd12 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1683,21 +1683,25 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1683 /* packet from other interface */ 1683 /* packet from other interface */
1684 struct mesh_path *mppath; 1684 struct mesh_path *mppath;
1685 int is_mesh_mcast = 1; 1685 int is_mesh_mcast = 1;
1686 char *mesh_da; 1686 const u8 *mesh_da;
1687 1687
1688 rcu_read_lock(); 1688 rcu_read_lock();
1689 if (is_multicast_ether_addr(skb->data)) 1689 if (is_multicast_ether_addr(skb->data))
1690 /* DA TA mSA AE:SA */ 1690 /* DA TA mSA AE:SA */
1691 mesh_da = skb->data; 1691 mesh_da = skb->data;
1692 else { 1692 else {
1693 static const u8 bcast[ETH_ALEN] =
1694 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
1695
1693 mppath = mpp_path_lookup(skb->data, sdata); 1696 mppath = mpp_path_lookup(skb->data, sdata);
1694 if (mppath) { 1697 if (mppath) {
1695 /* RA TA mDA mSA AE:DA SA */ 1698 /* RA TA mDA mSA AE:DA SA */
1696 mesh_da = mppath->mpp; 1699 mesh_da = mppath->mpp;
1697 is_mesh_mcast = 0; 1700 is_mesh_mcast = 0;
1698 } else 1701 } else {
1699 /* DA TA mSA AE:SA */ 1702 /* DA TA mSA AE:SA */
1700 mesh_da = dev->broadcast; 1703 mesh_da = bcast;
1704 }
1701 } 1705 }
1702 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc, 1706 hdrlen = ieee80211_fill_mesh_addresses(&hdr, &fc,
1703 mesh_da, dev->dev_addr); 1707 mesh_da, dev->dev_addr);