use eth_broadcast_addr() to assign broadcast address

Using eth_broadcast_addr() to assign broadcast address instead
of copying from an array that contains the all-ones broadcast
address

Port 78adf574c969c14a470b686af8d6bd7e1dcf142b
Port 3b0a4a1bdb0f6348dba797a0fa1cf161f5639ded
Port 44c26bec861476f89ac5aee0bb19df128a42543b

Link: https://lore.kernel.org/r/20210616081243.2511663-4-yangyingliang@huawei.com
This commit is contained in:
Carlos Garces 2021-10-20 19:02:50 +02:00
parent 77e7d6747c
commit 27246f4eb5
6 changed files with 15 additions and 27 deletions

View File

@ -811,7 +811,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method)
if (*((unsigned char *)&iph->daddr + 3) == 0xff) { if (*((unsigned char *)&iph->daddr + 3) == 0xff) {
/* L2 is unicast but L3 is broadcast, make L2 bacome broadcast */ /* L2 is unicast but L3 is broadcast, make L2 bacome broadcast */
RTW_INFO("NAT25: Set DA as boardcast\n"); RTW_INFO("NAT25: Set DA as boardcast\n");
memset(skb->data, 0xff, ETH_ALEN); eth_broadcast_addr(skb->data);
} else { } else {
/* forward unknow IP packet to upper TCP/IP */ /* forward unknow IP packet to upper TCP/IP */
RTW_INFO("NAT25: Replace DA with BR's MAC\n"); RTW_INFO("NAT25: Replace DA with BR's MAC\n");

View File

@ -5786,7 +5786,6 @@ int _issue_probereq_p2p(_adapter *padapter, u8 *da, int wait_ack)
unsigned char *mac; unsigned char *mac;
struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
struct wifidirect_info *pwdinfo = &(padapter->wdinfo); struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 };
u16 wpsielen = 0, p2pielen = 0; u16 wpsielen = 0, p2pielen = 0;
@ -5831,8 +5830,8 @@ int _issue_probereq_p2p(_adapter *padapter, u8 *da, int wait_ack)
memcpy(pwlanhdr->addr3, pwdinfo->p2p_peer_interface_addr, ETH_ALEN); memcpy(pwlanhdr->addr3, pwdinfo->p2p_peer_interface_addr, ETH_ALEN);
} else { } else {
/* broadcast probe request frame */ /* broadcast probe request frame */
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr1);
memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr3);
} }
} }
memcpy(pwlanhdr->addr2, mac, ETH_ALEN); memcpy(pwlanhdr->addr2, mac, ETH_ALEN);
@ -7792,7 +7791,6 @@ void issue_beacon(_adapter *padapter, int timeout_ms)
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
WLAN_BSSID_EX *cur_network = &(pmlmeinfo->network); WLAN_BSSID_EX *cur_network = &(pmlmeinfo->network);
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
#ifdef CONFIG_P2P #ifdef CONFIG_P2P
struct wifidirect_info *pwdinfo = &(padapter->wdinfo); struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
@ -7838,7 +7836,7 @@ void issue_beacon(_adapter *padapter, int timeout_ms)
fctrl = &(pwlanhdr->frame_ctl); fctrl = &(pwlanhdr->frame_ctl);
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr1);
memcpy(pwlanhdr->addr2, adapter_mac_addr(padapter), ETH_ALEN); memcpy(pwlanhdr->addr2, adapter_mac_addr(padapter), ETH_ALEN);
memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN);
@ -8392,7 +8390,6 @@ int _issue_probereq(_adapter *padapter, const NDIS_802_11_SSID *pssid, const u8
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
int bssrate_len = 0; int bssrate_len = 0;
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
#ifdef CONFIG_RTW_CFGVENDOR_RANDOM_MAC_OUI #ifdef CONFIG_RTW_CFGVENDOR_RANDOM_MAC_OUI
struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(padapter); struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(padapter);
#endif #endif
@ -8432,8 +8429,8 @@ int _issue_probereq(_adapter *padapter, const NDIS_802_11_SSID *pssid, const u8
memcpy(pwlanhdr->addr3, da, ETH_ALEN); memcpy(pwlanhdr->addr3, da, ETH_ALEN);
} else { } else {
/* broadcast probe request frame */ /* broadcast probe request frame */
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr1);
memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr3);
} }
memcpy(pwlanhdr->addr2, mac, ETH_ALEN); memcpy(pwlanhdr->addr2, mac, ETH_ALEN);

View File

@ -5968,7 +5968,6 @@ static void rtw_hal_construct_P2PBeacon(_adapter *padapter, u8 *pframe, u32 *pLe
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
WLAN_BSSID_EX *cur_network = &(pmlmeinfo->network); WLAN_BSSID_EX *cur_network = &(pmlmeinfo->network);
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
#ifdef CONFIG_P2P #ifdef CONFIG_P2P
struct wifidirect_info *pwdinfo = &(padapter->wdinfo); struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
#endif /* CONFIG_P2P */ #endif /* CONFIG_P2P */
@ -5988,7 +5987,7 @@ static void rtw_hal_construct_P2PBeacon(_adapter *padapter, u8 *pframe, u32 *pLe
fctrl = &(pwlanhdr->frame_ctl); fctrl = &(pwlanhdr->frame_ctl);
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr1);
memcpy(pwlanhdr->addr2, adapter_mac_addr(padapter), ETH_ALEN); memcpy(pwlanhdr->addr2, adapter_mac_addr(padapter), ETH_ALEN);
memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN);
@ -7389,8 +7388,6 @@ void rtw_hal_construct_beacon(_adapter *padapter,
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
WLAN_BSSID_EX *cur_network = &(pmlmeinfo->network); WLAN_BSSID_EX *cur_network = &(pmlmeinfo->network);
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
/* RTW_INFO("%s\n", __FUNCTION__); */ /* RTW_INFO("%s\n", __FUNCTION__); */
@ -7399,7 +7396,7 @@ void rtw_hal_construct_beacon(_adapter *padapter,
fctrl = &(pwlanhdr->frame_ctl); fctrl = &(pwlanhdr->frame_ctl);
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr1);
memcpy(pwlanhdr->addr2, adapter_mac_addr(padapter), ETH_ALEN); memcpy(pwlanhdr->addr2, adapter_mac_addr(padapter), ETH_ALEN);
memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN);
@ -7526,8 +7523,6 @@ void rtw_hal_construct_fw_dbg_msg_pkt(
struct wlan_network *cur_network = &pmlmepriv->cur_network; struct wlan_network *cur_network = &pmlmepriv->cur_network;
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
/* RTW_INFO("%s:%d\n", __FUNCTION__, bForcePowerSave); */ /* RTW_INFO("%s:%d\n", __FUNCTION__, bForcePowerSave); */
@ -7536,7 +7531,7 @@ void rtw_hal_construct_fw_dbg_msg_pkt(
fctrl = &pwlanhdr->frame_ctl; fctrl = &pwlanhdr->frame_ctl;
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr1);
memcpy(pwlanhdr->addr2, adapter_mac_addr(padapter), ETH_ALEN); memcpy(pwlanhdr->addr2, adapter_mac_addr(padapter), ETH_ALEN);
memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN);
@ -8040,7 +8035,6 @@ static void rtw_hal_construct_ProbeReq(_adapter *padapter, u8 *pframe,
struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv);
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
int bssrate_len = 0; int bssrate_len = 0;
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe;
mac = adapter_mac_addr(padapter); mac = adapter_mac_addr(padapter);
@ -8048,8 +8042,8 @@ static void rtw_hal_construct_ProbeReq(_adapter *padapter, u8 *pframe,
fctrl = &(pwlanhdr->frame_ctl); fctrl = &(pwlanhdr->frame_ctl);
*(fctrl) = 0; *(fctrl) = 0;
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr1);
memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr3);
memcpy(pwlanhdr->addr2, mac, ETH_ALEN); memcpy(pwlanhdr->addr2, mac, ETH_ALEN);

