Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cd9afa6

Browse files
committedMay 10, 2024·
Upgrade testing code and tocumentation to APuP
1 parent 03538c2 commit cd9afa6

File tree

2 files changed

+278
-59
lines changed

2 files changed

+278
-59
lines changed
 

‎packages/lime-curtigghio/README.adoc

+21-20
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
:lang: en
55

66
*TL;DR* Fiddling with hostad code I have managed to successfully establish WiFi
7-
communication between multiple AP configured in WDS, each of them send and
8-
receive traffic from the other as if the where associated stations, while they
9-
are all configured in AP WDS mode. This P2P like behavior have multiple
10-
advantages compared to the usual setup where one of them is configures as AP and
11-
all the others as station, and also compared to Ad-Hoc mode and 802.11s.
7+
communication between multiple AP, each of them send and receive traffic from
8+
the other as if they where associated stations, while they are all configured in
9+
AP mode. This P2P like behavior have multiple advantages compared to the usual
10+
setup where one of them is configured as AP and all the others as stations, and
11+
also compared to Ad-Hoc, WDS, 802.11s, Multi-AP and EasyMesh.
12+
I have named this operanting mode APuP (Access Point Micro Peering).
1213

1314

1415
== A bit of context
@@ -32,10 +33,13 @@ determined it\'s silent demisal. New radios drivers and firmwares doesn\'t
3233
support 802.11s well. New WiFi standards doesn\'t bring much improvements to
3334
802.11s mesh mode, while they do improve a lot AP-STA modes. Still our need of
3435
nodes being able to comunicate to anyone in range is strong. In this context,
35-
looking for a modern solution I started talking with Felix Fietkau (nbd), in
36-
this conversation a new idea emerged, if AP mode is what is getting more support
37-
and improvements, can\'t we just use that on all nodes with some slight
38-
modification so all AP can talk each other?
36+
looking for a modern solution I started asking myself, is there an hard to
37+
resolve problem that impede AP nodes in sight to talk each other?
38+
Talking about my thinking with Felix Fietkau (nbd), we agreed that it might be
39+
possible for AP nodes to commuicate directly each other, and because AP mode is
40+
what is getting more support and improvements, if we can we just use that on
41+
all nodes with some slight modification so all AP in sight can talk each other,
42+
we could solve this problem that afflict us since WiFi creation.
3943
Felix suggested that this should be possible and with a bit of luck should not
4044
even need kernel and driver modifications, modifing `hostapd` in a way that each
4145
AP adds the other in sight to its station list could be enough and it is indeed
@@ -184,7 +188,7 @@ additional sources.
184188
`for mPatch in ~/Builds/openwrt/package/network/services/hostapd/patches/*.patch ; do patch -p1 < $mPatch ; done`
185189

186190
The modified `hostapd` code I published on my
187-
https://gitlab.com/g10h4ck/hostap/-/tree/lime_curtigghio[gitlab sandbox] already
191+
https://gitlab.com/g10h4ck/hostap/-/tree/APuP[gitlab sandbox] already
188192
includes those so you don't need to reapply them.
189193

190194
To clean and re-build only hostapd package use
@@ -207,16 +211,16 @@ automatically by `hostapd` and potentially creating a loop, I have temporarly
207211
disabled bridging in `hostapd_set_wds_sta` defined in +src/ap/ap_drv_ops.c+,
208212
this should become a runtime configuration later.
209213

210-
I have also added a compile time config `CONFIG_NO_LIME_CURTIGGHIO` in
211-
+hostapd/Makefile+ so this modifications can easly be disabled at compile time.
214+
I have also added a compile time config `CONFIG_APUP` in +hostapd/Makefile+ so
215+
this modifications can be easly enabled at compile time.
212216

213217
I have tested the modifications and after a bunch of round of trial and error
214218
works as expected, with good performances, you can see the +test.sh+ script
215219
which configures four vanilla OpenWrt routers into a working testbed to see how
216220
to use this.
217221

218222
The modified `hostapd` code is published on my
219-
https://gitlab.com/g10h4ck/hostap/-/tree/lime_curtigghio[gitlab sandbox]
223+
https://gitlab.com/g10h4ck/hostap/-/tree/APuP[gitlab sandbox]
220224

221225

222226
== Useful snippets
@@ -455,19 +459,16 @@ Sun Jan 1 22:07:28 2023 daemon.notice hostapd: LIME_CURTIJJO nl80211: Drv Event
455459

456460
http://www.bradgoodman.com/bittool/
457461

