Add support for Linux Kernel 6.1

This commit is contained in:
Sophie Brun 2023-02-21 14:50:58 +01:00
parent 3c1147c914
commit 524958cc4b
No known key found for this signature in database
GPG Key ID: 5792783B206FEE30
2 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,112 @@
From: Sophie Brun <sophie@offensive-security.com>
Date: Tue, 21 Feb 2023 14:49:29 +0100
Subject: Add Linux 6.1 build support
Origin: https://github.com/aircrack-ng/rtl8188eus/pull/226
---
dkms.conf | 1 -
os_dep/linux/ioctl_cfg80211.c | 21 +++++++++++++++++++--
os_dep/linux/os_intfs.c | 4 ++++
os_dep/osdep_service.c | 4 +++-
4 files changed, 26 insertions(+), 4 deletions(-)
diff --git a/dkms.conf b/dkms.conf
index 2c60a99..d1d1dc8 100644
--- a/dkms.conf
+++ b/dkms.conf
@@ -7,4 +7,3 @@ PROCS_NUM=`nproc`
DEST_MODULE_LOCATION[0]="/updates"
MAKE="'make' -j$PROCS_NUM KVER=${kernelver} KSRC=/lib/modules/${kernelver}/build"
AUTOINSTALL="yes"
-REMAKE_INITRD=no
diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c
index b68e5eb..b799e58 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..1d28862 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
+#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..5480971 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;

View File

@ -1 +1,2 @@
add-support-kernel-5.17.patch add-support-kernel-5.17.patch
add-linux-6.1-support.patch