View File

@ -984,8 +984,6 @@ exit:
static void rtw_hal_construct_CTS(PADAPTER padapter, u8 *pframe, u32 *pLength) static void rtw_hal_construct_CTS(PADAPTER padapter, u8 *pframe, u32 *pLength)
{ {
u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
/* frame type, length = 1*/ /* frame type, length = 1*/
set_frame_sub_type(pframe, WIFI_RTS); set_frame_sub_type(pframe, WIFI_RTS);
@ -997,7 +995,7 @@ static void rtw_hal_construct_CTS(PADAPTER padapter, u8 *pframe, u32 *pLength)
*(pframe + 3) = 0x78; *(pframe + 3) = 0x78;
/* frame recvaddr, length = 6 */ /* frame recvaddr, length = 6 */
memcpy((pframe + 4), broadcast_addr, ETH_ALEN); eth_broadcast_addr((pframe + 4));
memcpy((pframe + 4 + ETH_ALEN), adapter_mac_addr(padapter), ETH_ALEN); memcpy((pframe + 4 + ETH_ALEN), adapter_mac_addr(padapter), ETH_ALEN);
memcpy((pframe + 4 + ETH_ALEN*2), adapter_mac_addr(padapter), ETH_ALEN); memcpy((pframe + 4 + ETH_ALEN*2), adapter_mac_addr(padapter), ETH_ALEN);
*pLength = 22; *pLength = 22;

View File

@ -788,7 +788,6 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(_adapter *padapter, struct wlan_net
size_t len, bssinf_len = 0; size_t len, bssinf_len = 0;
struct rtw_ieee80211_hdr *pwlanhdr; struct rtw_ieee80211_hdr *pwlanhdr;
unsigned short *fctrl; unsigned short *fctrl;
u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
struct wireless_dev *wdev = padapter->rtw_wdev; struct wireless_dev *wdev = padapter->rtw_wdev;
struct wiphy *wiphy = wdev->wiphy; struct wiphy *wiphy = wdev->wiphy;
@ -863,7 +862,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(_adapter *padapter, struct wlan_net
/* pmlmeext->mgnt_seq++; */ /* pmlmeext->mgnt_seq++; */
if (pnetwork->network.Reserved[0] == BSS_TYPE_BCN) { /* IEEE80211_STYPE_BEACON */ if (pnetwork->network.Reserved[0] == BSS_TYPE_BCN) { /* IEEE80211_STYPE_BEACON */
memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); eth_broadcast_addr(pwlanhdr->addr1);
set_frame_sub_type(pbuf, IEEE80211_STYPE_BEACON); set_frame_sub_type(pbuf, IEEE80211_STYPE_BEACON);
} else { } else {
memcpy(pwlanhdr->addr1, adapter_mac_addr(padapter), ETH_ALEN); memcpy(pwlanhdr->addr1, adapter_mac_addr(padapter), ETH_ALEN);
@ -1724,7 +1723,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev
memset(param, 0, param_len); memset(param, 0, param_len);
param->cmd = IEEE_CMD_SET_ENCRYPTION; param->cmd = IEEE_CMD_SET_ENCRYPTION;
memset(param->sta_addr, 0xff, ETH_ALEN); eth_broadcast_addr(param->sta_addr);
switch (params->cipher) { switch (params->cipher) {
case IW_AUTH_CIPHER_NONE: case IW_AUTH_CIPHER_NONE:

View File

@ -3040,7 +3040,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev,
memset(param, 0, param_len); memset(param, 0, param_len);
param->cmd = IEEE_CMD_SET_ENCRYPTION; param->cmd = IEEE_CMD_SET_ENCRYPTION;
memset(param->sta_addr, 0xff, ETH_ALEN); eth_broadcast_addr(param->sta_addr);
switch (pext->alg) { switch (pext->alg) {