Compare commits

...

71 Commits

Author SHA1 Message Date
Chaitanya Godavarthi
3531b884c1 wifi-3258: Fix bridge client traffic on same wifi interface
Allow bridging broadcast and multicast traffic within same
bridge port if hairpinmode is enabled for that port.
This fixes the ARP packet between clients on same wifi interface
being dropped.

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-08-09 18:39:54 -04:00
Chaitanya Godavarthi
5ef0556406 wifi-3051: Set proper mode & freq in RRM NF chan switch
For RRM noise floor driven channel change:
1. Set HT VHT HE based on the hw_mode
2. Set secondary frequency (center_freq1) based on bandwidth

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-08-06 09:12:45 -04:00
ravi vaishnav
bdbf536c85 Wifi-3246. Add chan_info data to existing survey info data
The data from the chan_info events were overwriting the data
to the existing survey info counters. The data in the chan_info
events were Read-On-Clear where as the Survey info was maintained
as incremental stats and the application in the User space
performs the calculations based on incremental survey info stats.
As an example, the survey->time was always stored as 150 due to
chan_info event's Clear-On-Read nature. And this lead to the
difference calcuation as 0 at the User space application.

Solution is to add the incoming chan_info data to the existing
survey info stats, instead of replacing the existing data with new.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-08-05 18:02:32 -04:00
Owen Anderson
80bfd39857 WIFI-3306: Updated the LLDP description with firmware version info and br-wan IP
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-08-05 12:38:44 -04:00
Owen Anderson
d3f8a54de5 WIFI-2059: Removed if statement that blocked some ip updates
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-08-04 11:38:18 -04:00
Yashvardhan
8bec57d411 wifi-3331: Fix opensync Firmware version date format
- Opensync fw version date was getting trimmed.
   This patch fixes the same

Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-08-03 23:50:02 -04:00
Arif Alam
36b10b5048 WIFI-3023: fix mac assign on ath11k
Port over mac assign fix from v2.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-07-31 08:19:42 -04:00
Chaitanya Godavarthi
a019801c15 wifi-3301:Sync Wifi_associated_Clients if opensync restarts
Query the driver and update the wifi_associated_clients list
during wm initialization.

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-07-31 08:18:07 -04:00
Yashvardhan
dee3bd0d76 Wifi-3309: Fix Tx power reporting
- AP was not reporting the Channel Tx power currently set in
   the firmware. This patch reads the Tx power from debugFS stats
   and reports it to cloud through Wifi_Radio_State table

Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-07-31 08:15:39 -04:00
John Crispin
8d09f695a2 ipq807x: fix the reset buttons on the CIG units
Signed-off-by: John Crispin <john@phrozen.org>
2021-07-29 16:43:17 -04:00
Owen Anderson
3a195281a9 WIFI-2844: Removed the fallback case for when country code isn't set
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-07-29 16:37:40 -04:00
Chaitanya Godavarthi
ce33028760 wifi-3288:Fix Associated clients in case of roaming
Associated clients list decrements when client roams
from vifX to vifY. In this case, the client is
first added to the global client list as part of it
associating with vifY (but in actual it doesnt add as
the entry for client already exists) and then deleted
from the same as part of dissassociating from vifX.

Fix is to change the vif the client entry points to
instead of add/delete the client entry.

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-07-29 16:35:22 -04:00
Owen Anderson
d5320b26c2 WIFI-3236: Added reason code to switch_chan ubus call
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-07-29 14:42:58 -04:00
Yashvardhan
0d48934f34 Wifi-3237: Fix missing and duplicate client events
Some client events are duplicated and some of them are missing in the
client event report.

Root Cause 1: Processed clients events were not tagged in hostapd and
were thus getting duplicated during subsequent polling of client events.
Root Cause 2: Race between processing and clearing of client sessions
was leading to missing events.

Solution 1: Processed client events are tagged in hostapd and are reported only once.
Solution 2: Sessions are cleared only after they are processed by SM.

Also got rid of some unnecessary logs.

Acceptance Criteria: No duplicate client events in the mqtt report send by AP.
Sessions in the hostapd are successfully cleared after being processed by SM.

Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-07-28 09:59:45 -04:00
Chaitanya Godavarthi
0ec23e8dba wifi-2940: Add ath11k beacon and mcast rate
Add support for changing mcast and beacon rate
in opensync for ath11k
Add debugfs entry for ath11k driver to set mcast,
beacon and mgmt rate.
For help:
cat /sys/kernel/debug/ieee80211/phyX/ath11k/set_rates

Eg: Set beacon rate to 12Mbps for iface wlan0 5G band
echo "wlan0 beacon 5 0x10000002" > /sys/kernel/debug/ieee80211/phy0/ath11k/set_rates

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-07-28 09:12:46 -04:00
Yashvardhan
0d1096b754 wifi-3203 Fix ath10k version in the rx_bss patch
- Fix rx_bss patch to compile for the current ath10k version used
   which is ath10k-5.7

Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-07-22 09:54:34 -04:00
Arthur Su
de16ed3a49 wifi-2984: tplink device mount manufacturing data and certificates
The TP-Link device mounts the production_info partition, and apnos will
access the manufacturing data and copy the certificate to its use when
it is first booted.

Signed-off-by: Arthur Su <arthur.su@tp-link.com>

wifi-2984: tplink device mount manufacturing data and certificates

The EX227 and EX447 devices are added ath11k_generate_macs method.

Signed-off-by: Arthur Su <arthur.su@tp-link.com>
2021-07-21 09:54:45 -04:00
Chaitanya Godavarthi
7436923e62 wifi-2982 wifi-2944: Fix DFS channel switch for RRM
Switch to a DFS channel by RRM failed
since cac was not being run. We set the Beacon
CSA IE and reload the interface with new channel.

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-07-21 09:48:36 -04:00
Owen Anderson
f49c70d864 WIFI-3063: Changed the way that we fetch the interface name so the interface doesn't need to be online
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-07-20 09:44:55 -04:00
Yashvardhan
b613c1815a WIFI-3055: Fix data metric reporting inconsistency
Inconsistency(gaps in reporting) was noticed when metrics were observed
for 24 hours.

Root Cause: One of the sockets created and used in SM for periodic network-probe reporting
was not getting closed. Due to this system wide limit for maximum open file descriptors
was getting exhausted over a period of time and thus not allowing to create any more
sockets to send data.

Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-07-15 22:43:22 -04:00
Chaitanya Godavarthi
11af12a786 wifi-2981: Send proper mode and freq in channel switching
1. Set HT VHT HE based on the hw_mode
2. Set secondary frequency (center_freq1) based on bandwidth
3. Add HE parameter in ubus call switch_chan

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-07-15 16:04:15 -04:00
ravi vaishnav
17f86797d7 Wifi-3021. Avoid creating VLAN interface on LAN side
Under Bridged mode of configuration, when creating VLAN interface,
we create VLAN for both WAN and LAN side, whereas LAN side VLAN is
not requried.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-07-14 18:14:05 -04:00
Arif Alam
29290b5b85 WIFI-2939: Add offset to channel noisefloor
Add offset to channel noisefloor stats.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-07-14 09:12:26 -04:00
Nagendrababu
9796b90bf3 WiFi-1997-LEDs-Incorrect-Service-State
This Patch fixes leds incorrect service state issue, and correct the
label names for all wifi6 APs

Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
2021-07-13 19:39:30 -04:00
Nagendrababu
bf5fac9d97 WiFi5-APs-LED-label-Name-Change
This patch will change the ecw5410, ecw5211, and wf610D's LED label name

Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
2021-07-13 19:34:02 -04:00
Owen Anderson
52867a65b4 WIFI-2814: Removed duplicate entries from hostapd.sh
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-07-13 19:19:33 -04:00
Arthur Su
95f43d6da0 WIFI-2978 - Fix EC420 reset button
The EC420 reset button don't work, so it cannot be restarted or restored
to factory settings. The reset button is fixed to gpio18.

Signed-off-by: Arthur Su <arthur.su@tp-link.com>
2021-07-13 19:15:16 -04:00
Yashvardhan
60072a8ad6 ath10/11k: Report amount of time the radio spent receiving data on a local BSS
- Currently ath10/11k reports time_bss_rx (amount of time the radio spent receiving data on a local BSS)
   inside time_rx (amount of time the radio spent receiving data). This patch fixes the behavior.
 - Added support to report time_bss_rx over nl80211

Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-07-08 14:00:01 -04:00
Yashvardhan
6ca49d80fc WIFI-2954 - Fix channel survey dump
Channel time, busy and other survey counters are showing incorrect values (less than previous or sometimes zero).
Consecutive survey dumps are expected to return monotonically increasing counter values.

Root Cause:
Clear on read in ath10k was leading to this issue.

Solution: Use the non-clearing
WMI_BSS_SURVEY_REQ_TYPE_READ wmi_bss_survey_req_type

Note: ath11k already has this fix.

Patch also fixes the utilization percentage calculation for different survey parameters in opensync

Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-07-08 13:55:40 -04:00
ravi vaishnav
3cefdead18 Wifi-2952. Fix for flooding client events for Auth and Assoc
Sometimes we see a Client session created with sessionId=0,
and this never gets deleted. The AP keep on sending this event
as long as it exist in the events list.
SessionId=0 is invalid. Adding checks to avoid creating session
with Id=0. Also added a check in the opensync ubus to skip
already processed events.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-07-07 23:41:09 -04:00
Ammad Rehmat
f5470bf439 Wifi-2538 : clients dropped on RRM rebalance
Add rrm channel setting through radio config. This
allows channel change through radio config in the
case where vif is not reloaded.

The below commit disables reload of vif when setting
RRM parameters:
"wifi-2648:Config RRM params without wifi vif reload"

Signed-off-by: Ammad Rehmat <ammad.rehmat@connectus.ai>
Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-07-06 22:07:47 -04:00
Chaitanya Godavarthi
519898ea3b wifi-2648:Config RRM params without wifi vif reload
Configure the following without vif reload:
Tx power
probe_response_threshold
client disconnect threshold
Beacon and multicast rates

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-07-06 15:53:22 -04:00
Arif Alam
dedbb75ae6 WIFI-2626: radius proxy: fix wildcard realm config
Wildcard realm needs to be configured as the very last item.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-07-05 14:39:21 -04:00
Arif Alam
837b4511a1 WIFI-2691: Enable proxy arp by default
wifi6 AP does not forward broadcast ARP request sent from one wifi
client to another wifi client.  Enable proxy arp by default to have the
AP respond to ARP requests on behalf of the client.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-07-04 14:37:44 -04:00
Owen Anderson
bab7b18724 WIFI-2594: Added functionality to close lan ssh port in deployment
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-06-29 22:16:35 -04:00
Owen Anderson
5bf882b0e0 WIFI-2681: Allow re-trying a failed upgrade
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-06-25 15:24:37 -04:00
ravi vaishnav
0546954693 Wifi-2690. ipq807x:Enable bridge-mgr to control port mac address learning
Merging from uCentral-trunk.
The switch in the IPQ807x/IPQ60xx devices will automatically learn the mac
addresses behind a port. But it will not unlearn this entry when some mac
switches from the ethernet port to the CPU port. This will for example
happens when a device roams from on AP to another AP. At least when both
are APs are bridging the wifi traffic directly or indirectly (mesh) to the
same ethernet broadcast domain.

As result, the roaming device can no longer receive any ethernet packets
which the AP is expected to receive on the ethernet port. This state will
be kept for a couple of minutes until the entry in the FDB is dropped
automatically. But it is still possible for the wifi device to send data
via the ethernet during this whole time.

One solution is to just disable learning on all ports. The other option
would be to enable the qca bridge-mgr which takes care of gathering the
events from the bridge and forwards it to the qca-ssdk (to manipulate the
state of the switch). The latter option was chosen to follow the approach
which QCA is also using in their QSDK.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-06-25 15:20:35 -04:00
Owen Anderson
b6743c34ee WIFI-2825: Supress noisy logs
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-06-25 08:10:10 -04:00
Chaitanya Godavarthi
72fa379804 wifi-2649: Fix SM memory leak
memory leaks while reading apc state/config.
Change read method for apc state/config

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-06-25 08:06:16 -04:00
Nagendrababu
d852dcc8f2 WIFI-2728-captive-portal-config-parameters-overwriting-issue
This patch will add the conditions to respond captive portal API's to
only valid configuration

Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
2021-06-24 09:04:39 -04:00
Chaitanya Godavarthi
31abbf39ae wifi-2649 Fix Captive portal vifC vifS mismatch
Mismatch in vifC and vifS for captive portal is
leading to opennds restarts and memory leakage.
Fix by making sure the vifC and vifS are in parity.

uci_blob not being freed, fix by making uci_blob
as global so that it need not be freed and can
be reused instead.

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>

Cleaning up captive portal code to improve stability and reduce memory leaks

Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
2021-06-23 21:16:07 -04:00
Owen Anderson
63443bae1d WIFI-2685, WIFI-2694: Fixed issues in Luci http portal
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-06-23 15:52:51 -04:00
cbuschfb
4662b33549 Merge branch 'staging-revert-wifi-2152' into pending.
Per Yash request.

Signed-off-by: Chris Busch chrisbusch@fb.com
2021-06-21 16:23:10 -04:00
Yashvardhan
7614fc335b Revert "WIFI-2152: Allow re-trying a failed upgrade"
This reverts commit d6d45ba609.
2021-06-21 12:17:36 -07:00
Owen Anderson
208b016570 WIFI-2671: Added codes 12 & 13 for rebbot & factory reset upgrade options
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-06-18 16:47:41 -04:00
Owen Anderson
78b1f77a53 WIFI2680: Revert inactivefw if sysupgrade fails
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-06-18 16:39:53 -04:00
Owen Anderson
d6d45ba609 WIFI-2152: Allow re-trying a failed upgrade 2021-06-18 12:55:37 -04:00
John Crispin
bebf6d322d mac80211/ath11k: backport krak2 mitigation
Signed-off-by: John Crispin <john@phrozen.org>
2021-06-16 11:56:41 -04:00
Arif Alam
e8418c0c54 WIFI-1899: Fix disable dgaf config
Fix disable dgaf config not getting applied.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-06-16 11:39:58 -04:00
Arif Alam
1b45173b32 WIFI-2634: Enable RADIUS accounting multi session id AVP
Turn on PMKSA and Opportunistic Key Caching to get Acct-Multi-Session-Id working.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-06-16 11:35:28 -04:00
Arif Alam
29344abf3e WIFI-2087: WPA3-Enterprise 192-Bit support
Configure SUITE-B-192, BIP-GMAC-256 and GCMP-256.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-06-15 11:34:17 -04:00
Yashvardhan
39bd8f30c0 wifi-2075- Fix for inconsistency in applying vif configuration
- During the configuration process, AP was triggering network
   and wireless reload multiple times in a very short window
   resulting in a poorly configured hostapd. This patch makes sure
   that network/wireless is reloaded only once after all the configuration
   is committed to UCI files.

Signed-off-by: Yashvardhan <yashvardhan@netexperience.com>
2021-06-15 11:32:00 -04:00
Rick Sommerville
1791870562 WIFI-2604 wlan-ap-factory-reset.sh calls DigiCert
Signed-off-by: Rick Sommerville <rick.sommerville@netexperience.com>
2021-06-15 08:06:53 -04:00
Chaitanya Godavarthi
b2a9e6316c wifi-2512: apc gets stuck in wt mode 1 in 5 reboots
Check if APC conf is disabled and not update the
APC state.

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-06-14 13:07:12 -04:00
ravi vaishnav
463f903992 Wifi-2635. Correcting the Model name format
When the manufacturer block does not contain the model info,
it is then extracted from /tmp/sysinfo/board_name, stripped
off the manufacturer name and converted for all upper case string.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-06-11 21:06:17 -04:00
Nagendrababu
547fb36d78 WIFI-1934-LED-Turnoff
This Patch will add support to turnoff LEDs of the AP through cloud
command

Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
2021-06-11 09:43:14 -04:00
Arif Alam
b9e54ac20e WIFI-838: Dynamic discovery of HSPs/IDPs
Dynamically discover RADSEC endpoint based on NAPTR DNS records.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-06-11 09:34:24 -04:00
ravi vaishnav
490adac587 Wifi-2544. Fix for Off-chan dwell time configuration
Applying the user configured dwell time for off-channel scan
requests. This needed driver changes to accommodate the command/event
processing time in the configured scan timeout, otherwise the scan
is aborted resulting in no off-channel survey results.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-06-11 09:07:56 -04:00
Owen Anderson
8a69771074 WIFI-2410: Fixed position of ubus check in hostapd assoc code
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-06-08 21:25:40 -04:00
Nagendrababu
cfba41d7cc WIFI-1907-CPU-Utilization
Made minor changes to improve the accuracy of cpu utilization metric

Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
2021-06-07 20:10:43 -04:00
Owen Anderson
e6bb6f7d4f WIFI-721: Added new var to Radio State that stores max channel power
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-06-07 19:48:40 -04:00
ravi vaishnav
c0cb6baa89 Wifi-2542. Fix for populating correct ID in AWLAN_Node
This fix applies to EA8300, WF194c and EAP102. For these APs,
the br-wan is mapped to eth1 instead of eth0. Adding fix to
use the mac address from eth1 as ID for these particular APs.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-06-07 19:38:47 -04:00
Rick Sommerville
28bc1daeac WIFI-2502 Fix WM crash due to invalid data
Signed-off-by: Rick Sommerville <rick.sommerville@netexperience.com>
2021-06-07 19:34:09 -04:00
Nagendrababu
80f67521f8 WIFI-1933-Blink-APs-LED
This patch will change the label names for WiFi6 APs to follow common naming convention

Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
2021-06-04 13:08:00 -04:00
ravi vaishnav
7569b618ff WiFi-1827. Updates for RRM Channel Hop based on Noise Floor threshold
Average Noise Floor is calcluated for the last few samples based on the
configured Noise Floor time. This calculated avg Noise Floor is compared
against the configured Noise Floor threshold to decide if a Channel hop
is required. While calculating the average, each noise sample is first
converted from dBm to milliWatts, an avaerage of the all the noise
samples in milliWatt is calculated, then the average is converted back
to dBm.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-06-04 12:48:23 -04:00
Owen Anderson
3881ec638b WIFI-2148: Added auto value for hw_mode in config
Signed-off-by: Owen Anderson <owenthomasanderson@gmail.com>
2021-06-03 12:50:56 -04:00
Chaitanya Godavarthi
b71059cce6 wifi-2512 APC state gets stuck in WT mode on bootup
Sometimes the APC_State mode gets stuck in WT mode
on bootup. Sometimes the APC State gets updated at
the same time as disabling the APC (SIGTERM puts it in NC mode)
So it may get updated to WT just after SIGTERM handler
puts it in NC mode.
Fix this by setting APC_State in NC mode again after disabling
the APC from opensync (wm).

Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
2021-06-03 12:17:48 -04:00
Arif Alam
f68851cc75 WIFI-2517: auto config radius params when radius proxy is enabled
Auto configure per-ssid radius params to talk to the radius proxy service.

Signed-off-by: Arif Alam <arif.alam@netexperience.com>
2021-06-03 11:56:33 -04:00
Nagendrababu
34c9006ede WIFI-1864-CPU-Temperature_Update
This patch will add the support to read the cpu temperature of ath11k
chipset boards and update to the UI
Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
2021-06-03 11:50:45 -04:00
ravi vaishnav
e528b832bb Wifi-2529. SM crash when DM tries to re-spawn the SM process.
The earlier changes for detaching the nl sockets for SM activity
also included a small change to relocate the event subscription.
This relocation of code is causing the crash due to possible
NULL pointer dereference.
Reverting the event subscription relocation code to avoid the
continuous SM crash.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-06-03 11:44:01 -04:00
ravi vaishnav
89640188c9 Wifi-2384. Fix for StatsManager crash
Could not root-cause the issue for SM crash, but there were enough
indications of some kind of memory corruption. Different core captures
show the code crashing at different places. An experiment to unblock
the SM socket on the receive end helped avoid the corruption and
subsequently the crashes.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
2021-06-02 16:06:04 -04:00
101 changed files with 12875 additions and 516 deletions

View File

@@ -0,0 +1,626 @@
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=qca-nss-clients
PKG_SOURCE_PROTO:=git
PKG_BRANCH:=master
PKG_RELEASE:=2
PKG_SOURCE_URL:=https://source.codeaurora.org/quic/qsdk/oss/lklm/nss-clients/
PKG_VERSION:=9136ef60bf68ceed760781d3acbeddb05470e432
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=$(PKG_VERSION)
#PKG_BUILD_DEPENDS := PACKAGE_kmod-qca-nss-crypto:kmod-qca-nss-crypto
MAKE_OPTS:=
include $(INCLUDE_DIR)/package.mk
# Keep default as ipq806x for branches that does not have subtarget framework
ifeq ($(CONFIG_TARGET_ipq),y)
subtarget:=$(SUBTARGET)
else
subtarget:=$(CONFIG_TARGET_BOARD)
endif
ifneq (, $(findstring $(subtarget), "ipq807x" "ipq807x_ipq807x" "ipq60xx" "ipq807x_ipq60xx"))
# DTLS Manager v2.0 for Hawkeye/Cypress
DTLSMGR_DIR:=v2.0
# IPsec Manager v2.0 for Hawkeye/Cypress
IPSECMGR_DIR:=v2.0
else
# DTLS Manager v1.0 for Akronite.
DTLSMGR_DIR:=v1.0
# IPsec Manager v1.0 for Akronite.
IPSECMGR_DIR:=v1.0
endif
define KernelPackage/qca-nss-drv-tun6rd
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - tun6rd
DEPENDS:=+kmod-qca-nss-drv +kmod-sit @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/qca-nss-tun6rd.ko
AUTOLOAD:=$(call AutoLoad,60,qca-nss-tun6rd)
endef
define KernelPackage/qca-nss-drv-tun6rd/Description
Kernel modules for NSS connection manager - Support for 6rd tunnel
endef
define KernelPackage/qca-nss-drv-dtlsmgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - dtlsmgr
DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-cfi-cryptoapi @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/dtls/$(DTLSMGR_DIR)/qca-nss-dtlsmgr.ko
endef
define KernelPackage/qca-nss-drv-dtls/Description
Kernel modules for NSS connection manager - Support for DTLS sessions
endef
define KernelPackage/qca-nss-drv-tlsmgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - tlsmgr
DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx +kmod-qca-nss-drv +kmod-qca-nss-cfi @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/tls/qca-nss-tlsmgr.ko
endef
define KernelPackage/qca-nss-drv-tls/Description
Kernel modules for NSS connection manager - Support for TLS sessions
endef
define KernelPackage/qca-nss-drv-l2tpv2
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - l2tp
DEPENDS:=+kmod-qca-nss-drv +kmod-ppp +kmod-l2tp @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/l2tp/l2tpv2/qca-nss-l2tpv2.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-l2tpv2)
endef
define KernelPackage/qca-nss-drv-l2tp/Description
Kernel modules for NSS connection manager - Support for l2tp tunnel
endef
define KernelPackage/qca-nss-drv-pptp
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - PPTP
DEPENDS:=+kmod-qca-nss-drv +kmod-pptp @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/pptp/qca-nss-pptp.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-pptp)
endef
define KernelPackage/qca-nss-drv-pptp/Description
Kernel modules for NSS connection manager - Support for PPTP tunnel
endef
define KernelPackage/qca-nss-drv-pppoe
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - PPPoE
DEPENDS:=+kmod-qca-nss-drv +kmod-pppoe @!LINUX_3_18 \
+!(TARGET_ipq_ipq807x_QSDK_256||TARGET_ipq_ipq60xx_QSDK_256):kmod-bonding
FILES:=$(PKG_BUILD_DIR)/pppoe/qca-nss-pppoe.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-pppoe)
endef
define KernelPackage/qca-nss-drv-pppoe/Description
Kernel modules for NSS connection manager - Support for PPPoE
endef
define KernelPackage/qca-nss-drv-map-t
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - MAP-T
DEPENDS:=+kmod-qca-nss-drv +kmod-nat46 @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/map/map-t/qca-nss-map-t.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-map-t)
endef
define KernelPackage/qca-nss-drv-map-t/Description
Kernel modules for NSS connection manager - Support for MAP-T
endef
define KernelPackage/qca-nss-drv-gre
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - GRE
DEPENDS:=@TARGET_ipq_ipq806x||TARGET_ipq806x||TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64 \
+kmod-qca-nss-drv @!LINUX_3_18 +kmod-gre6
FILES:=$(PKG_BUILD_DIR)/gre/qca-nss-gre.ko $(PKG_BUILD_DIR)/gre/test/qca-nss-gre-test.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-gre)
endef
define KernelPackage/qca-nss-drv-gre/Description
Kernel modules for NSS connection manager - Support for GRE
endef
define KernelPackage/qca-nss-drv-tunipip6
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (connection manager) - DS-lite and ipip6 Tunnel
DEPENDS:=+kmod-qca-nss-drv +kmod-iptunnel6 +kmod-ip6-tunnel @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/tunipip6/qca-nss-tunipip6.ko
AUTOLOAD:=$(call AutoLoad,60,qca-nss-tunipip6)
endef
define KernelPackage/qca-nss-drv-tunipip6/Description
Kernel modules for NSS connection manager
Add support for DS-lite and ipip6 tunnel
endef
define KernelPackage/qca-nss-drv-profile
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18
TITLE:=Profiler for QCA NSS driver (IPQ806x)
FILES:=$(PKG_BUILD_DIR)/profiler/qca-nss-profile-drv.ko
endef
define KernelPackage/qca-nss-drv-profile/Description
This package contains a NSS driver profiler for QCA chipset
endef
define KernelPackage/qca-nss-drv-ipsecmgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (ipsec manager) - ipsecmgr
DEPENDS:=@TARGET_ipq806x||TARGET_ipq_ipq806x||TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx \
+kmod-qca-nss-drv +kmod-qca-nss-cfi-cryptoapi +kmod-qca-nss-cfi-ocf @!LINUX_3_18
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-l2tpv2),)
DEPENDS:=+kmod-qca-nss-drv-l2tpv2
endif
FILES:=$(PKG_BUILD_DIR)/ipsecmgr/$(IPSECMGR_DIR)/qca-nss-ipsecmgr.ko
AUTOLOAD:=$(call AutoLoad,60,qca-nss-ipsecmgr)
endef
define KernelPackage/qca-nss-drv-ipsecmgr/Description
Kernel module for NSS IPsec offload manager
endef
define KernelPackage/qca-nss-drv-ipsecmgr-klips
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS (ipsec klips)
DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx \
+kmod-qca-nss-drv-ipsecmgr kmod-qca-nss-ecm
FILES:=$(PKG_BUILD_DIR)/ipsecmgr/$(IPSECMGR_DIR)/plugins/klips/qca-nss-ipsec-klips.ko
endef
define KernelPackage/qca-nss-drv-ipsecmgr-klips/Description
NSS Kernel module for IPsec klips offload
endef
define KernelPackage/qca-nss-drv-capwapmgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-drv-dtlsmgr @!LINUX_3_18
TITLE:=NSS CAPWAP Manager for QCA NSS driver (IPQ806x)
FILES:=$(PKG_BUILD_DIR)/capwapmgr/qca-nss-capwapmgr.ko
endef
define KernelPackage/qca-nss-drv-capwapmgr/Description
This package contains a NSS CAPWAP Manager
endef
define KernelPackage/qca-nss-drv-bridge-mgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS bridge manager
DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx \
+TARGET_ipq_ipq807x:kmod-qca-nss-drv-vlan-mgr \
+TARGET_ipq_ipq807x_ipq807x:kmod-qca-nss-drv-vlan-mgr \
+TARGET_ipq807x:kmod-qca-nss-drv-vlan-mgr \
+TARGET_ipq807x_ipq807x:kmod-qca-nss-drv-vlan-mgr \
+TARGET_ipq_ipq60xx:kmod-qca-nss-drv-vlan-mgr \
+TARGET_ipq807x_ipq60xx:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \
+!(TARGET_ipq_ipq807x_QSDK_256||TARGET_ipq_ipq60xx_QSDK_256):kmod-bonding
FILES:=$(PKG_BUILD_DIR)/bridge/qca-nss-bridge-mgr.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-bridge-mgr)
endef
define KernelPackage/qca-nss-drv-bridge-mgr/Description
Kernel modules for NSS bridge manager
endef
define KernelPackage/qca-nss-drv-vlan-mgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS vlan manager
DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx +kmod-qca-nss-drv @!LINUX_3_18 \
+!(TARGET_ipq_ipq807x_QSDK_256||TARGET_ipq_ipq60xx_QSDK_256):kmod-bonding
FILES:=$(PKG_BUILD_DIR)/vlan/qca-nss-vlan.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-vlan)
endef
define KernelPackage/qca-nss-drv-vlan-mgr/Description
Kernel modules for NSS vlan manager
endef
define KernelPackage/qca-nss-drv-qdisc
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Support
TITLE:=Qdisc for configuring shapers in NSS
DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/nss_qdisc/qca-nss-qdisc.ko
AUTOLOAD:=$(call AutoLoad,58,qca-nss-qdisc)
endef
define KernelPackage/qca-nss-drv-qdisc/Description
Linux qdisc that aids in configuring shapers in the NSS
endef
define KernelPackage/qca-nss-drv-igs
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Support
TITLE:=Action for offloading traffic to an IFB interface to perform ingress shaping.
DEPENDS:=@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64 \
+kmod-qca-nss-drv +kmod-sched-core +kmod-ifb +kmod-qca-nss-drv-qdisc @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/nss_qdisc/igs/act_nssmirred.ko
endef
define KernelPackage/qca-nss-drv-igs/Description
Linux action that helps in offloading traffic to an IFB interface to perform ingress shaping.
endef
define KernelPackage/qca-nss-drv-lag-mgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS LAG manager
DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18 \
+TARGET_ipq_ipq807x:kmod-qca-nss-drv-vlan-mgr \
+TARGET_ipq_ipq807x_ipq807x:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \
+TARGET_ipq807x:kmod-qca-nss-drv-vlan-mgr \
+TARGET_ipq807x_ipq807x:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \
+TARGET_ipq_ipq60xx:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \
+TARGET_ipq807x_ipq60xx:kmod-qca-nss-drv-vlan-mgr @!LINUX_3_18 \
+kmod-bonding
FILES:=$(PKG_BUILD_DIR)/lag/qca-nss-lag-mgr.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-lag-mgr)
endef
define KernelPackage/qca-nss-drv-lag-mgr/Description
Kernel modules for NSS LAG manager
endef
define KernelPackage/qca-nss-drv-netlink
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=@TARGET_ipq807x||TARGET_ipq_ipq807x||TARGET_ipq807x_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx||TARGET_ipq_ipq50xx||TARGET_ipq_ipq50xx_64 \
+kmod-qca-nss-drv @!LINUX_3_18 \
+PACKAGE_kmod-qca-nss-drv-ipsecmgr:kmod-qca-nss-drv-ipsecmgr \
+PACKAGE_kmod-qca-nss-drv-dtlsmgr:kmod-qca-nss-drv-dtlsmgr \
+PACKAGE_kmod-qca-nss-drv-capwapmgr:kmod-qca-nss-drv-capwapmgr @!LINUX_3_18
TITLE:=NSS NETLINK Manager for QCA NSS driver
FILES:=$(PKG_BUILD_DIR)/netlink/qca-nss-netlink.ko
endef
define KernelPackage/qca-nss-drv-netlink/Description
Kernel module for NSS netlink manager
endef
define KernelPackage/qca-nss-drv-ovpn-mgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for NSS OpenVPN manager
DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-cfi +kmod-tun +kmod-ipt-conntrack @!LINUX_3_18 \
@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx
FILES:=$(PKG_BUILD_DIR)/openvpn/src/qca-nss-ovpn-mgr.ko
endef
define KernelPackage/qca-nss-drv-ovpn-mgr/Description
Kernel module for NSS OpenVPN manager
endef
define KernelPackage/qca-nss-drv-ovpn-link
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
TITLE:=Kernel driver for interfacing NSS OpenVPN manager with ECM
DEPENDS:=+kmod-qca-nss-drv-ovpn-mgr +kmod-qca-nss-ecm-premium @!LINUX_3_18 \
@TARGET_ipq_ipq807x||TARGET_ipq_ipq807x_ipq807x||TARGET_ipq_ipq60xx||TARGET_ipq807x_ipq60xx
FILES:=$(PKG_BUILD_DIR)/openvpn/plugins/qca-nss-ovpn-link.ko
endef
define KernelPackage/qca-nss-drv-ovpn-link/Description
This module registers with ECM and communicates with NSS OpenVPN manager for supporting OpenVPN offload.
endef
define KernelPackage/qca-nss-drv-pvxlanmgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18
TITLE:=NSS PVXLAN Manager for QCA NSS driver
FILES:=$(PKG_BUILD_DIR)/pvxlanmgr/qca-nss-pvxlanmgr.ko
endef
define KernelPackage/qca-nss-drv-pvxlanmgr/Description
Kernel module for managing NSS PVxLAN
endef
define KernelPackage/qca-nss-drv-eogremgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-drv-gre @!LINUX_3_18
TITLE:=NSS EOGRE Manager for QCA NSS driver
FILES:=$(PKG_BUILD_DIR)/eogremgr/qca-nss-eogremgr.ko
endef
define KernelPackage/qca-nss-drv-eogremgr/Description
Kernel module for managing NSS EoGRE
endef
define KernelPackage/qca-nss-drv-clmapmgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=+kmod-qca-nss-drv +kmod-qca-nss-drv-eogremgr @!LINUX_3_18
TITLE:=NSS clmap Manager for QCA NSS driver
FILES:=$(PKG_BUILD_DIR)/clmapmgr/qca-nss-clmapmgr.ko
endef
define KernelPackage/qca-nss-drv-clmapmgr/Description
Kernel module for managing NSS clmap
endef
define KernelPackage/qca-nss-drv-vxlanmgr
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=+kmod-qca-nss-drv +kmod-vxlan @!LINUX_3_18
TITLE:=NSS VxLAN Manager for QCA NSS driver
FILES:=$(PKG_BUILD_DIR)/vxlanmgr/qca-nss-vxlanmgr.ko
AUTOLOAD:=$(call AutoLoad,51,qca-nss-vxlanmgr)
endef
define KernelPackage/qca-nss-drv-vxlanmgr/Description
Kernel module for managing NSS VxLAN
endef
define KernelPackage/qca-nss-drv-match
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Devices
DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18
TITLE:=NSS Match for QCA NSS driver
FILES:=$(PKG_BUILD_DIR)/match/qca-nss-match.ko
endef
define KernelPackage/qca-nss-drv-match/Description
Kernel module for managing NSS Match
endef
define KernelPackage/qca-nss-drv-mirror
SECTION:=kernel
CATEGORY:=Kernel modules
SUBMENU:=Network Support
TITLE:=Module for mirroring packets from NSS to host.
DEPENDS:=+kmod-qca-nss-drv @!LINUX_3_18
FILES:=$(PKG_BUILD_DIR)/mirror/qca-nss-mirror.ko
endef
define KernelPackage/qca-nss-drv-mirror/Description
Kernel module for managing NSS Mirror
endef
define Build/InstallDev/qca-nss-clients
$(INSTALL_DIR) $(1)/usr/include/qca-nss-clients
$(CP) $(PKG_BUILD_DIR)/netlink/include/* $(1)/usr/include/qca-nss-clients/
$(CP) $(PKG_BUILD_DIR)/exports/* $(1)/usr/include/qca-nss-clients/
endef
define Build/InstallDev
$(call Build/InstallDev/qca-nss-clients,$(1))
endef
define KernelPackage/qca-nss-drv-ovpn-mgr/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/qca-nss-ovpn.init $(1)/etc/init.d/qca-nss-ovpn
endef
define KernelPackage/qca-nss-drv-ipsecmgr-klips/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/qca-nss-ipsec $(1)/etc/init.d/qca-nss-ipsec
endef
define KernelPackage/qca-nss-drv-igs/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/qca-nss-mirred.init $(1)/etc/init.d/qca-nss-mirred
endef
EXTRA_CFLAGS+= \
-I$(STAGING_DIR)/usr/include/qca-nss-drv \
-I$(STAGING_DIR)/usr/include/qca-nss-crypto \
-I$(STAGING_DIR)/usr/include/qca-nss-cfi \
-I$(STAGING_DIR)/usr/include/qca-nss-gmac \
-I$(STAGING_DIR)/usr/include/qca-ssdk \
-I$(STAGING_DIR)/usr/include/qca-ssdk/fal \
-I$(STAGING_DIR)/usr/include/nat46
# Build individual packages if selected
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-profile),)
MAKE_OPTS+=profile=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-capwapmgr),)
MAKE_OPTS+=capwapmgr=y
EXTRA_CFLAGS += -DNSS_CAPWAPMGR_ONE_NETDEV
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tun6rd),)
MAKE_OPTS+=tun6rd=m
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-dtlsmgr),)
MAKE_OPTS+=dtlsmgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tlsmgr),)
MAKE_OPTS+=tlsmgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-l2tpv2),)
MAKE_OPTS+=l2tpv2=y
EXTRA_CFLAGS += -DNSS_L2TPV2_ENABLED
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pptp),)
MAKE_OPTS+=pptp=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-map-t),)
MAKE_OPTS+=map-t=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-tunipip6),)
MAKE_OPTS+=tunipip6=m
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-qdisc),)
MAKE_OPTS+=qdisc=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-igs),)
MAKE_OPTS+=igs=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ipsecmgr),)
EXTRA_CFLAGS+= -I$(PKG_BUILD_DIR)/exports
MAKE_OPTS+=ipsecmgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ipsecmgr-klips),)
EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/qca-nss-ecm
MAKE_OPTS+=ipsecmgr-klips=m
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-bridge-mgr),)
MAKE_OPTS+=bridge-mgr=y
#enable OVS bridge if ovsmgr is enabled
ifneq ($(CONFIG_PACKAGE_kmod-qca-ovsmgr),)
MAKE_OPTS+= NSS_BRIDGE_MGR_OVS_ENABLE=y
EXTRA_CFLAGS+= -I$(STAGING_DIR)/usr/include/qca-ovsmgr
endif
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-vlan-mgr),)
MAKE_OPTS+=vlan-mgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-lag-mgr),)
MAKE_OPTS+=lag-mgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-gre),)
EXTRA_CFLAGS+= -I$(PKG_BUILD_DIR)/exports
MAKE_OPTS+=gre=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pppoe),)
MAKE_OPTS+=pppoe=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-netlink),)
MAKE_OPTS+=netlink=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ovpn-mgr),)
MAKE_OPTS+=ovpn-mgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-ovpn-link),)
MAKE_OPTS+=ovpn-link=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-pvxlanmgr),)
MAKE_OPTS+=pvxlanmgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-eogremgr),)
MAKE_OPTS+=eogremgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-clmapmgr),)
MAKE_OPTS+=clmapmgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-vxlanmgr),)
MAKE_OPTS+=vxlanmgr=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-match),)
MAKE_OPTS+=match=y
endif
ifneq ($(CONFIG_PACKAGE_kmod-qca-nss-drv-mirror),)
MAKE_OPTS+=mirror=y
endif
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" $(strip $(MAKE_OPTS)) \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
M="$(PKG_BUILD_DIR)" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
SoC="$(subtarget)" \
DTLSMGR_DIR="$(DTLSMGR_DIR)" \
IPSECMGR_DIR="$(IPSECMGR_DIR)" \
modules
endef
$(eval $(call KernelPackage,qca-nss-drv-profile))
#$(eval $(call KernelPackage,qca-nss-drv-capwapmgr))
$(eval $(call KernelPackage,qca-nss-drv-tun6rd))
#$(eval $(call KernelPackage,qca-nss-drv-dtlsmgr))
$(eval $(call KernelPackage,qca-nss-drv-l2tpv2))
$(eval $(call KernelPackage,qca-nss-drv-pptp))
$(eval $(call KernelPackage,qca-nss-drv-pppoe))
$(eval $(call KernelPackage,qca-nss-drv-map-t))
$(eval $(call KernelPackage,qca-nss-drv-tunipip6))
$(eval $(call KernelPackage,qca-nss-drv-qdisc))
$(eval $(call KernelPackage,qca-nss-drv-igs))
#$(eval $(call KernelPackage,qca-nss-drv-netlink))
#$(eval $(call KernelPackage,qca-nss-drv-ipsecmgr))
#$(eval $(call KernelPackage,qca-nss-drv-ipsecmgr-klips))
$(eval $(call KernelPackage,qca-nss-drv-bridge-mgr))
$(eval $(call KernelPackage,qca-nss-drv-vlan-mgr))
$(eval $(call KernelPackage,qca-nss-drv-lag-mgr))
$(eval $(call KernelPackage,qca-nss-drv-gre))
#$(eval $(call KernelPackage,qca-nss-drv-ovpn-mgr))
#$(eval $(call KernelPackage,qca-nss-drv-ovpn-link))
$(eval $(call KernelPackage,qca-nss-drv-pvxlanmgr))
$(eval $(call KernelPackage,qca-nss-drv-eogremgr))
$(eval $(call KernelPackage,qca-nss-drv-clmapmgr))
$(eval $(call KernelPackage,qca-nss-drv-vxlanmgr))
$(eval $(call KernelPackage,qca-nss-drv-match))
#$(eval $(call KernelPackage,qca-nss-drv-tlsmgr))
$(eval $(call KernelPackage,qca-nss-drv-mirror))

View File

@@ -0,0 +1,92 @@
#!/bin/sh /etc/rc.common
#
# Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
NSS_IPSEC_LOG_FILE=/tmp/.nss_ipsec_log
NSS_IPSEC_LOG_STR_ECM="ECM_Loaded"
ecm_load () {
if [ ! -d /sys/module/ecm ]; then
/etc/init.d/qca-nss-ecm start
if [ -d /sys/module/ecm ]; then
echo ${NSS_IPSEC_LOG_STR_ECM} >> ${NSS_IPSEC_LOG_FILE}
fi
fi
}
ecm_unload () {
if [ -f /tmp/.nss_ipsec_log ]; then
str=`grep ${NSS_IPSEC_LOG_STR_ECM} ${NSS_IPSEC_LOG_FILE}`
if [[ $str == ${NSS_IPSEC_LOG_STR_ECM} ]]; then
/etc/init.d/qca-nss-ecm stop
`sed 's/${NSS_IPSEC_LOG_STR_ECM}/ /g' $NSS_IPSEC_LOG_FILE > $NSS_IPSEC_LOG_FILE`
fi
fi
}
ecm_disable() {
if [ ! -d /sys/module/ecm ]; then
return;
fi
echo 1 > /sys/kernel/debug/ecm/front_end_ipv4_stop
echo 1 > /sys/kernel/debug/ecm/front_end_ipv6_stop
echo 1 > /sys/kernel/debug/ecm/ecm_db/defunct_all
sleep 2
}
ecm_enable() {
if [ ! -d /sys/module/ecm ]; then
return;
fi
echo 0 > /sys/kernel/debug/ecm/ecm_db/defunct_all
echo 0 > /sys/kernel/debug/ecm/front_end_ipv4_stop
echo 0 > /sys/kernel/debug/ecm/front_end_ipv6_stop
}
start() {
ecm_load
local kernel_version=$(uname -r)
insmod /lib/modules/${kernel_version}/qca-nss-ipsec-klips.ko
if [ "$?" -gt 0 ]; then
echo "Failed to load plugin. Please start ecm if not done already"
ecm_enable
return
fi
/etc/init.d/ipsec start
sleep 2
ipsec eroute
ecm_enable
}
stop() {
ecm_disable
/etc/init.d/ipsec stop
rmmod qca-nss-ipsec-klips
ecm_unload
}
restart() {
stop
start
}

View File

@@ -0,0 +1,28 @@
#!/bin/sh /etc/rc.common
###########################################################################
# Copyright (c) 2019, The Linux Foundation. All rights reserved.
# Permission to use, copy, modify, and/or distribute this software for
# any purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
###########################################################################
restart() {
rmmod act_nssmirred.ko
insmod act_nssmirred.ko
}
start() {
insmod act_nssmirred.ko
}
stop() {
rmmod act_nssmirred.ko
}

View File

@@ -0,0 +1,69 @@
#!/bin/sh /etc/rc.common
###########################################################################
# Copyright (c) 2019, The Linux Foundation. All rights reserved.
# Permission to use, copy, modify, and/or distribute this software for
# any purpose with or without fee is hereby granted, provided that the
# above copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
###########################################################################
ecm_disable() {
if [ ! -d /sys/module/ecm ]; then
return
fi
echo 1 > /sys/kernel/debug/ecm/front_end_ipv4_stop
echo 1 > /sys/kernel/debug/ecm/front_end_ipv6_stop
echo 1 > /sys/kernel/debug/ecm/ecm_db/defunct_all
sleep 2
}
ecm_enable() {
if [ ! -d /sys/module/ecm ]; then
return
fi
echo 0 > /sys/kernel/debug/ecm/ecm_db/defunct_all
echo 0 > /sys/kernel/debug/ecm/front_end_ipv4_stop
echo 0 > /sys/kernel/debug/ecm/front_end_ipv6_stop
}
restart() {
ecm_disable
/etc/init.d/openvpn stop
rmmod qca-nss-ovpn-link
rmmod qca-nss-ovpn-mgr
insmod qca-nss-ovpn-mgr
insmod qca-nss-ovpn-link
if [ "$?" -gt 0 ]; then
echo "Failed to load plugin. Please start ecm if not done already"
ecm_enable
return
fi
ecm_enable
}
start() {
restart
}
stop() {
ecm_disable
/etc/init.d/openvpn stop
rmmod qca-nss-ovpn-link
rmmod qca-nss-ovpn-mgr
ecm_enable
}

View File

@@ -214,6 +214,9 @@ hostapd_common_add_bss_config() {
config_add_int maxassoc max_inactivity
config_add_boolean disassoc_low_ack isolate short_preamble
config_add_int signal_connect signal_stay signal_poll_time \
signal_drop_reason signal_strikes
config_add_int \
wep_rekey eap_reauth_period \
wpa_group_rekey wpa_pair_rekey wpa_master_rekey
@@ -485,6 +488,7 @@ hostapd_set_bss_options() {
local wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_key_mgmt
json_get_vars \
signal_connect signal_stay signal_poll_time signal_drop_reason signal_strikes \
wep_rekey wpa_group_rekey wpa_pair_rekey wpa_master_rekey wpa_strict_rekey \
wpa_disable_eapol_key_retries tdls_prohibit \
maxassoc max_inactivity disassoc_low_ack isolate auth_cache \
@@ -520,8 +524,15 @@ hostapd_set_bss_options() {
set_default rssi_reject_assoc_rssi 0
set_default rssi_ignore_probe_request 0
set_default rts_threshold -1
set_default proxy_arp 0
set_default signal_connect -128
set_default signal_stay -128
set_default signal_poll_time 5
set_default signal_drop_reason 3
set_default signal_strikes 3
set_default proxy_arp 1
set_default multicast_to_unicast 0
append bss_conf "ctrl_interface=/var/run/hostapd"
if [ "$isolate" -gt 0 ]; then
append bss_conf "ap_isolate=$isolate" "$N"
@@ -549,6 +560,11 @@ hostapd_set_bss_options() {
append bss_conf "rssi_reject_assoc_rssi=$rssi_reject_assoc_rssi" "$N"
append bss_conf "rssi_ignore_probe_request=$rssi_ignore_probe_request" "$N"
append bss_conf "rts_threshold=$rts_threshold" "$N"
append bss_conf "signal_connect=$signal_connect" "$N"
append bss_conf "signal_stay=$signal_stay" "$N"
append bss_conf "signal_poll_time=$signal_poll_time" "$N"
append bss_conf "signal_strikes=$signal_strikes" "$N"
append bss_conf "signal_drop_reason=$signal_drop_reason" "$N"
[ -n "$proxy_arp" ] && append bss_conf "proxy_arp=$proxy_arp" "$N"
[ -n "$multicast_to_unicast" ] && append bss_conf "multicast_to_unicast=$multicast_to_unicast" "$N"
@@ -831,7 +847,15 @@ hostapd_set_bss_options() {
json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
append bss_conf "ieee80211w=$ieee80211w" "$N"
[ "$ieee80211w" -gt "0" ] && {
append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
case "$auth_type" in
eap192)
append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N"
append bss_conf "group_cipher=GCMP-256" "$N"
;;
*)
append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
;;
esac
[ -n "$ieee80211w_max_timeout" ] && \
append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
[ -n "$ieee80211w_retry_timeout" ] && \
@@ -961,10 +985,10 @@ hostapd_set_bss_options() {
if [ "$hs20" = "1" ]; then
append bss_conf "hs20=1" "$N"
append_hs20_icons
[ -n "$disable_dgaf"] && append bss_conf "disable_dgaf=$disable_dgaf" "$N"
[ -n "$osen"] && append bss_conf "osen=$osen" "$N"
[ -n "$disable_dgaf" ] && append bss_conf "disable_dgaf=$disable_dgaf" "$N"
[ -n "$osen" ] && append bss_conf "osen=$osen" "$N"
[ "$anqp_domain_id" -gt 0 ] && append bss_conf "anqp_domain_id=$anqp_domain_id" "$N"
[ -n "$hs20_deauth_req_timeout"] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N"
[ -n "$hs20_deauth_req_timeout" ] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N"
[ -n "$osu_ssid" ] && append bss_conf "osu_ssid=$osu_ssid" "$N"
[ -n "$hs20_wan_metrics" ] && append bss_conf "hs20_wan_metrics=$hs20_wan_metrics" "$N"
[ -n "$hs20_operating_class" ] && append bss_conf "hs20_operating_class=$hs20_operating_class" "$N"
@@ -976,7 +1000,6 @@ hostapd_set_bss_options() {
json_for_each_item append_venue_url venue_url
json_for_each_item append_nai_realm nai_realm
json_for_each_item append_hs20_conn_capab hs20_conn_capab
json_for_each_item append_hs20_oper_friendly_name hs20_oper_friendly_name
json_for_each_item append_osu_provider osu_provider
json_for_each_item append_operator_icon operator_icon
[ -n "$interworking" ] && append bss_conf "interworking=$interworking" "$N"

View File

@@ -0,0 +1,32 @@
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -4463,6 +4463,14 @@ static void handle_assoc(struct hostapd_
ieee802_11_set_beacons(hapd->iface);
}
+ ubus_resp = hostapd_ubus_handle_event(hapd, &req);
+ if (ubus_resp) {
+ wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
+ MAC2STR(mgmt->sa));
+ resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
+ goto fail;
+ }
+
update_ht_state(hapd, sta);
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
@@ -4568,14 +4576,6 @@ static void handle_assoc(struct hostapd_
pos, left, rssi, omit_rsnxe);
os_free(tmp);
- ubus_resp = hostapd_ubus_handle_event(hapd, &req);
- if (ubus_resp) {
- wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
- MAC2STR(mgmt->sa));
- resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
- goto fail;
- }
-
/*
* Remove the station in case tranmission of a success response fails
* (the STA was added associated to the driver) or if the station was

View File

@@ -0,0 +1,68 @@
Index: hostapd-2020-07-02-58b384f4/src/ap/ubus.c
===================================================================
--- hostapd-2020-07-02-58b384f4.orig/src/ap/ubus.c
+++ hostapd-2020-07-02-58b384f4/src/ap/ubus.c
@@ -1483,7 +1483,63 @@ static int hostapd_get_bss_list(struct u
return 0;
}
+enum {
+ MOD_IFACE,
+ MOD_PARAM,
+ MOD_PARAM_VAL,
+ __PARAM_MAX
+};
+
+static const struct blobmsg_policy mod_param_policy[__PARAM_MAX] = {
+ [MOD_IFACE] = { "iface", BLOBMSG_TYPE_STRING },
+ [MOD_PARAM] = { "param", BLOBMSG_TYPE_STRING },
+ [MOD_PARAM_VAL] = { "param_val", BLOBMSG_TYPE_STRING },
+};
+
+
+static int
+hostapd_param_modify(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__PARAM_MAX];
+ struct hapd_interfaces *interfaces = NULL;
+ struct hostapd_data *hapd_bss = NULL;
+ struct hostapd_config *iconf = NULL;
+ struct hostapd_iface *iface = NULL;
+ size_t i = 0;
+
+ interfaces = get_hapd_interfaces_from_object(obj);
+ blobmsg_parse(mod_param_policy, __PARAM_MAX, tb, blob_data(msg),
+ blob_len(msg));
+
+ if (!tb[MOD_PARAM] || !tb[MOD_IFACE] || !tb[MOD_PARAM_VAL])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ wpa_printf(MSG_DEBUG, "Modifyint %s=%s for %s",
+ blobmsg_get_string(tb[MOD_PARAM]),
+ blobmsg_get_string(tb[MOD_PARAM_VAL]),
+ blobmsg_get_string(tb[MOD_IFACE]));
+
+ hapd_bss = hostapd_get_iface(interfaces,
+ blobmsg_get_string(tb[MOD_IFACE]));
+
+ if (hapd_bss) {
+ iconf = hapd_bss->iconf;
+ if (os_strcmp(blobmsg_get_string(tb[MOD_PARAM]),
+ "rssi_ignore_probe_request") == 0) {
+ iconf->rssi_ignore_probe_request = atoi(blobmsg_get_string(tb[MOD_PARAM_VAL]));
+
+ }
+ }
+
+ return UBUS_STATUS_OK;
+}
+
+
+
static const struct ubus_method daemon_methods[] = {
+ UBUS_METHOD("param_mod", hostapd_param_modify, mod_param_policy),
UBUS_METHOD("config_add", hostapd_config_add, config_add_policy),
UBUS_METHOD("config_remove", hostapd_config_remove, config_remove_policy),
UBUS_METHOD_NOARG("get_bss_list", hostapd_get_bss_list),

View File

@@ -0,0 +1,14 @@
Index: hostapd-2020-07-02-58b384f4/src/ap/ubus.c
===================================================================
--- hostapd-2020-07-02-58b384f4.orig/src/ap/ubus.c
+++ hostapd-2020-07-02-58b384f4/src/ap/ubus.c
@@ -1655,7 +1655,8 @@ int hostapd_ubus_handle_rt_event(struct
session_id = sta->cl_session_id;
/* find by session id */
- rec = avl_find_element(&hapd->ubus.rt_events, &session_id, rec, avl);
+ if (session_id)
+ rec = avl_find_element(&hapd->ubus.rt_events, &session_id, rec, avl);
/* prepare rec if not found */
if (!rec) {

View File

@@ -0,0 +1,28 @@
Index: hostapd-2020-07-02-58b384f4/src/ap/ubus.c
===================================================================
--- hostapd-2020-07-02-58b384f4.orig/src/ap/ubus.c
+++ hostapd-2020-07-02-58b384f4/src/ap/ubus.c
@@ -528,6 +528,7 @@ enum {
CSA_SEC_CHANNEL_OFFSET,
CSA_HT,
CSA_VHT,
+ CSA_HE,
CSA_BLOCK_TX,
__CSA_MAX
};
@@ -541,6 +542,7 @@ static const struct blobmsg_policy csa_p
[CSA_SEC_CHANNEL_OFFSET] = { "sec_channel_offset", BLOBMSG_TYPE_INT32 },
[CSA_HT] = { "ht", BLOBMSG_TYPE_BOOL },
[CSA_VHT] = { "vht", BLOBMSG_TYPE_BOOL },
+ [CSA_HE] = { "he", BLOBMSG_TYPE_BOOL },
[CSA_BLOCK_TX] = { "block_tx", BLOBMSG_TYPE_BOOL },
};
@@ -783,6 +785,7 @@ hostapd_switch_chan(struct ubus_context
SET_CSA_SETTING(CSA_SEC_CHANNEL_OFFSET, freq_params.sec_channel_offset, u32);
SET_CSA_SETTING(CSA_HT, freq_params.ht_enabled, bool);
SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool);
+ SET_CSA_SETTING(CSA_HE, freq_params.he_enabled, bool);
SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool);
for (i = 0; i < hapd->iface->num_bss; i++) {

View File

@@ -0,0 +1,299 @@
Index: hostapd-2020-07-02-58b384f4/src/ap/ubus.c
===================================================================
--- hostapd-2020-07-02-58b384f4.orig/src/ap/ubus.c
+++ hostapd-2020-07-02-58b384f4/src/ap/ubus.c
@@ -21,6 +21,7 @@
#include "rrm.h"
#include "wnm_ap.h"
#include "taxonomy.h"
+#include "common/hw_features_common.h"
static struct ubus_context *ctx;
static struct blob_buf b;
@@ -754,6 +755,207 @@ static int hostapd_get_chan_switch_event
return 0;
}
+#define HOSTAPD_DFS_CSA_DUR 1
+int csa_ch_id, csa_cf0_id, csa_cf1_id = 0;
+int csa_bw = CHANWIDTH_USE_HT;
+struct csa_settings css;
+
+struct hostapd_channel_data *freq_to_chan(struct hostapd_iface *iface, int freq)
+{
+ struct hostapd_hw_modes *mode;
+ struct hostapd_channel_data *chan;
+ int i;
+
+ mode = iface->current_mode;
+ if (mode == NULL || freq == 0) {
+ wpa_printf(MSG_INFO, "%s: mode is NULL", __func__);
+ return NULL;
+ }
+
+ for (i = 0; i < iface->current_mode->num_channels; i++) {
+ chan = &iface->current_mode->channels[i];
+ if (chan->freq == freq) {
+ return chan; /* Channel found */
+ }
+ }
+ return NULL;
+}
+
+void hostapd_dfs_csa_timeout(void *eloop_data, void *user_data)
+{
+ struct hostapd_data *hapd = eloop_data;
+ struct hostapd_iface *iface = hapd->iface;
+ struct csa_settings *css = user_data;
+ int ret = 0;
+
+ wpa_printf(MSG_DEBUG, "%s Stopping CSA in dfs ", __func__);
+
+ hapd->csa_in_progress = 0;
+
+ hostapd_disable_iface(iface);
+
+ iface->freq = css->freq_params.freq;
+ iface->conf->channel = csa_ch_id;
+ iface->conf->secondary_channel = css->freq_params.sec_channel_offset;
+ hostapd_set_oper_centr_freq_seg0_idx(iface->conf, csa_cf0_id);
+ hostapd_set_oper_centr_freq_seg1_idx(iface->conf, csa_cf1_id);
+ hostapd_set_oper_chwidth(iface->conf, csa_bw);
+ iface->conf->ieee80211n = css->freq_params.ht_enabled;
+ iface->conf->ieee80211ac = css->freq_params.vht_enabled;
+ iface->conf->ieee80211ax = css->freq_params.he_enabled;
+ wpa_printf(MSG_INFO, "%s: freq=%d chan=%d sec_ch=%d cf0=%d cf1=%d bw=%d 11n=%d, ac=%d, ax=%d",
+ __func__, iface->freq, iface->conf->channel,
+ iface->conf->secondary_channel, csa_cf0_id, csa_cf1_id,
+ css->freq_params.bandwidth, iface->conf->ieee80211n,
+ iface->conf->ieee80211ac, iface->conf->ieee80211ax);
+
+ ret = hostapd_enable_iface(iface);
+ if (ret == 0)
+ hostapd_ubus_handle_channel_switch_event(iface,
+ HOSTAPD_UBUS_HIGH_INTERFERENCE,
+ iface->freq);
+}
+
+int hostapd_dfs_set_beacon_csa(struct hostapd_iface *iface, struct csa_settings *css)
+{
+ struct hostapd_data *hapd = iface->bss[0];
+ struct hostapd_data *hapd_bss = NULL;
+ struct csa_settings csa_settings;
+ int secondary_channel = 0;
+ u8 vht_oper_centr_freq_seg0_idx;
+ u8 vht_oper_centr_freq_seg1_idx;
+ int err = 0, i = 0;
+
+ if (hapd->csa_in_progress == 1) {
+ wpa_printf(MSG_ERROR, "CSA in progress, cannot switch channel");
+ return -1;
+ }
+
+ eloop_cancel_timeout(hostapd_dfs_csa_timeout, hapd, NULL);
+
+ /* Setup Beacon CSA request */
+ secondary_channel = iface->conf->secondary_channel;
+ vht_oper_centr_freq_seg0_idx =
+ iface->conf->vht_oper_centr_freq_seg0_idx;
+ vht_oper_centr_freq_seg1_idx =
+ iface->conf->vht_oper_centr_freq_seg1_idx;
+
+ os_memset(&csa_settings, 0, sizeof(csa_settings));
+ err = hostapd_set_freq_params(&csa_settings.freq_params,
+ iface->conf->hw_mode,
+ iface->freq,
+ iface->conf->channel,
+ iface->conf->enable_edmg,
+ iface->conf->edmg_channel,
+ iface->conf->ieee80211n,
+ iface->conf->ieee80211ac,
+ iface->conf->ieee80211ax,
+ secondary_channel,
+ hostapd_get_oper_chwidth(iface->conf),
+ vht_oper_centr_freq_seg0_idx,
+ vht_oper_centr_freq_seg1_idx,
+ iface->current_mode->vht_capab,
+ &iface->current_mode->he_capab[IEEE80211_MODE_AP]);
+ if (err) {
+ wpa_printf(MSG_ERROR, "DFS failed to calculate CSA freq params");
+ return -1;
+ }
+
+ if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) {
+ wpa_printf(MSG_ERROR, "CSA is not supported");
+ return -1;
+ }
+
+ /* Set Beacon */
+ for (i = 0; i < hapd->iface->num_bss; i++) {
+ hapd_bss = iface->bss[i];
+ hapd_bss->cs_freq_params = csa_settings.freq_params;
+ hapd_bss->cs_count = css->cs_count;
+ hapd_bss->cs_block_tx = css->block_tx;
+ err = ieee802_11_set_beacon(hapd_bss);
+ if (err)
+ wpa_printf(MSG_ERROR, "CSA beacon set failed, changing channel without an Announcement");
+ }
+
+ hapd->csa_in_progress = 1;
+
+ /* Switch Channel after a timeout */
+ eloop_register_timeout(HOSTAPD_DFS_CSA_DUR, 0,
+ hostapd_dfs_csa_timeout, hapd, css);
+
+ return 0;
+}
+
+int hostapd_switch_chan_dfs(struct hostapd_iface *iface,
+ struct csa_settings *css)
+{
+ struct hostapd_channel_data *ch, *cf1, *cf2 = NULL;
+ int res = 0;
+
+ if (iface == NULL)
+ return -1;
+
+ /* Set channel id and center frequecies id */
+ if (css->freq_params.freq > 0) {
+ ch = freq_to_chan(iface, css->freq_params.freq);
+ csa_ch_id = ch->chan;
+ }
+
+ if (css->freq_params.center_freq1 > 0) {
+ csa_cf0_id = 36 + (css->freq_params.center_freq1 - 5180) / 5;
+ }
+
+ if (css->freq_params.center_freq2 > 0) {
+ csa_cf1_id = 36 + (css->freq_params.center_freq2 - 5180) / 5;
+ }
+
+ wpa_printf(MSG_DEBUG, "%s freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds, ieee80211n=%d, ieee80211ac=%d, ieee80211ax=%d ", __func__,
+ css->freq_params.freq,
+ csa_ch_id, css->freq_params.sec_channel_offset,
+ css->freq_params.bandwidth, csa_cf0_id, csa_cf1_id,
+ iface->dfs_cac_ms / 1000, iface->conf->ieee80211n,
+ iface->conf->ieee80211ac, iface->conf->ieee80211ax);
+
+ /* Set bandwidth */
+ switch (css->freq_params.bandwidth) {
+ case 0:
+ case 20:
+ case 40:
+ csa_bw = CHANWIDTH_USE_HT;
+ break;
+ case 80:
+ if (css->freq_params.center_freq2)
+ csa_bw = CHANWIDTH_80P80MHZ;
+ else
+ csa_bw = CHANWIDTH_80MHZ;
+ break;
+ case 160:
+ csa_bw = CHANWIDTH_160MHZ;
+ break;
+ default:
+ wpa_printf(MSG_WARNING, "Unknown CSA bandwidth: %d",
+ css->freq_params.bandwidth);
+ break;
+ }
+
+ /* Set new frequency info */
+ iface->freq = css->freq_params.freq;
+ iface->conf->channel = csa_ch_id;
+ iface->conf->secondary_channel = css->freq_params.sec_channel_offset;
+ hostapd_set_oper_centr_freq_seg0_idx(iface->conf, csa_cf0_id);
+ hostapd_set_oper_centr_freq_seg1_idx(iface->conf, csa_cf1_id);
+ hostapd_set_oper_chwidth(iface->conf, csa_bw);
+ iface->conf->ieee80211n = css->freq_params.ht_enabled;
+ iface->conf->ieee80211ac = css->freq_params.vht_enabled;
+ iface->conf->ieee80211ax = css->freq_params.he_enabled;
+
+ /*Set beacon for CSA*/
+ hostapd_dfs_set_beacon_csa(iface, css);
+
+ return 0;
+
+}
+
static int
hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
@@ -761,14 +963,19 @@ hostapd_switch_chan(struct ubus_context
{
struct blob_attr *tb[__CSA_MAX];
struct hostapd_data *hapd = get_hapd_from_object(obj);
- struct csa_settings css;
+ struct hostapd_iface *iface = hapd->iface;
+ struct hostapd_channel_data *chan =NULL;
int i;
+ int freq = 0;
blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[CSA_FREQ])
return UBUS_STATUS_INVALID_ARGUMENT;
+ freq = blobmsg_get_u32(tb[CSA_FREQ]);
+ chan = freq_to_chan(iface, freq);
+
memset(&css, 0, sizeof(css));
css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]);
@@ -788,6 +995,21 @@ hostapd_switch_chan(struct ubus_context
SET_CSA_SETTING(CSA_HE, freq_params.he_enabled, bool);
SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool);
+ wpa_printf(MSG_INFO, "%s: CSS freq=%d chan=%d sec_chan_off=%d, width=%d, seg0=%d, seg1=%d", __func__,
+ css.freq_params.freq,
+ chan->chan, css.freq_params.sec_channel_offset,
+ css.freq_params.bandwidth,
+ css.freq_params.center_freq1,
+ css.freq_params.center_freq2);
+
+ if ((chan->flag & HOSTAPD_CHAN_RADAR) &&
+ ((chan->flag & HOSTAPD_CHAN_DFS_MASK)
+ != HOSTAPD_CHAN_DFS_AVAILABLE)) {
+ wpa_printf(MSG_INFO, "%s: DFS chan need CAC", __func__);
+ hostapd_switch_chan_dfs(iface, &css);
+ return UBUS_STATUS_OK;
+ }
+
for (i = 0; i < hapd->iface->num_bss; i++) {
if (hostapd_switch_channel(hapd->iface->bss[i], &css) != 0)
return UBUS_STATUS_NOT_SUPPORTED;
@@ -1454,10 +1676,16 @@ void hostapd_ubus_free_bss(struct hostap
}
free(name);
- for (size_t i = 0; i < bss_nr; i++)
- os_free(bss_lst[i]);
- free(bss_lst);
- bss_lst = NULL;
+
+ if (bss_lst != NULL) {
+ for (size_t i = 0; i < bss_nr; i++) {
+ os_free(bss_lst[i]);
+ bss_lst[i] = NULL;
+ }
+ free(bss_lst);
+ bss_lst = NULL;
+ bss_nr = 0;
+ }
}
static int hostapd_get_bss_list(struct ubus_context *ctx,
@@ -1477,9 +1705,11 @@ static int hostapd_get_bss_list(struct u
a = blobmsg_open_array(&b_ev, "bss_list");
/* check bss list from hapd */
for (size_t i = 0; i < bss_nr; i++) {
- b = blobmsg_open_table(&b_ev, NULL);
- blobmsg_add_string(&b_ev, "name", bss_lst[i]);
- blobmsg_close_table(&b_ev, b);
+ if (bss_lst[i] != NULL) {
+ b = blobmsg_open_table(&b_ev, NULL);
+ blobmsg_add_string(&b_ev, "name", bss_lst[i]);
+ blobmsg_close_table(&b_ev, b);
+ }
}
blobmsg_close_array(&b_ev, a);
ubus_send_reply(ctx, req, b_ev.head);

View File

@@ -0,0 +1,64 @@
--- a/src/ap/ubus.c
+++ b/src/ap/ubus.c
@@ -531,6 +531,7 @@ enum {
CSA_VHT,
CSA_HE,
CSA_BLOCK_TX,
+ CSA_REASON,
__CSA_MAX
};
@@ -545,6 +546,7 @@ static const struct blobmsg_policy csa_p
[CSA_VHT] = { "vht", BLOBMSG_TYPE_BOOL },
[CSA_HE] = { "he", BLOBMSG_TYPE_BOOL },
[CSA_BLOCK_TX] = { "block_tx", BLOBMSG_TYPE_BOOL },
+ [CSA_REASON] = { "reason", BLOBMSG_TYPE_INT32 },
};
#ifdef NEED_AP_MLME
@@ -810,7 +812,7 @@ void hostapd_dfs_csa_timeout(void *eloop
iface->conf->ieee80211ac, iface->conf->ieee80211ax);
ret = hostapd_enable_iface(iface);
- if (ret == 0)
+ if (ret == 0 && css->reason == 0)
hostapd_ubus_handle_channel_switch_event(iface,
HOSTAPD_UBUS_HIGH_INTERFERENCE,
iface->freq);
@@ -994,6 +996,7 @@ hostapd_switch_chan(struct ubus_context
SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool);
SET_CSA_SETTING(CSA_HE, freq_params.he_enabled, bool);
SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool);
+ SET_CSA_SETTING(CSA_REASON, reason, u32);
wpa_printf(MSG_INFO, "%s: CSS freq=%d chan=%d sec_chan_off=%d, width=%d, seg0=%d, seg1=%d", __func__,
css.freq_params.freq,
@@ -1015,7 +1018,9 @@ hostapd_switch_chan(struct ubus_context
return UBUS_STATUS_NOT_SUPPORTED;
}
- hostapd_ubus_handle_channel_switch_event(hapd->iface, HOSTAPD_UBUS_HIGH_INTERFERENCE, css.freq_params.freq);
+ if (css.reason == 0) {
+ hostapd_ubus_handle_channel_switch_event(hapd->iface, HOSTAPD_UBUS_HIGH_INTERFERENCE, css.freq_params.freq);
+ }
return UBUS_STATUS_OK;
#undef SET_CSA_SETTING
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2404,6 +2404,7 @@ struct beacon_data {
* @freq_params: Next channel frequency parameter
* @beacon_csa: Beacon/probe resp/asooc resp info for CSA period
* @beacon_after: Next beacon/probe resp/asooc resp info
+ * @reason: The reason why we are switching the channel
* @counter_offset_beacon: Offset to the count field in beacon's tail
* @counter_offset_presp: Offset to the count field in probe resp.
*/
@@ -2414,6 +2415,7 @@ struct csa_settings {
struct hostapd_freq_params freq_params;
struct beacon_data beacon_csa;
struct beacon_data beacon_after;
+ u32 reason;
u16 counter_offset_beacon[2];
u16 counter_offset_presp[2];

View File

@@ -0,0 +1,112 @@
--- a/src/ap/ubus.c
+++ b/src/ap/ubus.c
@@ -580,6 +580,7 @@ static int hostapd_clear_session(struct
{
if (session_id == rec->session_id) {
/* dec counter and delete */
+ wpa_printf(MSG_INFO, "%s Deleting client session with session id %llu", __func__, session_id);
cached_events_nr -= rec->rec_nr;
avl_delete(&hapd->ubus.rt_events, &rec->avl);
os_free(rec->records);
@@ -633,6 +634,11 @@ static int hostapd_sessions(struct ubus_
/* messages for current session */
for (size_t i = 0; i < rec->rec_nr; i++) {
c_rec = &rec->records[i];
+ if (c_rec->processed) {
+ /* Record is already reported, continue */
+ continue;
+ }
+
/* check message type */
switch (c_rec->type) {
/* ClientAuthEvent */
@@ -646,6 +652,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_u32(&b_ev, "auth_status", p->auth_status);
blobmsg_add_string(&b_ev, "ssid", p->ssid);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -665,6 +672,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_u8(&b_ev, "using11v", p->using11v);
blobmsg_add_string(&b_ev, "ssid", p->ssid);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -680,6 +688,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_u32(&b_ev, "internal_rc", p->internal_rc);
blobmsg_add_string(&b_ev, "ssid", p->ssid);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -693,6 +702,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_u64(&b_ev, "fdata_tx_up_ts_in_us", p->tx_ts.tv_sec * (uint64_t)1000000);
blobmsg_add_u64(&b_ev, "fdata_rx_up_ts_in_us", p->rx_ts.tv_sec * (uint64_t)1000000);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -705,6 +715,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_string(&b_ev, "sta_mac", p->sta_mac);
blobmsg_add_string(&b_ev, "ip_address", p->ip_addr);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -1912,6 +1923,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_AUTH;
rp->u.auth.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
@@ -1942,6 +1954,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_ASSOC;
rp->u.assoc.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
/* frequency */
@@ -1986,6 +1999,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_DISASSOC;
rp->u.disassoc.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
/* frequency */
@@ -2017,6 +2031,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_FDATA;
rp->u.fdata.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
/* STA MAC */
@@ -2045,6 +2060,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_IP;
rp->u.ip.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
/* STA MAC */
--- a/src/ap/ubus.h
+++ b/src/ap/ubus.h
@@ -110,6 +110,7 @@ struct client_ip_event {
};
struct client_session_record {
+ bool processed;
int type;
uint64_t timestamp;
union {

View File

@@ -0,0 +1,31 @@
--- a/drivers/net/wireless/ath/ath11k/wmi.c
+++ b/drivers/net/wireless/ath/ath11k/wmi.c
@@ -7339,16 +7339,18 @@
survey = &ar->survey[idx];
- survey->noise = bss_ch_info_ev.noise_floor;
- survey->time = div_u64(total, cc_freq_hz);
- survey->time_busy = div_u64(busy, cc_freq_hz);
- survey->time_rx = div_u64(rx_bss, cc_freq_hz);
- survey->time_tx = div_u64(tx, cc_freq_hz);
- survey->filled |= (SURVEY_INFO_NOISE_DBM |
- SURVEY_INFO_TIME |
- SURVEY_INFO_TIME_BUSY |
- SURVEY_INFO_TIME_RX |
- SURVEY_INFO_TIME_TX);
+ survey->noise = bss_ch_info_ev.noise_floor;
+ survey->time = div_u64(total, cc_freq_hz);
+ survey->time_busy = div_u64(busy, cc_freq_hz);
+ survey->time_rx = div_u64(rx, cc_freq_hz);
+ survey->time_bss_rx = div_u64(rx_bss, cc_freq_hz);
+ survey->time_tx = div_u64(tx, cc_freq_hz);
+ survey->filled |= (SURVEY_INFO_NOISE_DBM |
+ SURVEY_INFO_TIME |
+ SURVEY_INFO_TIME_BUSY |
+ SURVEY_INFO_TIME_RX |
+ SURVEY_INFO_TIME_TX |
+ SURVEY_INFO_TIME_BSS_RX);
exit:
spin_unlock_bh(&ar->data_lock);
complete(&ar->bss_survey_done);

View File

@@ -0,0 +1,84 @@
From 0e23a88c63d6abbeaef8ec90bd29584b7c5068bd Mon Sep 17 00:00:00 2001
From: Sriram R <srirrama@codeaurora.org>
Date: Thu, 10 Dec 2020 14:20:50 +0530
Subject: [PATCH] ath11k: Clear the fragment cache during key install
Currently the fragment cache setup during peer assoc is
cleared during peer delete. In case a key reinstallation
happens with the same peer, possibilitites are same fragment cache
where some fragments were added before key installation could be clubbed
with fragments received after. In ideal cases where
this could result in wrong PN since we expect all fragments to
have incrementing PN, this behavior could be explioted
to mix fragments of different data resulting in a proper
unintended reassembled packet to be passed up the stack.
Signed-off-by: Sriram R <srirrama@codeaurora.org>
---
drivers/net/wireless/ath/ath11k/dp_rx.c | 19 +++++++++++++++++++
drivers/net/wireless/ath/ath11k/dp_rx.h | 1 +
drivers/net/wireless/ath/ath11k/mac.c | 6 ++++++
3 files changed, 26 insertions(+)
diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c
index 0fa25c1..06bbd6e 100644
--- a/drivers/net/wireless/ath/ath11k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.c
@@ -844,6 +844,25 @@ static void ath11k_dp_rx_frags_cleanup(struct dp_rx_tid *rx_tid, bool rel_link_d
__skb_queue_purge(&rx_tid->rx_frags);
}
+void ath11k_peer_frags_flush(struct ath11k *ar, struct ath11k_peer *peer)
+{
+ struct dp_rx_tid *rx_tid;
+ int i;
+
+ lockdep_assert_held(&ar->ab->base_lock);
+
+ for (i = 0; i <= IEEE80211_NUM_TIDS; i++) {
+ rx_tid = &peer->rx_tid[i];
+
+ spin_unlock_bh(&ar->ab->base_lock);
+ del_timer_sync(&rx_tid->frag_timer);
+ spin_lock_bh(&ar->ab->base_lock);
+
+ ath11k_dp_rx_frags_cleanup(rx_tid, true);
+
+ }
+}
+
void ath11k_peer_rx_tid_cleanup(struct ath11k *ar, struct ath11k_peer *peer)
{
struct dp_rx_tid *rx_tid;
diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.h b/drivers/net/wireless/ath/ath11k/dp_rx.h
index f005ded..732f9a7 100644
--- a/drivers/net/wireless/ath/ath11k/dp_rx.h
+++ b/drivers/net/wireless/ath/ath11k/dp_rx.h
@@ -68,6 +68,7 @@ int ath11k_dp_peer_rx_pn_replay_config(struct ath11k_vif *arvif,
const u8 *peer_addr,
enum set_key_cmd key_cmd,
struct ieee80211_key_conf *key);
+void ath11k_peer_frags_flush(struct ath11k *ar, struct ath11k_peer *peer);
void ath11k_peer_rx_tid_cleanup(struct ath11k *ar, struct ath11k_peer *peer);
void ath11k_peer_rx_tid_delete(struct ath11k *ar,
struct ath11k_peer *peer, u8 tid);
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 4c88eab..91d645e 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -3707,6 +3707,12 @@ static int ath11k_mac_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
*/
spin_lock_bh(&ab->base_lock);
peer = ath11k_peer_find(ab, arvif->vdev_id, peer_addr);
+
+ /* flush the fragments cache during key (re)install to
+ * ensure all frags in the new frag list belong to the same key.
+ */
+ if (peer && cmd == SET_KEY)
+ ath11k_peer_frags_flush(ar, peer);
spin_unlock_bh(&ab->base_lock);
if (!peer) {
--
2.7.4

View File

@@ -0,0 +1,242 @@
From patchwork Tue May 11 18:02:44 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Johannes Berg <johannes@sipsolutions.net>
X-Patchwork-Id: 12251641
X-Patchwork-Delegate: johannes@sipsolutions.net
Return-Path: <linux-wireless-owner@kernel.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
aws-us-west-2-korg-lkml-1.web.codeaurora.org
X-Spam-Level:
X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,
HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH,
MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT
autolearn=unavailable autolearn_force=no version=3.4.0
Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
by smtp.lore.kernel.org (Postfix) with ESMTP id 5E0C4C43617
for <linux-wireless@archiver.kernel.org>;
Tue, 11 May 2021 18:03:20 +0000 (UTC)
Received: from vger.kernel.org (vger.kernel.org [23.128.96.18])
by mail.kernel.org (Postfix) with ESMTP id 2E1D461625
for <linux-wireless@archiver.kernel.org>;
Tue, 11 May 2021 18:03:20 +0000 (UTC)
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
id S231693AbhEKSEZ (ORCPT
<rfc822;linux-wireless@archiver.kernel.org>);
Tue, 11 May 2021 14:04:25 -0400
Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41156 "EHLO
lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
with ESMTP id S231561AbhEKSEV (ORCPT
<rfc822;linux-wireless@vger.kernel.org>);
Tue, 11 May 2021 14:04:21 -0400
Received: from sipsolutions.net (s3.sipsolutions.net
[IPv6:2a01:4f8:191:4433::2])
by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D055CC06175F;
Tue, 11 May 2021 11:03:10 -0700 (PDT)
Received: by sipsolutions.net with esmtpsa
(TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)
(Exim 4.94.2)
(envelope-from <johannes@sipsolutions.net>)
id 1lgWir-007aAS-9o; Tue, 11 May 2021 20:03:09 +0200
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Cc: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>, stable@vger.kernel.org
Subject: [PATCH 03/18] mac80211: properly handle A-MSDUs that start with an
RFC 1042 header
Date: Tue, 11 May 2021 20:02:44 +0200
Message-Id:
<20210511200110.0b2b886492f0.I23dd5d685fe16d3b0ec8106e8f01b59f499dffed@changeid>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20210511180259.159598-1-johannes@sipsolutions.net>
References: <20210511180259.159598-1-johannes@sipsolutions.net>
MIME-Version: 1.0
Precedence: bulk
List-ID: <linux-wireless.vger.kernel.org>
X-Mailing-List: linux-wireless@vger.kernel.org
From: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
Properly parse A-MSDUs whose first 6 bytes happen to equal a rfc1042
header. This can occur in practice when the destination MAC address
equals AA:AA:03:00:00:00. More importantly, this simplifies the next
patch to mitigate A-MSDU injection attacks.
Cc: stable@vger.kernel.org
Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
include/net/cfg80211.h | 4 ++--
net/mac80211/rx.c | 2 +-
net/wireless/util.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
Index: backports-20200902_001-4.4.60-931c337125/include/net/cfg80211.h
===================================================================
--- backports-20200902_001-4.4.60-931c337125.orig/include/net/cfg80211.h
+++ backports-20200902_001-4.4.60-931c337125/include/net/cfg80211.h
@@ -5631,7 +5631,7 @@ unsigned int ieee80211_get_mesh_hdrlen(s
*/
int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
const u8 *addr, enum nl80211_iftype iftype,
- u8 data_offset);
+ u8 data_offset, bool is_amsdu);
/**
* ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
@@ -5643,7 +5643,7 @@ int ieee80211_data_to_8023_exthdr(struct
static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
enum nl80211_iftype iftype)
{
- return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0);
+ return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0, false);
}
/**
Index: backports-20200902_001-4.4.60-931c337125/net/mac80211/rx.c
===================================================================
--- backports-20200902_001-4.4.60-931c337125.orig/net/mac80211/rx.c
+++ backports-20200902_001-4.4.60-931c337125/net/mac80211/rx.c
@@ -6,7 +6,7 @@
* Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2013-2014 Intel Mobile Communications GmbH
* Copyright(c) 2015 - 2017 Intel Deutschland GmbH
- * Copyright (C) 2018-2020 Intel Corporation
+ * Copyright (C) 2018-2021 Intel Corporation
*/
#include <linux/jiffies.h>
@@ -2555,13 +2555,13 @@ static bool ieee80211_frame_allowed(stru
struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
/*
- * Allow EAPOL frames to us/the PAE group address regardless
- * of whether the frame was encrypted or not.
- */
- if (ehdr->h_proto == rx->sdata->control_port_protocol &&
- (ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) ||
- ether_addr_equal(ehdr->h_dest, pae_group_addr)))
- return true;
+ * Allow EAPOL frames to us/the PAE group address regardless of
+ * whether the frame was encrypted or not, and always disallow
+ * all other destination addresses for them.
+ */
+ if (unlikely(ehdr->h_proto == rx->sdata->control_port_protocol))
+ return ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) ||
+ ether_addr_equal(ehdr->h_dest, pae_group_addr);
if (ieee80211_802_1x_port_control(rx) ||
ieee80211_drop_unencrypted(rx, fc))
@@ -2632,7 +2632,26 @@ static void ieee80211_deliver_skb_to_loc
cfg80211_rx_control_port(dev, skb, noencrypt);
dev_kfree_skb(skb);
} else {
+ struct ethhdr *ehdr = (void *)skb_mac_header(skb);
memset(skb->cb, 0, sizeof(skb->cb));
+ /*
+ * 802.1X over 802.11 requires that the authenticator address
+ * be used for EAPOL frames. However, 802.1X allows the use of
+ * the PAE group address instead. If the interface is part of
+ * a bridge and we pass the frame with the PAE group address,
+ * then the bridge will forward it to the network (even if the
+ * client was not associated yet), which isn't supposed to
+ * happen.
+ * To avoid that, rewrite the destination address to our own
+ * address, so that the authenticator (e.g. hostapd) will see
+ * the frame, but bridge won't forward it anywhere else. Note
+ * that due to earlier filtering, the only other address can
+ * be the PAE group address.
+ */
+ if (unlikely(skb->protocol == sdata->control_port_protocol &&
+ !ether_addr_equal(ehdr->h_dest, sdata->vif.addr)))
+ ether_addr_copy(ehdr->h_dest, sdata->vif.addr);
+
netif_rx_nss(rx, skb);
}
}
@@ -2672,6 +2691,7 @@ ieee80211_deliver_skb(struct ieee80211_r
if ((sdata->vif.type == NL80211_IFTYPE_AP ||
sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
!(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) &&
+ ehdr->h_proto != rx->sdata->control_port_protocol &&
(sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) {
if (is_multicast_ether_addr(ehdr->h_dest) &&
ieee80211_vif_get_num_mcast_if(sdata) != 0) {
@@ -2781,7 +2801,7 @@ __ieee80211_rx_h_amsdu(struct ieee80211_
if (ieee80211_data_to_8023_exthdr(skb, &ethhdr,
rx->sdata->vif.addr,
rx->sdata->vif.type,
- data_offset))
+ data_offset, true))
return RX_DROP_UNUSABLE;
ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr,
@@ -2838,6 +2858,23 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx
if (is_multicast_ether_addr(hdr->addr1))
return RX_DROP_UNUSABLE;
+ if (rx->key) {
+ /*
+ * We should not receive A-MSDUs on pre-HT connections,
+ * and HT connections cannot use old ciphers. Thus drop
+ * them, as in those cases we couldn't even have SPP
+ * A-MSDUs or such.
+ */
+ switch (rx->key->conf.cipher) {
+ case WLAN_CIPHER_SUITE_WEP40:
+ case WLAN_CIPHER_SUITE_WEP104:
+ case WLAN_CIPHER_SUITE_TKIP:
+ return RX_DROP_UNUSABLE;
+ default:
+ break;
+ }
+ }
+
return __ieee80211_rx_h_amsdu(rx, 0);
}
Index: backports-20200902_001-4.4.60-931c337125/net/wireless/util.c
===================================================================
--- backports-20200902_001-4.4.60-931c337125.orig/net/wireless/util.c
+++ backports-20200902_001-4.4.60-931c337125/net/wireless/util.c
@@ -474,7 +474,7 @@ EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen)
int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
const u8 *addr, enum nl80211_iftype iftype,
- u8 data_offset)
+ u8 data_offset, bool is_amsdu)
{
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
struct {
@@ -562,7 +562,7 @@ int ieee80211_data_to_8023_exthdr(struct
skb_copy_bits(skb, hdrlen, &payload, sizeof(payload));
tmp.h_proto = payload.proto;
- if (likely((ether_addr_equal(payload.hdr, rfc1042_header) &&
+ if (likely((!is_amsdu && ether_addr_equal(payload.hdr, rfc1042_header) &&
tmp.h_proto != htons(ETH_P_AARP) &&
tmp.h_proto != htons(ETH_P_IPX)) ||
ether_addr_equal(payload.hdr, bridge_tunnel_header)))
@@ -708,6 +708,9 @@ void ieee80211_amsdu_to_8023s(struct sk_
remaining = skb->len - offset;
if (subframe_len > remaining)
goto purge;
+ /* mitigate A-MSDU aggregation injection attacks */
+ if (ether_addr_equal(eth.h_dest, rfc1042_header))
+ goto purge;
offset += sizeof(struct ethhdr);
last = remaining <= subframe_len + padding;
Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/nss.c
===================================================================
--- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/nss.c
+++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/nss.c
@@ -477,7 +477,7 @@ static int ath11k_nss_deliver_rx(struct
}
if (ieee80211_data_to_8023_exthdr(skb, NULL, vif->addr, vif->type,
- data_offs - hdr_len)) {
+ data_offs - hdr_len, false)) {
dev_kfree_skb_any(skb);
return -EINVAL;
}

View File

@@ -0,0 +1,392 @@
Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/debug.c
===================================================================
--- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/debug.c
+++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/debug.c
@@ -1838,6 +1838,230 @@ static const struct file_operations fops
.open = simple_open
};
+static ssize_t ath11k_read_set_rates(struct file *file,
+ char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ const char buf[] =
+ "This is to set fixed bcast, mcast, and beacon rates. Normal rate-ctrl\n"
+ "is handled through normal API using 'iw', etc.\n"
+ "To set a value, you specify the dev-name, type, band and rate-code:\n"
+ "types: bcast, mcast, beacon, mgmt\n"
+ "bands: 2, 5\n"
+ "rate-codes: 1M (0x10000103), 2M (0x10000102), 5.5M (0x10000101),\n 11M (0x10000100), 6M (0x10000003),9M (0x10000007),\n 12M (0x10000002), 18M (0x10000006),\n 24M (0x10000001), 36M (0x10000005), 48M (0x10000000),\n 54M (0x10000004) , 0xFF default\n"
+ "Example, set beacon to 18Mbps on wlan0(2.4G):\n echo \"wlan0 beacon 2 0x10000006\" > /sys/kernel/debug/ieee80211/phy0/ath11k/set_rates\n";
+
+ return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+}
+
+bool check_band_rate_compat(struct ath11k *ar, long rc, int band)
+{
+ struct ieee80211_supported_band *sband = NULL;
+ int br, i = 0;
+ long rcode = 0;
+
+ sband = ar->hw->wiphy->bands[band];
+ if (sband == NULL) {
+ ath11k_err(ar->ab, "band not valid\n");
+ return false;
+ }
+
+ for (i = 0; i < sband->n_bitrates; i++) {
+ br = sband->bitrates[i].bitrate;
+ rcode = ath11k_mac_get_rate_hw_value(sband->bitrates[i].bitrate);
+ if (rcode == rc){
+ return true;
+ }
+ }
+ ath11k_err(ar->ab, "rate-code not found rc=%ld(0x%lx)", rc, rc);
+ return false;
+}
+
+/* Set the rates for specific types of traffic. */
+static ssize_t ath11k_write_set_rates(struct file *file,
+ const char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct ath11k *ar = file->private_data;
+ char buf[80];
+ int ret;
+ struct ath11k_vif *arvif;
+ struct ieee80211_vif *vif;
+ unsigned int vdev_id = 0xFFFF;
+ char* bufptr = buf;
+ long rc;
+ int cfg_band;
+ struct cfg80211_chan_def def;
+ char dev_name_match[IFNAMSIZ + 2];
+ struct wireless_dev *wdev;
+ int set_rate_type;
+
+ memset(buf, 0, sizeof(buf));
+
+ simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+
+ /* make sure that buf is null terminated */
+ buf[sizeof(buf) - 1] = 0;
+
+ /* drop the possible '\n' from the end */
+ if (buf[count - 1] == '\n')
+ buf[count - 1] = 0;
+
+ mutex_lock(&ar->conf_mutex);
+
+ /* Ignore empty lines, 'echo' appends them sometimes at least. */
+ if (buf[0] == 0) {
+ ret = count;
+ goto exit;
+ }
+
+ /* String starts with vdev name, ie 'wlan0' Find the proper vif that
+ * matches the name.
+ */
+ list_for_each_entry(arvif, &ar->arvifs, list) {
+ vif = arvif->vif;
+ wdev = ieee80211_vif_to_wdev(vif);
+
+ if (!wdev)
+ continue;
+ snprintf(dev_name_match, sizeof(dev_name_match) - 1, "%s ",
+ wdev->netdev->name);
+ if (strncmp(dev_name_match, buf, strlen(dev_name_match)) == 0) {
+ vdev_id = arvif->vdev_id;
+ bufptr = buf + strlen(dev_name_match);
+ break;
+ }
+ }
+
+ if (vdev_id == 0xFFFF) {
+ ath11k_warn(ar->ab, "set-rate, unknown netdev name: %s\n", buf);
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ /* Now, check the type. */
+ if (strncmp(bufptr, "beacon ", strlen("beacon ")) == 0) {
+ set_rate_type = WMI_VDEV_PARAM_BEACON_RATE;
+ bufptr += strlen("beacon ");
+ }
+ else if (strncmp(bufptr, "mgmt ", strlen("mgmt ")) == 0) {
+ set_rate_type = WMI_VDEV_PARAM_MGMT_RATE;
+ bufptr += strlen("mgmt ");
+ }
+ else if (strncmp(bufptr, "bcast ", strlen("bcast ")) == 0) {
+ set_rate_type = WMI_VDEV_PARAM_BCAST_DATA_RATE;
+ bufptr += strlen("bcast ");
+ }
+ else if (strncmp(bufptr, "mcast ", strlen("mcast ")) == 0) {
+ set_rate_type = WMI_VDEV_PARAM_MCAST_DATA_RATE;
+ bufptr += strlen("mcast ");
+ }
+ else {
+ ath11k_warn(ar->ab, "set-rate, invalid rate type: %s\n",
+ bufptr);
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ /* And the band */
+ if (strncmp(bufptr, "2 ", 2) == 0) {
+ cfg_band = NL80211_BAND_2GHZ;
+ bufptr += 2;
+ }
+ else if (strncmp(bufptr, "5 ", 2) == 0) {
+ cfg_band = NL80211_BAND_5GHZ;
+ bufptr += 2;
+ }
+ else if (strncmp(bufptr, "60 ", 3) == 0) {
+ cfg_band = NL80211_BAND_60GHZ;
+ bufptr += 3;
+ }
+ else {
+ ath11k_warn(ar->ab, "set-rate, invalid band: %s\n",
+ bufptr);
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ /* Parse the rate-code. */
+ ret = kstrtol(bufptr, 0, &rc);
+ if (ret != 0) {
+ ath11k_warn(ar->ab, "set-rate, invalid rate-code: %s\n",
+ bufptr);
+ goto exit;
+ }
+
+ /* Store the value so we can re-apply it if firmware is restarted. */
+ if (set_rate_type == WMI_VDEV_PARAM_MGMT_RATE) {
+ arvif->mgt_rate[cfg_band] = rc;
+ arvif->mgt_rate_set[cfg_band] = true;
+ }
+ else if (set_rate_type == WMI_VDEV_PARAM_BCAST_DATA_RATE) {
+ arvif->bcast_rate[cfg_band] = rc;
+ arvif->bcast_rate_set[cfg_band] = true;
+ }
+ else if (set_rate_type == WMI_VDEV_PARAM_MCAST_DATA_RATE) {
+ arvif->mcast_rate[cfg_band] = rc;
+ arvif->mcast_rate_set[cfg_band] = true;
+ }
+ else if (set_rate_type == WMI_VDEV_PARAM_BEACON_RATE) {
+ arvif->bcn_rate[cfg_band] = rc;
+ arvif->bcn_rate_set[cfg_band] = true;
+ }
+
+ if (ar->state != ATH11K_STATE_ON &&
+ ar->state != ATH11K_STATE_RESTARTED) {
+ /* OK, we will set it when vdev comes up */
+ ath11k_warn(ar->ab, "set-rates, deferred-state is down, vdev %i type: 0x%x rc: 0x%lx band: %d\n",
+ arvif->vdev_id, set_rate_type, rc, cfg_band);
+ goto exit;
+ }
+
+ if (ath11k_mac_vif_chan(vif, &def) == 0) {
+ if (def.chan->band != cfg_band) {
+ /* We stored value, will apply it later if we move to
+ * the different band.
+ */
+ ath11k_warn(ar->ab, "set-rates, deferred-other-band, vdev %i type: 0x%x rc: 0x%lx band: %d\n",
+ arvif->vdev_id, set_rate_type,
+ rc, cfg_band);
+ goto exit;
+ }
+
+ if (check_band_rate_compat(ar, rc, def.chan->band) == false) {
+ ath11k_warn(ar->ab, "set-rate, wrong rate code\n");
+ ret = -EINVAL;
+ goto exit;
+ }
+ }
+
+ /* finally, send results to the firmware */
+ ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
+ set_rate_type, rc);
+ if (ret) {
+ ath11k_warn(ar->ab, "set-rates: vdev %i failed to set fixed rate, param 0x%x rate-code 0x%02lx\n",
+ arvif->vdev_id, set_rate_type, rc);
+ goto exit;
+ }
+
+ ath11k_warn(ar->ab, "set-rates, vdev %i type: 0x%x rc: 0x%lx band: %d\n",
+ arvif->vdev_id, set_rate_type, rc, cfg_band);
+
+ ret = count;
+
+exit:
+ mutex_unlock(&ar->conf_mutex);
+ return ret;
+}
+
+static const struct file_operations fops_set_rates = {
+ .read = ath11k_read_set_rates,
+ .write = ath11k_write_set_rates,
+ .open = simple_open,
+ .owner = THIS_MODULE,
+ .llseek = default_llseek,
+};
+
static ssize_t ath11k_write_enable_m3_dump(struct file *file,
const char __user *ubuf,
size_t count, loff_t *ppos)
@@ -2532,6 +2756,9 @@ int ath11k_debug_register(struct ath11k
&fops__btcoex_duty_cycle);
debugfs_create_file("dump_mgmt_stats", 0644, ar->debug.debugfs_pdev,
ar, &fops_dump_mgmt_stats);
+ debugfs_create_file("set_rates", 0600, ar->debug.debugfs_pdev,
+ ar, &fops_set_rates);
+
if (ar->hw->wiphy->bands[NL80211_BAND_5GHZ]) {
debugfs_create_file("dfs_simulate_radar", 0200,
Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/mac.c
===================================================================
--- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/mac.c
+++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/mac.c
@@ -414,8 +414,8 @@ static u8 ath11k_parse_mpdudensity(u8 mp
}
}
-static int ath11k_mac_vif_chan(struct ieee80211_vif *vif,
- struct cfg80211_chan_def *def)
+int ath11k_mac_vif_chan(struct ieee80211_vif *vif,
+ struct cfg80211_chan_def *def)
{
struct ieee80211_chanctx_conf *conf;
@@ -2633,7 +2633,7 @@ static void ath11k_bss_disassoc(struct i
/* TODO: cancel connection_loss_work */
}
-static u32 ath11k_mac_get_rate_hw_value(int bitrate)
+u32 ath11k_mac_get_rate_hw_value(int bitrate)
{
u32 preamble;
u16 hw_value;
@@ -2672,6 +2672,11 @@ static void ath11k_recalculate_mgmt_rate
lockdep_assert_held(&ar->conf_mutex);
+ /* If user has over-ridden the mgt rate, don't muck with it here. */
+ if (arvif->mgt_rate_set[def->chan->band] ||
+ arvif->bcn_rate_set[def->chan->band])
+ return;
+
sband = ar->hw->wiphy->bands[def->chan->band];
basic_rate_idx = ffs(vif->bss_conf.basic_rates) - 1;
bitrate = sband->bitrates[basic_rate_idx].bitrate;
@@ -2682,12 +2687,14 @@ static void ath11k_recalculate_mgmt_rate
return;
}
+ arvif->mgt_rate[def->chan->band] = hw_rate_code;
vdev_param = WMI_VDEV_PARAM_MGMT_RATE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param,
hw_rate_code);
if (ret)
ath11k_warn(ar->ab, "failed to set mgmt tx rate %d\n", ret);
+ arvif->bcn_rate[def->chan->band] = hw_rate_code;
vdev_param = WMI_VDEV_PARAM_BEACON_RATE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param,
hw_rate_code);
@@ -3116,17 +3123,23 @@ static void ath11k_mac_op_bss_info_chang
rate = ATH11K_HW_RATE_CODE(hw_value, 0, preamble);
ath11k_dbg(ar->ab, ATH11K_DBG_MAC,
- "mac vdev %d mcast_rate %x\n",
- arvif->vdev_id, rate);
-
- vdev_param = WMI_VDEV_PARAM_MCAST_DATA_RATE;
- ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
- vdev_param, rate);
- if (ret)
- ath11k_warn(ar->ab,
- "failed to set mcast rate on vdev %i: %d\n",
- arvif->vdev_id, ret);
+ "mac vdev %d mcast_rate %x override-set-mcast: %d override-set-bcast: %d\n",
+ arvif->vdev_id, rate, arvif->mcast_rate_set[band],
+ arvif->bcast_rate_set[band]);
+
+ if (!arvif->mcast_rate_set[band]) {
+ arvif->mcast_rate[band] = rate;
+ vdev_param = WMI_VDEV_PARAM_MCAST_DATA_RATE;
+ ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
+ vdev_param, rate);
+ if (ret)
+ ath11k_warn(ar->ab,
+ "failed to set mcast rate on vdev %i: %d\n",
+ arvif->vdev_id, ret);
+ }
+ if (!arvif->bcast_rate_set[band]) {
+ arvif->bcast_rate[band] = rate;
vdev_param = WMI_VDEV_PARAM_BCAST_DATA_RATE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
vdev_param, rate);
@@ -3134,6 +3147,7 @@ static void ath11k_mac_op_bss_info_chang
ath11k_warn(ar->ab,
"failed to set bcast rate on vdev %i: %d\n",
arvif->vdev_id, ret);
+ }
}
if (changed & BSS_CHANGED_BASIC_RATES &&
@@ -5832,6 +5846,12 @@ static int ath11k_mac_op_add_interface(s
memset(arvif, 0, sizeof(*arvif));
+ memset(&arvif->bcast_rate, WMI_FIXED_RATE_NONE,
+ sizeof(arvif->bcast_rate));
+ memset(&arvif->mcast_rate, WMI_FIXED_RATE_NONE,
+ sizeof(arvif->mcast_rate));
+ memset(&arvif->mgt_rate, WMI_FIXED_RATE_NONE, sizeof(arvif->mgt_rate));
+
arvif->ar = ar;
arvif->vif = vif;
Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/mac.h
===================================================================
--- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/mac.h
+++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/mac.h
@@ -164,4 +164,8 @@ u8 ath11k_mac_bw_to_mac80211_bw(u8 bw);
enum ath11k_supported_bw ath11k_mac_mac80211_bw_to_ath11k_bw(enum rate_info_bw bw);
enum hal_encrypt_type ath11k_dp_tx_get_encrypt_type(u32 cipher);
void ath11k_mac_bcn_tx_event(struct ath11k_vif *arvif);
+int ath11k_mac_vif_chan(struct ieee80211_vif *vif,
+ struct cfg80211_chan_def *def);
+
+u32 ath11k_mac_get_rate_hw_value(int bitrate);
#endif
Index: backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/core.h
===================================================================
--- backports-20200902_001-4.4.60-931c337125.orig/drivers/net/wireless/ath/ath11k/core.h
+++ backports-20200902_001-4.4.60-931c337125/drivers/net/wireless/ath/ath11k/core.h
@@ -265,6 +265,23 @@ struct ath11k_vif {
#ifdef CPTCFG_ATH11K_NSS_SUPPORT
struct arvif_nss nss;
#endif
+ /* Firmware allows configuring rate of each of these traffic types.
+ * 0xFF will mean value has not been set by user, and in that case,
+ * we will auto-adjust the rates based on the legacy rate mask.
+ **/
+ /* TODO-BEN: This may conflict with upstream code? */
+ u8 mcast_rate[NUM_NL80211_BANDS];
+ u8 bcast_rate[NUM_NL80211_BANDS];
+ u8 mgt_rate[NUM_NL80211_BANDS];
+ u8 bcn_rate[NUM_NL80211_BANDS];
+
+ /* Flag if these rates are set through debugfs, in that case, ignore
+ * setting from farther up the stack.
+ */
+ bool mcast_rate_set[NUM_NL80211_BANDS];
+ bool bcast_rate_set[NUM_NL80211_BANDS];
+ bool mgt_rate_set[NUM_NL80211_BANDS];
+ bool bcn_rate_set[NUM_NL80211_BANDS];
};
struct ath11k_vif_iter {

View File

@@ -0,0 +1,22 @@
diff -Naur a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
--- a/drivers/net/wireless/ath/ath11k/mac.c 2021-06-09 10:02:12.040840722 -0400
+++ b/drivers/net/wireless/ath/ath11k/mac.c 2021-06-10 10:40:12.094003411 -0400
@@ -3472,13 +3472,14 @@
scan_timeout = min_t(u32, arg->max_rest_time *
(arg->chan_list.num_chan - 1) + (req->duration +
ATH11K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD) *
- arg->chan_list.num_chan, arg->max_scan_time +
- ATH11K_MAC_SCAN_TIMEOUT_MSECS);
+ arg->chan_list.num_chan, arg->max_scan_time);
} else {
- /* Add a 200ms margin to account for event/command processing */
- scan_timeout = arg->max_scan_time + ATH11K_MAC_SCAN_TIMEOUT_MSECS;
+ scan_timeout = arg->max_scan_time;
}
+ /* Add a 200ms margin to account for event/command processing */
+ scan_timeout += ATH11K_MAC_SCAN_TIMEOUT_MSECS;
+
ret = ath11k_start_scan(ar, arg);
if (ret) {
ath11k_warn(ar->ab, "failed to start hw scan: %d\n", ret);

View File

@@ -0,0 +1,22 @@
diff -Naur a/ath10k-5.7/mac.c b/ath10k-5.7/mac.c
--- a/ath10k-5.7/mac.c 2021-06-09 16:30:17.793556032 -0400
+++ b/ath10k-5.7/mac.c 2021-06-09 17:38:08.587733979 -0400
@@ -7103,13 +7103,15 @@
scan_timeout = min_t(u32, arg.max_rest_time *
(arg.n_channels - 1) + (req->duration +
ATH10K_SCAN_CHANNEL_SWITCH_WMI_EVT_OVERHEAD) *
- arg.n_channels, arg.max_scan_time + 200);
+ arg.n_channels, arg.max_scan_time);
} else {
- /* Add a 200ms margin to account for event/command processing */
- scan_timeout = arg.max_scan_time + 200;
+ scan_timeout = arg.max_scan_time;
}
+ /* Add a 200ms margin to account for event/command processing */
+ scan_timeout += 200;
+
ret = ath10k_start_scan(ar, &arg);
if (ret) {
ath10k_warn(ar, "failed to start hw scan: %d\n", ret);

View File

@@ -0,0 +1,11 @@
--- a/ath10k-5.7/mac.c 2021-07-06 11:12:56.022146449 -0700
+++ b/ath10k-5.7/mac.c 2021-07-06 19:37:52.352753693 -0700
@@ -8286,7 +8286,7 @@
struct ieee80211_channel *channel)
{
int ret;
- enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ_CLEAR;
+ enum wmi_bss_survey_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ;
lockdep_assert_held(&ar->conf_mutex);

View File

@@ -0,0 +1,31 @@
--- a/ath10k-5.7/wmi.c
+++ b/ath10k-5.7/wmi.c
@@ -6347,16 +6347,18 @@
survey = &ar->survey[idx];
- survey->noise = noise_floor;
- survey->time = div_u64(total, cc_freq_hz);
- survey->time_busy = div_u64(busy, cc_freq_hz);
- survey->time_rx = div_u64(rx_bss, cc_freq_hz);
- survey->time_tx = div_u64(tx, cc_freq_hz);
- survey->filled |= (SURVEY_INFO_NOISE_DBM |
- SURVEY_INFO_TIME |
- SURVEY_INFO_TIME_BUSY |
- SURVEY_INFO_TIME_RX |
- SURVEY_INFO_TIME_TX);
+ survey->noise = noise_floor;
+ survey->time = div_u64(total, cc_freq_hz);
+ survey->time_busy = div_u64(busy, cc_freq_hz);
+ survey->time_rx = div_u64(rx, cc_freq_hz);
+ survey->time_bss_rx = div_u64(rx_bss, cc_freq_hz);
+ survey->time_tx = div_u64(tx, cc_freq_hz);
+ survey->filled |= (SURVEY_INFO_NOISE_DBM |
+ SURVEY_INFO_TIME |
+ SURVEY_INFO_TIME_BUSY |
+ SURVEY_INFO_TIME_RX |
+ SURVEY_INFO_TIME_TX |
+ SURVEY_INFO_TIME_BSS_RX);
exit:
spin_unlock_bh(&ar->data_lock);
complete(&ar->bss_survey_done);

View File

@@ -810,7 +810,15 @@ hostapd_set_bss_options() {
json_get_vars ieee80211w_mgmt_cipher ieee80211w_max_timeout ieee80211w_retry_timeout
append bss_conf "ieee80211w=$ieee80211w" "$N"
[ "$ieee80211w" -gt "0" ] && {
append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
case "$auth_type" in
eap192)
append bss_conf "group_mgmt_cipher=BIP-GMAC-256" "$N"
append bss_conf "group_cipher=GCMP-256" "$N"
;;
*)
append bss_conf "group_mgmt_cipher=${ieee80211w_mgmt_cipher:-AES-128-CMAC}" "$N"
;;
esac
[ -n "$ieee80211w_max_timeout" ] && \
append bss_conf "assoc_sa_query_max_timeout=$ieee80211w_max_timeout" "$N"
[ -n "$ieee80211w_retry_timeout" ] && \
@@ -895,10 +903,10 @@ hostapd_set_bss_options() {
if [ "$hs20" = "1" ]; then
append bss_conf "hs20=1" "$N"
append_hs20_icons
[ -n "$disable_dgaf"] && append bss_conf "disable_dgaf=$disable_dgaf" "$N"
[ -n "$osen"] && append bss_conf "osen=$osen" "$N"
[ -n "$disable_dgaf" ] && append bss_conf "disable_dgaf=$disable_dgaf" "$N"
[ -n "$osen" ] && append bss_conf "osen=$osen" "$N"
[ "$anqp_domain_id" -gt 0 ] && append bss_conf "anqp_domain_id=$anqp_domain_id" "$N"
[ -n "$hs20_deauth_req_timeout"] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N"
[ -n "$hs20_deauth_req_timeout" ] && append bss_conf "hs20_deauth_req_timeout=$hs20_deauth_req_timeout" "$N"
[ -n "$osu_ssid" ] && append bss_conf "osu_ssid=$osu_ssid" "$N"
[ -n "$hs20_wan_metrics" ] && append bss_conf "hs20_wan_metrics=$hs20_wan_metrics" "$N"
[ -n "$hs20_operating_class" ] && append bss_conf "hs20_operating_class=$hs20_operating_class" "$N"
@@ -910,7 +918,6 @@ hostapd_set_bss_options() {
json_for_each_item append_venue_url venue_url
json_for_each_item append_nai_realm nai_realm
json_for_each_item append_hs20_conn_capab hs20_conn_capab
json_for_each_item append_hs20_oper_friendly_name hs20_oper_friendly_name
json_for_each_item append_osu_provider osu_provider
json_for_each_item append_operator_icon operator_icon
[ -n "$interworking" ] && append bss_conf "interworking=$interworking" "$N"

View File

@@ -0,0 +1,32 @@
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -4463,6 +4463,14 @@ static void handle_assoc(struct hostapd_
ieee802_11_set_beacons(hapd->iface);
}
+ ubus_resp = hostapd_ubus_handle_event(hapd, &req);
+ if (ubus_resp) {
+ wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
+ MAC2STR(mgmt->sa));
+ resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
+ goto fail;
+ }
+
update_ht_state(hapd, sta);
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
@@ -4568,14 +4576,6 @@ static void handle_assoc(struct hostapd_
pos, left, rssi, omit_rsnxe);
os_free(tmp);
- ubus_resp = hostapd_ubus_handle_event(hapd, &req);
- if (ubus_resp) {
- wpa_printf(MSG_DEBUG, "Station " MACSTR " assoc rejected by ubus handler.\n",
- MAC2STR(mgmt->sa));
- resp = ubus_resp > 0 ? (u16) ubus_resp : WLAN_STATUS_UNSPECIFIED_FAILURE;
- goto fail;
- }
-
/*
* Remove the station in case tranmission of a success response fails
* (the STA was added associated to the driver) or if the station was

View File

@@ -0,0 +1,65 @@
Index: hostapd-2020-06-08-5a8b3662/src/ap/ubus.c
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/ubus.c
+++ hostapd-2020-06-08-5a8b3662/src/ap/ubus.c
@@ -1486,7 +1486,60 @@ static int hostapd_get_bss_list(struct u
return 0;
}
+enum {
+ MOD_IFACE,
+ MOD_PARAM,
+ MOD_PARAM_VAL,
+ __PARAM_MAX
+};
+
+static const struct blobmsg_policy mod_param_policy[__PARAM_MAX] = {
+ [MOD_IFACE] = { "iface", BLOBMSG_TYPE_STRING },
+ [MOD_PARAM] = { "param", BLOBMSG_TYPE_STRING },
+ [MOD_PARAM_VAL] = { "param_val", BLOBMSG_TYPE_STRING },
+};
+
+static int
+hostapd_param_modify(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__PARAM_MAX];
+ struct hapd_interfaces *interfaces = NULL;
+ struct hostapd_data *hapd_bss = NULL;
+ struct hostapd_config *iconf = NULL;
+ struct hostapd_iface *iface = NULL;
+ size_t i = 0;
+
+ interfaces = get_hapd_interfaces_from_object(obj);
+ blobmsg_parse(mod_param_policy, __PARAM_MAX, tb, blob_data(msg),
+ blob_len(msg));
+ if (!tb[MOD_PARAM] || !tb[MOD_IFACE] || !tb[MOD_PARAM_VAL])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ wpa_printf(MSG_DEBUG, "Modifyint %s=%s for %s",
+ blobmsg_get_string(tb[MOD_PARAM]),
+ blobmsg_get_string(tb[MOD_PARAM_VAL]),
+ blobmsg_get_string(tb[MOD_IFACE]));
+
+ hapd_bss = hostapd_get_iface(interfaces,
+ blobmsg_get_string(tb[MOD_IFACE]));
+
+ if (hapd_bss) {
+ iconf = hapd_bss->iconf;
+ if (os_strcmp(blobmsg_get_string(tb[MOD_PARAM]),
+ "rssi_ignore_probe_request") == 0) {
+ iconf->rssi_ignore_probe_request = atoi(blobmsg_get_string(tb[MOD_PARAM_VAL]));
+
+ }
+ }
+
+ return UBUS_STATUS_OK;
+}
+
+
static const struct ubus_method daemon_methods[] = {
+ UBUS_METHOD("param_mod", hostapd_param_modify, mod_param_policy),
UBUS_METHOD("config_add", hostapd_config_add, config_add_policy),
UBUS_METHOD("config_remove", hostapd_config_remove, config_remove_policy),
UBUS_METHOD_NOARG("get_bss_list", hostapd_get_bss_list),

View File

@@ -0,0 +1,14 @@
Index: hostapd-2020-06-08-5a8b3662/src/ap/ubus.c
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/ubus.c
+++ hostapd-2020-06-08-5a8b3662/src/ap/ubus.c
@@ -1657,7 +1657,8 @@ int hostapd_ubus_handle_rt_event(struct
session_id = sta->cl_session_id;
/* find by session id */
- rec = avl_find_element(&hapd->ubus.rt_events, &session_id, rec, avl);
+ if (session_id)
+ rec = avl_find_element(&hapd->ubus.rt_events, &session_id, rec, avl);
/* prepare rec if not found */
if (!rec) {

View File

@@ -0,0 +1,299 @@
Index: hostapd-2020-06-08-5a8b3662/src/ap/ubus.c
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/ubus.c
+++ hostapd-2020-06-08-5a8b3662/src/ap/ubus.c
@@ -21,6 +21,7 @@
#include "rrm.h"
#include "wnm_ap.h"
#include "taxonomy.h"
+#include "common/hw_features_common.h"
static struct ubus_context *ctx;
static struct blob_buf b;
@@ -754,6 +755,208 @@ static int hostapd_get_chan_switch_event
return 0;
}
+#define HOSTAPD_DFS_CSA_DUR 1
+int csa_ch_id, csa_cf0_id, csa_cf1_id = 0;
+int csa_bw = CHANWIDTH_USE_HT;
+struct csa_settings css;
+
+struct hostapd_channel_data *freq_to_chan(struct hostapd_iface *iface, int freq)
+{
+ struct hostapd_hw_modes *mode;
+ struct hostapd_channel_data *chan;
+ int i;
+
+ mode = iface->current_mode;
+ if (mode == NULL || freq == 0) {
+ wpa_printf(MSG_INFO, "%s: mode is NULL", __func__);
+ return NULL;
+ }
+
+ for (i = 0; i < iface->current_mode->num_channels; i++) {
+ chan = &iface->current_mode->channels[i];
+ if (chan->freq == freq) {
+ return chan; /* Channel found */
+ }
+ }
+ return NULL;
+}
+
+void hostapd_dfs_csa_timeout(void *eloop_data, void *user_data)
+{
+ struct hostapd_data *hapd = eloop_data;
+ struct hostapd_iface *iface = hapd->iface;
+ struct csa_settings *css = user_data;
+ int ret = 0;
+
+ wpa_printf(MSG_DEBUG, "%s Stopping CSA in dfs ", __func__);
+
+ hapd->csa_in_progress = 0;
+
+ hostapd_disable_iface(iface);
+
+ iface->freq = css->freq_params.freq;
+ iface->conf->channel = csa_ch_id;
+ iface->conf->secondary_channel = css->freq_params.sec_channel_offset;
+ hostapd_set_oper_centr_freq_seg0_idx(iface->conf, csa_cf0_id);
+ hostapd_set_oper_centr_freq_seg1_idx(iface->conf, csa_cf1_id);
+ hostapd_set_oper_chwidth(iface->conf, csa_bw);
+ iface->conf->ieee80211n = css->freq_params.ht_enabled;
+ iface->conf->ieee80211ac = css->freq_params.vht_enabled;
+ iface->conf->ieee80211ax = css->freq_params.he_enabled;
+ wpa_printf(MSG_INFO, "%s: freq=%d chan=%d sec_ch=%d cf0=%d cf1=%d bw=%d 11n=%d, ac=%d, ax=%d",
+ __func__, iface->freq, iface->conf->channel,
+ iface->conf->secondary_channel, csa_cf0_id, csa_cf1_id,
+ css->freq_params.bandwidth, iface->conf->ieee80211n,
+ iface->conf->ieee80211ac, iface->conf->ieee80211ax);
+
+ ret = hostapd_enable_iface(iface);
+ if (ret == 0)
+ hostapd_ubus_handle_channel_switch_event(iface,
+ HOSTAPD_UBUS_HIGH_INTERFERENCE,
+ iface->freq);
+
+}
+
+int hostapd_dfs_set_beacon_csa(struct hostapd_iface *iface, struct csa_settings *css)
+{
+ struct hostapd_data *hapd = iface->bss[0];
+ struct hostapd_data *hapd_bss = NULL;
+ struct csa_settings csa_settings;
+ int secondary_channel = 0;
+ u8 vht_oper_centr_freq_seg0_idx;
+ u8 vht_oper_centr_freq_seg1_idx;
+ int err = 0, i = 0;
+
+ if (hapd->csa_in_progress == 1) {
+ wpa_printf(MSG_ERROR, "CSA in progress, cannot switch channel");
+ return -1;
+ }
+
+ eloop_cancel_timeout(hostapd_dfs_csa_timeout, hapd, NULL);
+
+ /* Setup Beacon CSA request */
+ secondary_channel = iface->conf->secondary_channel;
+ vht_oper_centr_freq_seg0_idx =
+ iface->conf->vht_oper_centr_freq_seg0_idx;
+ vht_oper_centr_freq_seg1_idx =
+ iface->conf->vht_oper_centr_freq_seg1_idx;
+
+ os_memset(&csa_settings, 0, sizeof(csa_settings));
+ err = hostapd_set_freq_params(&csa_settings.freq_params,
+ iface->conf->hw_mode,
+ iface->freq,
+ iface->conf->channel,
+ iface->conf->enable_edmg,
+ iface->conf->edmg_channel,
+ iface->conf->ieee80211n,
+ iface->conf->ieee80211ac,
+ iface->conf->ieee80211ax,
+ secondary_channel,
+ hostapd_get_oper_chwidth(iface->conf),
+ vht_oper_centr_freq_seg0_idx,
+ vht_oper_centr_freq_seg1_idx,
+ iface->current_mode->vht_capab,
+ &iface->current_mode->he_capab[IEEE80211_MODE_AP]);
+ if (err) {
+ wpa_printf(MSG_ERROR, "DFS failed to calculate CSA freq params");
+ return -1;
+ }
+
+
+ if (!(hapd->iface->drv_flags & WPA_DRIVER_FLAGS_AP_CSA)) {
+ wpa_printf(MSG_ERROR, "CSA is not supported");
+ return -1;
+ }
+
+ /* Set Beacon */
+ for (i = 0; i < hapd->iface->num_bss; i++) {
+ hapd_bss = iface->bss[i];
+ hapd_bss->cs_freq_params = csa_settings.freq_params;
+ hapd_bss->cs_count = css->cs_count;
+ hapd_bss->cs_block_tx = css->block_tx;
+ err = ieee802_11_set_beacon(hapd_bss);
+ if (err)
+ wpa_printf(MSG_ERROR, "CSA beacon set failed, changing channel without an Announcement");
+ }
+
+ hapd->csa_in_progress = 1;
+
+ /* Switch Channel after a timeout */
+ eloop_register_timeout(HOSTAPD_DFS_CSA_DUR, 0,
+ hostapd_dfs_csa_timeout, hapd, css);
+
+ return 0;
+}
+
+int hostapd_switch_chan_dfs(struct hostapd_iface *iface,
+ struct csa_settings *css)
+{
+ struct hostapd_channel_data *ch, *cf1, *cf2 = NULL;
+ int res = 0;
+
+ if (iface == NULL)
+ return -1;
+
+ /* Set channel id and center frequecies id */
+ if (css->freq_params.freq > 0) {
+ ch = freq_to_chan(iface, css->freq_params.freq);
+ csa_ch_id = ch->chan;
+ }
+
+ if (css->freq_params.center_freq1 > 0) {
+ csa_cf0_id = 36 + (css->freq_params.center_freq1 - 5180) / 5;
+ }
+
+ if (css->freq_params.center_freq2 > 0) {
+ csa_cf1_id = 36 + (css->freq_params.center_freq2 - 5180) / 5;
+ }
+
+ wpa_printf(MSG_DEBUG, "%s freq=%d chan=%d sec_chan=%d, width=%d, seg0=%d, seg1=%d, cac_time=%ds, ieee80211n=%d, ieee80211ac=%d, ieee80211ax=%d ", __func__,
+ css->freq_params.freq,
+ csa_ch_id, css->freq_params.sec_channel_offset,
+ css->freq_params.bandwidth, csa_cf0_id, csa_cf1_id,
+ iface->dfs_cac_ms / 1000, iface->conf->ieee80211n,
+ iface->conf->ieee80211ac, iface->conf->ieee80211ax);
+
+ /* Set bandwidth */
+ switch (css->freq_params.bandwidth) {
+ case 0:
+ case 20:
+ case 40:
+ csa_bw = CHANWIDTH_USE_HT;
+ break;
+ case 80:
+ if (css->freq_params.center_freq2)
+ csa_bw = CHANWIDTH_80P80MHZ;
+ else
+ csa_bw = CHANWIDTH_80MHZ;
+ break;
+ case 160:
+ csa_bw = CHANWIDTH_160MHZ;
+ break;
+ default:
+ wpa_printf(MSG_WARNING, "Unknown CSA bandwidth: %d",
+ css->freq_params.bandwidth);
+ break;
+ }
+
+ /* Set new frequency info */
+ iface->freq = css->freq_params.freq;
+ iface->conf->channel = csa_ch_id;
+ iface->conf->secondary_channel = css->freq_params.sec_channel_offset;
+ hostapd_set_oper_centr_freq_seg0_idx(iface->conf, csa_cf0_id);
+ hostapd_set_oper_centr_freq_seg1_idx(iface->conf, csa_cf1_id);
+ hostapd_set_oper_chwidth(iface->conf, csa_bw);
+ iface->conf->ieee80211n = css->freq_params.ht_enabled;
+ iface->conf->ieee80211ac = css->freq_params.vht_enabled;
+ iface->conf->ieee80211ax = css->freq_params.he_enabled;
+
+ /*Set beacon for CSA*/
+ hostapd_dfs_set_beacon_csa(iface, css);
+
+ return 0;
+}
+
static int
hostapd_switch_chan(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
@@ -761,14 +964,19 @@ hostapd_switch_chan(struct ubus_context
{
struct blob_attr *tb[__CSA_MAX];
struct hostapd_data *hapd = get_hapd_from_object(obj);
- struct csa_settings css;
+ struct hostapd_iface *iface = hapd->iface;
+ struct hostapd_channel_data *chan =NULL;
int i;
+ int freq = 0;
blobmsg_parse(csa_policy, __CSA_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[CSA_FREQ])
return UBUS_STATUS_INVALID_ARGUMENT;
+ freq = blobmsg_get_u32(tb[CSA_FREQ]);
+ chan = freq_to_chan(iface, freq);
+
memset(&css, 0, sizeof(css));
css.freq_params.freq = blobmsg_get_u32(tb[CSA_FREQ]);
@@ -787,6 +995,20 @@ hostapd_switch_chan(struct ubus_context
SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool);
SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool);
+ wpa_printf(MSG_INFO, "%s: CSS freq=%d chan=%d sec_chan_off=%d, width=%d, seg0=%d, seg1=%d", __func__,
+ css.freq_params.freq,
+ chan->chan, css.freq_params.sec_channel_offset,
+ css.freq_params.bandwidth,
+ css.freq_params.center_freq1,
+ css.freq_params.center_freq2);
+
+ if ((chan->flag & HOSTAPD_CHAN_RADAR) &&
+ ((chan->flag & HOSTAPD_CHAN_DFS_MASK)
+ != HOSTAPD_CHAN_DFS_AVAILABLE)) {
+ wpa_printf(MSG_INFO, "%s: DFS chan need CAC", __func__);
+ hostapd_switch_chan_dfs(iface, &css);
+ return UBUS_STATUS_OK;
+ }
for (i = 0; i < hapd->iface->num_bss; i++) {
if (hostapd_switch_channel(hapd->iface->bss[i], &css) != 0)
@@ -1454,10 +1676,16 @@ void hostapd_ubus_free_bss(struct hostap
}
free(name);
- for (size_t i = 0; i < bss_nr; i++)
- os_free(bss_lst[i]);
- free(bss_lst);
- bss_lst = NULL;
+
+ if (bss_lst != NULL) {
+ for (size_t i = 0; i < bss_nr; i++) {
+ os_free(bss_lst[i]);
+ bss_lst[i] = NULL;
+ }
+ free(bss_lst);
+ bss_lst = NULL;
+ bss_nr = 0;
+ }
}
static int hostapd_get_bss_list(struct ubus_context *ctx,
@@ -1477,9 +1705,11 @@ static int hostapd_get_bss_list(struct u
a = blobmsg_open_array(&b_ev, "bss_list");
/* check bss list from hapd */
for (size_t i = 0; i < bss_nr; i++) {
- b = blobmsg_open_table(&b_ev, NULL);
- blobmsg_add_string(&b_ev, "name", bss_lst[i]);
- blobmsg_close_table(&b_ev, b);
+ if (bss_lst[i] != NULL) {
+ b = blobmsg_open_table(&b_ev, NULL);
+ blobmsg_add_string(&b_ev, "name", bss_lst[i]);
+ blobmsg_close_table(&b_ev, b);
+ }
}
blobmsg_close_array(&b_ev, a);
ubus_send_reply(ctx, req, b_ev.head);

View File

@@ -0,0 +1,64 @@
--- a/src/ap/ubus.c
+++ b/src/ap/ubus.c
@@ -530,6 +530,7 @@ enum {
CSA_HT,
CSA_VHT,
CSA_BLOCK_TX,
+ CSA_REASON,
__CSA_MAX
};
@@ -543,6 +544,7 @@ static const struct blobmsg_policy csa_p
[CSA_HT] = { "ht", BLOBMSG_TYPE_BOOL },
[CSA_VHT] = { "vht", BLOBMSG_TYPE_BOOL },
[CSA_BLOCK_TX] = { "block_tx", BLOBMSG_TYPE_BOOL },
+ [CSA_REASON] = { "reason", BLOBMSG_TYPE_INT32 },
};
#ifdef NEED_AP_MLME
@@ -810,7 +812,7 @@ void hostapd_dfs_csa_timeout(void *eloop
iface->conf->ieee80211ac, iface->conf->ieee80211ax);
ret = hostapd_enable_iface(iface);
- if (ret == 0)
+ if (ret == 0 && css->reason == 0)
hostapd_ubus_handle_channel_switch_event(iface,
HOSTAPD_UBUS_HIGH_INTERFERENCE,
iface->freq);
@@ -994,6 +996,7 @@ hostapd_switch_chan(struct ubus_context
SET_CSA_SETTING(CSA_HT, freq_params.ht_enabled, bool);
SET_CSA_SETTING(CSA_VHT, freq_params.vht_enabled, bool);
SET_CSA_SETTING(CSA_BLOCK_TX, block_tx, bool);
+ SET_CSA_SETTING(CSA_REASON, reason, u32);
wpa_printf(MSG_INFO, "%s: CSS freq=%d chan=%d sec_chan_off=%d, width=%d, seg0=%d, seg1=%d", __func__,
css.freq_params.freq,
@@ -1015,7 +1018,9 @@ hostapd_switch_chan(struct ubus_context
return UBUS_STATUS_NOT_SUPPORTED;
}
- hostapd_ubus_handle_channel_switch_event(hapd->iface,HOSTAPD_UBUS_HIGH_INTERFERENCE, css.freq_params.freq);
+ if (css.reason == 0) {
+ hostapd_ubus_handle_channel_switch_event(hapd->iface, HOSTAPD_UBUS_HIGH_INTERFERENCE, css.freq_params.freq);
+ }
return UBUS_STATUS_OK;
#undef SET_CSA_SETTING
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -2291,6 +2291,7 @@ struct beacon_data {
* @freq_params: Next channel frequency parameter
* @beacon_csa: Beacon/probe resp/asooc resp info for CSA period
* @beacon_after: Next beacon/probe resp/asooc resp info
+ * @reason: The reason why we are switching the channel
* @counter_offset_beacon: Offset to the count field in beacon's tail
* @counter_offset_presp: Offset to the count field in probe resp.
*/
@@ -2301,6 +2302,7 @@ struct csa_settings {
struct hostapd_freq_params freq_params;
struct beacon_data beacon_csa;
struct beacon_data beacon_after;
+ u32 reason;
u16 counter_offset_beacon[2];
u16 counter_offset_presp[2];

View File

@@ -0,0 +1,111 @@
--- a/src/ap/ubus.c
+++ b/src/ap/ubus.c
@@ -578,6 +578,7 @@ static int hostapd_clear_session(struct
{
if (session_id == rec->session_id) {
/* dec counter and delete */
+ wpa_printf(MSG_INFO, "%s Deleting client session with session id %llu", __func__, session_id);
cached_events_nr -= rec->rec_nr;
avl_delete(&hapd->ubus.rt_events, &rec->avl);
os_free(rec->records);
@@ -631,6 +632,10 @@ static int hostapd_sessions(struct ubus_
/* messages for current session */
for (size_t i = 0; i < rec->rec_nr; i++) {
c_rec = &rec->records[i];
+ if (c_rec->processed) {
+ /* Record is already reported, continue */
+ continue;
+ }
/* check message type */
switch (c_rec->type) {
/* ClientAuthEvent */
@@ -644,6 +649,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_u32(&b_ev, "auth_status", p->auth_status);
blobmsg_add_string(&b_ev, "ssid", p->ssid);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -663,6 +669,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_u8(&b_ev, "using11v", p->using11v);
blobmsg_add_string(&b_ev, "ssid", p->ssid);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -678,6 +685,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_u32(&b_ev, "internal_rc", p->internal_rc);
blobmsg_add_string(&b_ev, "ssid", p->ssid);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -691,6 +699,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_u64(&b_ev, "fdata_tx_up_ts_in_us", p->tx_ts.tv_sec * (uint64_t)1000000);
blobmsg_add_u64(&b_ev, "fdata_rx_up_ts_in_us", p->rx_ts.tv_sec * (uint64_t)1000000);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -703,6 +712,7 @@ static int hostapd_sessions(struct ubus_
blobmsg_add_string(&b_ev, "sta_mac", p->sta_mac);
blobmsg_add_string(&b_ev, "ip_address", p->ip_addr);
blobmsg_close_table(&b_ev, t_msg);
+ c_rec->processed = true;
break;
}
@@ -1911,6 +1921,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_AUTH;
rp->u.auth.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
@@ -1941,6 +1952,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_ASSOC;
rp->u.assoc.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
/* frequency */
@@ -1985,6 +1997,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_DISASSOC;
rp->u.disassoc.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
/* frequency */
@@ -2016,6 +2029,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_FDATA;
rp->u.fdata.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
/* STA MAC */
@@ -2044,6 +2058,7 @@ int hostapd_ubus_handle_rt_event(struct
struct client_session_record *rp = &rec->records[rec->rec_nr - 1];
rp->type = CST_IP;
rp->u.ip.session_id = rec->session_id;
+ rp->processed = false;
/* timestamp */
rp->timestamp = timestamp;
/* STA MAC */
--- a/src/ap/ubus.h
+++ b/src/ap/ubus.h
@@ -110,6 +110,7 @@ struct client_ip_event {
};
struct client_session_record {
+ bool processed;
int type;
uint64_t timestamp;
union {

View File

@@ -444,6 +444,10 @@ return view.extend({
o.datatype = 'ip4addr("nomask")';
o.depends('proto', 'static');
o = s.option(form.Button, 'save', _(''));
o.inputtitle = _('Save Settings');
o.onclick = ui.createHandlerFn(this, 'handleSettingsSave', m);
s = m.section(form.NamedSection, 'lan', 'lan', _('LAN'));
o = s.option(form.Value, 'addr', _('IP Address'));
@@ -456,7 +460,7 @@ return view.extend({
o = s.option(form.Button, 'save', _(''));
o.inputtitle = _('Save Settings');
o.onclick = ui.createHandlerFn(this, 'handleSettingsSave', m);
o.onclick = ui.createHandlerFn(this, 'handleLANSettingsSave', m);
s = m.section(form.NamedSection, 'maintenance', 'maintenance', _('System Maintenance'));

View File

@@ -1,4 +1,12 @@
@import url('https://fonts.googleapis.com/css2?family=Montserrat&display=swap');
/* latin */
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(Montserrat_latin.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
--main-bright-color: #1B465C;

View File

@@ -52,7 +52,6 @@ define Package/opennds/install
$(INSTALL_DIR) $(1)/usr/lib/opennds
$(CP) ./files/lib/splash.css $(1)/etc/opennds/htdocs/
$(CP) ./files/lib/Tip.png $(1)/etc/opennds/htdocs/images/
$(CP) ./files/lib/opennds $(1)/etc/config/
$(CP) ./files/etc/init.d/opennds $(1)/etc/init.d/
$(CP) ./files/lib/login.sh $(1)/usr/lib/opennds/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,17 @@
#!/bin/sh
# Finds the highest settings an AP can support for various settings when set to "auto" in config
find_auto_hwmode() {
# This function finds the highest mode (hw_mode) that the AP can support
# Arguments
device=$1
mode='11n'
iw phy "$device" info | grep -q 'VHT Capabilities*' && mode="11ac"
iw phy "$device" info | grep -q 'HE.*Capabilities' && mode="11ax"
echo "$mode"
}
find_auto_hwmode $1

View File

@@ -0,0 +1,55 @@
#! /bin/sh
usage() {
echo "Usage: ${0} <realm>"
exit 1
}
test -n "${1}" || usage
REALM="${1}"
DIGCMD=$(command -v dig)
PRINTCMD=$(command -v printf)
validate_host() {
echo ${@} | tr -d '\n\t\r' | grep -E '^[_0-9a-zA-Z][-._0-9a-zA-Z]*$'
}
validate_port() {
echo ${@} | tr -d '\n\t\r' | grep -E '^[0-9]+$'
}
srv_lookup() {
${DIGCMD} +short srv $SRV_HOST | sort -n -k1 |
while read line ; do
set $line ; PORT=$(validate_port $3) ; HOST=$(validate_host $4)
if [ -n "${HOST}" ] && [ -n "${PORT}" ]; then
$PRINTCMD "\thost ${HOST%.}:${PORT}\n"
fi
done
}
naptr_lookup() {
${DIGCMD} +short naptr ${REALM} | grep aaa+auth:radius.tls.tcp | sort -n -k1 |
while read line; do
set $line ; TYPE=$3 ; HOST=$6
if [ "$TYPE" = "\"s\"" -o "$TYPE" = "\"S\"" ]; then
SRV_HOST=${HOST%.}
srv_lookup
fi
done
}
if test -x "${DIGCMD}" ; then
SERVERS=$(naptr_lookup)
else
echo "${0} requires \"dig\" command."
exit 1
fi
if test -n "${SERVERS}" ; then
$PRINTCMD "server dynamic_radsec.${REALM} {\n${SERVERS}\n\ttype TLS\n}\n"
exit 0
fi
exit 10 # No server found.

View File

@@ -24,7 +24,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IMGFILE="$(ls ${1}.*)"
# Get the most recent upgrade file available
IMGFILE="$(ls -t1 ${1}.* | head -n 1)"
if [ -z "$IMGFILE" ] || [ ! -f "$IMGFILE" ] ; then
echo
@@ -34,11 +35,14 @@ fi
# Set the current version as inactive before the upgrade
FW_VERSION=`sed -n 's/FW_IMAGE_ACTIVE:\(.*\)/\1/p' < /usr/opensync/.versions`
FW_BACKUP=$(uci get system.tip.inactivefw)
uci set system.tip.inactivefw="${FW_VERSION}"
uci commit
uci commit system
/sbin/sysupgrade $IMGFILE
if [ "$?" != "0" ] ; then
uci set system.tip.inactivefw="${FW_BACKUP}"
uci commit system
echo "$0: Sysupgrade failed."
exit 1
fi

View File

@@ -0,0 +1,15 @@
#!/bin/sh
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
exit 1
fi
action=$1
[ "$action" = "enable" ] && [ ! -f /etc/ssh-flag ] && uci set firewall.lan_ssh_rule.target='REJECT'
[ "$action" = "disable" ] && uci set firewall.lan_ssh_rule.target='ACCEPT'
uci commit firewall
/etc/init.d/firewall restart
exit 0

View File

@@ -0,0 +1,5 @@
#!/bin/sh
#Blink AP's LED
/usr/opensync/tools/ovsh insert Node_Config module:="led" key:="led_blink" value:="on"

View File

@@ -0,0 +1,5 @@
#!/bin/sh
#Turnoff blinking of AP's LED
/usr/opensync/tools/ovsh insert Node_Config module:="led" key:="led_off" value:="off"

View File

@@ -40,6 +40,9 @@ else
redirector_addr=$1
fi
# Enable lan ssh accsess
lan-ssh-firewall disable
echo "${redirector_addr}" > /usr/opensync/certs/redirector.txt
/etc/init.d/uhttpd enable
/etc/init.d/uhttpd start

View File

@@ -13,8 +13,21 @@ hwmode=$(uci get wireless.${radio}.hwmode)
bcn_rate=$(($(uci get wireless.${DEVICENAME}.bcn_rate)/10))
mcast_rate=$(uci get wireless.${DEVICENAME}.mcast_rate)
ATH10K_FILE="/sys/kernel/debug/ieee80211/${phy}/ath10k/set_rates"
if [ -f "$ATH10K_FILE" ]; then
# ath10k rate-codes: 0x43 1M, 0x42 2M, 0x41 5.5M, 0x40 11M, 0x3 6M, 0x7 9M, 0x2 12M, 0x6 18M, 0x1 24M, 0x5 36M, 0x0 48M, 0x4 54M, 0xFF default
rate_codes="1:0x43 2:0x42 5:0x41 11:0x40 6:0x3 9:0x7 12:0x2 18:0x6 24:0x1 36:0x5 48:0x0 54:0x4"
rate_codes="1:0x43 2:0x42 5:0x41 11:0x40 6:0x3 9:0x7 12:0x2 18:0x6 24:0x1 36:0x5 48:0x0 54:0x4"
SET_RATES_PATH=${ATH10K_FILE}
fi
ATH11K_FILE="/sys/kernel/debug/ieee80211/${phy}/ath11k/set_rates"
if [ -f "$ATH11K_FILE" ]; then
# ath11k rate-codes: 0x10000103 1M, 0x10000102 2M, 0x10000101 5.5M, 0x10000100 11M, 0x10000003 6M, 0x10000007 9M, 0x10000002 12M, 0x10000006 18M, 0x10000001 24M, 0x10000005 36M, 0x10000000 48M, 0x10000004 54M
rate_codes="1:0x10000103 2:0x10000102 5:0x10000101 11:0x10000100 6:0x10000003 9:0x10000007 12:0x10000002 18:0x10000006 24:0x10000001 36:0x10000005 48:0x10000000 54:0x10000004"
SET_RATES_PATH=${ATH11K_FILE}
fi
# Default codes
beacon_code=0xFF
@@ -34,5 +47,15 @@ done
# set rates
logger -t hotplug "Set Tx rates for device ${DEVICENAME}"
sleep 20
echo "${DEVICENAME} beacon ${band} ${beacon_code}" > /sys/kernel/debug/ieee80211/${phy}/ath10k/set_rates
echo "${DEVICENAME} mcast ${band} ${mcast_code}" > /sys/kernel/debug/ieee80211/${phy}/ath10k/set_rates
[ "${beacon_code}" = "0xFF" ] || {
echo "${DEVICENAME} beacon ${band} ${beacon_code}" > ${SET_RATES_PATH}
if [ -f "$ATH11K_FILE" ]; then
echo "${DEVICENAME} mgmt ${band} ${beacon_code}" > ${SET_RATES_PATH}
fi
}
[ "${mcast_code}" = "0xFF" ] || {
echo "${DEVICENAME} mcast ${band} ${mcast_code}" > ${SET_RATES_PATH}
}

View File

@@ -72,63 +72,6 @@ Index: opensync-2.0.5.0/interfaces/opensync.ovsschema
}
}
}
Index: opensync-2.0.5.0/platform/openwrt/src/lib/target/src/radio_ubus.c
===================================================================
--- opensync-2.0.5.0.orig/platform/openwrt/src/lib/target/src/radio_ubus.c
+++ opensync-2.0.5.0/platform/openwrt/src/lib/target/src/radio_ubus.c
@@ -10,6 +10,7 @@
extern struct ev_loop *wifihal_evloop;
static struct ubus_context *ubus;
extern struct ev_loop *wifihal_evloop;
+extern void apc_state_set(struct blob_attr *msg);
int hapd_rrm_enable(char *name, int neighbor, int beacon)
{
@@ -179,6 +180,7 @@ radio_ubus_add_vif_cb(struct ubus_contex
return UBUS_STATUS_OK;
}
+
static const struct ubus_method radio_ubus_methods[] = {
UBUS_METHOD("dbg_add_vif", radio_ubus_add_vif_cb, add_vif_policy),
UBUS_METHOD("dummy", radio_ubus_dummy_cb, dummy_policy),
@@ -201,8 +203,36 @@ static void radio_ubus_connect(struct ub
ubus_add_object(ubus, &radio_ubus_object);
}
+static int radio_ubus_notify(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ char *str;
+
+ str = blobmsg_format_json(msg, true);
+ LOGD("ubus: Received ubus notify '%s': %s\n", method, str);
+ free(str);
+
+ if (!strncmp(method, "apc", 3)) {
+ LOGD("APC notification Received");
+ apc_state_set(msg);
+ }
+
+ return 0;
+}
+
+
+
static struct ubus_instance ubus_instance = {
.connect = radio_ubus_connect,
+ .notify = radio_ubus_notify,
+ .list = {
+ {
+ .path = "apc",
+ },
+ },
+ .len = 1,
+
};
int radio_ubus_init(void)
Index: opensync-2.0.5.0/src/lib/schema/inc/schema_consts.h
===================================================================
--- opensync-2.0.5.0.orig/src/lib/schema/inc/schema_consts.h

View File

@@ -1,6 +1,6 @@
--- a/interfaces/opensync.ovsschema
+++ b/interfaces/opensync.ovsschema
@@ -9492,6 +9492,137 @@
@@ -9493,6 +9493,146 @@
},
"isRoot": true,
"maxRows": 1
@@ -25,6 +25,15 @@
+ "max": 1
+ }
+ },
+ "auto_discover": {
+ "type": {
+ "key": {
+ "type": "boolean"
+ },
+ "min": 1,
+ "max": 1
+ }
+ },
+ "server": {
+ "type": {
+ "key": {

View File

@@ -0,0 +1,12 @@
--- a/interfaces/opensync.ovsschema
+++ b/interfaces/opensync.ovsschema
@@ -1357,7 +1357,8 @@
"11n",
"11ab",
"11ac",
- "11ax"
+ "11ax",
+ "auto"
]
]
},

View File

@@ -0,0 +1,19 @@
--- a/interfaces/opensync.ovsschema
+++ b/interfaces/opensync.ovsschema
@@ -1880,7 +1880,15 @@
"min": 0,
"max": "unlimited"
}
- }
+ },
+ "channel_max_power": {
+ "type": {
+ "key": "integer",
+ "value": "integer",
+ "min": 0,
+ "max": "unlimited"
+ }
+ }
},
"isRoot": true,
"maxRows": 256

View File

@@ -0,0 +1,13 @@
Index: opensync-2.0.5.0/src/lib/target/src/target_linux.c
===================================================================
--- opensync-2.0.5.0.orig/src/lib/target/src/target_linux.c
+++ opensync-2.0.5.0/src/lib/target/src/target_linux.c
@@ -249,7 +249,7 @@ static bool linux_device_cpuutil_get(dpp
}
/* Calculate percentage and round */
- busy = (1.0 - ((double)diff.hz_idle / (double)hz_total_diff)) * 100.0;
+ busy = (100.0 - (((double)diff.hz_idle *100.0) / (double)hz_total_diff));
cpuutil->cpu_util = (uint32_t) (busy + 0.5);

View File

@@ -0,0 +1,16 @@
Index: opensync-2.0.5.0/src/lib/datapipeline/inc/dpp_types.h
===================================================================
--- opensync-2.0.5.0.orig/src/lib/datapipeline/inc/dpp_types.h
+++ opensync-2.0.5.0/src/lib/datapipeline/inc/dpp_types.h
@@ -148,10 +148,9 @@ typedef enum
RADIO_SCAN_TYPE_FULL,
RADIO_SCAN_TYPE_ONCHAN,
RADIO_SCAN_TYPE_OFFCHAN,
+ RADIO_SCAN_MAX_TYPE_QTY
} radio_scan_type_t;
-#define RADIO_SCAN_MAX_TYPE_QTY 3
-
typedef enum
{
RADIO_QUEUE_TYPE_VI = 0,

View File

@@ -0,0 +1,12 @@
--- a/src/um/src/um_ovsdb.c
+++ b/src/um/src/um_ovsdb.c
@@ -356,7 +356,8 @@ static void callback_AWLAN_Node(
//TODO Is there something that needs to be done here?
}
- if(awlan_node->upgrade_timer_changed){
+ if(awlan_node->upgrade_timer_changed
+ || ((awlan_node->firmware_url_changed) && (strlen(awlan_node->firmware_url) > 0))) {
if (awlan_node->upgrade_timer > 0)
{
/* if there is active timer, stop it to set new value */

View File

@@ -0,0 +1,32 @@
--- a/src/um/inc/um.h
+++ b/src/um/inc/um.h
@@ -32,6 +32,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBI
#define UM_STS_FW_DL_START (10) /* FW download started */
#define UM_STS_FW_DL_END (11) /* FW download successfully completed */
+#define UM_STS_RB_END (12) /* Reboot has been started */
+#define UM_STS_FR_END (13) /* Factory reset has been started */
#define UM_STS_FW_WR_START (20) /* FW write on alt partition started */
#define UM_STS_FW_WR_END (21) /* FW image write successfully completed */
#define UM_STS_FW_BC_START (30) /* Bootconfig partition update started */
--- a/src/um/src/um_ovsdb.c
+++ b/src/um/src/um_ovsdb.c
@@ -248,8 +248,16 @@ static void cb_upg(const osp_upg_op_t op
case OSP_UPG_DL:
if (status == OSP_UPG_OK)
{
- LOG(INFO, "Download successfully completed");
- ret_status = UM_STS_FW_DL_END;
+ if (!strcmp(upg_url, "reboot")) {
+ LOG(INFO, "Reboot successfully initiated");
+ ret_status = UM_STS_RB_END;
+ } else if (!strcmp(upg_url, "factory")) {
+ LOG(INFO, "Factory reset successfully initiated");
+ ret_status = UM_STS_FR_END;
+ } else {
+ LOG(INFO, "Download successfully completed");
+ ret_status = UM_STS_FW_DL_END;
+ }
}
else
{

View File

@@ -0,0 +1,11 @@
--- a/src/lib/ovsdb/src/ovsdb_table.c
+++ b/src/lib/ovsdb/src/ovsdb_table.c
@@ -560,7 +560,7 @@ void ovsdb_table_update_cb(ovsdb_update_
return;
}
- LOG(INFO, "MON upd: %s table: %s row: %s", typestr, table->table_name, mon_uuid );
+ LOG(TRACE, "MON upd: %s table: %s row: %s", typestr, table->table_name, mon_uuid );
if (LOG_SEVERITY_TRACE <= log_module_severity_get(MODULE_ID))
{

View File

@@ -40,17 +40,20 @@ start_service() {
echo "Checking Redirector"
redirector=$(uci get system.tip.redirector)
if [ -z "$redirector" ]; then
[[ -f /usr/opensync/certs/redirector.txt ]] && redirector=$(cat /usr/opensync/certs/redirector.txt | tr -d '\r\n')
if [ -z "$redirector" ]; then
logger -t opensync "Contacting DigiCert for redirector address"
wlan_ap_redirector.sh
[[ -f /usr/opensync/certs/redirector.txt ]] && saved_redirector=$(cat /usr/opensync/certs/redirector.txt | tr -d '\r\n')
logger -t opensync "Contacting DigiCert for redirector address"
wlan_ap_redirector.sh
new_redirector=$(uci get system.tip.redirector)
if [ -z "$new_redirector" && -n "$saved_redirector" ]; then
logger -t opensync "No response from DigiCert, using saved redirector address ${saved_redirector}"
wlan_ap_redirector.sh ${saved_redirector}
else
logger -t opensync "Restoring redirector ${redirector} after factory reset"
wlan_ap_redirector.sh ${redirector}
logger -t opensync "DigiCert returned redirector address ${new_redirector}"
fi
else
logger -t opensync "Using existing redirector address ${redirector}"
[[ -f /usr/opensync/certs/redirector.txt ]] || echo "${redirector}" > /usr/opensync/certs/redirector.txt
fi
[[ -f /usr/opensync/certs/redirector.txt ]] || echo "${redirector}" > /usr/opensync/certs/redirector.txt
echo "Starting OpenSync"
procd_set_param command ${PROG}
procd_close_instance

View File

@@ -1,6 +1,10 @@
/* SPDX-License-Identifier: BSD-3-Clause */
#include <string.h>
#include <glob.h>
#include <linux/limits.h>
#include <libgen.h>
#include <stdio.h>
#include <libubox/blobmsg_json.h>
#include "uci.h"
#include "command.h"
@@ -156,7 +160,6 @@ static void syslog_handler(int type,
blob_to_uci_section(uci, "system", "@system[-1]", "system",
b.head, &log_param, NULL);
uci_commit_all(uci);
system("/sbin/reload_config");
if (del)
node_state_del("syslog");
else
@@ -249,10 +252,205 @@ static void ntp_handler(int type,
blob_to_uci_section(uci, "system", "ntp", "timeserver",
b.head, &ntp_param, NULL);
uci_commit_all(uci);
system("/sbin/reload_config");
ntp_state(0);
}
enum {
LED_ATTR_SYSFS,
LED_ATTR_TRIGGER,
LED_ATTR_DELAYON,
LED_ATTR_DELAYOFF,
LED_ATTR_VALUE,
LED_ATTR_KEY,
__LED_ATTR_MAX,
};
static const struct blobmsg_policy led_policy[__LED_ATTR_MAX] = {
[LED_ATTR_SYSFS] = { .name = "sysfs", .type = BLOBMSG_TYPE_STRING },
[LED_ATTR_TRIGGER] = { .name = "trigger", .type = BLOBMSG_TYPE_STRING },
[LED_ATTR_DELAYON] = { .name = "delayon", .type = BLOBMSG_TYPE_STRING},
[LED_ATTR_DELAYOFF] = { .name = "delayoff", .type = BLOBMSG_TYPE_STRING},
[LED_ATTR_VALUE] = { .name = "value", .type = BLOBMSG_TYPE_STRING},
[LED_ATTR_KEY] = { .name = "key", .type = BLOBMSG_TYPE_STRING},
};
static const struct uci_blob_param_list led_param = {
.n_params = __LED_ATTR_MAX,
.params = led_policy,
};
static char led[][8]={"lan", "wan", "eth", "wifi2", "wifi5", "wlan2g", "wlan5g", "power","eth0",
"status", "eth1", "wifi2g", "eth2", "wifi5g", "plug", "world", "usb", "linksys", "wps", "bt"};
static struct blob_buf b;
#define DEFAULT_BOARD_JSON "/etc/board.json"
static struct blob_attr *board_info;
static void led_state(int config)
{
struct blob_attr *tb[__LED_ATTR_MAX] = { };
struct uci_package *system;
struct uci_section *s = NULL;
struct uci_element *e = NULL;
char val[8];
char key[16];
blob_buf_init(&b, 0);
uci_load(uci, "system", &system);
uci_foreach_element(&system->sections, e) {
s = uci_to_section(e);
if (!strcmp(s->type, "led")) {
uci_to_blob(&b, s, &led_param);
blobmsg_parse(led_policy, __LED_ATTR_MAX, tb, blob_data(b.head), blob_len(b.head));
if(tb[LED_ATTR_KEY])
strcpy(key, blobmsg_get_string(tb[LED_ATTR_KEY]));
if(tb[LED_ATTR_VALUE])
strcpy(val, blobmsg_get_string(tb[LED_ATTR_VALUE]));
break;
}
s = NULL;
}
if (!s)
goto out;
if (config)
node_config_set("led", key, val);
node_state_set("led", key, val);
out:
uci_unload(uci, system);
}
int available_led_check(char *led_name)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE(led); i++) {
if(!strcmp(led_name,led[i])) {
return 1;
}
}
return 0;
}
static void set_led_config(char *trigger_name, char *key, char* value, char* led_string, char* led_section)
{
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "sysfs", led_string);
blobmsg_add_string(&b, "trigger", trigger_name);
blobmsg_add_string(&b, "value", value);
blobmsg_add_string(&b, "key", key);
blob_to_uci_section(uci, "system", led_section, "led", b.head, &led_param, NULL);
return;
}
static struct blob_attr* config_find_blobmsg_attr(struct blob_attr *attr, const char *name, int type)
{
struct blobmsg_policy policy = { .name = name, .type = type };
struct blob_attr *cur;
blobmsg_parse(&policy, 1, &cur, blobmsg_data(attr), blobmsg_len(attr));
return cur;
}
static char* get_phy_map_led_info(char* wifi)
{
struct blob_attr *cur;
blob_buf_init(&b, 0);
if (!blobmsg_add_json_from_file(&b, DEFAULT_BOARD_JSON)) {
return NULL;
}
if (board_info != NULL) {
free(board_info);
board_info = NULL;
}
cur = config_find_blobmsg_attr(b.head, "led", BLOBMSG_TYPE_TABLE);
if (!cur) {
LOGD("Failed to find led objet in board.json file");
return NULL;
}
board_info = blob_memdup(cur);
if (!board_info)
return NULL;
cur = config_find_blobmsg_attr(board_info, wifi, BLOBMSG_TYPE_TABLE);
if (!cur) {
LOGD("Failed to find %s objet in board.json file", wifi);
return NULL;
}
cur = config_find_blobmsg_attr(cur, "trigger", BLOBMSG_TYPE_STRING);
if (!cur) {
LOGD("Failed to find trigger in board.json file");
return NULL;
}
return blobmsg_get_string(cur);
}
static void get_led_info_from_sys_config(char* key, char* value)
{
char led_string[32];
char ap_name[16];
char color[16];
char led_section[16];
char led_name_final[24];
char sys[8];
char class[8];
char leds[8];
char sysled[PATH_MAX];
glob_t gl;
unsigned int i;
if (glob("/sys/class/leds/*", GLOB_NOSORT, NULL, &gl))
return;
for (i = 0; i < gl.gl_pathc; i++) {
strncpy(sysled, gl.gl_pathv[i], sizeof(sysled));
sscanf(sysled,"/%[^/]/%[^/]/%[^/]/%s", sys, class, leds, led_string);
sscanf(led_string,"%[^:]:%[^:]:%s",ap_name, color, led_section);
if(available_led_check(led_section)) {
snprintf(led_name_final, sizeof(led_name_final), "%s%s","led_",led_section);
if(!strcmp(key, "led_blink")) {
set_led_config("heartbeat", key, value, led_string, led_name_final);
}
else if(!strcmp(key, "led_off")) {
set_led_config("none", key, value, led_string, led_name_final);
}
else {
if(!strcmp(led_section, "wifi2g") || !strcmp(led_section, "wifi5g")) {
set_led_config(get_phy_map_led_info(led_section), key, value, led_string, led_name_final);
}
else
set_led_config("none", key, value, led_string, led_name_final);
}
}
}
globfree(&gl);
return;
}
static void led_handler(int type,
struct schema_Node_Config *old,
struct schema_Node_Config *conf)
{
int del=1;
switch (type) {
case OVSDB_UPDATE_NEW:
case OVSDB_UPDATE_MODIFY:
if (!strcmp(conf->key, "led_blink") || !strcmp(conf->key, "led_off")) {
get_led_info_from_sys_config(conf->key, conf->value);
del=0;
}
break;
case OVSDB_UPDATE_DEL:
get_led_info_from_sys_config("led_state", "default");
break;
default:
LOGD("Invalid Command");
}
uci_commit_all(uci);
if(del)
node_state_del("led");
else
led_state(0);
}
static struct node_handler {
char *name;
void (*handler)(int type,
@@ -270,6 +468,11 @@ static struct node_handler {
.handler = ntp_handler,
.state = ntp_state,
},
{
.name = "led",
.handler = led_handler,
.state = led_state,
},
};
static void callback_Node_Config(ovsdb_update_monitor_t *mon,

View File

@@ -10,6 +10,13 @@
static ovsdb_table_t table_Manager;
static int done;
static void disable_ssh()
{
LOGN("Disabling LAN ssh access");
system("lan-ssh-firewall enable");
}
static void stop_http(void *arg)
{
LOGN("Stopping webserver");
@@ -17,6 +24,8 @@ static void stop_http(void *arg)
system("uci commit system");
system("/etc/init.d/uhttpd stop");
system("/etc/init.d/uhttpd disable");
disable_ssh();
}
static void callback_Manager(ovsdb_update_monitor_t *mon,

View File

@@ -54,7 +54,7 @@ UNIT_CFLAGS := -I$(UNIT_PATH)/inc
UNIT_CFLAGS += -Isrc/lib/common/inc/
UNIT_CFLAGS += -Isrc/lib/version/inc/
UNIT_LDFLAGS += -lev -lubox -luci -lubus -lwebsocket
UNIT_LDFLAGS += -lev -lubox -luci -lubus -lwebsocket -lblobmsg_json
UNIT_LDFLAGS += -lrt
UNIT_EXPORT_CFLAGS := $(UNIT_CFLAGS)

View File

@@ -10,7 +10,7 @@ extern const struct schema_Wifi_VIF_Config *vconf;
extern void vif_captive_portal_set (const struct schema_Wifi_VIF_Config *vconf, char *ifname);
extern void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate);
extern void captive_portal_init();
extern void splash_page_logo(char* dest_file,char* src_url);
extern void captive_portal_files_download(char* dest_file,char* src_url);
extern void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf, char *ifname);
extern void vif_state_dhcp_allowlist_get(struct schema_Wifi_VIF_State *vstate);

View File

@@ -0,0 +1,30 @@
/* SPDX-License-Identifier: BSD-3-Clause */
#ifndef _FIXUP_H__
#define _FIXUP_H__
struct vif_fixup {
struct avl_node avl;
char name[IF_NAMESIZE];
bool has_captive;
};
struct vif_fixup * vif_fixup_find(const char *name);
void vif_fixup_del(char *ifname);
bool vif_fixup_captive_enabled(void);
bool vif_fixup_iface_captive_enabled(const char *ifname);
void vif_fixup_set_iface_captive(const char *ifname, bool en);
struct radio_fixup {
struct avl_node avl;
char rname[IF_NAMESIZE];
char hw_mode[8];
};
struct radio_fixup * radio_fixup_find(const char *name);
void radio_fixup_del(char *ifname);
void radio_fixup_set_hw_mode(const char *ifname, char *hw_mode);
char *radio_fixup_get_hw_mode(const char *ifname);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -5,13 +5,14 @@
extern int phy_from_path(char *path, char *phy);
extern int phy_get_mac(char *phy, char *mac);
extern int phy_find_hwmon(char *path, char *hwmon);
extern int phy_find_hwmon(char *phy, char *hwmon, bool *DegreesNotMilliDegrees);
extern int phy_get_tx_chainmask(const char *name);
extern int phy_get_rx_chainmask(const char *name);
extern int phy_get_tx_available_antenna(const char *name);
extern int phy_get_rx_available_antenna(const char *name);
extern int phy_get_max_tx_power(const char *name , int channel);
extern int phy_get_channels(const char *name, int *channel);
extern int phy_get_dfs_channels(const char *name, int *channel);
extern int phy_get_channels_state(const char *name,
struct schema_Wifi_Radio_State *rstate);
extern int phy_get_band(const char *name, char *band);

View File

@@ -3,6 +3,10 @@
#ifndef _RADIO_H__
#define _RADIO_H__
#include "ovsdb_update.h"
#define CONFIG_APPLY_TIMEOUT 35
struct rrm_neighbor {
char *mac;
char *ssid;
@@ -10,17 +14,24 @@ struct rrm_neighbor {
};
extern const struct target_radio_ops *radio_ops;
extern int reload_config;
extern struct blob_buf b;
extern struct uci_context *uci;
extern int radio_ubus_init(void);
int ubus_set_hapd_param(const char *if_name, const char *param, const char *pval);
int ubus_set_signal_thresholds(const char *if_name, int connect, int stay);
extern int hapd_rrm_enable(char *name, int neighbor, int beacon);
extern int hapd_rrm_set_neighbors(char *name, struct rrm_neighbor *neigh, int count);
extern void radio_maverick(void *arg);
int nl80211_channel_get(char *name, unsigned int *chan);
void set_config_apply_timeout(ovsdb_update_monitor_t *mon);
bool apc_read_conf(struct schema_APC_Config *apcconf);
bool apc_read_state(struct schema_APC_State *apcst);
int ubus_set_channel_switch(const char *if_name, uint32_t frequency,
const char *hw_mode, int channel_bandwidth,
int sec_chan_offset, int reason);
#endif

View File

@@ -33,6 +33,7 @@ extern ovsdb_table_t table_Radius_Proxy_Config;
void callback_Radius_Proxy_Config(ovsdb_update_monitor_t *mon,
struct schema_Radius_Proxy_Config *old, struct schema_Radius_Proxy_Config *conf);
void radius_proxy_fixup(void);
#endif /* RADIUS_PROXY_H_INCLUDED */

View File

@@ -34,8 +34,12 @@ extern ovsdb_table_t table_Wifi_RRM_Config;
void rrm_config_vif(struct blob_buf *b, struct blob_buf *del,
const char * freq_band, const char * if_name);
int rrm_get_backup_channel(const char * freq_band);
bool rrm_config_txpower(const char *rname, unsigned int txpower);
void callback_Wifi_RRM_Config(ovsdb_update_monitor_t *mon,
struct schema_Wifi_RRM_Config *old, struct schema_Wifi_RRM_Config *conf);
void rrm_radio_rebalance_channel(const struct schema_Wifi_Radio_Config *rconf);
#endif /* RRM_CONFIG_H_INCLUDED */

View File

@@ -45,14 +45,14 @@ typedef struct
typedef struct
{
DPP_TARGET_SURVEY_RECORD_COMMON_STRUCT;
uint32_t chan_active;
uint32_t chan_busy;
uint32_t chan_busy_ext;
uint32_t chan_self;
uint32_t chan_rx;
uint32_t chan_tx;
uint64_t chan_active;
uint64_t chan_busy;
uint64_t chan_busy_ext;
uint64_t chan_self;
uint64_t chan_rx;
uint64_t chan_tx;
uint32_t chan_noise;
uint32_t duration_ms;
uint64_t duration_ms;
} target_survey_record_t;
typedef void target_capacity_data_t;

View File

@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: BSD-3-Clause */
#ifndef __TIMER_H__
#define __TIMER_H__
#include <sys/time.h>
struct timeout;
typedef void (*timeout_handler)(struct timeout *t);
struct timeout {
bool pending;
timeout_handler cb;
struct timeval time;
};
int timeout_set(struct timeout *timeout, int msecs);
void timer_expiry_check(struct timeout *timeout);
#endif

View File

@@ -6,6 +6,7 @@
#include <libubox/blobmsg.h>
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define ATH_DRIVER_NAME_LEN 16
struct mode_map {
int fiveg;
@@ -41,4 +42,8 @@ extern int net_get_mtu(char *iface);
extern int net_get_mac(char *iface, char *mac);
extern int net_is_bridge(char *iface);
extern char* get_max_channel_bw_channel(int channel_freq, const char* htmode);
int phy_find_hwmon_helper(char *dir, char *file, char *hwmon);
extern double dBm_to_mwatts(double dBm);
extern double mWatts_to_dBm(double mW);
extern int phy_get_ath_driver_name(char *phy, char *ath_driver);
#endif

View File

@@ -19,6 +19,7 @@
#define OVSDB_SECURITY_ENCRYPTION_WPA_SAE "WPA-SAE"
#define OVSDB_SECURITY_ENCRYPTION_WPA_EAP "WPA-EAP"
#define OVSDB_SECURITY_ENCRYPTION_WPA3_EAP "WPA3-EAP"
#define OVSDB_SECURITY_ENCRYPTION_WPA3_EAP_192 "WPA3-EAP-192"
#define OVSDB_SECURITY_RADIUS_SERVER_IP "radius_server_ip"
#define OVSDB_SECURITY_RADIUS_SERVER_PORT "radius_server_port"
#define OVSDB_SECURITY_RADIUS_SERVER_SECRET "radius_server_secret"

View File

@@ -47,6 +47,8 @@ UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/dhcpdiscovery.c
UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/radius_probe.c
UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/rrm_config.c
UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/radius_proxy.c
UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/timer.c
UNIT_SRC_TOP += $(OVERRIDE_DIR)/src/fixup.c
CONFIG_USE_KCONFIG=y
CONFIG_INET_ETH_LINUX=y

View File

@@ -20,10 +20,18 @@
#include "nl80211.h"
#include "utils.h"
#include "captive.h"
#include <libubox/avl-cmp.h>
#include <libubox/avl.h>
#include <libubox/vlist.h>
#include <net/if.h>
#include "fixup.h"
struct blob_buf cap={ };
static struct blob_buf cap={ };
static struct blob_buf cap_blob={ };
static struct blob_buf url_buf={ };
static struct uci_package *opennds;
static struct uci_context *cap_uci;
static struct uci_context *caps_uci;
static struct uci_context *capg_uci;
struct blob_attr *d;
#define SCHEMA_CAPTIVE_PORTAL_OPT_SZ 255
@@ -140,6 +148,10 @@ void vif_state_dhcp_allowlist_get(struct schema_Wifi_VIF_State *vstate)
char read_ifname[8];
char set[8];
struct blob_attr *td[__DNS_ATTR_MAX] = { };
if (vif_fixup_iface_captive_enabled(vstate->if_name) == false)
return;
uci_load(dns, "dhcp", &dhcp);
ip_section = uci_lookup_section(dns, dhcp,"dnsmasq");
if(!ip_section) {
@@ -182,12 +194,16 @@ void vif_dhcp_opennds_allowlist_set(const struct schema_Wifi_VIF_Config *vconf,
int i;
char ips[128];
char buff[64];
if (vif_fixup_iface_captive_enabled(vconf->if_name) == false)
return;
ipset_flush(ifname);
e = blobmsg_open_array(&dnsmas, "ipset");
for (i = 0; i < vconf->captive_allowlist_len; i++)
{
strcpy(buff,(char*)vconf->captive_allowlist[i]);
sprintf(ips,"/%s/set_%s", buff,"opennds");
snprintf(ips, sizeof(ips), "/%s/set_%s", buff,"opennds");
blobmsg_add_string(&dnsmas, NULL,ips);
}
blobmsg_close_array(&dnsmas, e);
@@ -235,10 +251,13 @@ void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate)
struct blob_attr *tc[__NDS_ATTR_MAX] = { };
struct uci_section *cp_section;
uci_load(cap_uci, "opennds", &opennds);
cp_section = uci_lookup_section(cap_uci, opennds,"opennds");
if (vif_fixup_iface_captive_enabled(vstate->if_name) == false)
return;
uci_load(capg_uci, "opennds", &opennds);
cp_section = uci_lookup_section(capg_uci, opennds,"opennds");
if(!cp_section) {
uci_unload(cap_uci, opennds);
uci_unload(capg_uci, opennds);
return;
}
blob_buf_init(&cap, 0);
@@ -351,15 +370,14 @@ void vif_state_captive_portal_options_get(struct schema_Wifi_VIF_State *vstate)
}
}
}
uci_unload(cap_uci, opennds);
uci_unload(capg_uci, opennds);
return;
}
void clean_up(CURL *curl,FILE* imagefile, FILE* headerfile)
void clean_up(CURL *curl,FILE* imagefile)
{
curl_easy_cleanup(curl);
fclose(imagefile);
fclose(headerfile);
return;
}
@@ -368,33 +386,27 @@ size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
return written;
}
void splash_page_logo(char* dest_file, char* src_url)
void captive_portal_files_download(char* dest_file, char* src_url)
{
CURL *curl;
CURLcode res;
FILE *imagefile;
FILE *headerfile;
static const char *clientcert = "/usr/opensync/certs/client.pem";
const char *clientcert = "/usr/opensync/certs/client.pem";
const char *clientkey = "/usr/opensync/certs/client_dec.key";
static const char *pHeaderFile = "/etc/opennds/splashlogo_header";
const char *keytype = "PEM";
char errbuf[CURL_ERROR_SIZE];
headerfile = fopen(pHeaderFile, "wb");
imagefile = fopen(dest_file, "wb");
if(imagefile == NULL){
LOG(ERR, "fopen failed");
if(headerfile)
fclose(headerfile);
return;
}
curl = curl_easy_init();
if (curl == NULL){
LOG(ERR, "curl_easy_init failed");
clean_up(curl,imagefile,headerfile);
clean_up(curl,imagefile);
return;
}
curl_easy_setopt(curl, CURLOPT_HEADERDATA, headerfile);
curl_easy_setopt(curl, CURLOPT_URL, src_url);
curl_easy_setopt(curl, CURLOPT_SSLCERT, clientcert);
curl_easy_setopt(curl, CURLOPT_SSLKEY, clientkey);
@@ -403,23 +415,22 @@ void splash_page_logo(char* dest_file, char* src_url)
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, imagefile);
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf);
curl_easy_setopt(curl, CURLOPT_HEADER, 0L);
res = curl_easy_perform(curl);
if (res != CURLE_OK){
clean_up(curl,imagefile,headerfile);
clean_up(curl,imagefile);
remove(dest_file);
return;
}
clean_up(curl,imagefile,headerfile);
clean_up(curl,imagefile);
return ;
}
int ipset_create(char *ifnds)
{
char command[64];
sprintf(command,"ipset create set_%s hash:ip", ifnds);
snprintf(command, sizeof(command), "ipset create set_%s hash:ip", ifnds);
return (system(command));
}
@@ -427,18 +438,19 @@ void captive_portal_get_current_urls(char *ifname, char *splash_logo, char *back
{
char *buf = NULL;
struct blob_attr *tc[__NDS_ATTR_MAX] = { };
struct blob_buf url_buf={ };
struct uci_section *cp_section;
struct uci_section *cp_section = NULL;
struct uci_package *opennds = NULL;
uci_load(cap_uci, "opennds", &opennds);
cp_section = uci_lookup_section(cap_uci, opennds,"opennds");
uci_load(caps_uci, "opennds", &opennds);
cp_section = uci_lookup_section(caps_uci, opennds,"opennds");
if(!cp_section) {
uci_unload(cap_uci, opennds);
uci_unload(caps_uci, opennds);
return;
}
blob_buf_init(&url_buf, 0);
uci_to_blob(&url_buf, cp_section, &opennds_param);
blobmsg_parse(opennds_policy, __NDS_ATTR_MAX, tc, blob_data(url_buf.head), blob_len(url_buf.head));
if (tc[NDS_ATTR_SPLASH_PAGE_LOGO]) {
@@ -460,7 +472,8 @@ void captive_portal_get_current_urls(char *ifname, char *splash_logo, char *back
} else {
user_file[0]=0;
}
uci_unload(cap_uci, opennds);
uci_unload(caps_uci, opennds);
return;
}
void opennds_parameters(char *ifname)
@@ -469,7 +482,7 @@ void opennds_parameters(char *ifname)
char users_router[7][64] = { "allow tcp port 53","allow udp port 53",
"allow udp port 67","allow tcp port 22",
"allow tcp port 23", "allow tcp port 80", "allow tcp port 443"};
struct blob_buf cap_blob={ };
blob_buf_init(&cap_blob, 0);
blobmsg_add_string(&cap_blob, "fwhook_enabled","1");
@@ -493,38 +506,35 @@ void opennds_parameters(char *ifname)
blobmsg_add_string(&cap_blob, NULL, users_router[i]);
}
blobmsg_close_array(&cap_blob, d);
blob_to_uci_section(cap_uci, "opennds", "opennds", "opennds", cap_blob.head, &opennds_param, NULL);
uci_commit_all(cap_uci);
blob_to_uci_section(caps_uci, "opennds", "opennds", "opennds", cap_blob.head, &opennds_param, NULL);
uci_commit_all(caps_uci);
return;
}
void opennds_section_del(char *section_name)
{
struct uci_package *opennds;
struct uci_context *nds_ctx;
struct uci_element *e = NULL, *tmp = NULL;
int ret = 0;
nds_ctx = uci_alloc_context();
ret = uci_load(nds_ctx, "opennds", &opennds);
ret = uci_load(caps_uci, "opennds", &opennds);
if (ret) {
LOGE("%s: %s uci_load() failed with rc %d", section_name, __func__, ret);
uci_free_context(nds_ctx);
uci_unload(caps_uci, opennds);
return;
}
uci_foreach_element_safe(&opennds->sections, tmp, e) {
struct uci_section *s = uci_to_section(e);
if (!strcmp(s->e.name, section_name)) {
uci_section_del(nds_ctx, "vif", "opennds", (char *)s->e.name, section_name);
uci_section_del(caps_uci, "vif", "opennds", (char *)s->e.name, section_name);
}
else {
continue;
}
}
uci_commit(nds_ctx, &opennds, false);
uci_unload(nds_ctx, opennds);
uci_free_context(nds_ctx);
uci_commit(caps_uci, &opennds, false);
uci_unload(caps_uci, opennds);
}
void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *ifname)
@@ -534,23 +544,26 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
const char *opt;
const char *val;
blob_buf_init(&cap, 0);
char path[64];
char webroot[64];
char path[64] = {0};
char webroot[64] = {0};
char ipset_tcp80[64];
char ipset_tcp443[64];
char splash_logo[84];
char back_image[84];
char user_file[84];
sprintf(path,"/etc/opennds/htdocs/images/");
sprintf(webroot,"/etc/opennds/htdocs");
sprintf(ipset_tcp80,"allow tcp port 80 ipset set_opennds");
sprintf(ipset_tcp443,"allow tcp port 443 ipset set_opennds");
char splash_logo[84] = {0};
char back_image[84] = {0};
char user_file[84] = {0};
snprintf(path, sizeof(path), "/etc/opennds/htdocs/images/");
snprintf(webroot, sizeof(webroot), "/etc/opennds/htdocs");
snprintf(ipset_tcp80, sizeof(ipset_tcp80),"allow tcp port 80 ipset set_opennds");
snprintf(ipset_tcp443, sizeof(ipset_tcp443), "allow tcp port 443 ipset set_opennds");
char file_path[128];
struct stat st = {0};
if (stat(path, &st) == -1)
mkdir(path, 0755);
captive_portal_get_current_urls(ifname, splash_logo, back_image, user_file);
for (j = 0; j < SCHEMA_CAPTIVE_PORTAL_OPTS_MAX; j++) {
@@ -575,6 +588,7 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
blobmsg_add_string(&cap, NULL, ipset_tcp80);
blobmsg_add_string(&cap, NULL, ipset_tcp443);
blobmsg_close_array(&cap, d);
vif_fixup_set_iface_captive(ifname, true);
} else if (strcmp(value,"username")==0) {
blobmsg_add_string(&cap, "webroot",webroot);
@@ -589,6 +603,8 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
blobmsg_add_string(&cap, NULL, ipset_tcp443);
blobmsg_close_array(&cap, d);
vif_fixup_set_iface_captive(ifname, true);
} else if (strcmp(value,"radius")==0) {
blobmsg_add_string(&cap, "webroot",webroot);
opennds_parameters("opennds");
@@ -596,14 +612,19 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
blobmsg_add_string(&cap, "enabled", "1");
blobmsg_add_string(&cap, "gatewayinterface","br-lan");
blobmsg_add_string(&cap, "preauth", "/usr/lib/opennds/radius.sh");
ipset_create("opennds");
d = blobmsg_open_array(&cap, "preauthenticated_users");
blobmsg_add_string(&cap, NULL, ipset_tcp80);
blobmsg_add_string(&cap, NULL, ipset_tcp443);
blobmsg_close_array(&cap, d);
vif_fixup_set_iface_captive(ifname, true);
}
else {
opennds_section_del("opennds");
vif_fixup_set_iface_captive(ifname, false);
if (vif_fixup_captive_enabled() == false)
opennds_section_del("opennds");
return;
}
}
@@ -630,17 +651,21 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
blobmsg_add_string(&cap, "gatewayname", value);
else if (strcmp(opt, "splash_page_logo") == 0) {
blobmsg_add_string(&cap, "splash_page_logo", value);
if (strcmp(splash_logo,value) !=0) {
sprintf(file_path,"%s%s",path,"TipLogo.png");
splash_page_logo(file_path,value);
if (value[0] != '\0') {
blobmsg_add_string(&cap, "splash_page_logo", value);
if (strcmp(splash_logo,value) !=0) {
snprintf(file_path, sizeof(file_path), "%s%s",path,"TipLogo.png");
captive_portal_files_download(file_path,value);
}
}
} else if (strcmp(opt, "splash_page_background_logo") == 0) {
blobmsg_add_string(&cap, "page_background_logo", value);
if (strcmp(back_image,value) !=0) {
sprintf(file_path,"%s%s",path,"TipBackLogo.png");
splash_page_logo(file_path,value);
if (value[0] != '\0') {
blobmsg_add_string(&cap, "page_background_logo", value);
if (strcmp(back_image,value) !=0) {
snprintf(file_path, sizeof(file_path),"%s%s",path,"TipBackLogo.png");
captive_portal_files_download(file_path,value);
}
}
}
@@ -658,20 +683,24 @@ void vif_captive_portal_set(const struct schema_Wifi_VIF_Config *vconf, char *if
blobmsg_add_string(&cap, "login_success_text", value);
else if (strcmp(opt, "username_password_file") == 0) {
blobmsg_add_string(&cap, "username_password_file", value);
if (strcmp(user_file,value) !=0) {
sprintf(file_path,"%s%s",path,"userpass.dat");
splash_page_logo(file_path,value);
if (value[0] != '\0') {
blobmsg_add_string(&cap, "username_password_file", value);
if (strcmp(user_file,value) !=0) {
snprintf(file_path, sizeof(file_path),"%s%s",path,"userpass.dat");
captive_portal_files_download(file_path,value);
}
}
}
}
blob_to_uci_section(cap_uci, "opennds", "opennds", "opennds", cap.head, &opennds_param, NULL);
uci_commit_all(cap_uci);
blob_to_uci_section(caps_uci, "opennds", "opennds", "opennds", cap.head, &opennds_param, NULL);
uci_commit_all(caps_uci);
return;
}
void captive_portal_init()
{
cap_uci=uci_alloc_context();
caps_uci=uci_alloc_context();
capg_uci=uci_alloc_context();
dns=uci_alloc_context();
return;
}

View File

@@ -17,6 +17,7 @@
#include <sys/ioctl.h>
#include "target.h"
#include "dhcp_opt.h"
#include "log.h"
#include "dhcpdiscovery.h"
//#include "wc-dhcpdiscoveryDebug.h"
@@ -55,14 +56,15 @@ struct Answer_t
/**
* Use to setup the DHCP client
*/
int dhcp_setup(const char * serveripaddress, const char * device)
bool dhcp_setup(const char * serveripaddress, const char * device, int *fd)
{
struct hostent *hostent;
const int flag = 1;
struct sockaddr_in name;
struct ifreq ifr;
int dhcp_socket;
int dhcp_socket = -1;
*fd = -1;
/* We populate the interface info */
memset(&ifr, 0, sizeof(ifr));
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s\n", device);
@@ -71,7 +73,7 @@ int dhcp_setup(const char * serveripaddress, const char * device)
* setup sending socket
*/
if ((hostent=gethostbyname(serveripaddress))==NULL) {
return 0;
goto err;
}
dhcp_to.sin_family=AF_INET;
@@ -81,17 +83,16 @@ int dhcp_setup(const char * serveripaddress, const char * device)
dhcp_to.sin_port=htons(67);
if ((dhcp_socket=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP))==-1)
{
return 0;
if ((dhcp_socket=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP))==-1) {
goto err;
}
if (setsockopt (dhcp_socket, SOL_SOCKET, SO_REUSEADDR, (char *)&flag, sizeof flag) < 0) {
return 0;
goto err;
}
if (setsockopt(dhcp_socket,SOL_SOCKET,SO_BROADCAST,(char *)&flag, sizeof flag) < 0) {
return 0;
goto err;
}
name.sin_family = AF_INET;
@@ -101,10 +102,16 @@ int dhcp_setup(const char * serveripaddress, const char * device)
memset (name.sin_zero, 0, sizeof (name.sin_zero));
if (bind (dhcp_socket, (struct sockaddr *)&name, sizeof name) < 0) {
return 0;
goto err;
}
return dhcp_socket;
*fd = dhcp_socket;
return true;
err:
if (dhcp_socket >= 0)
close(dhcp_socket);
return false;
}
void parseDhcpMessage(unsigned char *buffer,int size, struct Answer_t * response)
@@ -440,41 +447,39 @@ bool generateQuery(const char *ifname)
const char * serverIP = "255.255.255.255";
const char * mac_address = getMACAddress(device);
struct Answer_t response;
int dhcp_socket = -1;
int dhcp_socket = dhcp_setup(serverIP, device);
if (!dhcp_setup(serverIP, device, &dhcp_socket)) {
LOGE("%s dhcp client setup failed at line %d", __func__, __LINE__);
goto clean;
}
if( dhcp_socket != 0)
{
// We sent a DISCOVER
send_dhcp_packet(dhcp_socket, DISCOVER,"0.0.0.0",NULL,"0.0.0.0",mac_address);
// We sent a DISCOVER
send_dhcp_packet(dhcp_socket, DISCOVER,"0.0.0.0",NULL,"0.0.0.0",mac_address);
if(waitForResponse(dhcp_socket, _serveripaddress, WAIT_TIMEOUT_SECONDS, OFFER, &response) == OFFER /* DHCP TYPE: Offer */)
{
/* We close our initial socket (which is configured for broadcasting) */
if (waitForResponse(dhcp_socket, _serveripaddress, WAIT_TIMEOUT_SECONDS, OFFER, &response) == OFFER /* DHCP TYPE: Offer */) {
/* We close our initial socket (which is configured for broadcasting) */
if (dhcp_socket >= 0)
close(dhcp_socket);
/* We open a direct connection (as opposed to broadcasted one) */
dhcp_socket = dhcp_setup(response.serverIP, device);
/* We send a request */
send_dhcp_packet(dhcp_socket, REQUEST /* Request */, response.serverIP, response.offeredIP, "0.0.0.0", mac_address);
if(waitForResponse(dhcp_socket, _serveripaddress, WAIT_TIMEOUT_SECONDS, ACK_REQUEST, &response) == ACK_REQUEST /* DHCP TYPE: ACK */)
{
rc = true;
}
}
else
{
close(dhcp_socket);
rc = false;
/* We open a direct connection (as opposed to broadcasted one) */
dhcp_socket = -1;
if (!dhcp_setup(response.serverIP, device, &dhcp_socket)) {
LOGE("%s dhcp client setup failed at line %d", __func__, __LINE__);
goto clean;
}
/* We send a request */
send_dhcp_packet(dhcp_socket, REQUEST /* Request */, response.serverIP, response.offeredIP, "0.0.0.0", mac_address);
if (waitForResponse(dhcp_socket, _serveripaddress, WAIT_TIMEOUT_SECONDS, ACK_REQUEST, &response) == ACK_REQUEST /* DHCP TYPE: ACK */)
rc = true;
}
if(mac_address)
{
clean:
if (mac_address)
free( (void*) mac_address);
}
if (dhcp_socket >= 0)
close(dhcp_socket);
return rc;
}

View File

@@ -0,0 +1,140 @@
/* SPDX-License-Identifier: BSD-3-Clause */
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <stdbool.h>
#include <errno.h>
#include <stdlib.h>
#include "log.h"
#include "const.h"
#include "target.h"
#include <libubox/avl-cmp.h>
#include <libubox/avl.h>
#include <libubox/vlist.h>
#include <net/if.h>
#include "fixup.h"
/*
* VIF Fixup
*/
static struct avl_tree vif_fixup_tree = AVL_TREE_INIT(vif_fixup_tree, avl_strcmp, false, NULL);
static struct avl_tree radio_fixup_tree = AVL_TREE_INIT(radio_fixup_tree, avl_strcmp, false, NULL);
struct vif_fixup * vif_fixup_find(const char *ifname)
{
struct vif_fixup *vif = avl_find_element(&vif_fixup_tree, ifname, vif, avl);
if (vif)
return vif;
/* Not found, add */
vif = malloc(sizeof(*vif));
if (!vif)
return NULL;
memset(vif, 0, sizeof(*vif));
strncpy(vif->name, ifname, IF_NAMESIZE);
vif->avl.key = vif->name;
avl_insert(&vif_fixup_tree, &vif->avl);
return vif;
}
void vif_fixup_del(char *ifname)
{
struct vif_fixup *vif = NULL;
vif = avl_find_element(&vif_fixup_tree, ifname, vif, avl);
if (vif) {
avl_delete(&vif_fixup_tree, &vif->avl);
free(vif);
}
}
bool vif_fixup_captive_enabled(void)
{
struct vif_fixup *vif_ptr = NULL;
struct vif_fixup *vif = NULL;
avl_for_each_element_safe(&vif_fixup_tree, vif, avl, vif_ptr) {
if (vif->has_captive == true)
return true;
}
return false;
}
bool vif_fixup_iface_captive_enabled(const char *ifname)
{
struct vif_fixup * vif = NULL;
vif = vif_fixup_find(ifname);
if (vif)
return vif->has_captive;
else
return false;
}
void vif_fixup_set_iface_captive(const char *ifname, bool en)
{
struct vif_fixup * vif = NULL;
vif = vif_fixup_find(ifname);
if (vif)
vif->has_captive = en;
}
struct radio_fixup * radio_fixup_find(const char *ifname)
{
struct radio_fixup *radio = avl_find_element(&radio_fixup_tree, ifname, radio, avl);
if (radio)
return radio;
/* Not found, add */
radio = malloc(sizeof(*radio));
if (!radio)
return NULL;
memset(radio, 0, sizeof(*radio));
strncpy(radio->rname, ifname, IF_NAMESIZE);
radio->avl.key = radio->rname;
avl_insert(&radio_fixup_tree, &radio->avl);
return radio;
}
void radio_fixup_del(char *ifname)
{
struct radio_fixup *radio = NULL;
radio = avl_find_element(&radio_fixup_tree, ifname, radio, avl);
if (radio) {
avl_delete(&radio_fixup_tree, &radio->avl);
free(radio);
}
}
void radio_fixup_set_hw_mode(const char *ifname, char *hw_mode)
{
struct radio_fixup * radio = NULL;
radio = radio_fixup_find(ifname);
if (radio)
strncpy(radio->hw_mode, hw_mode, strlen(hw_mode));
}
char * radio_fixup_get_hw_mode(const char *ifname)
{
struct radio_fixup * radio = NULL;
radio = radio_fixup_find(ifname);
if (radio)
return radio->hw_mode;
else
return NULL;
}

View File

@@ -27,6 +27,8 @@
#include "rrm_config.h"
#include "vlan.h"
#include "radius_proxy.h"
#include "timer.h"
#include "fixup.h"
ovsdb_table_t table_Hotspot20_Config;
ovsdb_table_t table_Hotspot20_OSU_Providers;
@@ -35,14 +37,16 @@ ovsdb_table_t table_Radius_Proxy_Config;
ovsdb_table_t table_APC_Config;
ovsdb_table_t table_APC_State;
ovsdb_table_t table_Wifi_VIF_Config;
ovsdb_table_t table_Wifi_Inet_Config;
ovsdb_table_t table_Node_Config;
unsigned int radproxy_apc = 0;
extern json_t* ovsdb_table_where(ovsdb_table_t *table, void *record);
static struct uci_package *wireless;
struct uci_context *uci;
struct blob_buf b = { };
struct blob_buf del = { };
int reload_config = 0;
static struct timespec startup_time;
enum {
@@ -58,7 +62,7 @@ enum {
WDEV_ATTR_TX_ANTENNA,
WDEV_ATTR_RX_ANTENNA,
WDEV_ATTR_FREQ_BAND,
WDEV_AATR_CHANNELS,
WDEV_ATTR_CHANNELS,
WDEV_ATTR_DISABLE_B_RATES,
WDEV_ATTR_MAXASSOC_CLIENTS,
WDEV_ATTR_LOCAL_PWR_CONSTRAINT,
@@ -78,7 +82,7 @@ static const struct blobmsg_policy wifi_device_policy[__WDEV_ATTR_MAX] = {
[WDEV_ATTR_TX_ANTENNA] = { .name = "txantenna", .type = BLOBMSG_TYPE_INT32 },
[WDEV_ATTR_RX_ANTENNA] = { .name = "rxantenna", .type = BLOBMSG_TYPE_INT32 },
[WDEV_ATTR_FREQ_BAND] = { .name = "freq_band", .type = BLOBMSG_TYPE_STRING },
[WDEV_AATR_CHANNELS] = {.name = "channels", .type = BLOBMSG_TYPE_ARRAY},
[WDEV_ATTR_CHANNELS] = {.name = "channels", .type = BLOBMSG_TYPE_ARRAY},
[WDEV_ATTR_DISABLE_B_RATES] = { .name = "legacy_rates", .type = BLOBMSG_TYPE_BOOL },
[WDEV_ATTR_MAXASSOC_CLIENTS] = { .name = "maxassoc", .type = BLOBMSG_TYPE_INT32 },
[WDEV_ATTR_LOCAL_PWR_CONSTRAINT] = { .name = "local_pwr_constraint", .type = BLOBMSG_TYPE_INT32 },
@@ -182,6 +186,106 @@ static void radio_state_custom_options_get(struct schema_Wifi_Radio_State *rstat
}
}
static void set_channel_max_power(struct schema_Wifi_Radio_State *rstate,
int *index, int channel,
int max_power)
{
rstate->channel_max_power_keys[*index] = channel;
rstate->channel_max_power[*index] = max_power;
*index += 1;
rstate->channel_max_power_len = *index;
}
// Update the entire channel_max_power map in the radio state
static void update_channel_max_power(char* phy, struct schema_Wifi_Radio_State *rstate) {
int channels[64];
int channel_count = phy_get_channels(phy, channels);
channel_count += phy_get_dfs_channels(phy, channels + channel_count);
// Clear the data previously stored in channel_max_power
memset(rstate->channel_max_power_keys, 0, sizeof(rstate->channel_max_power_keys));
memset(rstate->channel_max_power, 0, sizeof(rstate->channel_max_power));
rstate->channel_max_power_len = 0;
// Set the new values for channel_max_power
int i, index = 0;
for (i = 0; i < channel_count && i < 64; i++) {
int channel = channels[i];
int max_tx_power = phy_get_max_tx_power(phy, channel);
set_channel_max_power(rstate, &index, channel, max_tx_power);
}
}
static int get_channel_tx_power_debugfs(char *stats_path, int *tx_power)
{
bool found = false;
char str[512];
FILE * fp = NULL;
int txpower = -1;
int ret = -1;
fp = fopen(stats_path, "r");
if (!fp) {
LOGE("%s: Failed to get tx power, stats file does not exist", __func__);
return -1;
}
const char *substr = "Channel TX power";
while(fgets(str, 512, fp)) {
if((strstr(str, substr)) != NULL) {
char * plast = NULL, * pcur = str;
while ((pcur = strtok( pcur, " "))) {
plast = pcur;
pcur = NULL;
}
txpower = atoi(plast);
found = true;
break;
}
}
if (!found) {
LOGE("%s: Unable to find Tx Power in stats", __func__);
} else {
/* txpower is set as 2 units per dBm in FW */
*tx_power = txpower/2;
ret = 0;
}
if (fp)
fclose(fp);
return ret;
}
static int get_channel_tx_power(char* phy, int *tx_power)
{
char ath_driver[ATH_DRIVER_NAME_LEN] = {'\0'};
char stats_path[128];
if (phy_get_ath_driver_name(phy, ath_driver)) {
LOGE("%s: Failed to get ATH driver name", __func__);
return -1;
}
if (!strncmp(ath_driver, "ath10k", ATH_DRIVER_NAME_LEN)) {
snprintf(stats_path, sizeof(stats_path),
"/sys/kernel/debug/ieee80211/%s/%s/fw_stats", phy,
ath_driver);
} else if (!strncmp(ath_driver, "ath11k", ATH_DRIVER_NAME_LEN)) {
snprintf(stats_path, sizeof(stats_path),
"/sys/kernel/debug/ieee80211/%s/%s/fw_stats/pdev_stats", phy,
ath_driver);
} else {
LOGE("%s: Unknown ATH driver", __func__);
return -1;
}
if (get_channel_tx_power_debugfs(stats_path, tx_power)) {
LOGE("%s: Failed to get Channel Tx Power", __func__);
return -1;
}
return 0;
}
const struct uci_blob_param_list wifi_device_param = {
.n_params = __WDEV_ATTR_MAX,
.params = wifi_device_policy,
@@ -193,6 +297,7 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C
struct schema_Wifi_Radio_State rstate;
char phy[6];
int antenna;
int tx_power = -1;
uint32_t chan = 0;
LOGT("%s: get state", s->e.name);
@@ -217,6 +322,8 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C
return false;
}
update_channel_max_power(phy, &rstate);
if (tb[WDEV_ATTR_CHANNEL]) {
nl80211_channel_get(phy, &chan);
if(chan)
@@ -231,13 +338,14 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C
else
SCHEMA_SET_INT(rstate.enabled, 1);
if (tb[WDEV_ATTR_TXPOWER]) {
SCHEMA_SET_INT(rstate.tx_power, blobmsg_get_u32(tb[WDEV_ATTR_TXPOWER]));
/* 0 means max in UCI, 32 is max in OVSDB */
if (rstate.tx_power == 0)
rstate.tx_power = 32;
} else
if (!get_channel_tx_power(phy, &tx_power)) {
SCHEMA_SET_INT(rstate.tx_power, tx_power);
} else {
LOGE("%s: Failed to update Channel Tx Power", __func__);
/* Set Tx Power to max OVSDB value */
SCHEMA_SET_INT(rstate.tx_power, 32);
}
if (tb[WDEV_ATTR_BEACON_INT])
SCHEMA_SET_INT(rstate.bcn_int, blobmsg_get_u32(tb[WDEV_ATTR_BEACON_INT]));
@@ -278,6 +386,8 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C
if (m) {
SCHEMA_SET_STR(rstate.hw_mode, m->hwmode);
radio_fixup_set_hw_mode(rstate.if_name, m->hwmode);
if (m->htmode)
SCHEMA_SET_STR(rstate.ht_mode, m->htmode);
else
@@ -291,8 +401,6 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C
if (tb[WDEV_ATTR_COUNTRY])
SCHEMA_SET_STR(rstate.country, blobmsg_get_string(tb[WDEV_ATTR_COUNTRY]));
else
SCHEMA_SET_STR(rstate.country, "CA");
rstate.allowed_channels_len = phy_get_channels(phy, rstate.allowed_channels);
rstate.allowed_channels_present = true;
@@ -343,8 +451,10 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf,
strncpy(ifname, rconf->if_name, sizeof(ifname));
strncpy(phy, target_map_ifname(ifname), sizeof(phy));
if (changed->channel && rconf->channel)
if (changed->channel && rconf->channel) {
blobmsg_add_u32(&b, "channel", rconf->channel);
rrm_radio_rebalance_channel(rconf);
}
if (changed->enabled)
blobmsg_add_u8(&b, "disabled", rconf->enabled ? 0 : 1);
@@ -353,9 +463,12 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf,
int max_tx_power;
max_tx_power=phy_get_max_tx_power(phy,rconf->channel);
if (rconf->tx_power<=max_tx_power) {
rrm_config_txpower(rconf->if_name, rconf->tx_power);
blobmsg_add_u32(&b, "txpower", rconf->tx_power);
}
else {
rrm_config_txpower(rconf->if_name, max_tx_power);
blobmsg_add_u32(&b, "txpower", max_tx_power);
}
}
@@ -409,12 +522,31 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf,
if ((changed->ht_mode) || (changed->hw_mode) || (changed->freq_band)) {
int channel_freq;
char buffer[8];
FILE *confFile_p;
const char* hw_mode = rconf->hw_mode;
channel_freq = ieee80211_channel_to_frequency(rconf->channel);
struct mode_map *m = mode_map_get_uci(rconf->freq_band, get_max_channel_bw_channel(channel_freq, rconf->ht_mode), rconf->hw_mode);
if (!strcmp(rconf->hw_mode, "auto")) {
char command[] = "auto-conf ";
strcat(command, phy);
confFile_p = popen(command, "r");
if (confFile_p)
{
fgets(buffer, sizeof(buffer), confFile_p);
pclose(confFile_p);
buffer[strlen(buffer) - 1] = '\0'; // Remove extra \n that got added from 'echo' in script
hw_mode = buffer;
}
}
struct mode_map *m = mode_map_get_uci(rconf->freq_band, get_max_channel_bw_channel(channel_freq, rconf->ht_mode), hw_mode);
if (m) {
blobmsg_add_string(&b, "htmode", m->ucihtmode);
blobmsg_add_string(&b, "hwmode", m->ucihwmode);
blobmsg_add_u32(&b, "chanbw", 20);
radio_fixup_set_hw_mode(rconf->if_name, m->hwmode);
} else
LOGE("%s: failed to set ht/hwmode", rconf->if_name);
}
@@ -438,20 +570,14 @@ bool target_radio_config_set2(const struct schema_Wifi_Radio_Config *rconf,
blob_to_uci_section(uci, "wireless", rconf->if_name, "wifi-device",
b.head, &wifi_device_param, del.head);
reload_config = 1;
uci_commit_all(uci);
return true;
}
static void periodic_task(void *arg)
{
static int counter = 0;
struct uci_element *e = NULL, *tmp = NULL;
int ret = 0;
if ((counter % 15) && !reload_config)
goto done;
struct uci_element *e = NULL, *tmp = NULL;
if (startup_time.tv_sec) {
static struct timespec current_time;
@@ -462,20 +588,11 @@ static void periodic_task(void *arg)
radio_maverick(NULL);
}
}
if (reload_config) {
LOGD("periodic: reload_config");
reload_config = 0;
uci_commit_all(uci);
sync();
system("reload_config");
}
LOGD("periodic: start state update ");
ret = uci_load(uci, "wireless", &wireless);
if (ret) {
LOGE("%s: uci_load() failed with rc %d", __func__, ret);
return;
goto out;
}
uci_foreach_element_safe(&wireless->sections, tmp, e) {
struct uci_section *s = uci_to_section(e);
@@ -493,9 +610,8 @@ static void periodic_task(void *arg)
uci_unload(uci, wireless);
LOGD("periodic: stop state update ");
done:
counter++;
evsched_task_reschedule_ms(EVSCHED_SEC(1));
out:
evsched_task_reschedule_ms(EVSCHED_SEC(15));
}
bool target_radio_config_init2(void)
@@ -528,7 +644,6 @@ bool target_radio_config_init2(void)
}
if (invalidVifFound) {
uci_commit(uci, &wireless, false);
reload_config = 1;
}
uci_unload(uci, wireless);
@@ -611,6 +726,7 @@ void radio_maverick(void *arg)
uci_unload(uci, wireless);
}
static void callback_Hotspot20_Config(ovsdb_update_monitor_t *mon,
struct schema_Hotspot20_Config *old,
struct schema_Hotspot20_Config *conf)
@@ -630,6 +746,7 @@ static void callback_Hotspot20_Config(ovsdb_update_monitor_t *mon,
LOG(ERR, "Hotspot20_Config: unexpected mon_type %d %s", mon->mon_type, mon->mon_uuid);
break;
}
set_config_apply_timeout(mon);
return;
}
@@ -653,6 +770,7 @@ static void callback_Hotspot20_OSU_Providers(ovsdb_update_monitor_t *mon,
mon->mon_type, mon->mon_uuid);
break;
}
set_config_apply_timeout(mon);
return;
}
@@ -677,6 +795,7 @@ static void callback_Hotspot20_Icon_Config(ovsdb_update_monitor_t *mon,
mon->mon_type, mon->mon_uuid);
break;
}
set_config_apply_timeout(mon);
return;
}
@@ -768,9 +887,105 @@ static const struct blobmsg_policy apc_policy[__APC_ATTR_MAX] = {
struct schema_APC_Config apc_conf;
bool apc_read_conf(struct schema_APC_Config *apcconf)
{
json_t *jrows;
int cnt = 0;
int i = 0;
pjs_errmsg_t perr;
jrows = ovsdb_sync_select_where(SCHEMA_TABLE(APC_Config), NULL);
if(!jrows)
{
return false;
}
cnt = json_array_size(jrows);
if(!cnt)
{
json_decref(jrows);
return false;
}
for (i = 0; i < cnt; i++)
{
if(!schema_APC_Config_from_json(apcconf, json_array_get(jrows, i),
false, perr))
{
LOGE("Unable to parse APC Config column: %s", perr);
json_decref(jrows);
return false;
}
}
json_decref(jrows);
return true;
}
bool apc_read_state(struct schema_APC_State *apcst)
{
json_t *jrows;
int cnt = 0;
int i = 0;
pjs_errmsg_t perr;
jrows = ovsdb_sync_select_where(SCHEMA_TABLE(APC_State), NULL);
if(!jrows)
{
return false;
}
cnt = json_array_size(jrows);
if(!cnt)
{
json_decref(jrows);
return false;
}
for (i = 0; i < cnt; i++)
{
if(!schema_APC_State_from_json(apcst, json_array_get(jrows, i),
false, perr))
{
LOGE("Unable to parse APC State column: %s", perr);
json_decref(jrows);
return false;
}
}
json_decref(jrows);
return true;
}
/* Check if apc conf is disabled, if disabled the update state
* with NC mode and return, this is to avoid the apc ubus
* notifications which come after the APC is disabled */
bool apc_conf_en()
{
struct schema_APC_Config apcconf;
struct schema_APC_State apc_state;
if(apc_read_conf(&apcconf) == false)
return true;
if (apcconf.enabled == false) {
SCHEMA_SET_STR(apc_state.mode, "NC");
SCHEMA_SET_STR(apc_state.dr_addr, "0.0.0.0");
SCHEMA_SET_STR(apc_state.bdr_addr, "0.0.0.0");
SCHEMA_SET_INT(apc_state.enabled, false);
if (!ovsdb_table_update(&table_APC_State, &apc_state))
LOG(ERR, "APC_state: failed to update");
return false;
}
return true;
}
void apc_state_set(struct blob_attr *msg)
{
struct blob_attr *tb[__APC_ATTR_MAX] = { };
struct schema_APC_State apc_state;
if(apc_conf_en() == false)
return;
blobmsg_parse(apc_policy, __APC_ATTR_MAX, tb,
blob_data(msg), blob_len(msg));
@@ -814,13 +1029,35 @@ static int conn_since = 0;
static void apc_enable(bool flag) {
SCHEMA_SET_INT(apc_conf.enabled, flag);
if (!ovsdb_table_update(&table_APC_Config, &apc_conf)) {
LOG(ERR, "%s:APC_Config: failed to update", __func__);
return;
}
struct schema_APC_State apc_state;
LOGI("APC %s: %s APC", __func__, flag?"enable":"disable");
if (flag == false) {
if(apc_read_state(&apc_state) == false) {
LOG(ERR, "%s: APC_State read failed", __func__);
apc_state.enabled = true;
}
if (apc_state.enabled == true) {
SCHEMA_SET_INT(apc_conf.enabled, flag);
if (!ovsdb_table_update(&table_APC_Config, &apc_conf)) {
LOG(ERR, "%s:APC_Config: failed to update", __func__);
return;
}
SCHEMA_SET_STR(apc_state.mode, "NC");
SCHEMA_SET_STR(apc_state.dr_addr, "0.0.0.0");
SCHEMA_SET_STR(apc_state.bdr_addr, "0.0.0.0");
SCHEMA_SET_INT(apc_state.enabled, false);
if (!ovsdb_table_update(&table_APC_State, &apc_state))
LOG(ERR, "APC_state: failed to update");
}
} else {
SCHEMA_SET_INT(apc_conf.enabled, flag);
if (!ovsdb_table_update(&table_APC_Config, &apc_conf)) {
LOG(ERR, "%s:APC_Config: failed to update", __func__);
return;
}
}
}
static void
@@ -829,24 +1066,20 @@ apc_cld_mon_cb(struct schema_Manager *mgr)
int i = 0;
conn_since = 0;
struct schema_APC_State apc_state;
json_t *where;
int ret = 0;
int link = 1;
where = ovsdb_table_where(&table_APC_State, &apc_state);
if (false == ovsdb_table_select_one_where(&table_APC_State,
where, &apc_state)) {
if(apc_read_state(&apc_state) == false) {
LOG(ERR, "%s: APC_State read failed", __func__);
return;
}
/*Checks if wan ethernet port is down and disables apc*/
ret = system("/bin/check_wan_link.sh");
if (WIFEXITED(ret)) {
LOGI("The return value: %d\n", WEXITSTATUS(ret));
link = WEXITSTATUS(ret);
if (link == 0) {
LOGD("APC link down");
apc_enable(false);
return;
}
@@ -861,7 +1094,6 @@ apc_cld_mon_cb(struct schema_Manager *mgr)
if(!strncmp(mgr->status_keys[i] , "sec_since_connect",
strlen("sec_since_connect"))) {
conn_since = atoi(mgr->status[i]);
LOGI("conn_since: %d", conn_since);
break;
}
}
@@ -934,6 +1166,52 @@ void apc_init()
}
static void apply_config_handler(struct timeout *timeout)
{
radius_proxy_fixup();
uci_commit_all(uci);
sync();
LOGI("====Calling reload_config====");
system("/sbin/reload_config");
}
static struct timeout config_timer = {
.cb = apply_config_handler
};
static void config_timer_task(void *arg)
{
timer_expiry_check(&config_timer);
evsched_task_reschedule_ms(EVSCHED_SEC(1));
}
void set_config_apply_timeout(ovsdb_update_monitor_t *mon)
{
static bool firstconfig = true;
LOGI("=====Received config update - table:%s uuid:%s Action:%d======", mon->mon_table, mon->mon_uuid, mon->mon_type);
if(firstconfig) {
firstconfig = false;
timeout_set(&config_timer, CONFIG_APPLY_TIMEOUT * 1000);
evsched_task(&config_timer_task, NULL, EVSCHED_SEC(1));
} else {
timeout_set(&config_timer, CONFIG_APPLY_TIMEOUT * 1000);
}
}
static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon,
struct schema_Wifi_Inet_Config *old_rec,
struct schema_Wifi_Inet_Config *iconf)
{
set_config_apply_timeout(mon);
}
static void callback_Node_Config(ovsdb_update_monitor_t *mon,
struct schema_Node_Config *old,
struct schema_Node_Config *conf)
{
set_config_apply_timeout(mon);
}
bool target_radio_init(const struct target_radio_ops *ops)
{
uci = uci_alloc_context();
@@ -962,6 +1240,11 @@ bool target_radio_init(const struct target_radio_ops *ops)
OVSDB_TABLE_INIT(Radius_Proxy_Config, _uuid);
OVSDB_TABLE_MONITOR(Radius_Proxy_Config, false);
OVSDB_TABLE_INIT(Wifi_Inet_Config, _uuid);
OVSDB_TABLE_MONITOR(Wifi_Inet_Config, false);
OVSDB_TABLE_INIT(Node_Config, _uuid);
OVSDB_TABLE_MONITOR(Node_Config, false);
evsched_task(&periodic_task, NULL, EVSCHED_SEC(5));

View File

@@ -14,7 +14,6 @@
#include <sys/types.h>
#include <linux/sockios.h>
#include <linux/nl80211.h>
#include <netlink/msg.h>
#include <netlink/attr.h>
@@ -33,6 +32,7 @@
#include <sys/time.h>
#include "nl80211_cpy.h"
#include "target.h"
#include "nl80211.h"
#include "phy.h"
@@ -149,13 +149,31 @@ static void nl80211_add_station(struct nlattr **tb, char *ifname)
addr = nla_data(tb[NL80211_ATTR_MAC]);
vif_add_sta_rate_rule(addr, ifname);
sta = avl_find_element(&sta_tree, addr, sta, avl);
if (sta)
return;
wif = avl_find_element(&wif_tree, ifname, wif, avl);
if (!wif)
return;
sta = avl_find_element(&sta_tree, addr, sta, avl);
/* In case of roaming between interfaces (wif) the sta would
* already be in the sta_tree, but however it should be inserted
* again with new parent wif. Also, sta should be detached from
* old wif and attached to new wif.
* When the client roams between wifs, the sta assocs
* first to new wif(NEW_STATION nlevent) and then the hostapd
* deletes (DEL_STATION nlevent) the stale client from old wif.
*/
if (sta) {
if (!strcasecmp(wif->name, sta->parent->name)) {
return;
}
else {
list_del(&sta->iface);
sta->parent = wif;
list_add(&sta->iface, &wif->stas);
}
}
sta = malloc(sizeof(*sta));
if (!sta)
return;
@@ -174,6 +192,11 @@ static void _nl80211_del_station(char *ifname, struct wifi_station *sta)
{
vif_del_sta_rate_rule(sta->addr, ifname);
vif_add_station(sta, ifname, 0);
/* Dont delete sta if it has roamed to a new interface */
if (strcasecmp(ifname, sta->parent->name))
return;
list_del(&sta->iface);
avl_delete(&sta_tree, &sta->avl);
free(sta);
@@ -395,6 +418,7 @@ static void nl80211_add_phy(struct nlattr **tb, char *name)
if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR]) {
phy->chandfs[chan] = 1;
phy->chanpwr[chan] = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]);
phy->chandisabled[chan] = 0;
LOG(DEBUG, "%s: found dfs channel %d", phy->name, chan);
continue;
@@ -577,6 +601,18 @@ static void vif_poll_stations(void *arg)
evsched_task_reschedule_ms(EVSCHED_SEC(STA_POLL_INTERVAL));
}
void vif_get_assoc_stations(void)
{
struct wifi_iface *wif = NULL;
avl_for_each_element(&wif_tree, wif, avl) {
struct nl_msg *msg;
msg = unl_genl_msg(&unl_req, NL80211_CMD_GET_STATION, true);
nla_put_u32(msg, NL80211_ATTR_IFINDEX, wif->ifidx);
unl_genl_request(&unl_req, msg, nl80211_recv, NULL);
}
}
int radio_nl80211_init(void)
{
struct nl_msg *msg;
@@ -606,6 +642,8 @@ int radio_nl80211_init(void)
if (nl_socket_set_nonblocking(unl_notify.sock))
LOGE("radio_nl80211: Failed to set socket in the non blocking mode");
/* Get already associated stations if any */
vif_get_assoc_stations();
ev_io_init(&unl_io, nl80211_ev, unl_notify.sock->s_fd, EV_READ);
ev_io_start(wifihal_evloop, &unl_io);

View File

@@ -10,6 +10,47 @@
extern struct ev_loop *wifihal_evloop;
static struct ubus_context *ubus;
extern struct ev_loop *wifihal_evloop;
extern void apc_state_set(struct blob_attr *msg);
struct blob_buf ub = { };
int ubus_set_signal_thresholds(const char *if_name, int connect, int stay)
{
uint32_t id;
char path[64];
if (connect > 0 && stay > 0)
return -1;
snprintf(path, sizeof(path), "hostapd.%s", if_name);
if (ubus_lookup_id(ubus, path, &id))
return -1;
blob_buf_init(&b, 0);
blobmsg_add_u32(&b, "connect", connect);
blobmsg_add_u32(&b, "stay", stay);
return ubus_invoke(ubus, id, "set_required_signal", b.head, NULL, NULL, 1000);
}
int ubus_set_hapd_param(const char *if_name, const char *param, const char *pval)
{
uint32_t id;
char path[64];
snprintf(path, sizeof(path), "hostapd");
if (ubus_lookup_id(ubus, path, &id))
return -1;
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "iface", if_name);
blobmsg_add_string(&b, "param", param);
blobmsg_add_string(&b, "param_val", pval);
return ubus_invoke(ubus, id, "param_mod", b.head, NULL, NULL, 1000);
}
int hapd_rrm_enable(char *name, int neighbor, int beacon)
{
@@ -50,6 +91,48 @@ int hapd_rrm_set_neighbors(char *name, struct rrm_neighbor *neigh, int count)
return ubus_invoke(ubus, id, "rrm_nr_set", b.head, NULL, NULL, 1000);
}
int ubus_set_channel_switch(const char *if_name, uint32_t frequency,
const char *hw_mode, int channel_bandwidth,
int sec_chan_offset, int reason)
{
uint32_t id;
char path[64];
snprintf(path, sizeof(path), "hostapd.%s", if_name);
if (ubus_lookup_id(ubus, path, &id))
return -1;
blob_buf_init(&ub, 0);
if (!strncmp(hw_mode, "11n", strlen("11n"))) {
blobmsg_add_u8(&ub, "ht", 1);
} else if (!strncmp(hw_mode, "11ac", strlen("11ac"))) {
blobmsg_add_u8(&ub, "ht", 1);
blobmsg_add_u8(&ub, "vht", 1);
} else if (!strncmp(hw_mode, "11ax", strlen("11ax"))) {
blobmsg_add_u8(&ub, "ht", 1);
blobmsg_add_u8(&ub, "vht", 1);
blobmsg_add_u8(&ub, "he", 1);
}
if (channel_bandwidth == 40)
blobmsg_add_u32(&ub, "center_freq1", frequency+10);
else if (channel_bandwidth == 80)
blobmsg_add_u32(&ub, "center_freq1", frequency+30);
else if (channel_bandwidth == 20)
blobmsg_add_u32(&ub, "center_freq1", frequency);
else if (channel_bandwidth == 160)
blobmsg_add_u32(&ub, "center_freq1", frequency+70);
blobmsg_add_u32(&ub, "freq", frequency);
blobmsg_add_u32(&ub, "bcn_count", 5);
blobmsg_add_u32(&ub, "bandwidth", channel_bandwidth);
blobmsg_add_u32(&ub, "sec_channel_offset", sec_chan_offset);
blobmsg_add_u32(&ub, "reason", reason);
return ubus_invoke(ubus, id, "switch_chan", ub.head, NULL, NULL, 1000);
}
enum {
DUMMY_PARAMETER,
__DUMMY_MAX,
@@ -201,8 +284,33 @@ static void radio_ubus_connect(struct ubus_context *ctx)
ubus_add_object(ubus, &radio_ubus_object);
}
static int radio_ubus_notify(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{
char *str;
str = blobmsg_format_json(msg, true);
LOGD("ubus: Received ubus notify '%s': %s\n", method, str);
free(str);
if (!strncmp(method, "apc", 3)) {
LOGD("APC notification Received");
apc_state_set(msg);
}
return 0;
}
static struct ubus_instance ubus_instance = {
.connect = radio_ubus_connect,
.notify = radio_ubus_notify,
.list = {
{
.path = "apc",
},
},
.len = 1,
};
int radio_ubus_init(void)

View File

@@ -55,6 +55,7 @@ enum {
RADIUS_PROXY_SERVER_STATUS,
RADIUS_PROXY_SERVER_TLS,
RADIUS_PROXY_SERVER_CERT_NAME_CHECK,
RADIUS_PROXY_SERVER_DYNAMIC_LOOKUP,
__RADIUS_PROXY_SERVER_MAX
};
@@ -104,6 +105,7 @@ static const struct blobmsg_policy radius_proxy_server_policy[__RADIUS_PROXY_SER
[RADIUS_PROXY_SERVER_STATUS] = { .name = "statusServer", BLOBMSG_TYPE_BOOL },
[RADIUS_PROXY_SERVER_TLS] = { .name = "tls", BLOBMSG_TYPE_STRING },
[RADIUS_PROXY_SERVER_CERT_NAME_CHECK] = { .name = "certificateNameCheck", BLOBMSG_TYPE_BOOL },
[RADIUS_PROXY_SERVER_DYNAMIC_LOOKUP] = { .name = "dynamicLookupCommand", BLOBMSG_TYPE_STRING },
};
static const struct blobmsg_policy radius_proxy_realm_policy[__RADIUS_PROXY_REALM_MAX] = {
@@ -220,14 +222,6 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf)
char server_name[256] = {};
char acct_server_name[256] = {};
char tls_name[256] = {};
struct schema_APC_State apc_conf;
json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf);
if (false == ovsdb_table_select_one_where(&table_APC_State,
where, &apc_conf)) {
LOG(INFO, "APC_State read failed");
return false;
}
/* Configure options block */
blob_buf_init(&uci_buf, 0);
@@ -290,12 +284,19 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf)
"tls", uci_buf.head, &radius_proxy_tls_param, NULL);
blob_buf_init(&uci_buf, 0);
if (conf->auto_discover)
{ /* auto discover radsec server address via realm DNS NAPTR record */
blobmsg_add_string(&uci_buf, "dynamicLookupCommand", "/bin/dynamic_lookup.sh");
}
else
{
blobmsg_add_string(&uci_buf, "host", conf->server);
blobmsg_add_u32(&uci_buf, "port", conf->port);
blobmsg_add_string(&uci_buf, "secret", "radsec");
}
blobmsg_add_string(&uci_buf, "name", server_name);
blobmsg_add_string(&uci_buf, "host", conf->server);
blobmsg_add_string(&uci_buf, "type", "tls");
blobmsg_add_string(&uci_buf, "tls", tls_name);
blobmsg_add_u32(&uci_buf, "port", conf->port);
blobmsg_add_string(&uci_buf, "secret", "radsec");
blobmsg_add_bool(&uci_buf, "statusServer", 0);
blobmsg_add_bool(&uci_buf, "certificateNameCheck", 0);
blob_to_uci_section(uci, "radsecproxy", server_name, "server",
@@ -356,11 +357,99 @@ static bool radius_proxy_config_set(struct schema_Radius_Proxy_Config *conf)
blob_to_uci_section(uci, "radsecproxy", name, "realm",
uci_buf.head, &radius_proxy_realm_param, NULL);
}
uci_commit_all(uci);
return true;
}
void radius_proxy_fixup()
{
struct uci_package *radsecproxy;
struct uci_context *proxy_ctx;
struct uci_element *e = NULL, *tmp = NULL;
int ret=0, wildcard_count=0, j=0, section_count=0;
char *acct_server = NULL, *auth_server = NULL;
struct uci_section *wildcard_section = NULL;
struct blob_attr *tb[__RADIUS_PROXY_REALM_MAX] = {};
struct blob_attr *n;
char section_name[128] = {};
if (!ovsdb_table_select_where(&table_Radius_Proxy_Config, NULL, &j))
return;
proxy_ctx = uci_alloc_context();
ret = uci_load(proxy_ctx, "radsecproxy", &radsecproxy);
if (ret) {
LOGE("%s: uci_load() failed with rc %d", __func__, ret);
if (proxy_ctx)
uci_free_context(proxy_ctx);
return;
}
uci_foreach_element_safe(&radsecproxy->sections, tmp, e) {
struct uci_section *s = uci_to_section(e);
if ((s == NULL) || (s->type == NULL)) continue;
if (!strcmp(s->type, "realm")) {
const char *realm_name;
section_count++;
realm_name = uci_lookup_option_string(proxy_ctx, s, "name");
if (wildcard_count == 0 && (!strcmp((char *)realm_name, "*"))) {
wildcard_section = s;
wildcard_count = section_count;
}
}
else {
continue;
}
}
TRACEF("wildcard_count: %d section_count: %d", wildcard_count, section_count);
if ((wildcard_count != section_count) && (wildcard_section != NULL)) {
blob_buf_init(&b, 0);
uci_to_blob(&b, wildcard_section, &radius_proxy_realm_param);
blobmsg_parse(radius_proxy_realm_policy, __RADIUS_PROXY_REALM_MAX, tb,
blob_data(b.head), blob_len(b.head));
/* Delete and re-add the wildcard section */
struct blob_attr *ttb[1];
blobmsg_parse_array(radius_proxy_realm_policy, ARRAY_SIZE(ttb), ttb,
blobmsg_data(tb[RADIUS_PROXY_REALM_AUTH_SERVER]),
blobmsg_data_len(tb[RADIUS_PROXY_REALM_AUTH_SERVER]));
if (ttb[0]) {
auth_server = blobmsg_get_string(ttb[0]);
}
blobmsg_parse_array(radius_proxy_realm_policy, ARRAY_SIZE(ttb), ttb,
blobmsg_data(tb[RADIUS_PROXY_REALM_ACCT_SERVER]),
blobmsg_data_len(tb[RADIUS_PROXY_REALM_ACCT_SERVER]));
if (ttb[0]) {
acct_server = blobmsg_get_string(ttb[0]);
}
strcpy(section_name, (char *)wildcard_section->e.name);
TRACEF("Delete section: %s", section_name);
uci_section_del(proxy_ctx, "radsecproxy", "radsecproxy",
(char *)wildcard_section->e.name, "realm");
blob_buf_init(&uci_buf, 0);
blobmsg_add_string(&uci_buf, "name", "*");
n = blobmsg_open_array(&uci_buf, "server");
blobmsg_add_string(&uci_buf, NULL, auth_server);
blobmsg_close_array(&uci_buf, n);
n = blobmsg_open_array(&uci_buf, "accountingServer");
blobmsg_add_string(&uci_buf, NULL, acct_server);
blobmsg_close_array(&uci_buf, n);
blob_to_uci_section(proxy_ctx, "radsecproxy", section_name, "realm",
uci_buf.head, &radius_proxy_realm_param, NULL);
TRACEF("Add section: %s %s %s", section_name, auth_server, acct_server);
uci_commit_all(proxy_ctx);
}
uci_free_context(proxy_ctx);
}
static bool radius_proxy_config_delete()
{
struct uci_package *radsecproxy;
@@ -385,7 +474,6 @@ static bool radius_proxy_config_delete()
uci_commit(rad_uci, &radsecproxy, false);
uci_unload(rad_uci, radsecproxy);
uci_free_context(rad_uci);
reload_config = 1;
return true;
}
@@ -410,7 +498,8 @@ void callback_Radius_Proxy_Config(ovsdb_update_monitor_t *self,
LOG(ERR, "Radius_Proxy_Config: unexpected mon_type %d %s",
self->mon_type, self->mon_uuid);
break;
}
}
set_config_apply_timeout(self);
return;
}

View File

@@ -24,10 +24,190 @@
#include "uci.h"
#include "utils.h"
#include "captive.h"
#include <fcntl.h>
#include "fixup.h"
ovsdb_table_t table_Wifi_RRM_Config;
extern ovsdb_table_t table_Wifi_Radio_Config;
extern ovsdb_table_t table_Wifi_VIF_Config;
#define PHY_NAME_LEN 32
bool rrm_config_txpower(const char *rname, unsigned int txpower)
{
char cmd[126] = {0};
int rid = 0;
txpower = txpower * 100;
sscanf(rname, "radio%d", &rid);
memset(cmd, 0, sizeof(cmd));
/* iw dev <devname> set txpower <auto|fixed|limit> [<tx power in mBm>]*/
snprintf(cmd, sizeof(cmd),
"iw phy phy%d set txpower fixed %d", rid, txpower);
system(cmd);
return true;
}
/* Mcast & Beacon rate set */
#define NUM_OF_RATES 12
enum {
ATH10K_DRIVER,
ATH11K_DRIVER,
ATH_DRIVER_MAX
};
typedef struct ath_rate_codes {
unsigned int rate;
unsigned long code[ATH_DRIVER_MAX];
} ath_rc;
char ath_driver_name[ATH_DRIVER_MAX][16] = {"ath10k", "ath11k"};
ath_rc ath_rcodes[NUM_OF_RATES] = {{1, {0x43, 0x10000103}},
{2, {0x42, 0x10000102}},
{5, {0x41, 0x10000101}},
{11, {0x40, 0x10000100}},
{6, {0x3, 0x10000003}},
{9, {0x7, 0x10000007}},
{12, {0x2, 0x10000002}},
{18, {0x6, 0x10000006}},
{24, {0x1, 0x10000001}},
{36, {0x5, 0x10000005}},
{48, {0x0, 0x10000000}},
{54, {0x4, 0x10000004}}};
/* get phy name */
bool get_80211phy(const char *ifname, char *phy)
{
char path[126] = {0};
int fd, l = 0;
snprintf(path, sizeof(path), "/sys/class/net/%s/phy80211/name", ifname);
fd = open(path, O_RDONLY);
if (fd < 0) {
LOGE("%s: Unable to read sysfs phy name", __func__);
close(fd);
return false;
}
read(fd, phy, PHY_NAME_LEN);
close(fd);
l = strlen(phy);
phy[l-1] = '\0';
return true;
}
bool set_rates_sysfs(const char *type, int rate_code, const char *ifname,
char *band, int dn)
{
int fd = 0;
char path[126] = {0};
char value[126] = {0};
char phy[PHY_NAME_LEN] = {0};
unsigned int band_id = 0;
/* get phy name */
if (!get_80211phy(ifname, phy))
return false;
if (!strcmp(band, "2.4G"))
band_id = 2;
else
band_id = 5;
snprintf(path, sizeof(path),
"/sys/kernel/debug/ieee80211/%s/%s/set_rates", phy,
ath_driver_name[dn]);
snprintf(value, sizeof(value), "%s %s %d 0x%x",
ifname, type, band_id, rate_code);
fd = open(path, O_WRONLY);
if (fd < 0) {
LOGE("%s: Unable to read sysfs set_rates", __func__);
close(fd);
return false;
}
write(fd, value, sizeof(value));
close(fd);
return true;
}
int find_ath_driver_name(const char *ifname)
{
int dn = -1;
char path[126] = {0};
char phy[PHY_NAME_LEN] = {0};
/* get phy name */
if (!get_80211phy(ifname, phy))
return -1;
for (dn = 0; dn < ATH_DRIVER_MAX; dn++) {
snprintf(path, sizeof(path),
"/sys/kernel/debug/ieee80211/%s/%s/set_rates", phy,
ath_driver_name[dn]);
if (access(path, F_OK) == 0) {
return dn;
}
}
return -1;
}
int rrm_config_mcast_bcast_rate(const char *ifname, char *band,
unsigned int bcn_rate, unsigned int mcast_rate)
{
int i = 0;
bool rc = 0;
unsigned int bcn_code = 0xFF;
unsigned int mcast_code = 0xFF;
int dn = 0;
/*Find ath driver version ath10/11k*/
dn = find_ath_driver_name(ifname);
if (dn < -1) {
LOG(ERR, "%s: No set_rate path exists", __func__);
return -1;
}
/* beacon rate given by cloud in multiples of 10 */
if (bcn_rate > 0)
bcn_rate = bcn_rate/10;
/* Get rate code of given rate */
for (i = 0; i < NUM_OF_RATES; i++)
{
if (ath_rcodes[i].rate == bcn_rate)
bcn_code = ath_rcodes[i].code[dn];
if (ath_rcodes[i].rate == mcast_rate)
mcast_code = ath_rcodes[i].code[dn];
}
/* Set the rates to sysfs */
if (bcn_code != 0xFF)
{
if (set_rates_sysfs("beacon", bcn_code, ifname, band, dn) == false)
rc = -1;
/*Ath11k sets mgmt and beacon rates separately*/
if (dn == ATH11K_DRIVER)
if (set_rates_sysfs("mgmt", bcn_code, ifname, band, dn) == false)
rc = -1;
}
if (mcast_code != 0xFF)
{
if (set_rates_sysfs("mcast", mcast_code, ifname, band, dn) == false)
rc = -1;
}
return rc;
}
void rrm_config_vif(struct blob_buf *b, struct blob_buf *del, const char * freq_band, const char * if_name)
{
@@ -80,6 +260,103 @@ int rrm_get_backup_channel(const char * freq_band)
}
void rrm_noreload_config(struct schema_Wifi_RRM_Config *conf, const char *wlanif)
{
char pval[16];
int rc = 0;
if (conf->probe_resp_threshold_changed) {
/* rssi_ignore_probe_request and signal_connect should
* both be probe_resp_threshold */
snprintf(pval, sizeof(pval), "%d",
conf->probe_resp_threshold);
rc = ubus_set_hapd_param(wlanif,
"rssi_ignore_probe_request", pval);
if (rc < 0)
LOG(ERR, "RRM: Set rssi_ignore_probe_req failed");
rc = ubus_set_signal_thresholds(wlanif,
conf->probe_resp_threshold,
conf->client_disconnect_threshold);
if (rc < 0)
LOG(ERR, "RRM: Set probe_resp_threshold failed");
}
if (conf->client_disconnect_threshold_changed) {
rc = ubus_set_signal_thresholds(wlanif,
conf->probe_resp_threshold,
conf->client_disconnect_threshold);
if (rc < 0)
LOG(ERR, "RRM: Set client_disconnect_thres failed");
}
if (conf->mcast_rate_changed) {
rc = rrm_config_mcast_bcast_rate(wlanif, conf->freq_band, 0,
conf->mcast_rate);
if (rc < 0)
LOG(ERR, "RRM: Set mcast rate failed");
}
if (conf->beacon_rate_changed) {
rrm_config_mcast_bcast_rate(wlanif, conf->freq_band,
conf->beacon_rate, 0);
if (rc < 0)
LOG(ERR, "RRM: Set beacon rate failed");
}
}
void get_channel_bandwidth(const char* htmode, int *channel_bandwidth)
{
if(!strcmp(htmode, "HT20"))
*channel_bandwidth=20;
else if (!strcmp(htmode, "HT40"))
*channel_bandwidth=40;
else if(!strcmp(htmode, "HT80"))
*channel_bandwidth=80;
}
void rrm_radio_rebalance_channel(const struct schema_Wifi_Radio_Config *rconf)
{
int channel_bandwidth;
int sec_chan_offset=0;
struct mode_map *m = NULL;
int freq = 0;
char *mode = NULL;
int rid = 0;
char wlanif[16] = {0};
char *hw_mode;
sscanf(rconf->if_name, "radio%d", &rid);
snprintf(wlanif, sizeof(wlanif), "wlan%d", rid);
freq = ieee80211_channel_to_frequency(rconf->channel);
mode = get_max_channel_bw_channel(freq, rconf->ht_mode);
hw_mode = radio_fixup_get_hw_mode(rconf->if_name);
if (hw_mode == NULL) {
LOGE("Failed to get hw mode");
return;
}
m = mode_map_get_uci(rconf->freq_band, mode, hw_mode);
if (m)
sec_chan_offset = m->sec_channel_offset;
else
LOGE("failed to get channel offset");
get_channel_bandwidth(mode, &channel_bandwidth);
ubus_set_channel_switch(wlanif, freq, hw_mode,
channel_bandwidth, sec_chan_offset, 1);
}
static bool rrm_config_update( struct schema_Wifi_RRM_Config *conf, bool addNotDelete)
{
struct schema_Wifi_Radio_Config rconf;
@@ -89,12 +366,40 @@ static bool rrm_config_update( struct schema_Wifi_RRM_Config *conf, bool addNotD
int i;
if (false == ovsdb_table_select_one(&table_Wifi_Radio_Config,
SCHEMA_COLUMN(Wifi_Radio_Config, freq_band), conf->freq_band, &rconf))
SCHEMA_COLUMN(Wifi_Radio_Config, freq_band),
conf->freq_band, &rconf))
{
LOG(WARN, "Wifi_RRM_Config: No radio for band %s", conf->freq_band );
LOG(WARN, "Wifi_RRM_Config: No radio for band %s",
conf->freq_band );
return false;
}
/* Set RRM configurations which do not require a wifi vifs reload
* and return */
if (conf->mcast_rate_changed || conf->beacon_rate_changed ||
conf->probe_resp_threshold_changed ||
conf->client_disconnect_threshold_changed) {
LOGI("RRM Config: beacon_rate:%s mcast_rate:%s probe_resp_threshold:%s client_disconnect_threshold_changed:%s",
(conf->beacon_rate_changed)? "changed":"unchanged",
(conf->mcast_rate_changed)? "changed":"unchanged",
(conf->probe_resp_threshold_changed)? "changed":"unchanged",
(conf->client_disconnect_threshold_changed)? "changed":"unchanged");
for (i = 0; i < rconf.vif_configs_len; i++) {
if (!(where = ovsdb_where_uuid("_uuid",
rconf.vif_configs[i].uuid)))
continue;
memset(&vconf, 0, sizeof(vconf));
if (ovsdb_table_select_one_where(&table_Wifi_VIF_Config,
where, &vconf))
{
rrm_noreload_config(conf, vconf.if_name);
}
}
}
/*Reload the vifs to configure the RRM configurations*/
memset(&changed, 0, sizeof(changed));
for (i = 0; i < rconf.vif_configs_len; i++) {
if (!(where = ovsdb_where_uuid("_uuid", rconf.vif_configs[i].uuid)))
@@ -178,7 +483,7 @@ void callback_Wifi_RRM_Config(ovsdb_update_monitor_t *self,
default:
LOG(ERR, "Wifi_RRM_Config: unexpected mon_type %d %s", self->mon_type, self->mon_uuid);
break;
}
}
return;
}

View File

@@ -242,9 +242,9 @@ bool target_stats_survey_get(radio_entry_t *radio_cfg, uint32_t *chan_list,
while (!ds_dlist_is_empty(&raw_survey_list)) {
survey = ds_dlist_head(&raw_survey_list);
ds_dlist_remove(&raw_survey_list, survey);
LOGD("Survey entry dur %d busy %d tx %d rx %d chan %d active %d type %d",
LOGD("Survey entry dur %llu busy %llu tx %llu rx %llu rx_self %llu chan %d type %d",
survey->duration_ms, survey->chan_busy, survey->chan_tx, survey->chan_rx,
survey->info.chan, survey->chan_active, scan_type );
survey->chan_self, survey->info.chan, scan_type);
if ((scan_type == RADIO_SCAN_TYPE_ONCHAN) && (survey->duration_ms != 0)) {
if (survey->info.chan == chan_list[0]) {
ds_dlist_insert_tail(survey_list, survey);
@@ -267,25 +267,57 @@ bool target_stats_survey_get(radio_entry_t *radio_cfg, uint32_t *chan_list,
}
#define PERCENT(v1, v2) (v2 > 0 ? ((v1 > v2) ? 100 : (v1*100/v2)) : 0)
#define DELTA(n, p) ((n) < (p) ? (n) : (n) - (p))
bool target_stats_survey_convert(radio_entry_t *radio_cfg, radio_scan_type_t scan_type,
target_survey_record_t *data_new, target_survey_record_t *data_old,
dpp_survey_record_t *survey_record)
{
LOGD("Survey convert scan_type %d chan %d", scan_type, data_new->info.chan);
target_survey_record_t delta;
if (data_new->info.chan != data_old->info.chan) {
/* Do not consider the old channel's data */
memset(data_old, 0, sizeof(*data_old));
} else if ((data_new->duration_ms <= data_old->duration_ms) &&
(data_new->chan_busy <= data_old->chan_busy)) {
/*
* Take care of survey data from CHAN_INFO events which are Read-On-Clear
* in nature, whereas survey data from BSS_CHAN_INFO events are Read only.
* Chan_info event down in the driver updates only the duration, noise floor
* and the chan_busy data.
*/
data_new->duration_ms += data_old->duration_ms;
data_new->chan_busy += data_old->chan_busy;
}
LOGD("Survey convert scan_type %d chan %d duration_new:%llu duration_old:%llu "
"busy_new %llu busy_old:%llu tx_new %llu tx_old:%llu rx_new %llu rx_old:%llu "
"rx_self_new %llu rx_self_old:%llu",
scan_type, data_new->info.chan, data_new->duration_ms, data_old->duration_ms,
data_new->chan_busy, data_old->chan_busy, data_new->chan_tx, data_old->chan_tx,
data_new->chan_rx, data_old->chan_rx, data_new->chan_self, data_old->chan_self);
memset(&delta, 0, sizeof(delta));
delta.duration_ms = DELTA(data_new->duration_ms, data_old->duration_ms);
delta.chan_busy = DELTA(data_new->chan_busy, data_old->chan_busy);
delta.chan_busy_ext = DELTA(data_new->chan_busy_ext, data_old->chan_busy_ext);
delta.chan_tx = DELTA(data_new->chan_tx, data_old->chan_tx);
delta.chan_rx = DELTA(data_new->chan_rx, data_old->chan_rx);
delta.chan_self = DELTA(data_new->chan_self, data_old->chan_self);
survey_record->info.chan = data_new->info.chan;
survey_record->chan_tx = PERCENT(data_new->chan_tx, data_new->duration_ms);
survey_record->chan_self = PERCENT(data_new->chan_self, data_new->duration_ms);
survey_record->chan_rx = PERCENT(data_new->chan_rx, data_new->duration_ms);
survey_record->chan_busy_ext = PERCENT(data_new->chan_busy_ext, data_new->duration_ms);
survey_record->chan_busy = PERCENT(data_new->chan_busy, data_new->duration_ms);
survey_record->chan_tx = PERCENT(delta.chan_tx, delta.duration_ms);
survey_record->chan_self = PERCENT(delta.chan_self, delta.duration_ms);
survey_record->chan_rx = PERCENT(delta.chan_rx, delta.duration_ms);
survey_record->chan_busy_ext = PERCENT(delta.chan_busy_ext, delta.duration_ms);
survey_record->chan_busy = PERCENT(delta.chan_busy, delta.duration_ms);
survey_record->chan_noise = data_new->chan_noise;
survey_record->duration_ms = data_new->duration_ms;
survey_record->duration_ms = delta.duration_ms;
return true;
}
/******************************************************************************
* NEIGHBORS definitions
*****************************************************************************/
@@ -350,12 +382,12 @@ bool target_stats_device_temp_get(radio_entry_t *radio_cfg, dpp_device_temp_t *t
char hwmon_path[PATH_MAX];
int32_t temperature;
FILE *fp = NULL;
bool DegreesNotMilliDegrees;
if (phy_find_hwmon(target_map_ifname(radio_cfg->phy_name), hwmon_path)) {
if (phy_find_hwmon(target_map_ifname(radio_cfg->phy_name), hwmon_path, &DegreesNotMilliDegrees)) {
LOG(ERR, "%s: hwmon is missing", radio_cfg->phy_name);
return false;
}
fp = fopen(hwmon_path, "r");
if (!fp) {
LOG(ERR, "%s: Failed to open temp input files", radio_cfg->phy_name);
@@ -372,7 +404,10 @@ bool target_stats_device_temp_get(radio_entry_t *radio_cfg, dpp_device_temp_t *t
fclose(fp);
temp_entry->type = radio_cfg->type;
temp_entry->value = temperature / 1000;
if(DegreesNotMilliDegrees)
temp_entry->value = temperature;
else
temp_entry->value = temperature / 1000;
return true;
}

View File

@@ -13,7 +13,6 @@
#include <sys/types.h>
#include <linux/sockios.h>
#include <linux/nl80211.h>
#include <netlink/msg.h>
#include <netlink/attr.h>
@@ -30,6 +29,7 @@
#include <libubox/vlist.h>
#include <unl.h>
#include "nl80211_cpy.h"
#include "target.h"
#include "nl80211.h"
#include "phy.h"
@@ -38,9 +38,12 @@
extern struct ev_loop *wifihal_evloop;
static int nl80211_scan_started;
static struct unl unl;
static struct unl unl_req;
static struct unl unl_notify;
static ev_io unl_io;
#define NF_OFFSET_24G 14
#define NF_OFFSET_5G 10
struct nl80211_scan {
char name[IF_NAMESIZE];
target_scan_cb_t *scan_cb;
@@ -191,6 +194,19 @@ static int nl80211_assoclist_recv(struct nl_msg *msg, void *arg)
return NL_OK;
}
static int add_chan_noise_offset(unsigned int chan, int chan_noise)
{
int adjusted_chan_noise = 0;
if (chan > 13) {
adjusted_chan_noise = chan_noise + NF_OFFSET_5G;
} else {
adjusted_chan_noise = chan_noise + NF_OFFSET_24G;
}
return adjusted_chan_noise;
}
static int nl80211_survey_recv(struct nl_msg *msg, void *arg)
{
static struct nla_policy sp[NL80211_SURVEY_INFO_MAX + 1] = {
@@ -202,6 +218,7 @@ static int nl80211_survey_recv(struct nl_msg *msg, void *arg)
[NL80211_SURVEY_INFO_TIME_EXT_BUSY] = { .type = NLA_U64 },
[NL80211_SURVEY_INFO_TIME_SCAN] = { .type = NLA_U64 },
[NL80211_SURVEY_INFO_NOISE] = { .type = NLA_U8 },
[NL80211_SURVEY_INFO_TIME_BSS_RX] = { .type = NLA_U64 },
};
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
@@ -230,7 +247,7 @@ static int nl80211_survey_recv(struct nl_msg *msg, void *arg)
nla_get_u32(si[NL80211_SURVEY_INFO_FREQUENCY]));
if (si[NL80211_SURVEY_INFO_TIME_RX])
survey_record->chan_self = nla_get_u64(si[NL80211_SURVEY_INFO_TIME_RX]);
survey_record->chan_self = nla_get_u64(si[NL80211_SURVEY_INFO_TIME_BSS_RX]);
if (si[NL80211_SURVEY_INFO_TIME_TX])
survey_record->chan_tx = nla_get_u64(si[NL80211_SURVEY_INFO_TIME_TX]);
@@ -248,7 +265,8 @@ static int nl80211_survey_recv(struct nl_msg *msg, void *arg)
survey_record->duration_ms = nla_get_u64(si[NL80211_SURVEY_INFO_TIME]);
if (si[NL80211_SURVEY_INFO_NOISE])
survey_record->chan_noise = nla_get_u8(si[NL80211_SURVEY_INFO_NOISE]);
survey_record->chan_noise = add_chan_noise_offset(survey_record->info.chan,
nla_get_u8(si[NL80211_SURVEY_INFO_NOISE]));
survey_record->chan_in_use=si[NL80211_SURVEY_INFO_IN_USE] ? 1:0;
@@ -345,7 +363,7 @@ static struct nl_msg *nl80211_call_phy(char *name, int cmd, bool dump)
if (idx < 0)
return NULL;
msg = unl_genl_msg(&unl, cmd, dump);
msg = unl_genl_msg(&unl_req, cmd, dump);
nla_put_u32(msg, NL80211_ATTR_WIPHY, idx);
return msg;
@@ -461,7 +479,7 @@ static void nl80211_ev(struct ev_loop *ev, struct ev_io *io, int event)
nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, NULL);
nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, no_seq_check, NULL);
nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, nl80211_recv, NULL);
nl_recvmsgs(unl.sock, cb);
nl_recvmsgs(unl_notify.sock, cb);
nl_cb_put(cb);
}
@@ -471,9 +489,9 @@ static struct nl_msg *nl80211_call_vif(struct nl_call_param *nl_call_param, int
struct nl_msg *msg;
if (!nl80211_scan_started) {
unl_genl_subscribe(&unl, "scan");
unl_genl_subscribe(&unl_notify, "scan");
ev_io_init(&unl_io, nl80211_ev, unl.sock->s_fd, EV_READ);
ev_io_init(&unl_io, nl80211_ev, unl_notify.sock->s_fd, EV_READ);
ev_io_start(wifihal_evloop, &unl_io);
nl80211_scan_started = 1;
}
@@ -481,7 +499,7 @@ static struct nl_msg *nl80211_call_vif(struct nl_call_param *nl_call_param, int
if (!idx)
return NULL;
msg = unl_genl_msg(&unl, cmd, dump);
msg = unl_genl_msg(&unl_req, cmd, dump);
nla_put_u32(msg, NL80211_ATTR_IFINDEX, idx);
return msg;
@@ -494,7 +512,7 @@ int nl80211_get_tx_chainmask(char *name, unsigned int *mask)
if (!msg)
return -1;
return unl_genl_request(&unl, msg, nl80211_chainmask_recv, mask);
return unl_genl_request(&unl_req, msg, nl80211_chainmask_recv, mask);
}
int nl80211_get_oper_channel(char *name, unsigned int *chan)
@@ -505,10 +523,10 @@ int nl80211_get_oper_channel(char *name, unsigned int *chan)
if (!idx)
return -1;
msg = unl_genl_msg(&unl, NL80211_CMD_GET_INTERFACE, true);
msg = unl_genl_msg(&unl_req, NL80211_CMD_GET_INTERFACE, true);
nla_put_u32(msg, NL80211_ATTR_IFINDEX, idx);
return unl_genl_request(&unl, msg, nl80211_channel_recv, chan);
return unl_genl_request(&unl_req, msg, nl80211_channel_recv, chan);
}
int nl80211_get_ssid(struct nl_call_param *nl_call_param)
@@ -518,7 +536,7 @@ int nl80211_get_ssid(struct nl_call_param *nl_call_param)
if (!msg)
return -1;
return unl_genl_request(&unl, msg, nl80211_interface_recv, nl_call_param);
return unl_genl_request(&unl_req, msg, nl80211_interface_recv, nl_call_param);
}
int nl80211_get_assoclist(struct nl_call_param *nl_call_param)
@@ -528,7 +546,7 @@ int nl80211_get_assoclist(struct nl_call_param *nl_call_param)
if (!msg)
return -1;
return unl_genl_request(&unl, msg, nl80211_assoclist_recv, nl_call_param);
return unl_genl_request(&unl_req, msg, nl80211_assoclist_recv, nl_call_param);
}
int nl80211_get_survey(struct nl_call_param *nl_call_param)
@@ -538,7 +556,7 @@ int nl80211_get_survey(struct nl_call_param *nl_call_param)
if (!msg)
return -1;
return unl_genl_request(&unl, msg, nl80211_survey_recv, nl_call_param);
return unl_genl_request(&unl_req, msg, nl80211_survey_recv, nl_call_param);
}
int nl80211_scan_trigger(struct nl_call_param *nl_call_param, uint32_t *chan_list, uint32_t chan_num,
@@ -549,20 +567,39 @@ int nl80211_scan_trigger(struct nl_call_param *nl_call_param, uint32_t *chan_lis
struct nlattr *freq;
unsigned int i, flags = 0;
int ret = 0;
uint32_t oper_chan;
if (!msg)
return -1;
LOGT("%s: not setting dwell time\n", nl_call_param->ifname);
//nla_put_u16(msg, NL80211_ATTR_MEASUREMENT_DURATION, dwell_time);
if (nl80211_get_oper_channel(nl_call_param->ifname, &oper_chan) < 0) {
/* Could not get the current operating channel */
oper_chan = 0;
LOGE("%s: Could not get the current operating channel\n",
nl_call_param->ifname);
}
/* Add the ap-force flag, otherwise the scan fails on wifi6 APs */
flags |= NL80211_SCAN_FLAG_AP;
nla_put(msg, NL80211_ATTR_SCAN_FLAGS, sizeof(uint32_t), &flags);
if ((scan_type == RADIO_SCAN_TYPE_OFFCHAN) && dwell_time)
nla_put_u16(msg, NL80211_ATTR_MEASUREMENT_DURATION, dwell_time);
freq = nla_nest_start(msg, NL80211_ATTR_SCAN_FREQUENCIES);
for (i = 0; i < chan_num; i ++)
nla_put_u32(msg, i, ieee80211_channel_to_frequency(chan_list[i]));
for (i = 0; i < chan_num; i ++) {
if (!oper_chan || (scan_type == RADIO_SCAN_TYPE_FULL)) {
nla_put_u32(msg, i, ieee80211_channel_to_frequency(chan_list[i]));
}
else if ((scan_type == RADIO_SCAN_TYPE_OFFCHAN) &&
(chan_list[i] != oper_chan)) {
nla_put_u32(msg, i, ieee80211_channel_to_frequency(chan_list[i]));
}
else if ((scan_type == RADIO_SCAN_TYPE_ONCHAN) &&
(chan_list[i] == oper_chan)) {
nla_put_u32(msg, i, ieee80211_channel_to_frequency(chan_list[i]));
}
}
nla_nest_end(msg, freq);
ret = nl80211_scan_add(nl_call_param->ifname, scan_cb, scan_ctx);
@@ -571,8 +608,10 @@ int nl80211_scan_trigger(struct nl_call_param *nl_call_param, uint32_t *chan_lis
return -1;
}
ret = unl_genl_request(&unl, msg, nl80211_scan_trigger_recv, NULL);
if (ret) LOG(DEBUG, "%s: scan request failed %d\n", nl_call_param->ifname, ret);
ret = unl_genl_request(&unl_req, msg, nl80211_scan_trigger_recv, NULL);
if (ret)
LOG(DEBUG, "%s: scan request failed %d\n", nl_call_param->ifname, ret);
return ret;
}
@@ -587,7 +626,7 @@ int nl80211_scan_abort(struct nl_call_param *nl_call_param)
if (nl80211_scan)
nl80211_scan_del(nl80211_scan);
return unl_genl_request(&unl, msg, nl80211_scan_abort_recv, NULL);
return unl_genl_request(&unl_req, msg, nl80211_scan_abort_recv, NULL);
}
int nl80211_scan_dump(struct nl_call_param *nl_call_param)
@@ -597,18 +636,26 @@ int nl80211_scan_dump(struct nl_call_param *nl_call_param)
if (!msg)
return -1;
return unl_genl_request(&unl, msg, nl80211_scan_dump_recv, nl_call_param);
return unl_genl_request(&unl_req, msg, nl80211_scan_dump_recv, nl_call_param);
}
int stats_nl80211_init(void)
{
if (unl_genl_init(&unl, "nl80211") < 0) {
if (unl_genl_init(&unl_req, "nl80211") < 0) {
LOGE("failed to spawn nl80211");
return -1;
}
if (nl_socket_set_buffer_size(unl.sock, 262144, 0) < 0)
if (unl_genl_init(&unl_notify, "nl80211") < 0) {
LOGE("failed to spawn nl80211");
return -1;
}
if (nl_socket_set_buffer_size(unl_notify.sock, 262144, 0) < 0)
LOGE("stats_nl80211: Failed to set nl socket buffer size");
if (nl_socket_set_nonblocking(unl_notify.sock))
LOGE("stats_nl80211: Failed to set stats nl socket in the non blocking mode");
return 0;
}

View File

@@ -0,0 +1,62 @@
/* SPDX-License-Identifier: BSD-3-Clause */
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
#include "log.h"
#include "evsched.h"
#include "timer.h"
static int tv_diff(struct timeval *t1, struct timeval *t2)
{
return
(t1->tv_sec - t2->tv_sec) * 1000 +
(t1->tv_usec - t2->tv_usec) / 1000;
}
static void gettime(struct timeval *tv)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
tv->tv_sec = ts.tv_sec;
tv->tv_usec = ts.tv_nsec / 1000;
}
int timeout_set(struct timeout *timeout, int msecs)
{
if (!timeout) {
LOGE("%s No timer data", __func__);
return -1;
}
struct timeval *time = &timeout->time;
if (timeout->pending)
timeout->pending = false;
gettime(time);
time->tv_sec += msecs / 1000;
time->tv_usec += (msecs % 1000) * 1000;
if (time->tv_usec > 1000000) {
time->tv_sec++;
time->tv_usec -= 1000000;
}
timeout->pending = true;
return 0;
}
void timer_expiry_check(struct timeout *t)
{
struct timeval tv;
gettime(&tv);
if (t->pending && tv_diff(&t->time, &tv) <= 0) {
t->pending = false;
LOGI("%s Timer Expired..Executing callback", __func__);
if (t->cb)
t->cb(t);
}
}

View File

@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause */
#include <string.h>
#include <math.h>
#include <glob.h>
#include <libgen.h>
#include <fcntl.h>
@@ -195,24 +196,36 @@ int phy_from_path(char *_path, char *phy, unsigned int idx)
return ret;
}
int phy_find_hwmon(char *phy, char *hwmon)
int phy_find_hwmon_helper(char *dir, char *file, char *hwmon)
{
char tmp[PATH_MAX];
glob_t gl;
*hwmon = '\0';
snprintf(tmp, sizeof(tmp), "/sys/class/ieee80211/%s/device/hwmon/*", phy);
if (glob(tmp, GLOB_NOSORT | GLOB_MARK, NULL, &gl))
return -1;
if (glob(dir, GLOB_NOSORT | GLOB_MARK, NULL, &gl))
return -1;
if (gl.gl_pathc) {
strcpy(hwmon, gl.gl_pathv[0]);
strncat(hwmon, "temp1_input", PATH_MAX);
strncat(hwmon, file, PATH_MAX);
}
globfree(&gl);
return 0;
}
int phy_find_hwmon(char *phy, char *hwmon, bool *DegreesNotMilliDegrees)
{
char tmp[PATH_MAX];
*hwmon = '\0';
snprintf(tmp, sizeof(tmp), "/sys/class/ieee80211/%s/device/hwmon/*", phy);
if (!phy_find_hwmon_helper(tmp, "temp1_input", hwmon)) {
*DegreesNotMilliDegrees=false;
return 0;
}
snprintf(tmp, sizeof(tmp), "/sys/class/ieee80211/%s/cooling_device/subsystem/thermal_zone0/", phy);
if (!phy_find_hwmon_helper(tmp, "temp", hwmon)) {
*DegreesNotMilliDegrees=true;
return 0;
}
return -1;
}
int phy_get_mac(char *phy, char *mac)
{
int sz = ETH_ALEN * 3;
@@ -296,6 +309,21 @@ int phy_get_channels(const char *name, int *channel)
return j;
}
// Gets all the dfs channels avaible for a radio
int phy_get_dfs_channels(const char *name, int *dfs_channels)
{
struct wifi_phy *phy = phy_find(name);
int i, j = 0;
if (!phy)
return 0;
for (i = 0; (i < IEEE80211_CHAN_MAX) && (j < 64); i++)
if (phy->chandfs[i])
dfs_channels[j++] = i;
return j;
}
static void update_channels_state(struct schema_Wifi_Radio_State *rstate,
int *index, const char *key, int *value, int value_len)
{
@@ -390,6 +418,22 @@ int phy_lookup(char *name)
return atoi(buf);
}
int phy_get_ath_driver_name(char *phy, char *ath_driver)
{
glob_t gl;
char path[128];
snprintf(path, sizeof(path),
"/sys/kernel/debug/ieee80211/%s/[ath]*", phy);
if (glob(path, GLOB_NOSORT | GLOB_MARK, NULL, &gl))
return -1;
if (gl.gl_pathc) {
memset(ath_driver, '\0', ATH_DRIVER_NAME_LEN);
strncpy(ath_driver, basename(gl.gl_pathv[0]), ATH_DRIVER_NAME_LEN - 1);
}
globfree(&gl);
return 0;
}
int vif_get_mac(char *vap, char *mac)
{
int sz = ETH_ALEN * 3;
@@ -484,6 +528,17 @@ bool vif_state_to_conf(struct schema_Wifi_VIF_State *vstate,
}
vconf->custom_options_len = vstate->custom_options_len;
for (i = 0; i < vstate->captive_allowlist_len; i++)
STRSCPY(vconf->captive_allowlist[i], vstate->captive_allowlist[i]);
vconf->captive_allowlist_len = vstate->captive_allowlist_len;
for (i = 0; i < vstate->captive_portal_len; i++) {
STRSCPY(vconf->captive_portal_keys[i],
vstate->captive_portal_keys[i]);
STRSCPY(vconf->captive_portal[i], vstate->captive_portal[i]);
}
vconf->captive_portal_len = vstate->captive_portal_len;
return true;
#undef VIF_COPY
@@ -681,3 +736,14 @@ bool vif_get_key_for_key_distr(const char *secret, char *key_str)
fclose(fp);
return err;
}
double dBm_to_mwatts(double dBm)
{
return (pow(10,(dBm/10)));
}
double mWatts_to_dBm(double mW)
{
return (10*log10(mW));
}

View File

@@ -26,6 +26,7 @@
#include "ovsdb_table.h"
#include "ovsdb_sync.h"
#include "rrm_config.h"
#include "fixup.h"
#define MODULE_ID LOG_MODULE_ID_VIF
#define UCI_BUFFER_SIZE 80
@@ -136,6 +137,7 @@ enum {
WIF_ATTR_RADPROXY,
WIF_ATTR_PROXY_ARP,
WIF_ATTR_MCAST_TO_UCAST,
WIF_ATTR_AUTH_CACHE,
__WIF_ATTR_MAX,
};
@@ -233,6 +235,7 @@ static const struct blobmsg_policy wifi_iface_policy[__WIF_ATTR_MAX] = {
[WIF_ATTR_RADPROXY] = { .name = "radproxy", BLOBMSG_TYPE_STRING },
[WIF_ATTR_PROXY_ARP] = { .name = "proxy_arp", BLOBMSG_TYPE_BOOL },
[WIF_ATTR_MCAST_TO_UCAST] = { .name = "multicast_to_unicast", BLOBMSG_TYPE_BOOL },
[WIF_ATTR_AUTH_CACHE] = { .name = "auth_cache", BLOBMSG_TYPE_BOOL },
};
const struct uci_blob_param_list wifi_iface_param = {
@@ -322,10 +325,10 @@ static struct vif_crypto {
{ "sae-mixed", OVSDB_SECURITY_ENCRYPTION_WPA_SAE, OVSDB_SECURITY_MODE_MIXED, 0 },
{ "wpa3-only", OVSDB_SECURITY_ENCRYPTION_WPA3_EAP, OVSDB_SECURITY_MODE_WPA3, 1 },
{ "wpa3-mixed", OVSDB_SECURITY_ENCRYPTION_WPA3_EAP, OVSDB_SECURITY_MODE_MIXED, 1 },
{ "wpa3", OVSDB_SECURITY_ENCRYPTION_WPA3_EAP_192, OVSDB_SECURITY_MODE_WPA3, 1 },
};
extern ovsdb_table_t table_APC_State;
extern json_t* ovsdb_table_where(ovsdb_table_t *table, void *record);
extern unsigned int radproxy_apc;
/* Custom options table */
@@ -388,7 +391,8 @@ static int vif_config_security_set(struct blob_buf *b,
const char *mode = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_MODE);
unsigned int i;
unsigned int acct_interval;
const char *auth_server, *auth_port, *auth_secret, *security_key, *acct_server;
const char *auth_server, *auth_port, *auth_secret, *security_key;
const char *acct_server, *acct_port, *acct_secret;
char key_str[64], key_holder_str[128];
struct schema_APC_State apc_conf;
const char *local_server = "127.0.0.1";
@@ -410,14 +414,14 @@ static int vif_config_security_set(struct blob_buf *b,
if (vif_crypto[i].enterprise) {
if (vif_config_custom_opt_get_proxy(vconf)) {
if (vif_config_custom_opt_get_proxy(vconf)) { /* Radius Proxy Enabled */
LOGN("%s: Apply Proxy Security Settings", vconf->if_name);
json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf);
if (false == ovsdb_table_select_one_where(&table_APC_State,
where, &apc_conf)) {
LOG(INFO, "APC_State read failed");
if(apc_read_state(&apc_conf) == false)
{
LOGI("APC_State read failed");
return -1;
}
if (!strncmp(apc_conf.mode, "DR", 2)) {
auth_server = local_server;
acct_server = local_server;
@@ -430,16 +434,22 @@ static int vif_config_security_set(struct blob_buf *b,
auth_server = local_server;
acct_server = local_server;
}
auth_port = "1812";
auth_secret = "secret";
acct_port = "1813";
acct_secret = "secret";
}
else
else /* Radius Proxy Disabled */
{
auth_server = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_IP);
acct_server = SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_IP);
auth_port = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_PORT);
auth_secret = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_SECRET);
acct_port = SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_PORT);
acct_secret = SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_SECRET);
}
acct_interval = 0;
auth_port = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_PORT);
auth_secret = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_RADIUS_SECRET);
LOGT("%s: Server IP %s port %s secret %s", vconf->if_name, auth_server, auth_port, auth_secret);
if (!auth_server[0] || !auth_port[0] || !auth_secret[0]) {
@@ -451,10 +461,8 @@ static int vif_config_security_set(struct blob_buf *b,
blobmsg_add_string(b, "auth_port", auth_port );
blobmsg_add_string(b, "auth_secret", auth_secret );
blobmsg_add_string(b, "acct_server", acct_server);
blobmsg_add_string(b, "acct_port",
SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_PORT));
blobmsg_add_string(b, "acct_secret",
SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_SECRET));
blobmsg_add_string(b, "acct_port", acct_port);
blobmsg_add_string(b, "acct_secret", acct_secret);
blobmsg_add_bool(b, "request_cui", 1);
acct_interval = atoi(SCHEMA_KEY_VAL(vconf->security, OVSDB_SECURITY_RADIUS_ACCT_INTERVAL));
@@ -482,6 +490,7 @@ static int vif_config_security_set(struct blob_buf *b,
strcat(key_holder_str, key_str);
blobmsg_add_string(b, "r1kh", key_holder_str);
}
blobmsg_add_bool(b, "auth_cache", 1);
} else {
security_key = SCHEMA_KEY_VAL(vconf->security, SCHEMA_CONSTS_SECURITY_KEY);
if (security_key == NULL) {
@@ -1029,7 +1038,8 @@ void vif_section_del(char *section_name)
ret= uci_load(sec_ctx, "wireless", &wireless);
if (ret) {
LOGE("%s: %s uci_load() failed with rc %d", section_name, __func__, ret);
uci_free_context(sec_ctx);
if (sec_ctx)
uci_free_context(sec_ctx);
return;
}
uci_foreach_element_safe(&wireless->sections, tmp, e) {
@@ -1044,8 +1054,8 @@ void vif_section_del(char *section_name)
}
uci_commit(sec_ctx, &wireless, false);
uci_unload(sec_ctx, wireless);
uci_free_context(sec_ctx);
reload_config = 1;
if (sec_ctx)
uci_free_context(sec_ctx);
}
void vif_check_radius_proxy()
@@ -1054,8 +1064,7 @@ void vif_check_radius_proxy()
int n = 0;
void *buf = NULL;
json_t *where = ovsdb_table_where(&table_APC_State, &apc_conf);
if (false == ovsdb_table_select_one_where(&table_APC_State, where, &apc_conf))
if(apc_read_state(&apc_conf) == false)
{
LOGI("APC_State read failed");
return;
@@ -1316,12 +1325,14 @@ bool target_vif_config_del(const struct schema_Wifi_VIF_Config *vconf)
const char *ifname;
int ret = 0;
vif_fixup_del((char *)vconf->if_name);
vlan_del((char *)vconf->if_name);
vif_ctx = uci_alloc_context();
ret= uci_load(vif_ctx, "wireless", &wireless);
if (ret) {
LOGE("%s: %s uci_load() failed with rc %d", vconf->if_name, __func__, ret);
uci_free_context(vif_ctx);
if (vif_ctx)
uci_free_context(vif_ctx);
return false;
}
uci_foreach_element_safe(&wireless->sections, tmp, e) {
@@ -1330,15 +1341,19 @@ bool target_vif_config_del(const struct schema_Wifi_VIF_Config *vconf)
if (strcmp(s->type, "wifi-iface")) continue;
ifname = uci_lookup_option_string( vif_ctx, s, "ifname" );
if (!strcmp(ifname,vconf->if_name)) {
if (ifname == NULL) {
/* Delete this section because it doesn't have an ifname - it is invalid */
uci_section_del(vif_ctx, "vif", "wireless", (char *)s->e.name, "wifi-iface");
} else if (!strcmp(ifname,vconf->if_name)) {
/* Delete this section because it matches the if_name we are trying to delete */
uci_section_del(vif_ctx, "vif", "wireless", (char *)s->e.name, "wifi-iface");
break;
}
}
uci_commit(vif_ctx, &wireless, false);
uci_unload(vif_ctx, wireless);
uci_free_context(vif_ctx);
reload_config = 1;
if (vif_ctx)
uci_free_context(vif_ctx);
return true;
}
@@ -1393,7 +1408,7 @@ void vif_hs20_osu_update(struct schema_Hotspot20_OSU_Providers *osuconf)
blob_to_uci_section(uci, "wireless", osuconf->osu_provider_name, "osu-provider",
osu.head, &wifi_hs20_osu_param, NULL);
reload_config = 1;
uci_commit_all(uci);
}
@@ -1424,7 +1439,7 @@ void vif_hs20_icon_update(struct schema_Hotspot20_Icon_Config *iconconf)
blob_to_uci_section(uci, "wireless", iconconf->icon_config_name, "hs20-icon",
hs20.head, &wifi_hs20_icon_param, NULL);
reload_config = 1;
uci_commit_all(uci);
}
}
@@ -1447,9 +1462,9 @@ void vif_hs20_update(struct schema_Hotspot20_Config *hs2conf)
hs20_vif_config(&b, hs2conf);
blob_to_uci_section(uci, "wireless", vconf.if_name, "wifi-iface",
b.head, &wifi_iface_param, NULL);
reload_config = 1;
}
}
uci_commit_all(uci);
}
/* Mesh options table */
@@ -1517,8 +1532,7 @@ static int mesh_vif_config_set(const struct schema_Wifi_Radio_Config *rconf,
blobmsg_add_string(&mesh, "master", "bat0");
blob_to_uci_section(uci, "network", vconf->if_name, "interface",
mesh.head, &wifi_mesh_param, NULL);
reload_config = 1;
uci_commit_all(uci);
return 0;
}
@@ -1637,8 +1651,7 @@ static int ap_vif_config_set(const struct schema_Wifi_Radio_Config *rconf,
{
vif_dhcp_opennds_allowlist_set(vconf,(char*)vconf->if_name);
}
reload_config = 1;
uci_commit_all(uci);
return 0;
}

View File

@@ -75,7 +75,6 @@ const struct uci_blob_param_list network_param = {
.params = network_policy,
};
int reload_config = 0;
ovsdb_table_t table_Wifi_Inet_Config;
struct blob_buf b = { };
struct blob_buf del = { };
@@ -342,7 +341,6 @@ static int wifi_inet_conf_add(struct schema_Wifi_Inet_Config *iconf)
}
uci_commit_all(uci);
reload_config = 1;
return 0;
}
@@ -361,7 +359,6 @@ static void wifi_inet_conf_del(struct schema_Wifi_Inet_Config *iconf)
uci_section_del(uci, "network", "network", iconf->if_name, "interface");
uci_commit_all(uci);
reload_config = 1;
}
static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon,
@@ -370,10 +367,24 @@ static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon,
{
switch (mon->mon_type) {
case OVSDB_UPDATE_NEW:
if (iconf->parent_ifname_exists && iconf->vlan_id > 2) {
if(!strncmp(iconf->parent_ifname, "lan", strlen("lan"))) {
/* Skip adding VLAN interface for lan */
return;
}
}
wifi_inet_conf_add(iconf);
netifd_add_inet_conf(iconf);
break;
case OVSDB_UPDATE_MODIFY:
if (iconf->parent_ifname_exists && iconf->vlan_id > 2) {
if(!strncmp(iconf->parent_ifname, "lan", strlen("lan"))) {
/* Skip adding VLAN interface for lan */
return;
}
}
wifi_inet_conf_add(iconf);
netifd_modify_inet_conf(iconf);
break;
@@ -388,17 +399,6 @@ static void callback_Wifi_Inet_Config(ovsdb_update_monitor_t *mon,
return;
}
static void periodic_task(void *arg)
{
if (reload_config) {
uci_commit_all(uci);
system("reload_config");
reload_config = 0;
}
evsched_task_reschedule_ms(EVSCHED_SEC(5));
}
void wifi_inet_config_init(void)
{
struct uci_element *e = NULL;
@@ -418,7 +418,6 @@ void wifi_inet_config_init(void)
}
uci_unload(uci, network);
OVSDB_TABLE_MONITOR(Wifi_Inet_Config, false);
evsched_task(&periodic_task, NULL, EVSCHED_SEC(5));
return;
}

View File

@@ -48,6 +48,12 @@ typedef struct
ds_tree_node_t node;
} rrm_vif_state_t;
#define RRM_CHANNEL_INTERVAL 15
#define RRM_MAX_NF_SAMPLES 100
#define RRM_OBSS_HOP_MODE_NON_WIFI 1
#define RRM_OBSS_HOP_MODE_NON_WIFI_AND_OBSS 2
typedef struct
{
// Cached data
@@ -59,9 +65,17 @@ typedef struct
uint32_t min_load;
uint32_t beacon_rate;
uint32_t mcast_rate;
int32_t noise_floor_thresh;
uint32_t noise_floor_time;
int32_t non_wifi_thresh;
uint32_t non_wifi_time;
uint32_t obss_hop_mode;
// Internal state data
int32_t noise_lwm;
int32_t avg_nf;
int32_t rrm_chan_nf_next_el;
int32_t rrm_chan_nf_num_el;
double rrm_chan_nf_samples[RRM_MAX_NF_SAMPLES];
} rrm_entry_t;
typedef struct
@@ -75,10 +89,12 @@ int rrm_setup_monitor(void);
void rrm_channel_init(void);
int rrm_ubus_init(struct ev_loop *loop);
int ubus_get_noise(const char *if_name, uint32_t *noise);
int ubus_set_channel_switch(const char *if_name, uint32_t frequency, int channel_bandwidth, int sec_chan_offset);
int ubus_set_channel_switch(const char *if_name, uint32_t frequency, const char *hw_mode, int channel_bandwidth, int sec_chan_offset, int reason);
void set_rrm_parameters(rrm_entry_t *rrm_data);
ds_tree_t* rrm_get_rrm_config_list(void);
ds_tree_t* rrm_get_radio_list(void);
ds_tree_t* rrm_get_vif_list(void);
void rrm_reset_noise_floor_samples(rrm_entry_t *rrm_data);
void rrm_radio_rebalance_channel(const struct schema_Wifi_Radio_Config *rconf);
#endif /* RRM_H_INCLUDED */

View File

@@ -9,8 +9,6 @@
#include "uci.h"
#include "utils.h"
#define RRM_CHANNEL_INTERVAL 15.0
struct blob_buf b = { };
struct blob_buf del = { };
struct uci_context *uci;
@@ -103,6 +101,57 @@ void get_channel_bandwidth(const char* htmode, int *channel_bandwidth)
else if(!strcmp(htmode, "HT80"))
*channel_bandwidth=80;
}
/*
* A simple average is calculated against the Noise floor samples.
* - Returns a zero, if there are not enough samples in the list.
* - Or, returns a calculated avg of the noise samples.
* - A circular buffer is considered for storing the samples. New elements replace the
* old ones in this buffer.
* - The number of samples required is an integer value calculated based on the
* configuration time and the sample time.
* Example: If the config_time is 120 sec, and sample time is 15 sec, then number of
* samples required for averaging is 120/15 = 8 samples.
*/
int rrm_calculate_avg_noise_floor(rrm_entry_t *rrm_data, int nf, int config_time, int sample_time)
{
int ii;
double avg_mW = 0;
int num_samples = config_time/sample_time;
if (num_samples >= RRM_MAX_NF_SAMPLES)
num_samples = RRM_MAX_NF_SAMPLES;
/*
* Convert dBm to milliWatts,
* and replace the oldest element in the list with the new element
*/
rrm_data->rrm_chan_nf_samples[rrm_data->rrm_chan_nf_next_el] = dBm_to_mwatts(nf);
/* Update the index to the oldest element index taking care of the boundary */
rrm_data->rrm_chan_nf_next_el = (rrm_data->rrm_chan_nf_next_el+1)%num_samples;
if (rrm_data->rrm_chan_nf_num_el < num_samples)
{
rrm_data->rrm_chan_nf_num_el++;
return 0;
}
/* calculate average */
for (ii = 0; ii < num_samples; ii++)
{
avg_mW += rrm_data->rrm_chan_nf_samples[ii];
}
avg_mW = avg_mW/num_samples;
/* convert the averaged milliWats back to dBm */
return ((int)(mWatts_to_dBm(avg_mW)));
}
void rrm_reset_noise_floor_samples(rrm_entry_t *rrm_data)
{
rrm_data->rrm_chan_nf_next_el = 0;
rrm_data->rrm_chan_nf_num_el = 0;
}
void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents)
{
@@ -113,7 +162,6 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents)
rrm_radio_state_t *radio = NULL;
uint32_t noise;
int32_t nf;
int32_t nf_drop_threshold;
rrm_config_t *rrm_config;
ds_tree_t *radio_list = rrm_get_radio_list();
@@ -122,14 +170,13 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents)
{
noise = 0;
rrm_config = NULL;
nf_drop_threshold = 0;
if (ubus_get_noise(radio->config.if_name, &noise))
continue;
nf = (int32_t)noise;
if (nf > -1 || nf < -120)
if ((nf > -10) || (nf < -120))
continue;
rrm_config = rrm_get_rrm_config(radio->config.type);
@@ -137,43 +184,39 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents)
if (rrm_config == NULL)
continue;
if (nf < rrm_config->rrm_data.noise_lwm )
{
rrm_config->rrm_data.noise_lwm = nf;
LOGD("[%s] noise_lwm set to %d", radio->config.if_name, nf);
continue;
}
if (rrm_config->rrm_data.snr_percentage_drop == 0)
if ((rrm_config->rrm_data.backup_channel == 0) ||
(rrm_config->rrm_data.backup_channel == radio->config.chan))
continue;
if (rrm_config->rrm_data.backup_channel == 0)
if (rrm_config->rrm_data.noise_floor_thresh == 0)
continue;
nf_drop_threshold = ((int32_t)(100 - rrm_config->rrm_data.snr_percentage_drop) *
rrm_config->rrm_data.noise_lwm) / 100;
if (rrm_config->rrm_data.noise_floor_time == 0)
continue;
LOGD("[%s] backup=%d nf=%d nf_lwm=%d drop=%d thresh=%d",
LOGD("[%s] backup=%d nf=%d nf_thresh=%d",
radio->config.if_name,
rrm_config->rrm_data.backup_channel,
nf,
rrm_config->rrm_data.noise_lwm,
rrm_config->rrm_data.snr_percentage_drop,
nf_drop_threshold);
rrm_config->rrm_data.noise_floor_thresh);
if (nf > nf_drop_threshold)
rrm_config->rrm_data.avg_nf = rrm_calculate_avg_noise_floor(&(rrm_config->rrm_data),
nf, rrm_config->rrm_data.noise_floor_time, RRM_CHANNEL_INTERVAL);
if (rrm_config->rrm_data.avg_nf &&
(rrm_config->rrm_data.avg_nf > rrm_config->rrm_data.noise_floor_thresh))
{
LOGI("Interference detected on [%s], switching to backup_channel=%d nf=%d nf_lwm=%d drop=%d thresh=%d",
LOGI("Interference detected on [%s],"
" switching to backup_channel=%d avg_nf=%d nfthresh=%d",
radio->config.if_name,
rrm_config->rrm_data.backup_channel,
nf,
rrm_config->rrm_data.noise_lwm,
rrm_config->rrm_data.snr_percentage_drop,
nf_drop_threshold);
rrm_config->rrm_data.avg_nf,
rrm_config->rrm_data.noise_floor_thresh);
int channel_bandwidth;
int sec_chan_offset=0;
struct mode_map *m = mode_map_get_uci(radio->schema.freq_band, get_max_channel_bw_channel(ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel),
radio->schema.ht_mode), radio->schema.hw_mode);
struct mode_map *m = mode_map_get_uci(radio->schema.freq_band,
get_max_channel_bw_channel(ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel),
radio->schema.ht_mode), radio->schema.hw_mode);
if (m) {
sec_chan_offset = m->sec_channel_offset;
} else
@@ -182,7 +225,9 @@ void rrm_nf_timer_handler(struct ev_loop *loop, ev_timer *timer, int revents)
get_channel_bandwidth(get_max_channel_bw_channel(ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel),
radio->schema.ht_mode), &channel_bandwidth);
ubus_set_channel_switch(radio->config.if_name,
ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel), channel_bandwidth, sec_chan_offset);
ieee80211_channel_to_frequency(rrm_config->rrm_data.backup_channel), radio->schema.hw_mode, channel_bandwidth, sec_chan_offset, 0);
rrm_reset_noise_floor_samples(&(rrm_config->rrm_data));
}
}
}

View File

@@ -124,6 +124,21 @@ void rrm_config_update(void)
rrm_data.min_load = rrm->schema.min_load;
rrm_data.beacon_rate = rrm->schema.beacon_rate;
rrm_data.mcast_rate = rrm->schema.mcast_rate;
rrm_data.noise_floor_thresh = rrm->schema.noise_floor_thresh;
rrm_data.noise_floor_time = rrm->schema.noise_floor_time;
if (rrm_data.noise_floor_time/RRM_CHANNEL_INTERVAL > RRM_MAX_NF_SAMPLES)
{
LOG(WARN, "RRM Config: Noise floor time too high."
" nf_time:%d, sampling_interval:%d, max_num_samples:%d",
rrm_data.noise_floor_time, RRM_CHANNEL_INTERVAL,
RRM_MAX_NF_SAMPLES);
}
rrm_data.non_wifi_thresh = rrm->schema.non_wifi_thresh;
rrm_data.non_wifi_time = rrm->schema.non_wifi_time;
rrm_data.obss_hop_mode = rrm->schema.obss_hop_mode;
rrm_data.avg_nf = 0;
rrm_reset_noise_floor_samples(&rrm_data);
/* Update cache config */
rrm->rrm_data = rrm_data;
@@ -408,13 +423,7 @@ void rrm_update_rrm_config_cb(ovsdb_update_monitor_t *self)
return;
}
/* Reset configuration */
rrm_config->schema.backup_channel = 0;
rrm_config->schema.min_load = 0;
rrm_config->schema.beacon_rate = 0;
rrm_config->schema.mcast_rate = 0;
rrm_config->schema.snr_percentage_drop = 0;
rrm_config->schema.client_disconnect_threshold = 0;
rrm_config->schema.probe_resp_threshold = 0;
memset(&(rrm_config->schema), 0, sizeof(rrm_config->schema));
ds_tree_remove(&rrm_config_list, rrm_config);
free(rrm_config);

View File

@@ -51,7 +51,9 @@ int ubus_get_noise(const char *if_name, uint32_t *noise)
}
int ubus_set_channel_switch(const char *if_name, uint32_t frequency, int channel_bandwidth, int sec_chan_offset)
int ubus_set_channel_switch(const char *if_name, uint32_t frequency,
const char *hw_mode, int channel_bandwidth,
int sec_chan_offset, int reason)
{
uint32_t id;
static struct blob_buf b;
@@ -63,19 +65,32 @@ int ubus_set_channel_switch(const char *if_name, uint32_t frequency, int channel
return -1;
blob_buf_init(&b, 0);
if (channel_bandwidth == 20 || channel_bandwidth == 40) {
blobmsg_add_bool(&b, "ht", 1);
} else if (channel_bandwidth == 80) {
blobmsg_add_bool(&b, "vht", 1);
if (!strncmp(hw_mode, "11n", strlen("11n"))) {
blobmsg_add_u8(&b, "ht", 1);
} else if (!strncmp(hw_mode, "11ac", strlen("11ac"))) {
blobmsg_add_u8(&b, "ht", 1);
blobmsg_add_u8(&b, "vht", 1);
} else if (!strncmp(hw_mode, "11ax", strlen("11ax"))) {
blobmsg_add_u8(&b, "ht", 1);
blobmsg_add_u8(&b, "vht", 1);
blobmsg_add_u8(&b, "he", 1);
}
if (channel_bandwidth == 40 || channel_bandwidth == 80) {
if (channel_bandwidth == 40)
blobmsg_add_u32(&b, "center_freq1", frequency+10);
else if (channel_bandwidth == 80)
blobmsg_add_u32(&b, "center_freq1", frequency+30);
}
else if (channel_bandwidth == 20)
blobmsg_add_u32(&b, "center_freq1", frequency);
else if (channel_bandwidth == 160)
blobmsg_add_u32(&b, "center_freq1", frequency+70);
blobmsg_add_u32(&b, "freq", frequency);
blobmsg_add_u32(&b, "bcn_count", 5);
blobmsg_add_u32(&b, "bandwidth", channel_bandwidth);
blobmsg_add_u32(&b, "sec_channel_offset", sec_chan_offset);
blobmsg_add_u32(&b, "reason", reason);
return ubus_invoke(ubus, id, "switch_chan", b.head, NULL, NULL, 1000);
}

View File

@@ -6,18 +6,16 @@
/* Global list of events received from hostapd */
dpp_event_report_data_t g_event_report;
/* Internal list of processed events ready to be deleted from hostapd */
static ds_dlist_t deletion_pending_list;
static ds_dlist_t bss_list;
static struct ubus_context *ubus = NULL;
typedef struct {
uint64_t session_id;
char bss[UBUS_OBJ_LEN];
ds_dlist_node_t node;
} delete_entry_t;
static void ubus_garbage_collector(void *arg);
static const struct blobmsg_policy ubus_collector_chan_switch_event_policy[__CHANNEL_SWITCH_EVENT_MAX] = {
[CHAN_SWITCH_EVENT] = {.name = "chan_switch_event", .type = BLOBMSG_TYPE_TABLE},
};
@@ -166,6 +164,7 @@ static int client_first_data_event_cb(struct blob_attr *msg,
if (tb_client_first_data_event[CLIENT_FIRST_DATA_STA_MAC]) {
mac_address = blobmsg_get_string(tb_client_first_data_event[CLIENT_FIRST_DATA_STA_MAC]);
memcpy(dpp_session->first_data_event->sta_mac, mac_address, MAC_ADDRESS_STRING_LEN);
LOG(DEBUG, "ubus: Received FDATA event session_id:%llu client mac:%s", event_session_id, mac_address);
}
if (tb_client_first_data_event[CLIENT_FIRST_DATA_TIMESTAMP])
@@ -209,6 +208,7 @@ static int client_disconnect_event_cb(struct blob_attr *msg,
if (tb_client_disconnect_event[CLIENT_DISCONNECT_STA_MAC]) {
mac_address = blobmsg_get_string(tb_client_disconnect_event[CLIENT_DISCONNECT_STA_MAC]);
memcpy(dpp_session->disconnect_event->sta_mac, mac_address, MAC_ADDRESS_STRING_LEN);
LOG(DEBUG, "ubus: Received DISCONNECT event with session_id:%llu client mac:%s", event_session_id, mac_address);
}
if (tb_client_disconnect_event[CLIENT_DISCONNECT_BAND])
@@ -258,6 +258,7 @@ static int client_auth_event_cb(struct blob_attr *msg,
if (tb_client_auth_event[CLIENT_AUTH_STA_MAC]) {
mac_address = blobmsg_get_string(tb_client_auth_event[CLIENT_AUTH_STA_MAC]);
memcpy(dpp_session->auth_event->sta_mac, mac_address, MAC_ADDRESS_STRING_LEN);
LOG(DEBUG, "ubus: Received AUTH event with session_id:%llu client mac:%s", event_session_id, mac_address);
}
if (tb_client_auth_event[CLIENT_AUTH_BAND])
@@ -304,6 +305,7 @@ static int client_assoc_event_cb(struct blob_attr *msg,
if (tb_client_assoc_event[CLIENT_ASSOC_STA_MAC]) {
mac_address = blobmsg_get_string(tb_client_assoc_event[CLIENT_ASSOC_STA_MAC]);
memcpy(dpp_session->assoc_event->sta_mac, mac_address, MAC_ADDRESS_STRING_LEN);
LOG(DEBUG, "ubus: Received ASSOC event with session_id:%llu client mac:%s", event_session_id, mac_address);
}
if (tb_client_assoc_event[CLIENT_ASSOC_SSID]) {
@@ -365,6 +367,7 @@ static int client_ip_event_cb(struct blob_attr *msg,
if (tb_client_ip_event[CLIENT_IP_STA_MAC]) {
mac_address = blobmsg_get_string(tb_client_ip_event[CLIENT_IP_STA_MAC]);
memcpy(dpp_session->ip_event->sta_mac, mac_address, MAC_ADDRESS_STRING_LEN);
LOG(DEBUG, "ubus: Received IP event with session_id:%llu client mac:%s", event_session_id, mac_address);
}
if (tb_client_ip_event[CLIENT_IP_IP_ADDRESS]) {
@@ -390,11 +393,23 @@ static int (*client_event_handler_list[__CLIENT_EVENTS_MAX - 1])(
static void ubus_collector_complete_session_cb(struct ubus_request *req, int ret)
{
LOG(DEBUG, "ubus_collector_complete_session_cb");
if (req)
free(req);
}
static void session_delete(uint64_t session_id, char *ifname)
{
delete_entry_t *delete_entry = NULL;
delete_entry = calloc(1, sizeof(delete_entry_t));
if (delete_entry) {
memset(delete_entry, 0, sizeof(delete_entry_t));
delete_entry->session_id = session_id;
strncpy(delete_entry->bss, ifname, UBUS_OBJ_LEN);
evsched_task(&ubus_garbage_collector, delete_entry,
EVSCHED_SEC(SESSION_DELETE_TIMEOUT));
}
}
static void ubus_collector_session_cb(struct ubus_request *req, int type,
struct blob_attr *msg)
{
@@ -405,9 +420,9 @@ static void ubus_collector_session_cb(struct ubus_request *req, int type,
struct blob_attr *tb_client_events[__CLIENT_EVENTS_MAX] = {};
dpp_event_record_t *event_record = NULL;
uint64_t session_id = 0;
delete_entry_t *delete_entry = NULL;
int i = 0;
(void)type;
bool is_session_empty = true;
char *ifname = (char *)req->priv;
@@ -447,13 +462,18 @@ static void ubus_collector_session_cb(struct ubus_request *req, int type,
continue;
}
event_record = dpp_event_record_alloc();
session_id = blobmsg_get_u64(tb_client_events[CLIENT_SESSION_ID]);
if (!session_id) {
LOG(DEBUG, "ubus_collector: Invalid sessionId");
continue;
}
event_record = dpp_event_record_alloc();
if (!event_record) {
LOG(ERR, "ubus_collector: not enough memory for event_record");
continue;
}
session_id = blobmsg_get_u64(tb_client_events[CLIENT_SESSION_ID]);
event_record->client_session.session_id = session_id;
for (i = 0; i < __CLIENT_EVENTS_MAX - 1; i++) {
@@ -465,21 +485,19 @@ static void ubus_collector_session_cb(struct ubus_request *req, int type,
client_event_handler_list[i](
tb_client_events[i], &event_record->client_session,
session_id);
}
is_session_empty = false;
}
event_record->hasSMProcessed = false;
ds_dlist_insert_tail(&g_event_report.client_event_list, event_record);
event_record = NULL;
}
if (is_session_empty) {
dpp_event_record_free(event_record);
} else {
event_record->hasSMProcessed = false;
ds_dlist_insert_tail(&g_event_report.client_event_list, event_record);
event_record = NULL;
}
/* Schedule session for deletion */
delete_entry = calloc(1, sizeof(delete_entry_t));
if (delete_entry) {
memset(delete_entry, 0, sizeof(delete_entry_t));
delete_entry->session_id = session_id;
strncpy(delete_entry->bss, ifname, UBUS_OBJ_LEN);
ds_dlist_insert_tail(&deletion_pending_list, delete_entry);
delete_entry = NULL;
}
session_delete(session_id, ifname);
}
}
@@ -519,7 +537,6 @@ static void ubus_collector_hostapd_invoke(void *object_path)
static void ubus_collector_complete_bss_cb(struct ubus_request *req, int ret)
{
LOG(DEBUG, "ubus_collector_complete_bss_cb");
if (req)
free(req);
}
@@ -615,8 +632,6 @@ static void ubus_collector_chan_switch_events_cb(struct ubus_request *req, int t
if (!msg)
return;
LOG(DEBUG, "ubus_collector: received ubus collector chan event message");
error = blobmsg_parse(ubus_collector_chan_switch_event_policy,
__CHANNEL_SWITCH_EVENT_MAX, tb_chan_event_lst,
blobmsg_data(msg), blobmsg_data_len(msg));
@@ -658,7 +673,6 @@ static void ubus_collector_chan_switch_events_cb(struct ubus_request *req, int t
static void ubus_collector_complete_channel_switch_cb(struct ubus_request *req, int ret)
{
LOG(DEBUG, "ubus_collector_complete_channel_switch_cb");
if (req)
free(req);
}
@@ -678,8 +692,6 @@ static void ubus_collector_hostapd_channel_switch_invoke(void *arg)
return;
}
LOG(DEBUG, "ubus_collector: requesting hostapd channel switch data");
ubus_invoke_async(ubus, ubus_object_id, hostapd_method, NULL, req);
req->data_cb = (ubus_data_handler_t)ubus_collector_chan_switch_events_cb;
@@ -746,27 +758,12 @@ static void ubus_collector_hostapd_clear(uint64_t session_id, char *object_path)
static void ubus_garbage_collector(void *arg)
{
delete_entry_t *delete_entry = NULL;
delete_entry_t *delete_session = (delete_entry_t *)arg;
if (ds_dlist_is_empty(&deletion_pending_list)) {
evsched_task_reschedule();
return;
if (delete_session) {
ubus_collector_hostapd_clear(delete_session->session_id, delete_session->bss);
free(delete_session);
}
/* Remove a single session from the deletion list */
delete_entry = ds_dlist_head(&deletion_pending_list);
if (delete_entry) {
if (delete_entry->session_id) {
ubus_collector_hostapd_clear(delete_entry->session_id,
delete_entry->bss);
}
ds_dlist_remove_head(&deletion_pending_list);
free(delete_entry);
delete_entry = NULL;
}
evsched_task_reschedule();
}
int ubus_collector_init(void)
@@ -782,7 +779,6 @@ int ubus_collector_init(void)
/* Initialize the global events, session deletion and bss object lists */
ds_dlist_init(&g_event_report.client_event_list, dpp_event_record_t, node);
ds_dlist_init(&g_event_report.channel_switch_list, dpp_event_channel_switch_t, node);
ds_dlist_init(&deletion_pending_list, delete_entry_t, node);
ds_dlist_init(&bss_list, bss_obj_t, node);
/* Schedule an event: invoke hostapd ubus get bss list method */
@@ -803,15 +799,6 @@ int ubus_collector_init(void)
return -1;
}
/* Schedule an event: clear the hostapd sessions from opensync */
sched_status = evsched_task(&ubus_garbage_collector, NULL,
EVSCHED_SEC(UBUS_GARBAGE_COLLECTION_DELAY));
if (sched_status < 1) {
LOG(ERR, "ubus_collector: failed at task creation, status %d",
sched_status);
return -1;
}
/* Schedule an event: invoke hostapd ubus channel switch method */
sched_status = evsched_task(&ubus_collector_hostapd_channel_switch_invoke, NULL,
EVSCHED_SEC(UBUS_CHANNEL_SWITCH_POLLING_DELAY));

View File

@@ -31,8 +31,8 @@ void ubus_collector_cleanup(void);
/* Poll sessions after this many seconds */
#define UBUS_SESSIONS_POLLING_DELAY 9
/* Poll the session clearing 'garbage collector' after this many seconds */
#define UBUS_GARBAGE_COLLECTION_DELAY 1
/* Delete session after this many seconds of receiving any first event of the session */
#define SESSION_DELETE_TIMEOUT 30
#define UBUS_OBJ_LEN 64

View File

@@ -44,14 +44,14 @@ typedef struct
typedef struct
{
DPP_TARGET_SURVEY_RECORD_COMMON_STRUCT;
uint32_t chan_active;
uint32_t chan_busy;
uint32_t chan_busy_ext;
uint32_t chan_self;
uint32_t chan_rx;
uint32_t chan_tx;
uint64_t chan_active;
uint64_t chan_busy;
uint64_t chan_busy_ext;
uint64_t chan_self;
uint64_t chan_rx;
uint64_t chan_tx;
uint32_t chan_noise;
uint32_t duration_ms;
uint64_t duration_ms;
uint32_t chan_in_use;
} target_survey_record_t;

View File

@@ -72,7 +72,9 @@ static bool update_version_matrix(struct schema_AWLAN_Node *awlan)
{
FILE *fp = NULL;
char *line = NULL;
char *key, *val, *str = NULL;
char *sep = NULL;
char key[128] = {'\0'};
char val[128] = {'\0'};
size_t len;
int rd = 0;
char inactive_fw[128] = "";
@@ -87,15 +89,15 @@ static bool update_version_matrix(struct schema_AWLAN_Node *awlan)
line[rd - 1] = '\0';
else continue;
str = strdup(line);
key = strtok(str, ":");
val = strtok(NULL, ":");
/* Separate Key and Val */
sep = strchr(line, ':');
if (!sep)
continue;
*sep = '\0';
strncpy(key, line, sizeof(key) - 1);
strncpy(val, sep + 1, sizeof(key) - 1);
if (val == NULL) {
SCHEMA_KEY_VAL_SET(awlan->version_matrix, key, "");
} else {
SCHEMA_KEY_VAL_SET(awlan->version_matrix, key, val);
}
SCHEMA_KEY_VAL_SET(awlan->version_matrix, key, val);
}
/* Update the inactive firmware version */
@@ -104,8 +106,6 @@ static bool update_version_matrix(struct schema_AWLAN_Node *awlan)
if (line != NULL)
free(line);
if (str != NULL)
free(str);
fclose(fp);
return true;
}

View File

@@ -1,7 +1,7 @@
#!/bin/sh
[ "$ACTION" = ifup -o "$ACTION" = ifupdate ] || exit 0
[ "$INTERFACE" = wan ] || exit 0
[ "$INTERFACE" = wan ] || [ "$INTERFACE" = lan ] || exit 0
conflict=0
wan_ipaddr="$(ubus call network.interface.wan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')"

View File

@@ -86,7 +86,9 @@ linksys,ea8300)
MODEL_DESCR=$(cat /dev/mtd9 | grep modelDescription | cut -d "=" -f2 | tr -d '\r\n')
MANUF_URL=$(cat /dev/mtd9 | grep manufacturerURL | cut -d "=" -f2 | tr -d '\r\n')
CERT_REGION=$(cat /dev/mtd9 | grep cert_region | cut -d "=" -f2 | tr -d '\r\n')
ID=$(cat /dev/mtd9 | grep hw_mac_addr | cut -d "=" -f2 | tr -d '\r\n')
# Commenting out below, because hw_mac_addr is used for eth0/LAN interface
# whereas ID corresponds to the mac address of WAN interface.
#ID=$(cat /dev/mtd9 | grep hw_mac_addr | cut -d "=" -f2 | tr -d '\r\n')
MANUF_NAME=$(cat /dev/mtd9 | grep "manufacturer=" | cut -d "=" -f2 | tr -d '\r\n')
if [ ! $MANUF_NAME ]; then
MANUF_NAME="Linksys"
@@ -99,23 +101,56 @@ linksys,ea8300)
DAY=$(echo "$MANUF_DATE" | cut -d "/" -f3)
MANUF_DATE="$DAY-$MONTH-$YEAR"
;;
tp-link,ec420-g1)
tp-link,ec420-g1|\
tplink,ex227|\
tplink,ex447)
PLATFORM=$(cat /tmp/sysinfo/model)
SERIAL=$(cat /dev/mtd9 | grep serial_number | cut -d "=" -f2)
MODEL=$(cat /dev/mtd9 | grep "model=" | cut -d "=" -f2)
SKU=$(cat /dev/mtd9 | grep sku | cut -d "=" -f2)
CERT_REGION=$(cat /dev/mtd9 | grep certification_region | cut -d "=" -f2)
ID=$(cat /dev/mtd9 | grep mac_address | cut -d "=" -f2)
MANUF_DATE=$(cat /dev/mtd9 | grep manufacturer_date | cut -d "=" -f2)
MANUF_NAME=$(cat /dev/mtd9 | grep manufacturer_name | cut -d "=" -f2)
if [ ! $MANUF_NAME ]; then
MANUF_NAME="Proware (TP-Link)"
fi
MANUF_ABBR="PW"
MANUF_URL=$(cat /dev/mtd9 | grep manufacturer_url | cut -d "=" -f2)
MODEL_DESCR=$(cat /dev/mtd9 | grep model_description | cut -d "=" -f2)
MODEL_REV=$(cat /dev/mtd9 | grep model_revision | cut -d "=" -f2)
REF_DESIGN=$(cat /dev/mtd9 | grep reference_design | cut -d "=" -f2)
# tp-link device manufacturing data and certs are stored in product_info partition
tip_part=$(find_mtd_part "product_info" 2> /dev/null)
mkdir -p /tmp/.tip
if mount -t squashfs $tip_part /tmp/.tip &> /dev/null; then
SERIAL=$(cat /tmp/.tip/serial_number)
MODEL=$(cat /tmp/.tip/model)
SKU=$(cat /tmp/.tip/sku)
CERT_REGION=$(cat /tmp/.tip/certification_region)
ID=$(cat /tmp/.tip/mac_address)
MANUF_DATE=$(cat /tmp/.tip/manufacturer_date)
MANUF_NAME=$(cat /tmp/.tip/manufacturer_name)
MANUF_URL=$(cat /tmp/.tip/manufacturer_url)
MODEL_DESCR=$(cat /tmp/.tip/model_description)
MODEL_REV=$(cat /tmp/.tip/model_revision)
REF_DESIGN=$(cat /tmp/.tip/reference_design)
if [ -f /tmp/.tip/certs/ca.pem ] && [ -f /tmp/.tip/certs/client.pem ] && [ -f /tmp/.tip/certs/client_dec.key ]; then
# If certs are default certs, and they will be replaced by manufacturing certs.
if cmp /usr/opensync/certs/ca.pem /rom/usr/opensync/certs/ca.pem &> /dev/null || \
cmp /usr/opensync/certs/client.pem /rom/usr/opensync/certs/client.pem &> /dev/null || \
cmp /usr/opensync/certs/client_dec.key /rom/usr/opensync/certs/client_dec.key &> /dev/null; then
cp /tmp/.tip/certs/* /usr/opensync/certs/
fi
fi
umount -l /tmp/.tip &> /dev/null
# for EC420-G1 DVT sample
elif [ $(board_name) = "tp-link,ec420-g1" ]; then
SERIAL=$(cat /dev/mtd9 | grep serial_number | cut -d "=" -f2)
MODEL=$(cat /dev/mtd9 | grep "model=" | cut -d "=" -f2)
SKU=$(cat /dev/mtd9 | grep sku | cut -d "=" -f2)
CERT_REGION=$(cat /dev/mtd9 | grep certification_region | cut -d "=" -f2)
ID=$(cat /dev/mtd9 | grep mac_address | cut -d "=" -f2)
MANUF_DATE=$(cat /dev/mtd9 | grep manufacturer_date | cut -d "=" -f2)
MANUF_NAME=$(cat /dev/mtd9 | grep manufacturer_name | cut -d "=" -f2)
if [ ! $MANUF_NAME ]; then
MANUF_NAME="Proware (TP-Link)"
fi
MANUF_URL=$(cat /dev/mtd9 | grep manufacturer_url | cut -d "=" -f2)
MODEL_DESCR=$(cat /dev/mtd9 | grep model_description | cut -d "=" -f2)
MODEL_REV=$(cat /dev/mtd9 | grep model_revision | cut -d "=" -f2)
REF_DESIGN=$(cat /dev/mtd9 | grep reference_design | cut -d "=" -f2)
else
MODEL=$(cat /tmp/sysinfo/board_name)
SERIAL=$(cat /sys/class/net/eth0/address | tr -d :)
fi
;;
*)
MODEL=$(cat /tmp/sysinfo/board_name)
@@ -133,12 +168,16 @@ fi
# fallback check to get the id from mac address if flash does not contain this info.
if [ ! $ID ]; then
ID=$(cat /sys/class/net/eth0/address)
if [ $(board_name) == "cig,wf194c" ] || [ $(board_name) == "edgecore,eap102" ] || [ $(board_name) == "linksys,ea8300" ]; then
ID=$(cat /sys/class/net/eth1/address)
else
ID=$(cat /sys/class/net/eth0/address)
fi
fi
# fallback check to get the model if flash does not contain this info.
if [ ! $MODEL ]; then
MODEL=$(cat /tmp/sysinfo/board_name)
MODEL=$(cat /tmp/sysinfo/board_name | cut -d "," -f2 | awk '{print toupper($0)}')
fi
# Read the active firmware version info

View File

@@ -6,4 +6,15 @@ uci set network.wan.metric=1
uci set network.lan.metric=10
uci set network.wan.vlan_filtering=1
uci set network.lan.vlan_filtering=1
# Add LAN ssh rule
uci set firewall.lan_ssh_rule=rule
uci set firewall.lan_ssh_rule.src='lan'
uci set firewall.lan_ssh_rule.target='ACCEPT'
uci set firewall.lan_ssh_rule.proto='tcp'
uci set firewall.lan_ssh_rule.dest_port='22'
uci set firewall.lan_ssh_rule.name="Lan SSH Rule"
uci commit firewall
/etc/init.d/firewall restart
exit 0

View File

@@ -1,7 +1,7 @@
From f2dd3e3677ed1fed6ce328ce4976609b049bb64b Mon Sep 17 00:00:00 2001
From e4903ad3c873fef824f44fa7fb3696e03a778c3f Mon Sep 17 00:00:00 2001
From: John Crispin <john@phrozen.org>
Date: Sat, 18 Jul 2020 08:53:44 +0200
Subject: [PATCH 01/15] ipq807x: add the Qualcomm AX target support
Subject: [PATCH 01/33] ipq807x: add the Qualcomm AX target support
Signed-off-by: John Crispin <john@phrozen.org>
---
@@ -152,7 +152,7 @@ index 0000000000..6c429f1852
+exit 0
diff --git a/target/linux/ipq807x/Makefile b/target/linux/ipq807x/Makefile
new file mode 100644
index 0000000000..90df1f8a9a
index 0000000000..66031ace35
--- /dev/null
+++ b/target/linux/ipq807x/Makefile
@@ -0,0 +1,22 @@
@@ -175,7 +175,7 @@ index 0000000000..90df1f8a9a
+ kmod-usb-phy-ipq807x kmod-usb-dwc3-of-simple \
+ kmod-ath11k-ahb kmod-qrtr_mproc wpad \
+ kmod-gpio-button-hotplug \
+ qca-thermald-10.4 qca-ssdk-shell
+ qca-thermald-10.4 qca-ssdk-shell kmod-qca-nss-drv-bridge-mgr
+
+$(eval $(call BuildTarget))
diff --git a/target/linux/ipq807x/base-files/etc/board.d/01_leds b/target/linux/ipq807x/base-files/etc/board.d/01_leds
@@ -4903,7 +4903,7 @@ index 0000000000..9a5538aee3
+}
diff --git a/target/linux/ipq807x/config-4.4 b/target/linux/ipq807x/config-4.4
new file mode 100644
index 0000000000..858d7e1aee
index 0000000000..b187a643c1
--- /dev/null
+++ b/target/linux/ipq807x/config-4.4
@@ -0,0 +1,821 @@
@@ -8850,7 +8850,7 @@ index 0000000000..5744a2a5bf
+ struct comp_opts {
diff --git a/target/linux/ipq807x/patches/102-cig-wf188.patch b/target/linux/ipq807x/patches/102-cig-wf188.patch
new file mode 100644
index 0000000000..225ea45d08
index 0000000000..1ca355389d
--- /dev/null
+++ b/target/linux/ipq807x/patches/102-cig-wf188.patch
@@ -0,0 +1,869 @@
@@ -9169,8 +9169,8 @@ index 0000000000..225ea45d08
++ pinctrl-names = "default";
++
++ wps {
++ label = "wps";
++ linux,code = <KEY_WPS_BUTTON>;
++ label = "reset";
++ linux,code = <KEY_RESTART>;
++ gpios = <&tlmm 22 GPIO_ACTIVE_LOW>;
++ linux,input-type = <1>;
++ debounce-interval = <60>;
@@ -9597,8 +9597,8 @@ index 0000000000..225ea45d08
++ pinctrl-names = "default";
++
++ wps {
++ label = "wps";
++ linux,code = <KEY_WPS_BUTTON>;
++ label = "reset";
++ linux,code = <KEY_RESTART>;
++ gpios = <&tlmm 22 GPIO_ACTIVE_LOW>;
++ linux,input-type = <1>;
++ debounce-interval = <60>;
@@ -10547,7 +10547,7 @@ index 0000000000..c6d12fe963
++
diff --git a/target/linux/ipq807x/patches/104-wf194c.patch b/target/linux/ipq807x/patches/104-wf194c.patch
new file mode 100644
index 0000000000..7e7f172688
index 0000000000..05b1b18b6c
--- /dev/null
+++ b/target/linux/ipq807x/patches/104-wf194c.patch
@@ -0,0 +1,816 @@
@@ -10841,8 +10841,8 @@ index 0000000000..7e7f172688
++ pinctrl-names = "default";
++
++ button@1 {
++ label = "wps";
++ linux,code = <KEY_WPS_BUTTON>;
++ label = "reset";
++ linux,code = <KEY_RESTART>;
++ gpios = <&tlmm 67 GPIO_ACTIVE_LOW>;
++ linux,input-type = <1>;
++ debounce-interval = <60>;
@@ -11386,7 +11386,7 @@ index 0000000000..f91601ec59
+ /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
diff --git a/target/linux/ipq807x/patches/106-eap101.patch b/target/linux/ipq807x/patches/106-eap101.patch
new file mode 100644
index 0000000000..6b0eb2f831
index 0000000000..784fc5371e
--- /dev/null
+++ b/target/linux/ipq807x/patches/106-eap101.patch
@@ -0,0 +1,975 @@

View File

@@ -0,0 +1,232 @@
From 49bf9d17f0b3f7ebb4f9f562f10853e3fd067b7a Mon Sep 17 00:00:00 2001
From: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
Date: Wed, 30 Jun 2021 12:46:26 -0400
Subject: [PATCH] WiFi6 Aps LEDs Label name change
This patch fixes leds incorrect state issue and also chanage the label
names of leds
Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
---
.../ipq807x/base-files/etc/board.d/01_leds | 13 +-
.../111-WiFi6-Aps-LEDs-Label-Change.patch | 183 ++++++++++++++++++
2 files changed, 193 insertions(+), 3 deletions(-)
create mode 100644 target/linux/ipq807x/patches/111-WiFi6-Aps-LEDs-Label-Change.patch
diff --git a/target/linux/ipq807x/base-files/etc/board.d/01_leds b/target/linux/ipq807x/base-files/etc/board.d/01_leds
index 1402a74f3e..bca3ae8daa 100755
--- a/target/linux/ipq807x/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq807x/base-files/etc/board.d/01_leds
@@ -15,10 +15,17 @@ cig,wf194c)
ucidef_set_led_netdev "wan" "WAN" "wf194c:green:wan" "br-wan" "tx rx link"
ucidef_set_led_netdev "lan" "LAN" "wf194c:green:lan" "br-lan" "tx rx link"
;;
-edgecore,eap101 |\
+edgecore,eap101)
+ ucidef_set_led_wlan "wifi5g" "WIFI5G" "eap101:green:wifi5g" "phy0tx"
+ ucidef_set_led_wlan "wifi2g" "WIFI2G" "eap101:green:wifi2g" "phy1tx"
+ ;;
edgecore,eap102)
- ucidef_set_led_wlan "wlan5g" "WLAN5G" "green:wifi5" "phy0tx"
- ucidef_set_led_wlan "wlan2g" "WLAN2G" "green:wifi2" "phy1tx"
+ ucidef_set_led_wlan "wifi5g" "WIFI5G" "eap102:green:wifi5g" "phy0tx"
+ ucidef_set_led_wlan "wifi2g" "WIFI2G" "eap102:green:wifi2g" "phy1tx"
+ ;;
+cig,wf188n)
+ ucidef_set_led_wlan "wifi5g" "WIFI5G" "wf188:green:wifi5g" "phy0tx"
+ ucidef_set_led_wlan "wifi2g" "WIFI2G" "wf188:green:wifi2g" "phy1tx"
;;
esac
diff --git a/target/linux/ipq807x/patches/111-WiFi6-Aps-LEDs-Label-Change.patch b/target/linux/ipq807x/patches/111-WiFi6-Aps-LEDs-Label-Change.patch
new file mode 100644
index 0000000000..06533425a9
--- /dev/null
+++ b/target/linux/ipq807x/patches/111-WiFi6-Aps-LEDs-Label-Change.patch
@@ -0,0 +1,183 @@
+Index: linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq6018-cig-wf188.dts
+===================================================================
+--- linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce.orig/arch/arm64/boot/dts/qcom/qcom-ipq6018-cig-wf188.dts
++++ linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq6018-cig-wf188.dts
+@@ -309,28 +309,28 @@
+ pinctrl-names = "default";
+
+ led@25 {
+- label = "led_5g";
++ label = "wf188:green:wifi5g";
+ gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>;
+- linux,default-trigger = "wf188:green:5g";
++ linux,default-trigger = "wf188:green:wifi5g";
+ default-state = "off";
+ };
+ led@24 {
+- label = "led_2g";
++ label = "wf188:green:wifi2g";
+ gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>;
+- linux,default-trigger = "wf188:green:2g";
++ linux,default-trigger = "wf188:green:wifi2g";
+ default-state = "off";
+ };
+ led@18 {
+- label = "led_eth";
++ label = "wf188:green:eth";
+ gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "wf188:green:eth";
+- default-state = "off";
++ default-state = "on";
+ };
+ led_power: led@16 {
+- label = "led_pwr";
++ label = "wf188:green:power";
+ gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "wf188:green:power";
+- default-state = "off";
++ default-state = "on";
+ };
+ };
+
+Index: linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq6018-cig-wf188n.dts
+===================================================================
+--- linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce.orig/arch/arm64/boot/dts/qcom/qcom-ipq6018-cig-wf188n.dts
++++ linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq6018-cig-wf188n.dts
+@@ -309,28 +309,28 @@
+ pinctrl-names = "default";
+
+ led@25 {
+- label = "led_5g";
++ label = "wf188:green:wifi5g";
+ gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>;
+- linux,default-trigger = "wf188:green:5g";
++ linux,default-trigger = "wf188:green:wifi5g";
+ default-state = "off";
+ };
+ led@24 {
+- label = "led_2g";
++ label = "wf188:green:wifi2g";
+ gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>;
+- linux,default-trigger = "wf188:green:2g";
++ linux,default-trigger = "wf188:green:wifi2g";
+ default-state = "off";
+ };
+ led@18 {
+- label = "led_eth";
++ label = "wf188:green:eth";
+ gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "wf188:green:eth";
+- default-state = "off";
++ default-state = "on";
+ };
+ led_power: led@16 {
+- label = "led_pwr";
++ label = "wf188:green:power";
+ gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>;
+ linux,default-trigger = "wf188:green:power";
+- default-state = "off";
++ default-state = "on";
+ };
+ };
+
+Index: linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq6018-edgecore-eap101.dts
+===================================================================
+--- linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce.orig/arch/arm64/boot/dts/qcom/qcom-ipq6018-edgecore-eap101.dts
++++ linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq6018-edgecore-eap101.dts
+@@ -337,21 +337,21 @@
+ pinctrl-names = "default";
+
+ led@25 {
+- label = "green:wifi5";
+- gpios = <&tlmm 35 GPIO_ACTIVE_LOW>;
+- linux,default-trigger = "wf188:green:5g";
++ label = "eap101:green:wifi5g";
++ gpios = <&tlmm 35 GPIO_ACTIVE_HIGH>;
++ linux,default-trigger = "eap101:green:wifi5g";
+ default-state = "off";
+ };
+ led@24 {
+- label = "green:wifi2";
+- gpios = <&tlmm 37 GPIO_ACTIVE_LOW>;
+- linux,default-trigger = "wf188:green:2g";
++ label = "eap101:green:wifi2g";
++ gpios = <&tlmm 37 GPIO_ACTIVE_HIGH>;
++ linux,default-trigger = "eap101:green:wifi2g";
+ default-state = "off";
+ };
+ led_power: led@16 {
+- label = "led_pwr";
++ label = "eap101:green:power";
+ gpios = <&tlmm 74 GPIO_ACTIVE_HIGH>;
+- linux,default-trigger = "green:power";
++ linux,default-trigger = "eap101:green:power";
+ default-state = "off";
+ };
+ };
+Index: linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts
+===================================================================
+--- linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce.orig/arch/arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts
++++ linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq807x-eap102.dts
+@@ -671,29 +671,29 @@
+ pinctrl-names = "default";
+
+ led_power: led_pwr {
+- label = "green:power";
++ label = "eap102:green:power";
+ gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>;
+ default-state = "on";
+- linux,default-trigger = "led_pwr";
++ linux,default-trigger = "eap102:green:power";
+ };
+
+ led_2g {
+- label = "green:wifi2";
++ label = "eap102:green:wifi2g";
+ gpio = <&tlmm 47 GPIO_ACTIVE_HIGH>;
+ default-state = "off";
+ };
+
+ led_5g {
+- label = "green:wifi5";
++ label = "eap102:green:wifi5g";
+ gpio = <&tlmm 48 GPIO_ACTIVE_HIGH>;
+ default-state = "off";
+ };
+
+ led_bt {
+ gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>;
+- label = "green:bt";
+- default-state = "off";
+- linux,default-trigger = "led_bt";
++ label = "eap102:green:bt";
++ default-state = "on";
++ linux,default-trigger = "eap102:green:bt";
+ };
+ };
+ nss-macsec0 {
+Index: linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq807x-ex227.dts
+===================================================================
+--- linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce.orig/arch/arm64/boot/dts/qcom/qcom-ipq807x-ex227.dts
++++ linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq807x-ex227.dts
+@@ -600,7 +600,7 @@
+ pinctrl-names = "default";
+
+ led_power {
+- label = "led_power";
++ label = "ex227:blue:power";
+ gpio = <&tlmm 42 GPIO_ACTIVE_HIGH>;
+ default-state = "on";
+ };
+Index: linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq807x-ex447.dts
+===================================================================
+--- linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce.orig/arch/arm64/boot/dts/qcom/qcom-ipq807x-ex447.dts
++++ linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/arch/arm64/boot/dts/qcom/qcom-ipq807x-ex447.dts
+@@ -600,7 +600,7 @@
+ pinctrl-names = "default";
+
+ led_power {
+- label = "led_power";
++ label = "ex447:blue:power";
+ gpio = <&tlmm 42 GPIO_ACTIVE_HIGH>;
+ default-state = "on";
+ };
--
2.25.1

View File

@@ -0,0 +1,26 @@
From 97ba6e4ba01fc7c57f769ac6d5c0e5fdf8ef0f62 Mon Sep 17 00:00:00 2001
From: Arthur Su <arthur.su@tp-link.com>
Date: Mon, 12 Jul 2021 02:31:13 +0000
Subject: [PATCH] ipq40xx: fix EC420-G1 reset button
Signed-off-by: Arthur Su <arthur.su@tp-link.com>
---
.../arch/arm/boot/dts/qcom-ipq4019-tp-link-ec420-g1.dts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4019-tp-link-ec420-g1.dts b/target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4019-tp-link-ec420-g1.dts
index e2062e7cd0..fc48e605d5 100755
--- a/target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4019-tp-link-ec420-g1.dts
+++ b/target/linux/ipq40xx/files-4.14/arch/arm/boot/dts/qcom-ipq4019-tp-link-ec420-g1.dts
@@ -69,7 +69,7 @@
button@1 {
label = "reset";
linux,code = <KEY_RESTART>;
- gpios = <&tlmm 10 GPIO_ACTIVE_LOW>;
+ gpios = <&tlmm 18 GPIO_ACTIVE_LOW>;
linux,input-type = <1>;
};
};
--
2.20.1

View File

@@ -0,0 +1,115 @@
From 8091bc6a4e9167fe4dc9abea4433b4852a8a4020 Mon Sep 17 00:00:00 2001
From: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
Date: Mon, 12 Jul 2021 14:42:44 -0400
Subject: [PATCH] WiFI5 APs LED label change
This patch will change the label names of ecw5410, ecw5211, and wf610D
APs to follow common naming conventions
Signed-off-by: Nagendrababu <nagendrababu.bonkuri@connectus.ai>
---
.../ipq40xx/base-files/etc/board.d/01_leds | 8 ++++----
...000-ecw5211-AP-LED-label-name-change.patch | 19 +++++++++++++++++++
.../ipq806x/base-files/etc/board.d/01_leds | 4 ++--
.../arm/boot/dts/qcom-ipq8068-ecw5410.dts | 8 ++++----
4 files changed, 29 insertions(+), 10 deletions(-)
create mode 100644 target/linux/ipq40xx/patches-4.14/1000-ecw5211-AP-LED-label-name-change.patch
diff --git a/target/linux/ipq40xx/base-files/etc/board.d/01_leds b/target/linux/ipq40xx/base-files/etc/board.d/01_leds
index e1833ffcee..033661752c 100755
--- a/target/linux/ipq40xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq40xx/base-files/etc/board.d/01_leds
@@ -61,12 +61,12 @@ zyxel,nbg6617)
;;
edgecore,ecw5211 |\
zyxel,wre6606)
- ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2g" "phy0tpt"
- ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:green:wlan5g" "phy1tpt"
+ ucidef_set_led_wlan "wifi2g" "WIFI2G" "${boardname}:green:wifi2g" "phy0tpt"
+ ucidef_set_led_wlan "wifi5g" "WIFI5G" "${boardname}:green:wifi5g" "phy1tpt"
;;
cig,wf610d)
- ucidef_set_led_wlan "wlan2g" "WLAN2G" "wf6203:green:wifi2g" "phy0tpt"
- ucidef_set_led_wlan "wlan5g" "WLAN5G" "wf6203:green:wifi5g" "phy1tpt"
+ ucidef_set_led_wlan "wifi2g" "WIFI2G" "wf6203:green:wifi2g" "phy0tpt"
+ ucidef_set_led_wlan "wifi5g" "WIFI5G" "wf6203:green:wifi5g" "phy1tpt"
;;
*)
diff --git a/target/linux/ipq40xx/patches-4.14/1000-ecw5211-AP-LED-label-name-change.patch b/target/linux/ipq40xx/patches-4.14/1000-ecw5211-AP-LED-label-name-change.patch
new file mode 100644
index 0000000000..67664fb0fa
--- /dev/null
+++ b/target/linux/ipq40xx/patches-4.14/1000-ecw5211-AP-LED-label-name-change.patch
@@ -0,0 +1,19 @@
+Index: linux-4.14.187/arch/arm/boot/dts/qcom-ipq4018-ecw5211.dts
+===================================================================
+--- linux-4.14.187.orig/arch/arm/boot/dts/qcom-ipq4018-ecw5211.dts
++++ linux-4.14.187/arch/arm/boot/dts/qcom-ipq4018-ecw5211.dts
+@@ -37,12 +37,12 @@
+ };
+
+ wlan2g {
+- label = "ecw5211:green:wlan2g";
++ label = "ecw5211:green:wifi2g";
+ gpios = <&tlmm 3 GPIO_ACTIVE_HIGH>;
+ };
+
+ wlan5g {
+- label = "ecw5211:green:wlan5g";
++ label = "ecw5211:green:wifi5g";
+ gpios = <&tlmm 2 GPIO_ACTIVE_HIGH>;
+ };
+ };
diff --git a/target/linux/ipq806x/base-files/etc/board.d/01_leds b/target/linux/ipq806x/base-files/etc/board.d/01_leds
index ffefb9e01c..809eef820a 100755
--- a/target/linux/ipq806x/base-files/etc/board.d/01_leds
+++ b/target/linux/ipq806x/base-files/etc/board.d/01_leds
@@ -20,8 +20,8 @@ compex,wpq864)
ucidef_set_led_usbport "pcie-usb" "PCIe USB" "wpq864:green:usb-pcie" "usb3-port1"
;;
edgecore,ecw5410)
- ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2g" "phy1tpt"
- ucidef_set_led_wlan "wlan5g" "WLAN5G" "${boardname}:green:wlan5g" "phy0tpt"
+ ucidef_set_led_wlan "wifi2g" "WIFI2G" "${boardname}:green:wifi2g" "phy1tpt"
+ ucidef_set_led_wlan "wifi5g" "WIFI5G" "${boardname}:green:wifi5g" "phy0tpt"
;;
nec,wg2600hp)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "${boardname}:green:wlan2g" "phy1tpt"
diff --git a/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8068-ecw5410.dts b/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8068-ecw5410.dts
index 6bddc5e288..7caa1d7e0e 100644
--- a/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8068-ecw5410.dts
+++ b/target/linux/ipq806x/files-4.14/arch/arm/boot/dts/qcom-ipq8068-ecw5410.dts
@@ -82,17 +82,17 @@
};
wlan2g_green {
- label = "ecw5410:green:wlan2g";
+ label = "ecw5410:green:wifi2g";
gpios = <&qcom_pinmux 23 GPIO_ACTIVE_LOW>;
};
wlan2g_yellow {
- label = "ecw5410:yellow:wlan2g";
+ label = "ecw5410:yellow:wifi2g";
gpios = <&qcom_pinmux 24 GPIO_ACTIVE_LOW>;
};
wlan5g_green {
- label = "ecw5410:green:wlan5g";
+ label = "ecw5410:green:wifi5g";
gpios = <&qcom_pinmux 26 GPIO_ACTIVE_LOW>;
};
@@ -102,7 +102,7 @@
};
wlan5g_yellow {
- label = "ecw5410:yellow:wlan5g";
+ label = "ecw5410:yellow:wifi5g";
gpios = <&qcom_pinmux 59 GPIO_ACTIVE_LOW>;
};
};
--
2.25.1

View File

@@ -0,0 +1,38 @@
From 73bb7009f980da3e898b590be06328703235c8ee Mon Sep 17 00:00:00 2001
From: Arthur Su <arthur.su@tp-link.com>
Date: Fri, 16 Jul 2021 09:43:25 +0000
Subject: [PATCH] ipq40xx: change EC420-G1 patch_mac method
deprecate get_tip command, because manufacturing data aren't binrary
raw.
Signed-off-by: Arthur Su <arthur.su@tp-link.com>
---
.../base-files/etc/hotplug.d/firmware/11-ath10k-caldata | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
index 428002acf3..38f248fb6e 100644
--- a/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
+++ b/target/linux/ipq40xx/base-files/etc/hotplug.d/firmware/11-ath10k-caldata
@@ -129,7 +129,7 @@ case "$FIRMWARE" in
tp-link,ap2220 |\
tp-link,ec420-g1)
ath10kcal_extract "0:ART" 36864 12064
- ath10kcal_patch_mac_crc $(macaddr_add "$(get_tip mac_address)" 1) # 5G, wlan0
+ ath10kcal_patch_mac_crc $(macaddr_add "$(cat /sys/class/net/eth0/address)" 1) # 5G, wlan0
;;
esac
;;
@@ -200,7 +200,7 @@ case "$FIRMWARE" in
tp-link,ap2220 |\
tp-link,ec420-g1)
ath10kcal_extract "0:ART" 4096 12064
- ath10kcal_patch_mac_crc $(macaddr_add "$(get_tip mac_address)" 9) #2.4G, wlan1
+ ath10kcal_patch_mac_crc $(macaddr_add "$(cat /sys/class/net/eth0/address)" 9) #2.4G, wlan1
;;
esac
;;
--
2.20.1

View File

@@ -0,0 +1,52 @@
From efe92c7fc395794cbfc12d195dddb660be5e4f2c Mon Sep 17 00:00:00 2001
From: Arthur Su <arthur.su@tp-link.com>
Date: Mon, 19 Jul 2021 08:45:27 +0000
Subject: [PATCH] ipq807x: add ath11k_generate_macs method for EX227 and EX447
The ex227 and ex447 have 17 MACs,the base mac is reserved for WAN, and
other 16 MACs are reserved for WLAN0/WALN1.
Signed-off-by: Arthur Su <arthur.su@tp-link.com>
---
.../etc/hotplug.d/firmware/10-ath11k-caldata | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/10-ath11k-caldata b/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/10-ath11k-caldata
index 25b22887fe..e6eb7e2dfd 100755
--- a/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/10-ath11k-caldata
+++ b/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/10-ath11k-caldata
@@ -24,6 +24,20 @@ ath11k_generate_macs() {
done
}
+# The tplink device has 17 MAC addresses. The base MAC address is reserved for eth0(WAN),
+# 8 MACs are reserved for 5G wireless(WLAN0), and the other 8 MACs are reserved for 2.4G wireless(WLAN1).
+# eth0: base_mac
+# wlan0: base_mac+1 ~ base_mac+8
+# wlan1: base_mac+9 ~ base_mac+16
+ath11k_generate_macs_for_tplink() {
+ touch /lib/firmware/ath11k-macs
+ eth=$(cat /sys/class/net/eth0/address)
+ wlan0=$(macaddr_add ${eth} 1) # 5G, wlan0
+ echo -ne \\x${wlan0//:/\\x} >> /lib/firmware/ath11k-macs
+ wlan1=$(macaddr_add ${eth} 9) # 2.4G, wlan1
+ echo -ne \\x${wlan1//:/\\x} >> /lib/firmware/ath11k-macs
+}
+
caldata_die() {
echo "caldata: " "$*"
exit 1
@@ -88,6 +102,10 @@ ath11k-macs)
cig,wf188n)
ath11k_generate_macs
;;
+ tplink,ex227|\
+ tplink,ex447)
+ ath11k_generate_macs_for_tplink
+ ;;
esac
;;
*)
--
2.20.1

View File

@@ -0,0 +1,25 @@
From c095555876344c46ac2653e97f4848f7fedd781b Mon Sep 17 00:00:00 2001
From: Owen Anderson <owenthomasanderson@gmail.com>
Date: Fri, 16 Jul 2021 12:53:17 -0400
Subject: [PATCH] Changed the method we use to get the interface name for lldp
---
package/network/services/lldpd/files/lldpd.init | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
index bc429de484..64dfccfebe 100644
--- a/package/network/services/lldpd/files/lldpd.init
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -37,7 +37,7 @@ write_lldpd_conf()
local iface ifnames=""
for iface in $ifaces; do
local ifname=""
- if network_get_device ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then
+ if network_get_physdev ifname "$iface" || [ -e "/sys/class/net/$iface" ]; then
append ifnames "${ifname:-$iface}" ","
fi
done
--
2.25.1

View File

@@ -0,0 +1,114 @@
From c685d1eb284547aaefb6d7ccb03677905d652b17 Mon Sep 17 00:00:00 2001
From: Arif Alam <arif.alam@netexperience.com>
Date: Thu, 29 Jul 2021 15:25:57 -0400
Subject: [PATCH] Fix mac assign on ath11k
Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Arif Alam <arif.alam@netexperience.com>
---
.../files/lib/netifd/wireless/mac80211.sh | 13 +++++++++---
.../mac80211/files/lib/wifi/mac80211.sh | 1 +
.../etc/hotplug.d/firmware/10-ath11k-caldata | 20 ++++++-------------
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
index 36aebbb2cc..cf3e7ffbb8 100644
--- a/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/netifd/wireless/mac80211.sh
@@ -26,6 +26,7 @@ drv_mac80211_init_device_config() {
config_add_string tx_burst
config_add_int beacon_int chanbw frag rts
config_add_int rxantenna txantenna antenna_gain txpower distance
+ config_add_int num_global_macaddr
config_add_boolean noscan ht_coex
config_add_array ht_capab
config_add_array channels
@@ -382,7 +383,11 @@ mac80211_generate_mac() {
local oIFS="$IFS"; IFS=":"; set -- $ref; IFS="$oIFS"
macidx=$(($id + 1))
- [ "$((0x$mask1))" -gt 0 ] && {
+
+ local use_global=0
+ [ "$id" -gt 0 -a "$macidx" -le "$num_global_macaddr" ] && use_global=1
+
+ [ "$((0x$mask1))" -gt 0 -a "$use_global" -lt 1 ] && {
b1="0x$1"
[ "$id" -gt 0 ] && \
b1=$(($b1 ^ ((($id - 1) << 2) | 0x2)))
@@ -390,7 +395,7 @@ mac80211_generate_mac() {
return
}
- [ "$((0x$mask6))" -lt 255 ] && {
+ [ "$((0x$mask6))" -lt 255 -a "$use_global" -gt 0 ] && {
printf "%s:%s:%s:%s:%s:%02x" $1 $2 $3 $4 $5 $(( 0x$6 ^ $id ))
return
}
@@ -724,7 +729,8 @@ drv_mac80211_setup() {
country chanbw distance \
txpower antenna_gain \
rxantenna txantenna \
- frag rts beacon_int:100 htmode
+ frag rts beacon_int:100 htmode \
+ num_global_macaddr
json_get_values basic_rate_list basic_rate
json_select ..
@@ -763,6 +769,7 @@ drv_mac80211_setup() {
set_default txantenna 0xffffffff
set_default distance 0
set_default antenna_gain 0
+ set_default num_global_macaddr 1
[ "$txantenna" = "all" ] && txantenna=0xffffffff
[ "$rxantenna" = "all" ] && rxantenna=0xffffffff
diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
index 511a9188db..09452ab365 100644
--- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh
@@ -113,6 +113,7 @@ detect_mac80211() {
set wireless.radio${devidx}.hwmode=11${mode_band}
${dev_id}
${ht_capab}
+ set wireless.radio${devidx}.num_global_macaddr=8
set wireless.radio${devidx}.disabled=1
set wireless.default_radio${devidx}=wifi-iface
diff --git a/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/10-ath11k-caldata b/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/10-ath11k-caldata
index e6eb7e2dfd..02ea5056f4 100755
--- a/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/10-ath11k-caldata
+++ b/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/10-ath11k-caldata
@@ -5,23 +5,15 @@
. /lib/functions.sh
. /lib/functions/system.sh
-macaddr_setup() {
- local mac=$1
- local val=$2
- local oui=${mac%:*:*}
- local nic=$(echo $mac | cut -d: -f 5)
-
- nic=$(printf "%02x" $((0x${nic//:/} + $val & 0xff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/')
- echo $oui:$nic:01
-}
-
ath11k_generate_macs() {
touch /lib/firmware/ath11k-macs
eth=$(cat /sys/class/net/eth0/address)
- for a in `seq 1 3`; do
- m=$(macaddr_setup ${eth} $a)
- echo -ne \\x${m//:/\\x} >> /lib/firmware/ath11k-macs
- done
+ mac1=$(macaddr_add $eth 2)
+ mac2=$(macaddr_add $eth 10)
+ mac3=$(macaddr_add $eth 18)
+ echo -ne \\x${mac1//:/\\x} >> /lib/firmware/ath11k-macs
+ echo -ne \\x${mac2//:/\\x} >> /lib/firmware/ath11k-macs
+ echo -ne \\x${mac3//:/\\x} >> /lib/firmware/ath11k-macs
}
# The tplink device has 17 MAC addresses. The base MAC address is reserved for eth0(WAN),
--
2.25.1

View File

@@ -0,0 +1,68 @@
From 5e5917308f769f1228c572e4aed4f8f7f6434a14 Mon Sep 17 00:00:00 2001
From: Owen Anderson <owenthomasanderson@gmail.com>
Date: Wed, 4 Aug 2021 13:38:16 -0400
Subject: [PATCH] Updated LLDPD version to 1.0.5 and updated config information
---
package/network/services/lldpd/Makefile | 4 ++--
package/network/services/lldpd/files/lldpd.init | 11 ++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/package/network/services/lldpd/Makefile b/package/network/services/lldpd/Makefile
index 5b36155b71..48a3993492 100644
--- a/package/network/services/lldpd/Makefile
+++ b/package/network/services/lldpd/Makefile
@@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=lldpd
-PKG_VERSION:=1.0.3
+PKG_VERSION:=1.0.5
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://media.luffy.cx/files/lldpd
-PKG_HASH:=39fced395168015416bfe78b95414facf066f841f349024433aa20ab54e4c360
+PKG_HASH:=2dd3b212f4dbabfcbb2794c0010b245f9f8e74b387984e757be6243a74c6cb99
PKG_MAINTAINER:=Stijn Tintel <stijn@linux-ipv6.be>
PKG_LICENSE:=ISC
diff --git a/package/network/services/lldpd/files/lldpd.init b/package/network/services/lldpd/files/lldpd.init
index 64dfccfebe..66b5a74c18 100644
--- a/package/network/services/lldpd/files/lldpd.init
+++ b/package/network/services/lldpd/files/lldpd.init
@@ -12,11 +12,8 @@ LLDPD_CONFS_DIR=/tmp/lldpd.d
find_release_info()
{
- [ -s /etc/os-release ] && . /etc/os-release
- [ -z "$PRETTY_NAME" ] && [ -s /etc/openwrt_version ] && \
- PRETTY_NAME="$(cat /etc/openwrt_version)"
-
- echo "${PRETTY_NAME:-Unknown OpenWrt release} @ $(cat /proc/sys/kernel/hostname)"
+ FW_VERSION=`sed -n 's/FW_IMAGE_ACTIVE:\(.*\)/\1/p' < /usr/opensync/.versions`
+ echo "${FW_VERSION:-Unknown TIP OpenAp release} @ $(cat /proc/sys/kernel/hostname)"
}
write_lldpd_conf()
@@ -48,6 +45,8 @@ write_lldpd_conf()
[ -n "$lldp_description" ] && echo "configure system description" "\"$lldp_description\"" >> "$LLDPD_CONF"
[ -n "$lldp_hostname" ] && echo "configure system hostname" "\"$lldp_hostname\"" >> "$LLDPD_CONF"
+ echo "configure system ip management pattern br-wan" >> "$LLDPD_CONF"
+
# Since lldpd's sysconfdir is /tmp, we'll symlink /etc/lldpd.d to /tmp/$LLDPD_CONFS_DIR
[ -e $LLDPD_CONFS_DIR ] || ln -s /etc/lldpd.d $LLDPD_CONFS_DIR
}
@@ -107,6 +106,8 @@ reload_service() {
unconfigure lldp custom-tlv
unconfigure system interface pattern
unconfigure system description
+ unconfigure system hostname
+ unconfigure system ip management pattern
EOF
# Rewrite lldpd.conf
# If something changed it should be included by the lldpcli call
--
2.25.1

View File

@@ -0,0 +1,39 @@
From e0c226e8f5cfa6ec3537823685a803b970297005 Mon Sep 17 00:00:00 2001
From: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
Date: Sun, 8 Aug 2021 21:38:12 -0400
Subject: [PATCH] wifi-3258: Fix bridge client traffic on same wifi interface
Allow bridging broadcast and multicast traffic within same
bridge port if hairpinmode is enabled for that port.
This fixes the ARP packet between clients on same wifi interface
being dropped.
Signed-off-by: Chaitanya Godavarthi <chaitanya.kiran@netexperience.com>
---
...e-allow-bcast-mcast-same-port-hairpinmode.patch | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 target/linux/ipq807x/patches/112-bridge-allow-bcast-mcast-same-port-hairpinmode.patch
diff --git a/target/linux/ipq807x/patches/112-bridge-allow-bcast-mcast-same-port-hairpinmode.patch b/target/linux/ipq807x/patches/112-bridge-allow-bcast-mcast-same-port-hairpinmode.patch
new file mode 100644
index 0000000000..99989b3067
--- /dev/null
+++ b/target/linux/ipq807x/patches/112-bridge-allow-bcast-mcast-same-port-hairpinmode.patch
@@ -0,0 +1,14 @@
+Index: linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/net/bridge/br_forward.c
+===================================================================
+--- linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce.orig/net/bridge/br_forward.c
++++ linux-4.4.60-qsdk-10fd7d14853b7020b804acae690c8acec5d954ce/net/bridge/br_forward.c
+@@ -33,8 +33,7 @@ static inline int should_deliver(const s
+ struct net_bridge_vlan_group *vg;
+
+ vg = nbp_vlan_group_rcu(p);
+- return ((skb->dev != p->dev) || ((p->flags & BR_HAIRPIN_MODE) &&
+- (!is_multicast_ether_addr(eth_hdr(skb)->h_dest)))) &&
++ return ((skb->dev != p->dev) || (p->flags & BR_HAIRPIN_MODE)) &&
+ br_allowed_egress(vg, skb) && p->state == BR_STATE_FORWARDING;
+ }
+
--
2.25.1

Some files were not shown because too many files have changed in this diff Show More