Skip to content

Commit be6cded

Browse files
Ruan Jinjiegregkh
authored andcommitted
staging: rtl8723bs: Use helpers to check broadcast and multicast Ether addresses
Use is_multicast_ether_addr() and is_broadcast_ether_addr() instead of custom macro IS_MCAST() and MacAddr_isBcst(), the buffer is properly aligned. Signed-off-by: Ruan Jinjie <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 722de0e commit be6cded

File tree

10 files changed

+29
-44
lines changed

10 files changed

+29
-44
lines changed

drivers/staging/rtl8723bs/core/rtw_mlme.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr
25122512
struct sta_info *psta;
25132513
struct ht_priv *phtpriv;
25142514
struct pkt_attrib *pattrib = &pxmitframe->attrib;
2515-
s32 bmcst = IS_MCAST(pattrib->ra);
2515+
s32 bmcst = is_multicast_ether_addr(pattrib->ra);
25162516

25172517
/* if (bmcst || (padapter->mlmepriv.LinkDetectInfo.bTxBusyTraffic == false)) */
25182518
if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100))

drivers/staging/rtl8723bs/core/rtw_recv.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p
317317
if (prxattrib->encrypt == _TKIP_) {
318318
/* calculate mic code */
319319
if (stainfo) {
320-
if (IS_MCAST(prxattrib->ra)) {
320+
if (is_multicast_ether_addr(prxattrib->ra)) {
321321
/* mickey =&psecuritypriv->dot118021XGrprxmickey.skey[0]; */
322322
/* iv = precvframe->u.hdr.rx_data+prxattrib->hdrlen; */
323323
/* rxdata_key_idx =(((iv[3])>>6)&0x3) ; */
@@ -352,18 +352,18 @@ static signed int recvframe_chkmic(struct adapter *adapter, union recv_frame *p
352352
if (bmic_err == true) {
353353
/* double check key_index for some timing issue , */
354354
/* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */
355-
if ((IS_MCAST(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index))
355+
if ((is_multicast_ether_addr(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index))
356356
brpt_micerror = false;
357357

358358
if (prxattrib->bdecrypted && brpt_micerror)
359-
rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra));
359+
rtw_handle_tkip_mic_err(adapter, (u8)is_multicast_ether_addr(prxattrib->ra));
360360

361361
res = _FAIL;
362362

363363
} else {
364364
/* mic checked ok */
365365
if (!psecuritypriv->bcheck_grpkey &&
366-
IS_MCAST(prxattrib->ra))
366+
is_multicast_ether_addr(prxattrib->ra))
367367
psecuritypriv->bcheck_grpkey = true;
368368
}
369369
}
@@ -625,7 +625,7 @@ static void count_rx_stats(struct adapter *padapter, union recv_frame *prframe,
625625

626626
padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++;
627627

628-
if ((!MacAddr_isBcst(pattrib->dst)) && (!IS_MCAST(pattrib->dst)))
628+
if ((!is_broadcast_ether_addr(pattrib->dst)) && (!is_multicast_ether_addr(pattrib->dst)))
629629
padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++;
630630

631631
if (sta)
@@ -654,7 +654,7 @@ static signed int sta2sta_data_frame(struct adapter *adapter, union recv_frame *
654654
u8 *mybssid = get_bssid(pmlmepriv);
655655
u8 *myhwaddr = myid(&adapter->eeprompriv);
656656
u8 *sta_addr = NULL;
657-
signed int bmcast = IS_MCAST(pattrib->dst);
657+
signed int bmcast = is_multicast_ether_addr(pattrib->dst);
658658

659659
if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) ||
660660
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) {
@@ -690,7 +690,7 @@ static signed int sta2sta_data_frame(struct adapter *adapter, union recv_frame *
690690
} else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) {
691691
if (bmcast) {
692692
/* For AP mode, if DA == MCAST, then BSSID should be also MCAST */
693-
if (!IS_MCAST(pattrib->bssid)) {
693+
if (!is_multicast_ether_addr(pattrib->bssid)) {
694694
ret = _FAIL;
695695
goto exit;
696696
}
@@ -741,7 +741,7 @@ static signed int ap2sta_data_frame(struct adapter *adapter, union recv_frame *p
741741
struct mlme_priv *pmlmepriv = &adapter->mlmepriv;
742742
u8 *mybssid = get_bssid(pmlmepriv);
743743
u8 *myhwaddr = myid(&adapter->eeprompriv);
744-
signed int bmcast = IS_MCAST(pattrib->dst);
744+
signed int bmcast = is_multicast_ether_addr(pattrib->dst);
745745

746746
if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) &&
747747
(check_fwstate(pmlmepriv, _FW_LINKED) == true ||
@@ -1329,7 +1329,7 @@ static signed int validate_recv_data_frame(struct adapter *adapter, union recv_f
13291329
}
13301330

13311331
if (pattrib->privacy) {
1332-
GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, IS_MCAST(pattrib->ra));
1332+
GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, is_multicast_ether_addr(pattrib->ra));
13331333

13341334
SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt);
13351335
} else {
@@ -1354,7 +1354,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
13541354
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED) &&
13551355
adapter->securitypriv.binstallBIPkey == true) {
13561356
/* unicast management frame decrypt */
1357-
if (pattrib->privacy && !(IS_MCAST(GetAddr1Ptr(ptr))) &&
1357+
if (pattrib->privacy && !(is_multicast_ether_addr(GetAddr1Ptr(ptr))) &&
13581358
(subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC || subtype == WIFI_ACTION)) {
13591359
u8 *mgmt_DATA;
13601360
u32 data_len = 0;
@@ -1381,7 +1381,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
13811381
kfree(mgmt_DATA);
13821382
if (!precv_frame)
13831383
goto validate_80211w_fail;
1384-
} else if (IS_MCAST(GetAddr1Ptr(ptr)) &&
1384+
} else if (is_multicast_ether_addr(GetAddr1Ptr(ptr)) &&
13851385
(subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC)) {
13861386
signed int BIP_ret = _SUCCESS;
13871387
/* verify BIP MME IE of broadcast/multicast de-auth/disassoc packet */
@@ -2041,7 +2041,7 @@ static int recv_func(struct adapter *padapter, union recv_frame *rframe)
20412041

20422042
/* check if need to enqueue into uc_swdec_pending_queue*/
20432043
if (check_fwstate(mlmepriv, WIFI_STATION_STATE) &&
2044-
!IS_MCAST(prxattrib->ra) && prxattrib->encrypt > 0 &&
2044+
!is_multicast_ether_addr(prxattrib->ra) && prxattrib->encrypt > 0 &&
20452045
(prxattrib->bdecrypted == 0 || psecuritypriv->sw_decrypt == true) &&
20462046
psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPAPSK &&
20472047
!psecuritypriv->busetkipkey) {

drivers/staging/rtl8723bs/core/rtw_security.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe)
486486
if (pattrib->encrypt == _TKIP_) {
487487

488488
{
489-
if (IS_MCAST(pattrib->ra))
489+
if (is_multicast_ether_addr(pattrib->ra))
490490
prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
491491
else
492492
prwskey = pattrib->dot118021x_UncstKey.skey;
@@ -554,7 +554,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)
554554
if (prxattrib->encrypt == _TKIP_) {
555555
stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
556556
if (stainfo) {
557-
if (IS_MCAST(prxattrib->ra)) {
557+
if (is_multicast_ether_addr(prxattrib->ra)) {
558558
static unsigned long start;
559559
static u32 no_gkey_bc_cnt;
560560
static u32 no_gkey_mc_cnt;
@@ -1051,7 +1051,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe)
10511051

10521052
/* 4 start to encrypt each fragment */
10531053
if (pattrib->encrypt == _AES_) {
1054-
if (IS_MCAST(pattrib->ra))
1054+
if (is_multicast_ether_addr(pattrib->ra))
10551055
prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey;
10561056
else
10571057
prwskey = pattrib->dot118021x_UncstKey.skey;
@@ -1305,7 +1305,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe)
13051305
if (prxattrib->encrypt == _AES_) {
13061306
stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);
13071307
if (stainfo) {
1308-
if (IS_MCAST(prxattrib->ra)) {
1308+
if (is_multicast_ether_addr(prxattrib->ra)) {
13091309
static unsigned long start;
13101310
static u32 no_gkey_bc_cnt;
13111311
static u32 no_gkey_mc_cnt;

drivers/staging/rtl8723bs/core/rtw_sta_mgt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
471471
if (!hwaddr)
472472
return NULL;
473473

474-
if (IS_MCAST(hwaddr))
474+
if (is_multicast_ether_addr(hwaddr))
475475
addr = bc_addr;
476476
else
477477
addr = hwaddr;

drivers/staging/rtl8723bs/core/rtw_xmit.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p
473473
signed int res = _SUCCESS;
474474
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
475475
struct security_priv *psecuritypriv = &padapter->securitypriv;
476-
signed int bmcast = IS_MCAST(pattrib->ra);
476+
signed int bmcast = is_multicast_ether_addr(pattrib->ra);
477477

478478
memset(pattrib->dot118021x_UncstKey.skey, 0, 16);
479479
memset(pattrib->dot11tkiptxmickey.skey, 0, 16);
@@ -691,7 +691,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p
691691
else if (pattrib->dhcp_pkt == 1)
692692
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1);
693693

694-
bmcast = IS_MCAST(pattrib->ra);
694+
bmcast = is_multicast_ether_addr(pattrib->ra);
695695

696696
/* get sta_info */
697697
if (bmcast) {
@@ -765,7 +765,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr
765765
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
766766
u8 priority[4] = {0x0, 0x0, 0x0, 0x0};
767767
u8 hw_hdr_offset = 0;
768-
signed int bmcst = IS_MCAST(pattrib->ra);
768+
signed int bmcst = is_multicast_ether_addr(pattrib->ra);
769769

770770
hw_hdr_offset = TXDESC_OFFSET;
771771

@@ -1035,7 +1035,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct
10351035

10361036
u8 *pbuf_start;
10371037

1038-
s32 bmcst = IS_MCAST(pattrib->ra);
1038+
s32 bmcst = is_multicast_ether_addr(pattrib->ra);
10391039
s32 res = _SUCCESS;
10401040

10411041
if (!pxmitframe->buf_addr)
@@ -1143,7 +1143,7 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, s
11431143
u8 subtype;
11441144
struct sta_info *psta = NULL;
11451145
struct pkt_attrib *pattrib = &pxmitframe->attrib;
1146-
s32 bmcst = IS_MCAST(pattrib->ra);
1146+
s32 bmcst = is_multicast_ether_addr(pattrib->ra);
11471147
u8 *BIP_AAD = NULL;
11481148
u8 *MGMT_body = NULL;
11491149

@@ -2016,7 +2016,7 @@ signed int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct x
20162016
struct sta_priv *pstapriv = &padapter->stapriv;
20172017
struct pkt_attrib *pattrib = &pxmitframe->attrib;
20182018
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
2019-
signed int bmcst = IS_MCAST(pattrib->ra);
2019+
signed int bmcst = is_multicast_ether_addr(pattrib->ra);
20202020
bool update_tim = false;
20212021

20222022
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false)

drivers/staging/rtl8723bs/hal/hal_intf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ s32 rtw_hal_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe)
217217
/* memcpy(pmgntframe->attrib.ra, pwlanhdr->addr1, ETH_ALEN); */
218218

219219
if (padapter->securitypriv.binstallBIPkey == true) {
220-
if (IS_MCAST(pmgntframe->attrib.ra)) {
220+
if (is_multicast_ether_addr(pmgntframe->attrib.ra)) {
221221
pmgntframe->attrib.encrypt = _BIP_;
222222
/* pmgntframe->attrib.bswenc = true; */
223223
} else {

drivers/staging/rtl8723bs/hal/odm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static void odm_RefreshRateAdaptiveMaskCE(struct dm_odm_t *pDM_Odm)
429429
PSTA_INFO_T pstat = pDM_Odm->pODM_StaInfo[i];
430430

431431
if (IS_STA_VALID(pstat)) {
432-
if (IS_MCAST(pstat->hwaddr)) /* if (psta->mac_id == 1) */
432+
if (is_multicast_ether_addr(pstat->hwaddr)) /* if (psta->mac_id == 1) */
433433
continue;
434434

435435
if (true == ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) {
@@ -576,7 +576,7 @@ static void odm_RSSIMonitorCheckCE(struct dm_odm_t *pDM_Odm)
576576
for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) {
577577
psta = pDM_Odm->pODM_StaInfo[i];
578578
if (IS_STA_VALID(psta)) {
579-
if (IS_MCAST(psta->hwaddr)) /* if (psta->mac_id == 1) */
579+
if (is_multicast_ether_addr(psta->hwaddr)) /* if (psta->mac_id == 1) */
580580
continue;
581581

582582
if (psta->rssi_stat.UndecoratedSmoothedPWDB == (-1))

drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2609,7 +2609,7 @@ static void rtl8723b_fill_default_txdesc(
26092609
pmlmeinfo = &(pmlmeext->mlmext_info);
26102610

26112611
pattrib = &pxmitframe->attrib;
2612-
bmcst = IS_MCAST(pattrib->ra);
2612+
bmcst = is_multicast_ether_addr(pattrib->ra);
26132613

26142614
ptxdesc = (struct txdesc_8723b *)pbuf;
26152615

drivers/staging/rtl8723bs/include/wifi.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -211,21 +211,6 @@ enum {
211211

212212
#define GetAddr4Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 24))
213213

214-
#define MacAddr_isBcst(addr) \
215-
(\
216-
((addr[0] == 0xff) && (addr[1] == 0xff) && \
217-
(addr[2] == 0xff) && (addr[3] == 0xff) && \
218-
(addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \
219-
)
220-
221-
static inline int IS_MCAST(unsigned char *da)
222-
{
223-
if ((*da) & 0x01)
224-
return true;
225-
else
226-
return false;
227-
}
228-
229214
static inline unsigned char *rtl8723bs_get_ra(unsigned char *pframe)
230215
{
231216
unsigned char *ra;

drivers/staging/rtl8723bs/os_dep/recv_linux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, struct sk_buff *pkt, str
101101
struct sk_buff *pskb2 = NULL;
102102
struct sta_info *psta = NULL;
103103
struct sta_priv *pstapriv = &padapter->stapriv;
104-
int bmcast = IS_MCAST(pattrib->dst);
104+
int bmcast = is_multicast_ether_addr(pattrib->dst);
105105

106106
if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) {
107107
if (bmcast) {

0 commit comments

Comments
 (0)