developer | 617abbd | 2024-04-23 14:50:01 +0800 | [diff] [blame^] | 1 | From 30cd94f678f5f85703854812f0deb6467b37df5f Mon Sep 17 00:00:00 2001 |
| 2 | From: Sriram R <quic_srirrama@quicinc.com> |
| 3 | Date: Thu, 28 Mar 2024 23:46:39 +0530 |
| 4 | Subject: [PATCH 009/104] hostapd: MLO: pass link_id in get_hapd_bssid helper |
| 5 | function |
| 6 | |
| 7 | Currently get_hapd_bssid() function matches the given bssid in all bsses |
| 8 | of its own iface. However with MLO, there is requirement to check its |
| 9 | own partner BSS at least. |
| 10 | |
| 11 | Make changes to compare its link partners as well and if link id passed |
| 12 | matches with the link id of the partner then return it. |
| 13 | |
| 14 | Signed-off-by: Sriram R <quic_srirrama@quicinc.com> |
| 15 | Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com> |
| 16 | --- |
| 17 | src/ap/drv_callbacks.c | 47 +++++++++++++++++++++++++----------------- |
| 18 | 1 file changed, 28 insertions(+), 19 deletions(-) |
| 19 | |
| 20 | diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c |
| 21 | index 2d3206909..adac2d478 100644 |
| 22 | --- a/src/ap/drv_callbacks.c |
| 23 | +++ b/src/ap/drv_callbacks.c |
| 24 | @@ -1750,7 +1750,7 @@ switch_link_hapd(struct hostapd_data *hapd, int link_id) |
| 25 | #define HAPD_BROADCAST ((struct hostapd_data *) -1) |
| 26 | |
| 27 | static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 28 | - const u8 *bssid) |
| 29 | + const u8 *bssid, int link_id) |
| 30 | { |
| 31 | size_t i; |
| 32 | |
| 33 | @@ -1761,8 +1761,30 @@ static struct hostapd_data * get_hapd_bssid(struct hostapd_iface *iface, |
| 34 | return HAPD_BROADCAST; |
| 35 | |
| 36 | for (i = 0; i < iface->num_bss; i++) { |
| 37 | +#ifdef CONFIG_IEEE80211BE |
| 38 | + struct hostapd_data *hapd, *p_hapd; |
| 39 | + |
| 40 | + hapd = iface->bss[i]; |
| 41 | + if (ether_addr_equal(bssid, hapd->own_addr) || |
| 42 | + (hapd->conf->mld_ap && |
| 43 | + ether_addr_equal(bssid, hapd->mld->mld_addr) && |
| 44 | + link_id == hapd->mld_link_id)) { |
| 45 | + return hapd; |
| 46 | + } else if (hapd->conf->mld_ap) { |
| 47 | + for_each_mld_link(p_hapd, hapd) { |
| 48 | + if (p_hapd == hapd) |
| 49 | + continue; |
| 50 | + |
| 51 | + if (ether_addr_equal(bssid, p_hapd->own_addr) || |
| 52 | + (ether_addr_equal(bssid, p_hapd->mld->mld_addr) && |
| 53 | + link_id == p_hapd->mld_link_id)) |
| 54 | + return p_hapd; |
| 55 | + } |
| 56 | + } |
| 57 | +#else |
| 58 | if (ether_addr_equal(bssid, iface->bss[i]->own_addr)) |
| 59 | return iface->bss[i]; |
| 60 | +#endif /*CONFIG_IEEE80211BE */ |
| 61 | } |
| 62 | |
| 63 | return NULL; |
| 64 | @@ -1773,7 +1795,7 @@ static void hostapd_rx_from_unknown_sta(struct hostapd_data *hapd, |
| 65 | const u8 *bssid, const u8 *addr, |
| 66 | int wds) |
| 67 | { |
| 68 | - hapd = get_hapd_bssid(hapd->iface, bssid); |
| 69 | + hapd = get_hapd_bssid(hapd->iface, bssid, -1); |
| 70 | if (hapd == NULL || hapd == HAPD_BROADCAST) |
| 71 | return; |
| 72 | |
| 73 | @@ -1813,14 +1835,7 @@ static int hostapd_mgmt_rx(struct hostapd_data *hapd, struct rx_mgmt *rx_mgmt) |
| 74 | if (bssid == NULL) |
| 75 | return 0; |
| 76 | |
| 77 | -#ifdef CONFIG_IEEE80211BE |
| 78 | - if (hapd->conf->mld_ap && |
| 79 | - ether_addr_equal(hapd->mld->mld_addr, bssid)) |
| 80 | - is_mld = true; |
| 81 | -#endif /* CONFIG_IEEE80211BE */ |
| 82 | - |
| 83 | - if (!is_mld) |
| 84 | - hapd = get_hapd_bssid(iface, bssid); |
| 85 | + hapd = get_hapd_bssid(iface, bssid, rx_mgmt->link_id); |
| 86 | |
| 87 | if (!hapd) { |
| 88 | u16 fc = le_to_host16(hdr->frame_control); |
| 89 | @@ -1872,17 +1887,11 @@ static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, |
| 90 | struct ieee80211_hdr *hdr; |
| 91 | struct hostapd_data *orig_hapd, *tmp_hapd; |
| 92 | |
| 93 | -#ifdef CONFIG_IEEE80211BE |
| 94 | - if (hapd->conf->mld_ap && link_id != -1) { |
| 95 | - tmp_hapd = hostapd_mld_get_link_bss(hapd, link_id); |
| 96 | - if (tmp_hapd) |
| 97 | - hapd = tmp_hapd; |
| 98 | - } |
| 99 | -#endif /* CONFIG_IEEE80211BE */ |
| 100 | orig_hapd = hapd; |
| 101 | |
| 102 | hdr = (struct ieee80211_hdr *) buf; |
| 103 | - tmp_hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len)); |
| 104 | + hapd = switch_link_hapd(hapd, link_id); |
| 105 | + tmp_hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len), link_id); |
| 106 | if (tmp_hapd) { |
| 107 | hapd = tmp_hapd; |
| 108 | #ifdef CONFIG_IEEE80211BE |
| 109 | @@ -1899,7 +1908,7 @@ static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, |
| 110 | if (stype != WLAN_FC_STYPE_ACTION || len <= 25 || |
| 111 | buf[24] != WLAN_ACTION_PUBLIC) |
| 112 | return; |
| 113 | - hapd = get_hapd_bssid(orig_hapd->iface, hdr->addr2); |
| 114 | + hapd = get_hapd_bssid(orig_hapd->iface, hdr->addr2, link_id); |
| 115 | if (!hapd || hapd == HAPD_BROADCAST) |
| 116 | return; |
| 117 | /* |
| 118 | -- |
| 119 | 2.39.2 |
| 120 | |