Merge ~teknoraver/snappy-hwe-snaps/+git/wifi-ap:master into ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master

Proposed by Matteo Croce
Status: Merged
Approved by: Simon Fels
Approved revision: 4e6e06470c9dece16a06193618d728e0e32bc59b
Merged at revision: 3499a56b4604277c1907cc341adfc1b8eb6c3596
Proposed branch: ~teknoraver/snappy-hwe-snaps/+git/wifi-ap:master
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master
Diff against target: 188 lines (+73/-29)
3 files modified
bin/ap.sh (+33/-21)
tests/main/default-conf-brings-up-ap/task.yaml (+6/-8)
tests/main/utf8-ssid/task.yaml (+34/-0)
Reviewer Review Type Date Requested Status
Simon Fels Approve
System Enablement Bot continuous-integration Approve
Matteo Croce (community) Approve
Review via email: mp+309599@code.launchpad.net

Description of the change

Bugfixes in ap.sh and improvements in hostapd configuration.

spawn hostapd in foreground instead to start it in background and wait for its pid

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) :
review: Needs Fixing
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) wrote :

Also discussed with Matteo that he will add spread tests to verify both the UTF-8 SSID's and the WMM settings.

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Matteo Croce (teknoraver) :
review: Approve
Revision history for this message
Simon Fels (morphis) wrote :

Small comments inline otherwise LGTM