462+
458463
== WDS Station interface bridging
459464

460465
hostapd add WDS STA interfaces to a bridge either the same of plain station
461466
passed with the `bridge` option or to another one passed with the `wds_bridge`,
462467
in our use case this is not ideal as we might want the routing propocols access
463468
directly to the station interface. Moreover in a mesh setup multiple links could
464-
easily cause a bridge loop, that linux simple bride will be not able to handle
465-
as is.
466-
The fester and temporary workaround seems to be to create a custom bridge with
467-
pass that via the `wds_bridge` option and disable forwarding between interfaces
468-
via nftables.
469-
Later we can create an option for hostapd to disable the WDS station interface
470-
bridging.
469+
easily cause a bridge loop, that linux simple bridge will be not able to handle
470+
as is. To disable automatic bridging set `wds_bridge` to an empty string in the
471+
hostapd config file.
471472

472473

473474
== Interesting conversations

‎packages/lime-curtigghio/test.sh

+257-39
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,126 @@
22

33
## LibreMesh community mesh networks meta-firmware
44
##
5-
## Copyright (C) 2023 Gioacchino Mazzurco <gio@eigenlab.org>
6-
## Copyright (C) 2023 Asociación Civil Altermundi <info@altermundi.net>
5+
## Copyright (C) 2023-2024 Gioacchino Mazzurco <gio@polymathes.cc>
6+
## Copyright (C) 2023-2024 Asociación Civil Altermundi <info@altermundi.net>
77
##
88
## SPDX-License-Identifier: AGPL-3.0-only
99

10-
mBuildDir="/home/gio/Builds/openwrt"
1110

12-
cIface="em0"
11+
## Define default value for variable, take two arguments, $1 variable name,
12+
## $2 default variable value, if the variable is not already define define it
13+
## with default value.
14+
function define_default_value()
15+
{
16+
VAR_NAME="${1}"
17+
DEFAULT_VALUE="${2}"
18+
19+
[ -z "${!VAR_NAME}" ] && export ${VAR_NAME}="${DEFAULT_VALUE}" || true
20+
}
21+
22+
23+
define_default_value OPENWRT_BUILD_DIR "$HOME/Builds/openwrt-apup/"
24+
define_default_value KCONFIG_UTILS_DIR "$HOME/Development/kconfig-utils/"
25+
define_default_value HOSTAPD_REPO_DIR "$HOME/Development/hostap/"
26+
define_default_value OPENWRT_REPO_DIR "$HOME/Development/openwrt/"
27+
define_default_value NETIFD_REPO_DIR "$HOME/Development/netifd/"
28+
29+
30+
31+
cIface="usbe1"
1332

1433
bianco43IP="fe80::c24a:ff:fefc:2f12%$cIface"
1534
bluIP="fe80::6670:2ff:fede:c51e%$cIface"
1635
neroIP="fe80::c24a:ff:fe7a:acac%$cIface"
1736
verdeIP="fe80::ea94:f6ff:fe68:3364%$cIface"
1837

38+
dax1Ipll="fe80::aa63:7dff:fe2e:97c8%$cIface"
39+
dax2Ipll="fe80::aa63:7dff:fe2e:97d8%$cIface"
40+
41+
hlk1Ipll="169.254.145.20"
42+
hlk2Ipll="169.254.145.22"
43+
44+
source "${KCONFIG_UTILS_DIR}/kconfig-utils.sh"
45+
46+
function fTestConf()
47+
{
48+
kconfig_set CONFIG_DEVEL
49+
kconfig_set CONFIG_SRC_TREE_OVERRIDE
50+
51+
local mHostapdGitSrc="$OPENWRT_BUILD_DIR/package/network/services/hostapd/git-src"
52+
rm -f "$mHostapdGitSrc"
53+
ln -s "${HOSTAPD_REPO_DIR}/.git" "$mHostapdGitSrc"
54+
55+
local mNetifdGitSrc="$OPENWRT_BUILD_DIR/package/network/config/netifd/git-src"
56+
rm -f "$mNetifdGitSrc"
57+
ln -s "$NETIFD_REPO_DIR/.git" "$mNetifdGitSrc"
58+
59+
kconfig_set CONFIG_PACKAGE_iperf3
60+
61+
kconfig_unset CONFIG_PACKAGE_ppp
62+
kconfig_unset CONFIG_PACKAGE_ppp-mod-pppoe
63+
kconfig_unset CONFIG_PACKAGE_kmod-ppp
64+
kconfig_unset CONFIG_PACKAGE_kmod-pppoe
65+
kconfig_unset CONFIG_PACKAGE_kmod-pppox
66+
}
67+
68+
function fBuildDapX()
69+
{
70+
pushd "$OPENWRT_BUILD_DIR"
71+
72+
./scripts/feeds update -a
73+
./scripts/feeds install -a
74+
75+
# Prepare firmware for D-Link DAP-X1860
76+
echo "" > "$KCONFIG_CONFIG_PATH"
77+
kconfig_init_register
78+
79+
kconfig_set CONFIG_TARGET_ramips
80+
kconfig_set CONFIG_TARGET_ramips_mt7621
81+
kconfig_set CONFIG_TARGET_ramips_mt7621_DEVICE_dlink_dap-x1860-a1
82+
make defconfig
83+
84+
fTestConf
85+
make defconfig
86+
87+
kconfig_check
88+
kconfig_wipe_register
89+
90+
clean_hostapd
91+
92+
make -j $(($(nproc)-1))
93+
popd
94+
}
95+
96+
function fBuildHlk()
97+
{
98+
pushd "$OPENWRT_BUILD_DIR"
99+
100+
./scripts/feeds update -a
101+
./scripts/feeds install -a
102+
103+
# Prepare firmware for D-Link DAP-X1860
104+
echo "" > "$KCONFIG_CONFIG_PATH"
105+
kconfig_init_register
106+
107+
kconfig_set CONFIG_TARGET_ramips
108+
kconfig_set CONFIG_TARGET_ramips_mt7621
109+
kconfig_set CONFIG_TARGET_ramips_mt7621_DEVICE_hilink_hlk-7621a-evb
110+
make defconfig
111+
112+
kconfig_set CONFIG_PACKAGE_pciutils
113+
kconfig_set CONFIG_PACKAGE_kmod-mt7916-firmware
114+
fTestConf
115+
make defconfig
116+
117+
kconfig_check
118+
kconfig_wipe_register
119+
120+
clean_packages
121+
122+
make -j $(($(nproc)-1))
123+
popd
124+
}
19125

