Skip to content

Commit 54b37e6

Browse files
committed
Align with recent cfg80211 header
Starting from kernel version 6.7, several significant changes have been made to the cfg80211 subsystem. 1. The scan_width field is no longer present in the cfg80211_inform_bss structure. There really isn't any support for scanning at different channel widths than 20 MHz since there's no way to set it. 2. The parameters in the change_beacon function have been updated to cfg80211_ap_update. The change_beacon function now includes two additional parameters, fils_discovery and unsol_bcast_probe_resp, which arepart of the cfg80211_ap_update structure.
1 parent 308459f commit 54b37e6

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

vwifi.c

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ static void inform_bss(struct vwifi_vif *vif)
454454
struct cfg80211_inform_bss data = {
455455
/* the only channel */
456456
.chan = &ap->wdev.wiphy->bands[NL80211_BAND_2GHZ]->channels[0],
457+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
457458
.scan_width = NL80211_BSS_CHAN_WIDTH_20,
459+
#endif
458460
.signal = DBM_TO_MBM(rand_int_smooth(-100, -30, jiffies)),
459461
};
460462
int capability = WLAN_CAPABILITY_ESS;
@@ -529,7 +531,7 @@ static enum hrtimer_restart vwifi_beacon(struct hrtimer *timer)
529531
.boottime_ns = ktime_get_boottime_ns(),
530532
.chan = vif->channel,
531533
};
532-
534+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
533535
switch (vif->bw) {
534536
case NL80211_CHAN_WIDTH_5:
535537
bss_meta.scan_width = NL80211_BSS_CHAN_WIDTH_5;
@@ -541,7 +543,7 @@ static enum hrtimer_restart vwifi_beacon(struct hrtimer *timer)
541543
bss_meta.scan_width = NL80211_BSS_CHAN_WIDTH_20;
542544
break;
543545
}
544-
546+
#endif
545547
int capability = WLAN_CAPABILITY_ESS;
546548

547549
if (vif->privacy)
@@ -1577,7 +1579,7 @@ static int vwifi_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
15771579

15781580
return 0;
15791581
}
1580-
1582+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
15811583
static int vwifi_change_beacon(struct wiphy *wiphy,
15821584
struct net_device *ndev,
15831585
struct cfg80211_beacon_data *info)
@@ -1611,7 +1613,41 @@ static int vwifi_change_beacon(struct wiphy *wiphy,
16111613

16121614
return 0;
16131615
}
1616+
#else
1617+
static int vwifi_change_beacon(struct wiphy *wiphy,
1618+
struct net_device *ndev,
1619+
struct cfg80211_ap_update *info)
1620+
{
1621+
struct vwifi_vif *vif = ndev_get_vwifi_vif(ndev);
1622+
int ie_offset = DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_FIXED_LEN;
1623+
int head_ie_len, tail_ie_len;
1624+
1625+
/* cfg80211 and some user-space programs treat IEs as two-part:
1626+
* 1. head: 802.11 beacon frame header + beacon IEs before TIM IE
1627+
* 2. tail: beacon IEs after TIM IE
1628+
* We combine them and store them in vif->beacon_ie.
1629+
*/
1630+
head_ie_len = info->beacon.head_len - ie_offset;
1631+
tail_ie_len = info->beacon.tail_len;
16141632

1633+
if (likely(head_ie_len + tail_ie_len <= IE_MAX_LEN)) {
1634+
vif->beacon_ie_len = head_ie_len + tail_ie_len;
1635+
memset(vif->beacon_ie, 0, IE_MAX_LEN);
1636+
memcpy(vif->beacon_ie, &info->beacon.head[ie_offset], head_ie_len);
1637+
memcpy(vif->beacon_ie + head_ie_len, info->beacon.tail, tail_ie_len);
1638+
1639+
pr_info(
1640+
"%s: head_ie_len (before TIM IE) = %d, tail_ie_len = "
1641+
"%d",
1642+
__func__, head_ie_len, tail_ie_len);
1643+
} else {
1644+
pr_info("%s: IE exceed %d bytes!\n", __func__, IE_MAX_LEN);
1645+
return 1;
1646+
}
1647+
1648+
return 0;
1649+
}
1650+
#endif
16151651
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
16161652
static int vwifi_add_key(struct wiphy *wiphy,
16171653
struct net_device *ndev,
@@ -2550,7 +2586,9 @@ static void vwifi_virtio_mgmt_rx_scan_response(
25502586
};
25512587
struct cfg80211_inform_bss data = {
25522588
.chan = &rx_channel,
2589+
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 7, 0)
25532590
.scan_width = NL80211_BSS_CHAN_WIDTH_20,
2591+
#endif
25542592
.signal = DBM_TO_MBM(rand_int_smooth(-100, -30, jiffies)),
25552593
};
25562594

0 commit comments

Comments
 (0)