From 258b77d8700cc64e0444e3d8e02cb174c364154e Mon Sep 17 00:00:00 2001 From: gluker Date: Tue, 17 Jan 2023 05:26:40 +0300 Subject: [PATCH 01/10] build support for kernel 6.1 --- os_dep/linux/ioctl_cfg80211.c | 21 +++++++++++++++++++-- os_dep/linux/os_intfs.c | 6 +++++- os_dep/osdep_service.c | 4 +++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index b68e5eb..5372185 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -1660,6 +1660,9 @@ exit: } static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + , int link_id +#endif , u8 key_index #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) , bool pairwise @@ -1804,6 +1807,9 @@ addkey_end: } static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + , int link_id +#endif , u8 keyid #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) , bool pairwise @@ -1969,6 +1975,9 @@ exit: } static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + int link_id, +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr) #else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) */ @@ -1989,7 +1998,11 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, } static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, - struct net_device *ndev, u8 key_index + struct net_device *ndev, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + int link_id, +#endif + u8 key_index #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)) || defined(COMPAT_KERNEL_RELEASE) , bool unicast, bool multicast #endif @@ -2037,7 +2050,11 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) int cfg80211_rtw_set_default_mgmt_key(struct wiphy *wiphy, - struct net_device *ndev, u8 key_index) + struct net_device *ndev, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + int link_id, +#endif + u8 key_index) { #define SET_DEF_KEY_PARAM_FMT " key_index=%d" #define SET_DEF_KEY_PARAM_ARG , key_index diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index f006fc8..abc2eb2 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1618,7 +1618,11 @@ int rtw_os_ndev_register(_adapter *adapter, const char *name) u8 rtnl_lock_needed = rtw_rtnl_lock_needed(dvobj); #ifdef CONFIG_RTW_NAPI - netif_napi_add(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + netif_napi_add_weight(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT); +#else + netif_napi_add(ndev, &adapter->napi, rtw_recv_napi_poll, RTL_NAPI_WEIGHT); +#endif #endif /* CONFIG_RTW_NAPI */ #if defined(CONFIG_IOCTL_CFG80211) diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 7367bca..dc43b81 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2574,7 +2574,9 @@ u64 rtw_division64(u64 x, u64 y) inline u32 rtw_random32(void) { #ifdef PLATFORM_LINUX -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)) + return get_random_u32(); +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)) return prandom_u32(); #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 18)) u32 random_int; From 07e3bebfb62a670849f169965d1f8328360bfae6 Mon Sep 17 00:00:00 2001 From: gluker Date: Thu, 30 Mar 2023 15:51:10 +0300 Subject: [PATCH 02/10] Fix compiler warnings --- core/rtw_br_ext.c | 6 +++--- os_dep/linux/ioctl_linux.c | 2 +- os_dep/osdep_service.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c index 532d6b3..b47698f 100644 --- a/core/rtw_br_ext.c +++ b/core/rtw_br_ext.c @@ -102,7 +102,7 @@ static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, un } -static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) +static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag, unsigned int tag_size) { struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); int data_len; @@ -117,7 +117,7 @@ static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_ta /* have a room for new tag */ memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length)); ph->length = htons(ntohs(ph->length) + data_len); - memcpy((unsigned char *)ph->tag, tag, data_len); + memcpy((unsigned char *)ph->tag, tag, (data_len > tag_size) ? tag_size : data_len); return data_len; } @@ -1167,7 +1167,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) memcpy(tag->tag_data + MAGIC_CODE_LEN, skb->data + ETH_ALEN, ETH_ALEN); /* Add relay tag */ - if (__nat25_add_pppoe_tag(skb, tag) < 0) + if (__nat25_add_pppoe_tag(skb, tag, sizeof(tag_buf)) < 0) return -1; RTW_INFO("NAT25: Insert PPPoE, forward %s packet\n", diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c index 35421a7..fbc162f 100644 --- a/os_dep/linux/ioctl_linux.c +++ b/os_dep/linux/ioctl_linux.c @@ -9789,7 +9789,7 @@ 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)); - _rtw_memcpy(padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */ + _rtw_memcpy((void *)padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */ #ifdef CONFIG_P2P rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter)); diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index dc43b81..9753ba4 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2451,7 +2451,7 @@ int rtw_change_ifname(_adapter *padapter, const char *ifname) rtw_init_netdev_name(pnetdev, ifname); - _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); + _rtw_memcpy((void *)pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); if (rtnl_lock_needed) ret = register_netdev(pnetdev); From cf7c7bf8ff3583f975633c01b969d793e5bc5686 Mon Sep 17 00:00:00 2001 From: gluker Date: Thu, 30 Mar 2023 17:53:55 +0300 Subject: [PATCH 03/10] Fix compiler warnings --- core/rtw_br_ext.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c index b47698f..ce26443 100644 --- a/core/rtw_br_ext.c +++ b/core/rtw_br_ext.c @@ -102,7 +102,7 @@ static __inline__ unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, un } -static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag, unsigned int tag_size) +static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) { struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); int data_len; @@ -117,7 +117,10 @@ static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_ta /* have a room for new tag */ memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length)); ph->length = htons(ntohs(ph->length) + data_len); - memcpy((unsigned char *)ph->tag, tag, (data_len > tag_size) ? tag_size : data_len); +#pragma GCC diagnostic ignored "-Wstringop-overread" + memcpy((unsigned char *)ph->tag, tag, data_len); +#pragma GCC diagnostic pop + return data_len; } @@ -1167,7 +1170,7 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) memcpy(tag->tag_data + MAGIC_CODE_LEN, skb->data + ETH_ALEN, ETH_ALEN); /* Add relay tag */ - if (__nat25_add_pppoe_tag(skb, tag, sizeof(tag_buf)) < 0) + if (__nat25_add_pppoe_tag(skb, tag) < 0) return -1; RTW_INFO("NAT25: Insert PPPoE, forward %s packet\n", From 0ef6dd6c0eb77ae9d5d068435907cb7d567dd2f9 Mon Sep 17 00:00:00 2001 From: gluker Date: Thu, 30 Mar 2023 18:22:40 +0300 Subject: [PATCH 04/10] Build support for kernel 6.3 --- os_dep/linux/ioctl_cfg80211.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 5372185..7b06b6f 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -417,7 +417,9 @@ u8 rtw_cfg80211_ch_switch_notify(_adapter *adapter, u8 ch, u8 bw, u8 offset, u8 if (ret != _SUCCESS) goto exit; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)) + cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0, 0); +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)) cfg80211_ch_switch_notify(adapter->pnetdev, &chdef, 0); #else cfg80211_ch_switch_notify(adapter->pnetdev, &chdef); From 1c29b9bced86703496a372add609554fe3e269fd Mon Sep 17 00:00:00 2001 From: gluker Date: Sun, 2 Apr 2023 04:39:03 +0300 Subject: [PATCH 05/10] Fix kernel warning dump at net/wireless/sme.c:843 --- os_dep/linux/ioctl_cfg80211.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 7b06b6f..cd4b0f9 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -1106,6 +1106,7 @@ check_bss: #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0) || defined(RHEL79)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)) + roam_info.links[0].channel = notify_channel; roam_info.links[0].bssid = cur_network->network.MacAddress; #else roam_info.bssid = cur_network->network.MacAddress; @@ -1140,13 +1141,17 @@ check_bss: RTW_INFO("pwdev->sme_state(b)=%d\n", pwdev->sme_state); #endif - if (check_fwstate(pmlmepriv, WIFI_MONITOR_STATE) != _TRUE) - rtw_cfg80211_connect_result(pwdev, cur_network->network.MacAddress - , pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2 - , pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2 - , pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6 - , pmlmepriv->assoc_rsp_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 6 - , WLAN_STATUS_SUCCESS, GFP_ATOMIC); + if (check_fwstate(pmlmepriv, WIFI_MONITOR_STATE) != _TRUE) { + roam_info.links[0].bss = cfg80211_get_bss(pwdev->wiphy, roam_info.links[0].channel, + roam_info.links[0].bssid, pwdev->u.client.ssid, pwdev->u.client.ssid_len, + pwdev->conn_bss_type, IEEE80211_PRIVACY_ANY); + cfg80211_connect_bss(wdev_to_ndev(pwdev), cur_network->network.MacAddress, roam_info.links[0].bss + , pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2 + , pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2 + , pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6 + , pmlmepriv->assoc_rsp_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 6 + , WLAN_STATUS_SUCCESS, GFP_ATOMIC, NL80211_TIMEOUT_UNSPECIFIED); + } #if defined(RHEL79) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0) || defined(COMPAT_KERNEL_RELEASE)) RTW_INFO("pwdev->sme_state(a)=%d\n", pwdev->sme_state); #endif From 971fad152cfde2aabdf060718bd2c8a9564abf4d Mon Sep 17 00:00:00 2001 From: gluker Date: Sun, 2 Apr 2023 06:29:37 +0300 Subject: [PATCH 06/10] Adopt patch for 5.x kernel warning dump --- os_dep/linux/ioctl_cfg80211.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index cd4b0f9..cc804ac 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -1142,10 +1142,10 @@ check_bss: #endif if (check_fwstate(pmlmepriv, WIFI_MONITOR_STATE) != _TRUE) { - roam_info.links[0].bss = cfg80211_get_bss(pwdev->wiphy, roam_info.links[0].channel, - roam_info.links[0].bssid, pwdev->u.client.ssid, pwdev->u.client.ssid_len, - pwdev->conn_bss_type, IEEE80211_PRIVACY_ANY); - cfg80211_connect_bss(wdev_to_ndev(pwdev), cur_network->network.MacAddress, roam_info.links[0].bss + struct cfg80211_bss *bss; + bss = cfg80211_get_bss(pwdev->wiphy, NULL, cur_network->network.MacAddress, NULL, 0, + IEEE80211_BSS_TYPE_ANY, IEEE80211_PRIVACY_ANY); + cfg80211_connect_bss(wdev_to_ndev(pwdev), cur_network->network.MacAddress, bss , pmlmepriv->assoc_req + sizeof(struct rtw_ieee80211_hdr_3addr) + 2 , pmlmepriv->assoc_req_len - sizeof(struct rtw_ieee80211_hdr_3addr) - 2 , pmlmepriv->assoc_rsp + sizeof(struct rtw_ieee80211_hdr_3addr) + 6 From 06420d21f1af5f9da58fbba5b13acf5f3f85f30b Mon Sep 17 00:00:00 2001 From: gluker Date: Mon, 17 Apr 2023 19:40:36 +0300 Subject: [PATCH 07/10] Pragma GCC > 10 warning fix --- core/rtw_br_ext.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/rtw_br_ext.c b/core/rtw_br_ext.c index ce26443..1998500 100644 --- a/core/rtw_br_ext.c +++ b/core/rtw_br_ext.c @@ -117,10 +117,13 @@ static __inline__ int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_ta /* have a room for new tag */ memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length)); ph->length = htons(ntohs(ph->length) + data_len); -#pragma GCC diagnostic ignored "-Wstringop-overread" +#if (defined __GNUC__) && (__GNUC__ > 10) + #pragma GCC diagnostic ignored "-Wstringop-overread" +#endif memcpy((unsigned char *)ph->tag, tag, data_len); -#pragma GCC diagnostic pop - +#if (defined __GNUC__) && (__GNUC__ > 10) + #pragma GCC diagnostic pop +#endif return data_len; } From ecd47ade1eb0edc89b175533b2f03392ff423799 Mon Sep 17 00:00:00 2001 From: gluker Date: Thu, 27 Apr 2023 19:36:07 +0300 Subject: [PATCH 08/10] halrf_cmninfo_hook u32 -> enum fix --- hal/phydm/halrf/halrf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/phydm/halrf/halrf.h b/hal/phydm/halrf/halrf.h index 7240397..58c6ca2 100644 --- a/hal/phydm/halrf/halrf.h +++ b/hal/phydm/halrf/halrf.h @@ -354,7 +354,7 @@ halrf_cmn_info_init( void halrf_cmn_info_hook( void *dm_void, - u32 cmn_info, + enum halrf_cmninfo_hook cmn_info, void *value ); From f1a456db45d14914db664fb1edd5f8d4cdd0fcfa Mon Sep 17 00:00:00 2001 From: gluker Date: Thu, 14 Sep 2023 20:04:53 +0300 Subject: [PATCH 09/10] Update README.md --- README.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b135d44..671350c 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,25 @@ * MESH Support * Monitor mode * Frame injection -* Up to kernel v6.0+ +* Up to kernel v6.5+ ... And a bunch of various wifi chipsets # Howto build/install -1. You will need to blacklist another driver in order to use this one. -2. `echo 'blacklist r8188eu'|sudo tee -a '/etc/modprobe.d/realtek.conf'` -3. Reboot -4. cd rtl8188eus -5. `make && sudo make install` -6. Reboot in order to blacklist and load the new driver/module. +1. Compile and install the driver: +``` +cd rtl8188eus +make && sudo make install +``` +2. Blacklist another drivers in order to use this one: +``` +echo 'blacklist r8188eu' | sudo tee -a '/etc/modprobe.d/realtek.conf' +echo 'blacklist rtl8xxxu' | sudo tee -a '/etc/modprobe.d/realtek.conf' +``` +3. `reboot` or remove all drivers related to RTL8188 and reload this one: +``` +rmmod r8188eu rtl8xxxu 8188eu +modprobe 8188eu +``` # MONITOR MODE howto Use these steps to enter monitor mode. From ab10991fa817ec63682ec0f0cbd3524d3eb78fcc Mon Sep 17 00:00:00 2001 From: gluker Date: Thu, 14 Sep 2023 20:13:34 +0300 Subject: [PATCH 10/10] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 671350c..452c3da 100644 --- a/README.md +++ b/README.md @@ -41,14 +41,14 @@ modprobe 8188eu # MONITOR MODE howto Use these steps to enter monitor mode. ``` -$ sudo airmon-ng check kill -$ sudo ip link set down -$ sudo iw dev set type monitor +sudo airmon-ng check kill +sudo ip link set down +sudo iw dev set type monitor ``` Frame injection test may be performed with (after kernel v5.2 scanning is slow, run a scan or simply an airodump-ng first!) ``` -$ aireplay -9 +sudo aireplay-ng -9 ``` # NetworkManager configuration