Skip to content

Commit

Permalink
Merge pull request #333 from tomaspinho/fix-net-device-mac-copy
Browse files Browse the repository at this point in the history
fix old api usage when setting mac addresses on net devices
  • Loading branch information
tomaspinho authored Sep 15, 2023
2 parents d8d4095 + 42a854a commit 0d2c745
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions os_dep/linux/ioctl_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -9786,7 +9786,12 @@ 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)
_rtw_memcpy(padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */
#else
eth_hw_addr_set(padapter->pnetdev, get_hal_mac_addr(padapter));
#endif

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

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


rtw_netif_carrier_off(pnetdev);
Expand Down
16 changes: 16 additions & 0 deletions os_dep/linux/os_intfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,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)
_rtw_memcpy(pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */
#else
eth_hw_addr_set(pnetdev, sa->sa_data);
#endif

#if 0
if (rtw_is_hw_init_completed(padapter)) {
Expand Down Expand Up @@ -1703,7 +1707,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)
_rtw_memcpy(ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN);
#else
eth_hw_addr_set(ndev, adapter_mac_addr(adapter));
#endif

/* Tell the network stack we exist */

Expand Down Expand Up @@ -2671,7 +2679,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)
_rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN);
#else
eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter));
#endif
}
#endif /*CONFIG_PLATFORM_INTEL_BYT*/

Expand Down Expand Up @@ -3420,7 +3432,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)
_rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN);
#else
eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter));
#endif
#endif /* CONFIG_PLATFORM_INTEL_BYT */

rtw_clr_surprise_removed(padapter);
Expand Down
4 changes: 4 additions & 0 deletions os_dep/osdep_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -2513,7 +2513,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)
_rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN);
#else
eth_hw_addr_set(pnetdev, adapter_mac_addr(padapter));
#endif

if (rtnl_lock_needed)
ret = register_netdev(pnetdev);
Expand Down

0 comments on commit 0d2c745

Please sign in to comment.