review: Needs Fixing
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/ap.sh b/bin/ap.sh
2index 3dcb93d..1e91822 100755
3--- a/bin/ap.sh
4+++ b/bin/ap.sh
5@@ -39,7 +39,7 @@ if ! ifconfig $WIFI_INTERFACE ; then
6 fi
7
8 cleanup_on_exit() {
9- DNSMASQ_PID=$(cat $SNAP_DATA/dnsmasq.pid)
10+ read DNSMASQ_PID <$SNAP_DATA/dnsmasq.pid
11 # If dnsmasq is already gone don't error out here
12 kill -TERM $DNSMASQ_PID || true
13 wait $DNSMASQ_PID
14@@ -60,7 +60,7 @@ cleanup_on_exit() {
15 $SNAP/bin/iw dev $iface del
16 fi
17
18- if [ is_nm_running ] ; then
19+ if is_nm_running ; then
20 # Hand interface back to network-manager. This will also trigger the
21 # auto connection process inside network-manager to get connected
22 # with the previous network.
23@@ -100,7 +100,7 @@ if [ "$WIFI_INTERFACE_MODE" = "direct" ] ; then
24 fi
25
26
27-if [ is_nm_running ] ; then
28+if is_nm_running ; then
29 # Prevent network-manager from touching the interface we want to use. If
30 # network-manager was configured to use the interface its nothing we want
31 # to prevent here as this is how the user configured the system.
32@@ -117,7 +117,7 @@ if [ $? -ne 0 ] ; then
33 $SNAP/bin/iw dev $iface del
34 fi
35
36- if [ is_nm_running ] ; then
37+ if is_nm_running ; then
38 # Hand interface back to network-manager. This will also trigger the
39 # auto connection process inside network-manager to get connected
40 # with the previous network.
41@@ -153,21 +153,45 @@ driver=$driver
42 channel=$WIFI_CHANNEL
43 macaddr_acl=0
44 ignore_broadcast_ssid=0
45-wmm_enabled=1
46 ieee80211n=1
47 ssid=$WIFI_SSID
48+auth_algs=1
49+utf8_ssid=1
50 hw_mode=$WIFI_OPERATION_MODE
51+
52+# The wmm_* options are needed to enable AMPDU
53+# and get decent 802.11n throughput
54+wmm_enabled=1
55+wmm_enabled=1
56+wmm_ac_bk_cwmin=4
57+wmm_ac_bk_cwmax=10
58+wmm_ac_bk_aifs=7
59+wmm_ac_bk_txop_limit=0
60+wmm_ac_bk_acm=0
61+wmm_ac_be_aifs=3
62+wmm_ac_be_cwmin=4
63+wmm_ac_be_cwmax=10
64+wmm_ac_be_txop_limit=0
65+wmm_ac_be_acm=0
66+wmm_ac_vi_aifs=2
67+wmm_ac_vi_cwmin=3
68+wmm_ac_vi_cwmax=4
69+wmm_ac_vi_txop_limit=94
70+wmm_ac_vi_acm=0
71+wmm_ac_vo_aifs=2
72+wmm_ac_vo_cwmin=2
73+wmm_ac_vo_cwmax=3
74+wmm_ac_vo_txop_limit=47
75+wmm_ac_vo_acm=0
76 EOF
77
78 case "$WIFI_SECURITY" in
79 open)
80 cat <<-EOF >> $SNAP_DATA/hostapd.conf
81- auth_algs=1
82 EOF
83 ;;
84 wpa2)
85 cat <<-EOF >> $SNAP_DATA/hostapd.conf
86- auth_algs=3
87 wpa=2
88 wpa_key_mgmt=WPA-PSK
89 wpa_passphrase=$WIFI_SECURITY_PASSPHRASE
90@@ -196,18 +220,6 @@ case "$WIFI_HOSTAPD_DRIVER" in
91 esac
92
93 # Startup hostapd with the configuration we've put in place
94-$hostapd $EXTRA_ARGS $SNAP_DATA/hostapd.conf &
95-HOSTAPD_PID=$!
96-
97-trap exit_handler EXIT
98-function exit_handler() {
99- kill -TERM $HOSTAPD_PID
100- # Wait until hostapd is correctly terminated before we continue
101- # doing anything
102- wait $HOSTAPD_PID
103- cleanup_on_exit
104- exit 0
105-}
106-
107-wait $HOSTAPD_PID
108+$hostapd $EXTRA_ARGS $SNAP_DATA/hostapd.conf
109 cleanup_on_exit
110+exit 0
111diff --git a/tests/main/default-conf-brings-up-ap/task.yaml b/tests/main/default-conf-brings-up-ap/task.yaml
112index 349e7f4..d787a39 100644
113--- a/tests/main/default-conf-brings-up-ap/task.yaml
114+++ b/tests/main/default-conf-brings-up-ap/task.yaml
115@@ -17,8 +17,6 @@ execute: |
116 done
117
118 snap install wireless-tools
119- # FIXME: Can be dropped once we have a snap-declaration for this in place
120- snap connect wireless-tools:network-control core:network-control
121
122 # Scan for existing WiFi networks and ensure our 'Ubuntu' one is part
123 # of the result
124@@ -26,11 +24,11 @@ execute: |
125 wireless-tools.iw dev wlan1 scan | grep 'SSID: Ubuntu'
126 wireless-tools.iw dev wlan1 scan | grep 'primary channel: 6'
127 # There should be only a single network
128- network_count=`wireless-tools.iw dev wlan1 scan | grep 'SSID: Ubuntu' | wc -l`
129+ network_count=`wireless-tools.iw dev wlan1 scan | grep -c 'SSID: Ubuntu'`
130 test $network_count -eq 1
131 # The AP should not be secured by default
132- test ! `wireless-tools.iw dev wlan1 scan | grep 'WPA:'`
133- test ! `wireless-tools.iw dev wlan1 scan | grep 'RSN:'`
134+ ! wireless-tools.iw dev wlan1 scan | grep 'WPA:'
135+ ! wireless-tools.iw dev wlan1 scan | grep 'RSN:'
136
137 # Verify we can associate with the AP
138 wireless-tools.iw wlan1 connect Ubuntu
139@@ -39,6 +37,6 @@ execute: |
140 # And we should get an IP address assigned over DHCP
141 dhclient wlan1
142 # IP Address and routing needs to be correct
143- ifconfig wlan1 | grep 'inet addr:10.0.60'
144- ip route | grep '10.0.60.0/24 dev wlan1'
145- ip route | grep 'default via 10.0.60.1 dev wlan1'
146+ ifconfig wlan1 | fgrep 'inet addr:10.0.60.1'
147+ ip route | fgrep '10.0.60.0/24 dev wlan1'
148+ ip route | fgrep 'default via 10.0.60.1 dev wlan1'
149diff --git a/tests/main/utf8-ssid/task.yaml b/tests/main/utf8-ssid/task.yaml
150new file mode 100644
151index 0000000..b1ae11b
152--- /dev/null
153+++ b/tests/main/utf8-ssid/task.yaml
154@@ -0,0 +1,34 @@
155+summary: Verify that the AP can accept an UTF8 SSID
156+
157+prepare: |
158+ # Simulate two WiFi radio network interfaces
159+ modprobe mac80211_hwsim radios=2
160+
161+restore: |
162+ rmmod mac80211_hwsim
163+
164+execute: |
165+ # Default configuration will use wlan0 which we just created
166+ wifi-ap.config set disabled 0
167+ wifi-ap.config set wifi.ssid 'Ubuntu👍'
168+
169+ systemctl restart snap.wifi-ap.backend
170+ while ! systemctl status snap.wifi-ap.backend ; do
171+ sleep 1
172+ done
173+
174+ snap install wireless-tools
175+
176+ # Scan for existing WiFi networks and ensure our 'Ubuntu' one is part
177+ # of the result
178+ ifconfig wlan1 up
179+ wireless-tools.iw dev wlan1 scan | fgrep 'SSID: Ubuntu\xf0\x9f\x91\x8d'
180+
181+ # There should be only a single network
182+ network_count=`wireless-tools.iw dev wlan1 scan | fgrep -c 'SSID: Ubuntu\xf0\x9f\x91\x8d'`
183+ test $network_count -eq 1
184+
185+ # Verify we can associate with the AP
186+ wireless-tools.iw wlan1 connect 'Ubuntu👍'
187+ wireless-tools.iw dev wlan1 link | fgrep 'SSID: Ubuntu\xf0\x9f\x91\x8d'
188+

Subscribers

People subscribed via source and target branches

to all changes: