Skip to content

Commit a421775

Browse files
Omer Efratjmberg-intel
authored andcommitted
mac80211: use BIT_ULL for NL80211_STA_INFO_* attribute types
The BIT macro uses unsigned long which some architectures handle as 32 bit and therefore might cause macro's shift to overflow when used on a value equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards). Since 'filled' member in station_info changed to u64, BIT_ULL macro should be used with all NL80211_STA_INFO_* attribute types instead of BIT to prevent future possible bugs when one will use BIT macro for higher attributes by mistake. This commit cleans up all usages of BIT macro with the above field in mac80211 by changing it to BIT_ULL instead. Signed-off-by: Omer Efrat <omer.efrat@tandemg.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 397c657 commit a421775

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

net/mac80211/ethtool.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,16 @@ static void ieee80211_get_stats(struct net_device *dev,
116116
data[i++] = sta->sta_state;
117117

118118

119-
if (sinfo.filled & BIT(NL80211_STA_INFO_TX_BITRATE))
119+
if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))
120120
data[i] = 100000ULL *
121121
cfg80211_calculate_bitrate(&sinfo.txrate);
122122
i++;
123-
if (sinfo.filled & BIT(NL80211_STA_INFO_RX_BITRATE))
123+
if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE))
124124
data[i] = 100000ULL *
125125
cfg80211_calculate_bitrate(&sinfo.rxrate);
126126
i++;
127127

128-
if (sinfo.filled & BIT(NL80211_STA_INFO_SIGNAL_AVG))
128+
if (sinfo.filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))
129129
data[i] = (u8)sinfo.signal_avg;
130130
i++;
131131
} else {

net/mac80211/sta_info.c

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2114,38 +2114,38 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
21142114

21152115
drv_sta_statistics(local, sdata, &sta->sta, sinfo);
21162116

2117-
sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME) |
2118-
BIT(NL80211_STA_INFO_STA_FLAGS) |
2119-
BIT(NL80211_STA_INFO_BSS_PARAM) |
2120-
BIT(NL80211_STA_INFO_CONNECTED_TIME) |
2121-
BIT(NL80211_STA_INFO_RX_DROP_MISC);
2117+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME) |
2118+
BIT_ULL(NL80211_STA_INFO_STA_FLAGS) |
2119+
BIT_ULL(NL80211_STA_INFO_BSS_PARAM) |
2120+
BIT_ULL(NL80211_STA_INFO_CONNECTED_TIME) |
2121+
BIT_ULL(NL80211_STA_INFO_RX_DROP_MISC);
21222122

21232123
if (sdata->vif.type == NL80211_IFTYPE_STATION) {
21242124
sinfo->beacon_loss_count = sdata->u.mgd.beacon_loss_count;
2125-
sinfo->filled |= BIT(NL80211_STA_INFO_BEACON_LOSS);
2125+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_LOSS);
21262126
}
21272127

21282128
sinfo->connected_time = ktime_get_seconds() - sta->last_connected;
21292129
sinfo->inactive_time =
21302130
jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta));
21312131

2132-
if (!(sinfo->filled & (BIT(NL80211_STA_INFO_TX_BYTES64) |
2133-
BIT(NL80211_STA_INFO_TX_BYTES)))) {
2132+
if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) |
2133+
BIT_ULL(NL80211_STA_INFO_TX_BYTES)))) {
21342134
sinfo->tx_bytes = 0;
21352135
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
21362136
sinfo->tx_bytes += sta->tx_stats.bytes[ac];
2137-
sinfo->filled |= BIT(NL80211_STA_INFO_TX_BYTES64);
2137+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64);
21382138
}
21392139

2140-
if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_PACKETS))) {
2140+
if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_PACKETS))) {
21412141
sinfo->tx_packets = 0;
21422142
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++)
21432143
sinfo->tx_packets += sta->tx_stats.packets[ac];
2144-
sinfo->filled |= BIT(NL80211_STA_INFO_TX_PACKETS);
2144+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
21452145
}
21462146

2147-
if (!(sinfo->filled & (BIT(NL80211_STA_INFO_RX_BYTES64) |
2148-
BIT(NL80211_STA_INFO_RX_BYTES)))) {
2147+
if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_RX_BYTES64) |
2148+
BIT_ULL(NL80211_STA_INFO_RX_BYTES)))) {
21492149
sinfo->rx_bytes += sta_get_stats_bytes(&sta->rx_stats);
21502150

21512151
if (sta->pcpu_rx_stats) {
@@ -2157,10 +2157,10 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
21572157
}
21582158
}
21592159

2160-
sinfo->filled |= BIT(NL80211_STA_INFO_RX_BYTES64);
2160+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64);
21612161
}
21622162

2163-
if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_PACKETS))) {
2163+
if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_PACKETS))) {
21642164
sinfo->rx_packets = sta->rx_stats.packets;
21652165
if (sta->pcpu_rx_stats) {
21662166
for_each_possible_cpu(cpu) {
@@ -2170,17 +2170,17 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
21702170
sinfo->rx_packets += cpurxs->packets;
21712171
}
21722172
}
2173-
sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS);
2173+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS);
21742174
}
21752175

2176-
if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_RETRIES))) {
2176+
if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_RETRIES))) {
21772177
sinfo->tx_retries = sta->status_stats.retry_count;
2178-
sinfo->filled |= BIT(NL80211_STA_INFO_TX_RETRIES);
2178+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES);
21792179
}
21802180

2181-
if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_FAILED))) {
2181+
if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_FAILED))) {
21822182
sinfo->tx_failed = sta->status_stats.retry_failed;
2183-
sinfo->filled |= BIT(NL80211_STA_INFO_TX_FAILED);
2183+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED);
21842184
}
21852185

21862186
sinfo->rx_dropped_misc = sta->rx_stats.dropped;
@@ -2195,23 +2195,23 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
21952195

21962196
if (sdata->vif.type == NL80211_IFTYPE_STATION &&
21972197
!(sdata->vif.driver_flags & IEEE80211_VIF_BEACON_FILTER)) {
2198-
sinfo->filled |= BIT(NL80211_STA_INFO_BEACON_RX) |
2199-
BIT(NL80211_STA_INFO_BEACON_SIGNAL_AVG);
2198+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_BEACON_RX) |
2199+
BIT_ULL(NL80211_STA_INFO_BEACON_SIGNAL_AVG);
22002200
sinfo->rx_beacon_signal_avg = ieee80211_ave_rssi(&sdata->vif);
22012201
}
22022202

22032203
if (ieee80211_hw_check(&sta->local->hw, SIGNAL_DBM) ||
22042204
ieee80211_hw_check(&sta->local->hw, SIGNAL_UNSPEC)) {
2205-
if (!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL))) {
2205+
if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL))) {
22062206
sinfo->signal = (s8)last_rxstats->last_signal;
2207-
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
2207+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
22082208
}
22092209

22102210
if (!sta->pcpu_rx_stats &&
2211-
!(sinfo->filled & BIT(NL80211_STA_INFO_SIGNAL_AVG))) {
2211+
!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG))) {
22122212
sinfo->signal_avg =
22132213
-ewma_signal_read(&sta->rx_stats_avg.signal);
2214-
sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL_AVG);
2214+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL_AVG);
22152215
}
22162216
}
22172217

@@ -2220,11 +2220,11 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
22202220
* pcpu statistics
22212221
*/
22222222
if (last_rxstats->chains &&
2223-
!(sinfo->filled & (BIT(NL80211_STA_INFO_CHAIN_SIGNAL) |
2224-
BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)))) {
2225-
sinfo->filled |= BIT(NL80211_STA_INFO_CHAIN_SIGNAL);
2223+
!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL) |
2224+
BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG)))) {
2225+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL);
22262226
if (!sta->pcpu_rx_stats)
2227-
sinfo->filled |= BIT(NL80211_STA_INFO_CHAIN_SIGNAL_AVG);
2227+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_CHAIN_SIGNAL_AVG);
22282228

22292229
sinfo->chains = last_rxstats->chains;
22302230

@@ -2236,15 +2236,15 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
22362236
}
22372237
}
22382238

2239-
if (!(sinfo->filled & BIT(NL80211_STA_INFO_TX_BITRATE))) {
2239+
if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_TX_BITRATE))) {
22402240
sta_set_rate_info_tx(sta, &sta->tx_stats.last_rate,
22412241
&sinfo->txrate);
2242-
sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
2242+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
22432243
}
22442244

2245-
if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE))) {
2245+
if (!(sinfo->filled & BIT_ULL(NL80211_STA_INFO_RX_BITRATE))) {
22462246
if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0)
2247-
sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
2247+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BITRATE);
22482248
}
22492249

22502250
if (tidstats && !cfg80211_sinfo_alloc_tid_stats(sinfo, GFP_KERNEL)) {
@@ -2257,18 +2257,18 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
22572257

22582258
if (ieee80211_vif_is_mesh(&sdata->vif)) {
22592259
#ifdef CONFIG_MAC80211_MESH
2260-
sinfo->filled |= BIT(NL80211_STA_INFO_LLID) |
2261-
BIT(NL80211_STA_INFO_PLID) |
2262-
BIT(NL80211_STA_INFO_PLINK_STATE) |
2263-
BIT(NL80211_STA_INFO_LOCAL_PM) |
2264-
BIT(NL80211_STA_INFO_PEER_PM) |
2265-
BIT(NL80211_STA_INFO_NONPEER_PM);
2260+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_LLID) |
2261+
BIT_ULL(NL80211_STA_INFO_PLID) |
2262+
BIT_ULL(NL80211_STA_INFO_PLINK_STATE) |
2263+
BIT_ULL(NL80211_STA_INFO_LOCAL_PM) |
2264+
BIT_ULL(NL80211_STA_INFO_PEER_PM) |
2265+
BIT_ULL(NL80211_STA_INFO_NONPEER_PM);
22662266

22672267
sinfo->llid = sta->mesh->llid;
22682268
sinfo->plid = sta->mesh->plid;
22692269
sinfo->plink_state = sta->mesh->plink_state;
22702270
if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
2271-
sinfo->filled |= BIT(NL80211_STA_INFO_T_OFFSET);
2271+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_T_OFFSET);
22722272
sinfo->t_offset = sta->mesh->t_offset;
22732273
}
22742274
sinfo->local_pm = sta->mesh->local_pm;
@@ -2313,7 +2313,7 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
23132313
thr = sta_get_expected_throughput(sta);
23142314

23152315
if (thr != 0) {
2316-
sinfo->filled |= BIT(NL80211_STA_INFO_EXPECTED_THROUGHPUT);
2316+
sinfo->filled |= BIT_ULL(NL80211_STA_INFO_EXPECTED_THROUGHPUT);
23172317
sinfo->expected_throughput = thr;
23182318
}
23192319

0 commit comments

Comments
 (0)