20126
function dflash()
21127
{
@@ -30,7 +136,8 @@ function dflash()
30136

31137
[ "X$origHash" != "X$copiedHash" ] && echo "Hash mismatch" && return -1
32138

33-
ssh root@$dDevice "sysupgrade -n /tmp/$imgName"
139+
# Do not use -n as this will erease IP confifuration for hilink_hlk-7621a-evb
140+
ssh root@$dDevice "sysupgrade /tmp/$imgName"
34141

35142
# Wait the detached flashing to start
36143
sleep 10
@@ -59,6 +166,14 @@ function dWait()
59166

60167
function wait_all()
61168
{
169+
dWait ${hlk1Ipll}
170+
dWait ${hlk2Ipll}
171+
return
172+
173+
dWait ${dax1Ipll}
174+
dWait ${dax2Ipll}
175+
return
176+
62177
dWait ${verdeIP}
63178
dWait ${neroIP}
64179
dWait ${bluIP}
@@ -86,14 +201,17 @@ function dConf()
86201
set wireless.radio0.channel='9'
87202
set wireless.default_radio0.ssid='libre-curtigghio'
88203
set wireless.default_radio0.mode='ap'
89-
set wireless.default_radio0.wds='1'
90-
set wireless.default_radio0.network='curtigghio'
204+
set wireless.default_radio0.apup='1'
205+
set wireless.default_radio0.apup_peer_ifname_prefix='wlan0.peer'
206+
set wireless.default_radio0.network='lan'
91207
92208
set wireless.radio1.disabled='0'
93209
set wireless.default_radio1.ssid='libre-curtigghio'
94210
set wireless.default_radio1.mode='ap'
95-
set wireless.default_radio1.wds='1'
96-
set wireless.default_radio1.network='curtigghio'
211+
set wireless.default_radio1.apup='1'
212+
set wireless.default_radio1.apup_peer_ifname_prefix='wlan1.peer'
213+
set wireless.default_radio1.wds_bridge=''
214+
set wireless.default_radio1.network='lan'
97215
98216
set firewall.@defaults[0].input='ACCEPT'
99217
set firewall.@defaults[0].output='ACCEPT'
@@ -105,6 +223,14 @@ EOF
105223

106224
function conf_all()
107225
{
226+
dConf ${hlk1Ipll} "OpenWrt-Hlk1" "169.254.145.20"
227+
dConf ${hlk2Ipll} "OpenWrt-Hlk2" "169.254.145.22"
228+
return
229+
230+
dConf ${dax1Ipll} "OpenWrt-Dax1" "192.168.1.16"
231+
dConf ${dax2Ipll} "OpenWrt-Dax2" "192.168.1.18"
232+
return
233+
108234
dConf ${verdeIP} "OpenWrt-Verde" "192.168.1.4"
109235
dConf ${neroIP} "OpenWrt-nero" "192.168.1.10"
110236
dConf ${bluIP} "OpenWrt-blu" "192.168.1.8"
@@ -113,48 +239,105 @@ function conf_all()
113239

114240
function flash_all()
115241
{
116-
dflash ${verdeIP} "${mBuildDir}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr3600-v1-squashfs-sysupgrade.bin"
117-
dflash ${neroIP} "${mBuildDir}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr3600-v1-squashfs-sysupgrade.bin"
118-
dflash ${bluIP} "${mBuildDir}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr3600-v1-squashfs-sysupgrade.bin"
119-
dflash ${bianco43IP} "${mBuildDir}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr4300-v1-squashfs-sysupgrade.bin"
242+
dflash ${hlk1Ipll} "${OPENWRT_BUILD_DIR}/bin/targets/ramips/mt7621/openwrt-ramips-mt7621-hilink_hlk-7621a-evb-squashfs-sysupgrade.bin"
243+
dflash ${hlk2Ipll} "${OPENWRT_BUILD_DIR}/bin/targets/ramips/mt7621/openwrt-ramips-mt7621-hilink_hlk-7621a-evb-squashfs-sysupgrade.bin"
244+
245+
# dflash ${dax1Ipll} "${OPENWRT_BUILD_DIR}/bin/targets/ramips/mt7621/openwrt-ramips-mt7621-dlink_dap-x1860-a1-squashfs-sysupgrade.bin"
246+
# dflash ${dax2Ipll} "${OPENWRT_BUILD_DIR}/bin/targets/ramips/mt7621/openwrt-ramips-mt7621-dlink_dap-x1860-a1-squashfs-sysupgrade.bin"
247+
248+
# dflash ${verdeIP} "${OPENWRT_BUILD_DIR}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr3600-v1-squashfs-sysupgrade.bin"
249+
# dflash ${neroIP} "${OPENWRT_BUILD_DIR}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr3600-v1-squashfs-sysupgrade.bin"
250+
# dflash ${bluIP} "${OPENWRT_BUILD_DIR}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr3600-v1-squashfs-sysupgrade.bin"
251+
# dflash ${bianco43IP} "${OPENWRT_BUILD_DIR}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr4300-v1-squashfs-sysupgrade.bin"
120252

121253
wait_all
122254

123255
conf_all
124256

257+
ssh root@${hlk1Ipll} reboot
258+
ssh root@${hlk2Ipll} reboot
259+
260+
return
261+
262+
263+
ssh root@${dax1Ipll} reboot
264+
ssh root@${dax2Ipll} reboot
265+
266+
return
267+
125268
ssh root@${verdeIP} reboot
126269
ssh root@${neroIP} reboot
127270
ssh root@${bluIP} reboot
128271
ssh root@${bianco43IP} reboot
129272
}
130273

131-
function build_hostapd()
274+
function dev_packages_paths()
132275
{
133-
pushd "$mBuildDir"
276+
echo package/network/config/netifd \
277+
package/network/config/wifi-scripts \
278+
package/network/services/hostapd
279+
}
134280

135-
make package/network/services/hostapd/clean
136-
make package/network/services/hostapd/compile ||
137-
make package/network/services/hostapd/compile -j1 V=s
281+
function clean_packages()
282+
{
283+
pushd "$OPENWRT_BUILD_DIR"
284+
285+
for mPackagePath in $(dev_packages_paths) ; do
286+
make $mPackagePath/clean
287+
done
138288

139289
popd
140290
}
141291

142-
function upgrade_hostapd()
292+
function build_packages()
143293
{
144-
dAddress="$1"
145-
mHostapdPkgPath="$(ls $mBuildDir/bin/packages/mips_24kc/base/wpad-basic-*.ipk)"
294+
clean_packages
295+
296+
pushd "$OPENWRT_BUILD_DIR"
146297

147-
scp -O "$mHostapdPkgPath" root@[${dAddress}]:/tmp/
298+
for mPackagePath in $(dev_packages_paths); do
299+
make $mPackagePath/compile ||
300+
{
301+
make $mPackagePath/compile -j1 V=sc
302+
return -1
303+
}
304+
done
148305

149-
ssh root@${dAddress} "opkg install --force-reinstall \"/tmp/$(basename $mHostapdPkgPath)\" && reboot"
306+
popd
150307
}
151308

152-
function upgrade_hostapd_all()
309+
function upgrade_packages()
153310
{
154-
upgrade_hostapd $verdeIP
155-
upgrade_hostapd ${neroIP}
156-
upgrade_hostapd $bluIP
157-
upgrade_hostapd ${bianco43IP}
311+
local dAddress="$1"
312+
local dPkgArch="${2:-mipsel_24kc}"
313+
314+
local mInstalls=""
315+
316+
for mPackageName in \
317+
netifd \
318+
hostapd-common wpad-basic-mbedtls wifi-scripts ; do
319+
320+
local mPkgPath="$(ls "$OPENWRT_BUILD_DIR/bin/packages/$dPkgArch/base/$mPackageName"*.ipk)"
321+
scp -O "$mPkgPath" root@[${dAddress}]:/tmp/
322+
323+
mInstalls="$mInstalls \"/tmp/$(basename $mPkgPath)\""
324+
done
325+
326+
ssh root@${dAddress} "opkg install --force-reinstall $mInstalls && reboot"
327+
}
328+
329+
function upgrade_packages_all()
330+
{
331+
upgrade_packages ${hlk1Ipll}
332+
upgrade_packages ${hlk2Ipll}
333+
334+
# upgrade_hostapd ${dax1Ipll}
335+
# upgrade_hostapd ${dax2Ipll}
336+
337+
# upgrade_hostapd $verdeIP
338+
# upgrade_hostapd ${neroIP}
339+
# upgrade_hostapd $bluIP
340+
# upgrade_hostapd ${bianco43IP}
158341

159342
sleep 5s
160343

@@ -165,23 +348,58 @@ function errcho() { >&2 echo $@; }
165348

166349
function dTestMulticast()
167350
{
168-
dAddress="$1"
351+
local dAddress="$1"
169352

170353
[ "0$(ssh root@${dAddress} ping6 -c 4 ff02::1%phy0-ap0.sta1 | \
171354
grep duplicates | awk '{print $7}')" -gt "1" ] ||
172-
{ errcho dTestMulticast $1 Failed ; return -1 ; }
173-
errcho dTestMulticast $1 Success
355+
{ errcho dTestMulticast $dAddress Failed ; return -1 ; }
356+
errcho dTestMulticast $dAddress Success
174357
}
175358

359+
function dTestIperf3()
360+
{
361+
local clientAddress="$1"
362+
local servAddress="$2"
363+
local servIfaceAddress="$3"
364+
365+
ssh root@${servAddress} iperf3 -s
366+
ssh root@${clientAddress} iperf3 -c $servIfaceAddress
367+
}
368+
369+
function dTestUbusDev()
370+
{
371+
local dAddress="$1"
372+
373+
ssh root@${dAddress} reboot ; sleep 10
374+
375+
dWait ${dAddress}
376+
377+
ssh root@${dAddress} << REMOTE_HOST_EOS
378+
ubus call network add_dynamic_device '{"name":"nomestru", "type":"8021ad", "ifname":"wlan0.peer1", "vid":"47"}'
379+
ubus call network add_dynamic '{"name":"ifstru", "proto":"static", "auto":1, "device":"nomestru", "ipaddr":"169.254.145.20", "netmask":"255.255.255.255"}'
380+
ubus call network.interface.ifstru up
381+
ubus call network.device status '{"name":"nomestru"}'
382+
383+
ip address show nomestru
384+
REMOTE_HOST_EOS
385+
}
386+
387+
#fBuildDapX
388+
#fBuildHlk
389+
176390
#flash_all
177-
#conf_all
178391

179-
build_hostapd
180-
conf_all
181-
upgrade_hostapd_all
392+
#build_packages
393+
#upgrade_packages_all
394+
395+
dTestUbusDev ${hlk1Ipll}
396+
397+
#conf_all
182398

183-
dTestMulticast $bluIP
184-
dTestMulticast $verdeIP
185-
dTestMulticast $bianco43IP
186-
dTestMulticast $neroIP
399+
#dTestMulticast ${dax1Ipll}
400+
#dTestMulticast ${dax2Ipll}
187401

402+
# dTestMulticast $bluIP
403+
# dTestMulticast $verdeIP
404+
# dTestMulticast $bianco43IP
405+
# dTestMulticast $neroIP

0 commit comments

Comments
 (0)
Please sign in to comment.