Skip to content

Commit

Permalink
Merge pull request #18 from canyonbliss/fix-incorrect-netdevice-address
Browse files Browse the repository at this point in the history
use kernel etherdevice interface to set hw address
  • Loading branch information
Consti10 authored Mar 4, 2024
2 parents f21bbe9 + 792a739 commit 9857ab5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
5 changes: 4 additions & 1 deletion os_dep/linux/ioctl_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -9922,8 +9922,11 @@ static int rtw_mp_efuse_set(struct net_device *dev,
rtw_hal_read_chip_info(padapter);
/* set mac addr*/
rtw_macaddr_cfg(adapter_mac_addr(padapter), get_hal_mac_addr(padapter));
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 17, 0))
eth_hw_addr_set(padapter->pnetdev, get_hal_mac_addr(padapter));
#else
_rtw_memcpy(padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */

#endif
#ifdef CONFIG_P2P
rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter));
#endif
Expand Down
5 changes: 4 additions & 1 deletion os_dep/linux/mlme_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,11 @@ int hostapd_mode_init(_adapter *padapter)
mac[4] = 0x11;
mac[5] = 0x12;

#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 17, 0))
eth_hw_addr_set(pnetdev, mac);
#else
_rtw_memcpy(pnetdev->dev_addr, mac, ETH_ALEN);

#endif

rtw_netif_carrier_off(pnetdev);

Expand Down
19 changes: 17 additions & 2 deletions os_dep/linux/os_intfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,11 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *addr)
}

_rtw_memcpy(adapter_mac_addr(padapter), sa->sa_data, ETH_ALEN); /* set mac addr to adapter */
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 17, 0))
eth_hw_addr_set(pnetdev, sa->sa_data); /* set mac addr to net_device */
#else
_rtw_memcpy(pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */
#endif

#if 0
if (rtw_is_hw_init_completed(padapter)) {
Expand Down Expand Up @@ -1612,8 +1616,11 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name)

/* alloc netdev name */
rtw_init_netdev_name(ndev, name);

#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 17, 0))
eth_hw_addr_set(ndev, adapter_mac_addr(adapter)); /* set mac addr to net_device */
#else
_rtw_memcpy(ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN);
#endif
#if defined(CONFIG_NET_NS)
dev_net_set(ndev, wiphy_net(adapter_to_wiphy(adapter)));
#endif //defined(CONFIG_NET_NS)
Expand Down Expand Up @@ -2529,7 +2536,11 @@ int _netdev_vir_if_open(struct net_device *pnetdev)
rtw_mbid_camid_alloc(padapter, adapter_mac_addr(padapter));
#endif
rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter));
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 17, 0))
eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter));
#else
_rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN);
#endif
}
#endif /*CONFIG_PLATFORM_INTEL_BYT*/

Expand Down Expand Up @@ -3166,7 +3177,11 @@ int _netdev_open(struct net_device *pnetdev)
rtw_mbid_camid_alloc(padapter, adapter_mac_addr(padapter));
#endif
rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter));
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 17, 0))
eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter));
#else
_rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN);
#endif
#endif /* CONFIG_PLATFORM_INTEL_BYT */

rtw_clr_surprise_removed(padapter);
Expand Down Expand Up @@ -4855,4 +4870,4 @@ int get_openhd_override_channel(void){
}
int get_openhd_override_channel_width(void){
return openhd_override_channel_width;
}
}
5 changes: 4 additions & 1 deletion os_dep/osdep_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -2167,8 +2167,11 @@ int rtw_change_ifname(_adapter *padapter, const char *ifname)

rtw_init_netdev_name(pnetdev, ifname);

#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 17, 0))
eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter));
#else
_rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN);

#endif
if (rtnl_lock_needed)
ret = register_netdev(pnetdev);
else
Expand Down

0 comments on commit 9857ab5

Please sign in to comment.