Merge ~alfonsosanchezbeato/network-manager:test-ci into network-manager:snap-1.10

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Tony Espy
Approved revision: 44bb1fd711241a032021ea6780d926c7aff51f6e
Merged at revision: 068ecec4f35b4a37eb2c0abb971398fce492cee9
Proposed branch: ~alfonsosanchezbeato/network-manager:test-ci
Merge into: network-manager:snap-1.10
Diff against target: 2793 lines (+2389/-17)
50 files modified
debian/patches/series (+1/-0)
debian/patches/snap-support-ppp.patch (+134/-0)
docs/snap/configure-cellular-connections.md (+124/-0)
docs/snap/configure-wifi-connections.md (+80/-0)
docs/snap/edit-connections.md (+155/-0)
docs/snap/enable-ethernet-support.md (+38/-0)
docs/snap/explore-network-status.md (+52/-0)
docs/snap/faq.md (+18/-0)
docs/snap/index.md (+42/-0)
docs/snap/installation.md (+62/-0)
docs/snap/logging-messages.md (+43/-0)
docs/snap/metadata.yaml (+49/-0)
docs/snap/reference/available-commands.md (+19/-0)
docs/snap/reference/configuration/ethernet_support.md (+47/-0)
docs/snap/reference/dbus-api.md (+9/-0)
docs/snap/reference/snap-configuration/debug.md (+51/-0)
docs/snap/reference/snap-configuration/wifi-powersave.md (+38/-0)
docs/snap/reference/snap-configuration/wowlan.md (+126/-0)
docs/snap/release-notes.md (+35/-0)
docs/snap/report-bug.md (+36/-0)
docs/snap/routing-tables.md (+96/-0)
run-tests.sh (+88/-0)
snap-common/bin/snap-config.sh (+7/-8)
snap-patch/resolvconf.patch (+31/-0)
snap/snapcraft.yaml (+21/-9)
spread.yaml (+85/-0)
tests/full/correct-dns-setup/task.yaml (+47/-0)
tests/full/immutable-netplan-config/task.yaml (+10/-0)
tests/full/ipv6-address-assignment/task.yaml (+27/-0)
tests/full/ipv6-router-advertisements/task.yaml (+70/-0)
tests/full/no-netplan-default-config/task.yaml (+41/-0)
tests/full/system-network-is-active/task.yaml (+9/-0)
tests/full/wol-enabled-by-default/task.yaml (+60/-0)
tests/lib/prepare-all.sh (+63/-0)
tests/lib/prepare.sh (+46/-0)
tests/lib/restore-each.sh (+40/-0)
tests/lib/snap-names.sh (+7/-0)
tests/lib/utilities.sh (+166/-0)
tests/main/aliases/task.yaml (+13/-0)
tests/main/can-exec-iptables/task.yaml (+11/-0)
tests/main/debug-config-option/task.yaml (+27/-0)
tests/main/documentation-builds/task.yaml (+14/-0)
tests/main/ethernet-managed-by-networkmanager/task.yaml (+16/-0)
tests/main/installation/task.yaml (+17/-0)
tests/main/set-hostname/task.yaml (+17/-0)
tests/main/static-ip-configuration/task.yaml (+49/-0)
tests/main/wifi-connect-secured-ap/task.yaml (+14/-0)
tests/main/wifi-powersave-config-option/task.yaml (+31/-0)
tests/main/wifi-wowlan-config-option/task.yaml (+77/-0)
tests/main/wifi-wowlan-enabled-correctly/task.yaml (+30/-0)
Reviewer Review Type Date Requested Status
Tony Espy Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+368284@code.launchpad.net

Commit message

* Add iptables to the snap
* Do not call nmcli while NM is not running
* Add spread tests

Description of the change

* Add iptables to the snap
* Do not call nmcli while NM is not running
* Add spread tests

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
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
Tony Espy (awe) wrote :

All looks good, however I have a question about your inclusion of resolvconf in the snap:

snap: add pppd and resolconf scripts to the snap

These files cannot be accessed from the snap anymore in UC18. Note that
the resolvconf scripts will be used only when installed in a UC16
system.

I think what you mean is that "these files" are no longer accessible from the core18 base snap.

Also instead of copying the scripts directly into the snap, a better approach would be to consume the resolvconf debian package via 'stage-packages'.

review: Needs Fixing
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

@Tony, correct, that is what I was referring to. I have changed the commit message to reflect that, and also added an explanation on why I included the resolvconf files:

<<
    snap: add pppd and resolvconf scripts to the snap

    These files cannot be accessed from the snap anymore as they are not
    included in the core18 base. Note that the resolvconf scripts will be
    used only when installed in a UC16 system.

    The resolvconf files had to be modified to use the right folders, that
    is the reason for including them instead of staging from the debian
    package.
>>

Revision history for this message
Tony Espy (awe) wrote :

> @Tony, correct, that is what I was referring to. I have changed the commit
> message to reflect that, and also added an explanation on why I included the
> resolvconf files:
>
> <<
> snap: add pppd and resolvconf scripts to the snap
>
> These files cannot be accessed from the snap anymore as they are not
> included in the core18 base. Note that the resolvconf scripts will be
> used only when installed in a UC16 system.
>
> The resolvconf files had to be modified to use the right folders, that
> is the reason for including them instead of staging from the debian
> package.
> >>

Sure, but you couldn't you do this by applying patches to the files pulled out of the stage-package? Using your approach we're flying blind wrt to resolvconf CVEs.

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

@Tony, fair enough. Done.

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Tony Espy (awe) wrote :

Thanks for the changes, LGTM!

review: Approve
Revision history for this message
Tony Espy (awe) wrote :

One last comment, could you use different feature name branches for your future MPs? Otherwise we end up with duplicate merge commit messages like this:

Merge remote-tracking branch 'abeato/test-ci' into snap-1.10

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/README.snap b/README-SNAP.txt
0similarity index 100%0similarity index 100%
1rename from README.snap1rename from README.snap
2rename to README-SNAP.txt2rename to README-SNAP.txt
diff --git a/debian/patches/series b/debian/patches/series
index 0632066..3267d3c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -16,3 +16,4 @@ disable-libnm-glib-wifi-ap-test.patch
16disable-libnm-glib-test-devices-array.patch16disable-libnm-glib-test-devices-array.patch
17add-snap-support.patch17add-snap-support.patch
18disable-tests-that-fail-under-launchpad-builds.patch18disable-tests-that-fail-under-launchpad-builds.patch
19snap-support-ppp.patch
diff --git a/debian/patches/snap-support-ppp.patch b/debian/patches/snap-support-ppp.patch
19new file mode 10064420new file mode 100644
index 0000000..5b13a63
--- /dev/null
+++ b/debian/patches/snap-support-ppp.patch
@@ -0,0 +1,134 @@
1Index: build/src/ppp/nm-ppp-manager-call.c
2===================================================================
3--- build.orig/src/ppp/nm-ppp-manager-call.c
4+++ build/src/ppp/nm-ppp-manager-call.c
5@@ -30,7 +30,7 @@
6 #include "nm-core-utils.h"
7 #include "nm-ppp-plugin-api.h"
8
9-#define PPP_PLUGIN_PATH NMPLUGINDIR "/libnm-ppp-plugin.so"
10+#define PPP_PLUGIN_PATH "libnm-ppp-plugin.so"
11
12 /*****************************************************************************/
13
14@@ -39,42 +39,45 @@ static NMPPPOps *ppp_ops = NULL;
15 NMPPPManager *
16 nm_ppp_manager_create (const char *iface, GError **error)
17 {
18- NMPPPManager *ret;
19+ NMPPPManager *ret = NULL;
20 GModule *plugin;
21 GError *error_local = NULL;
22 NMPPPOps *ops;
23 struct stat st;
24 int errsv;
25+ char *libnm_ppp_path;
26+
27+ libnm_ppp_path = g_strdup_printf ("%s/%s", nm_utils_get_plugin_dir (), PPP_PLUGIN_PATH);
28
29 if (G_UNLIKELY (!ppp_ops)) {
30- if (stat (PPP_PLUGIN_PATH, &st) != 0) {
31+ if (stat (libnm_ppp_path, &st) != 0) {
32 errsv = errno;
33- g_set_error_literal (error,
34- NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN,
35- "the PPP plugin " PPP_PLUGIN_PATH " is not installed");
36- return NULL;
37+ g_set_error (error,
38+ NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN,
39+ "the PPP plugin %s is not installed", libnm_ppp_path);
40+ goto end;
41 }
42
43- if (!nm_utils_validate_plugin (PPP_PLUGIN_PATH, &st, &error_local)) {
44+ if (!nm_utils_validate_plugin (libnm_ppp_path, &st, &error_local)) {
45 g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN,
46- "could not load the PPP plugin " PPP_PLUGIN_PATH ": %s",
47- error_local->message);
48+ "could not load the PPP plugin %s: %s",
49+ libnm_ppp_path, error_local->message);
50 g_clear_error (&error_local);
51- return NULL;
52+ goto end;
53 }
54
55- plugin = g_module_open (PPP_PLUGIN_PATH, G_MODULE_BIND_LOCAL);
56+ plugin = g_module_open (libnm_ppp_path, G_MODULE_BIND_LOCAL);
57 if (!plugin) {
58 g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN,
59- "could not load the PPP plugin " PPP_PLUGIN_PATH ": %s",
60- g_module_error ());
61- return NULL;
62+ "could not load the PPP plugin %s: %s",
63+ libnm_ppp_path, g_module_error ());
64+ goto end;
65 }
66
67 if (!g_module_symbol (plugin, "ppp_ops", (gpointer) &ops)) {
68 g_set_error (error, NM_MANAGER_ERROR, NM_MANAGER_ERROR_MISSING_PLUGIN,
69 "error loading the PPP plugin: %s", g_module_error ());
70- return NULL;
71+ goto end;
72 }
73
74 /* after loading glib types from the plugin, we cannot unload the library anymore.
75@@ -90,11 +93,14 @@ nm_ppp_manager_create (const char *iface
76
77 ppp_ops = ops;
78
79- nm_log_info (LOGD_CORE | LOGD_PPP, "loaded PPP plugin " PPP_PLUGIN_PATH);
80+ nm_log_info (LOGD_CORE | LOGD_PPP, "loaded PPP plugin %s", libnm_ppp_path);
81 }
82
83 ret = ppp_ops->create (iface);
84 g_return_val_if_fail (ret, NULL);
85+
86+end:
87+ g_free (libnm_ppp_path);
88 return ret;
89 }
90
91Index: build/src/nm-core-utils.c
92===================================================================
93--- build.orig/src/nm-core-utils.c
94+++ build/src/nm-core-utils.c
95@@ -1171,10 +1171,38 @@ const char *const NM_PATHS_DEFAULT[] = {
96 NULL,
97 };
98
99+const char *const *
100+utils_get_search_paths(void)
101+{
102+ static char **paths;
103+
104+ const char *snap_path;
105+
106+ if (paths)
107+ return (const char *const *) paths;
108+
109+ snap_path = getenv("SNAP");
110+ if (snap_path) {
111+ unsigned np, i;
112+
113+ np = g_strv_length((char **) NM_PATHS_DEFAULT);
114+ paths = malloc(sizeof(char *)*(np*2 + 1));
115+ for (i = 0; i < np; ++i) {
116+ paths[i] = g_strdup_printf("%s%s", snap_path, NM_PATHS_DEFAULT[i]);
117+ paths[np + i] = g_strdup(NM_PATHS_DEFAULT[i]);
118+ }
119+ paths[2*np] = NULL;
120+ } else {
121+ paths = g_strdupv((char **) NM_PATHS_DEFAULT);;
122+ }
123+
124+ return (const char *const *) paths;
125+}
126+
127 const char *
128 nm_utils_find_helper(const char *progname, const char *try_first, GError **error)
129 {
130- return nm_utils_file_search_in_paths (progname, try_first, NM_PATHS_DEFAULT, G_FILE_TEST_IS_EXECUTABLE, NULL, NULL, error);
131+ return nm_utils_file_search_in_paths (progname, try_first, utils_get_search_paths (), G_FILE_TEST_IS_EXECUTABLE, NULL, NULL, error);
132 }
133
134 /*****************************************************************************/
diff --git a/docs/snap/configure-cellular-connections.md b/docs/snap/configure-cellular-connections.md
0new file mode 100644135new file mode 100644
index 0000000..215f2dc
--- /dev/null
+++ b/docs/snap/configure-cellular-connections.md
@@ -0,0 +1,124 @@
1---
2title: "Configure Cellular Connections"
3table_of_contents: False
4---
5
6# Configure Cellular Connections
7
8Check whether a modem was properly detected via:
9
10```
11$ sudo modem-manager.mmcli -L
12Found 1 modems:
13 /org/freedesktop/ModemManager1/Modem/0 [description]
14```
15
16In this case we have just one modem, with index 0 (the number at the end of the DBus object path).
17
18Show detailed information about the modem:
19
20```
21$ sudo modem-manager.mmcli -m 0
22/org/freedesktop/ModemManager1/Modem/0 (device id '871faa978a12ccb25b9fa30d15667571ab38ed88')
23 -------------------------
24 Hardware | manufacturer: 'ZTE INCORPORATED'
25 | model: 'MF626'
26 | revision: 'MF626V1.0.0B06'
27 | supported: 'gsm-umts'
28 | current: 'gsm-umts'
29 | equipment id: '357037039840195'
30 -------------------------
31 System | device: '/sys/devices/pci0000:00/0000:00:01.2/usb1/1-1'
32 | drivers: 'option1'
33 | plugin: 'ZTE'
34 | primary port: 'ttyUSB3'
35 | ports: 'ttyUSB0 (qcdm), ttyUSB1 (at), ttyUSB3 (at)'
36 -------------------------
37 Numbers | own : 'unknown'
38 -------------------------
39 Status | lock: 'sim-pin'
40 | unlock retries: 'sim-pin (3), sim-puk (10)'
41 | state: 'locked'
42 | power state: 'on'
43 | access tech: 'unknown'
44 | signal quality: '0' (cached)
45 -------------------------
46 Modes | supported: 'allowed: any; preferred: none'
47 | current: 'allowed: any; preferred: none'
48 -------------------------
49 Bands | supported: 'unknown'
50 | current: 'unknown'
51 -------------------------
52 IP | supported: 'none'
53 -------------------------
54 SIM | path: '/org/freedesktop/ModemManager1/SIM/0'
55
56 -------------------------
57 Bearers | paths: 'none'
58```
59
60In this case we can see that the SIM has PIN locking enabled and its state is
61‘locked’. To enter the PIN, we need to know the SIM index, which in this
62case is 0 (it is the number at the end of /org/freedesktop/ModemManager1/SIM/0).
63Once the index is known, we can enter the SIM PIN with:
64
65```
66$ sudo modem-manager.mmcli -i 0 --pin=<PIN>
67successfully sent PIN code to the SIM
68```
69
70Some more commands for handling SIM PINs include:
71
72```
73$ sudo modem-manager.mmcli -i 0 --pin=<PIN> --enable-pin
74$ sudo modem-manager.mmcli -i 0 --pin=<PIN> --disable-pin
75$ sudo modem-manager.mmcli -i 0 --pin=<PIN> --change-pin=<NEW_PIN>
76$ sudo modem-manager.mmcli -i 0 --puk=<PUK>
77```
78
79Which respectively enables PIN locking, disables PIN locking, changes the PIN code,
80and unlocks a [PUK](https://en.wikipedia.org/wiki/Personal_unblocking_code)-locked SIM.
81
82After that we can add a cellular connection with:
83
84```
85$ nmcli c add type gsm ifname <interface> con-name <name> apn <operator_apn>
86$ nmcli r wwan on
87```
88
89where &lt;interface&gt; is the string listed as “primary port” in the output from 'sudo mmcli -m &lt;N&gt;'
90(as previously described),
91&lt;name&gt; is an arbitrary name used to identify the connection, and &lt;operator_apn&gt; is
92the APN name for your cellular data plan. Note that &lt;interface&gt; is usually a serial
93port with pattern /dev/tty*, not a networking interface. The reason for ModemManager
94to use that instead of the networking interface is that this last one can appear/disappear
95dynamically while the ports do not if the hardware configuration remains unchanged.
96For instance, the networking interface can be ppp0, ppp1, etc., and it might be
97different each time it is possible to have other ppp connections with, say, VPNs.
98
99After executing these commands, NetworkManager will automatically try to bring up
100the cellular connection whenever ModemManager reports that the modem has
101registered (the state of the modem can be checked with the previously introduced
102command “sudo modem-manager.mmcli -m &lt;N&gt;”). When done successfully, NetworkManager
103will create routes for the new network interface, with less priority than
104Ethernet or WiFi interfaces. To disable the connection, we can do:
105
106```
107$ nmcli r wwan off
108```
109
110or change the autoconnect property and turn the connection off if we need more
111fine-grained control:
112
113```
114$ nmcli c modify <name> connection.autoconnect [yes|no]
115$ nmcli c down <name>
116```
117
118Finally, note that we can provide the PIN (so it is entered automatically) or more
119needed APN provisioning information when creating/modifying the WWAN connection.
120For instance:
121
122```
123$ nmcli c add type gsm ifname <interface> con-name <name> apn <operator_apn> username <user> password <password> pin <PIN>
124```
diff --git a/docs/snap/configure-wifi-connections.md b/docs/snap/configure-wifi-connections.md
0new file mode 100644125new file mode 100644
index 0000000..4602dfd
--- /dev/null
+++ b/docs/snap/configure-wifi-connections.md
@@ -0,0 +1,80 @@
1---
2title: "Configure WiFi Connections"
3table_of_contents: True
4---
5
6# Configure WiFi Connections
7
8This section explains how to establish a WiFi connection. It covers creating and
9modyfying connections as well as directly connecting.
10
11## Establish a Wireless Connection
12
13This section will show how to establish a wifi connection to the wireles
14network. Note that directly connecting will implicitly create a connection (that
15can be seen with "nmcli c"). The naming of such will follow "SSID N" pattern,
16where N is a number.
17
18First, determine the name of the WiFi interface:
19
20```
21$ nmcli d
22DEVICE TYPE STATE CONNECTION
23...
24wlan0 wifi disconnected --
25```
26
27Make sure the WiFi radio is on (which is its default state):
28
29```
30$ nmcli r wifi on
31```
32
33Then, list the available WiFi networks:
34
35```
36$ nmcli d wifi list
37* SSID MODE CHAN RATE SIGNAL BARS SECURITY
38 ...
39 my_wifi Infra 5 54 Mbit/s 89 ▂▄▆█ WPA2
40```
41
42As an example, to connect to the access point 'my_wifi', you would use the
43following command:
44
45```
46$ nmcli d wifi connect my_wifi password <password>
47```
48
49&lt;password&gt; is the password for the connection which needs to have 8-63
50characters or 64 hexadecimal characters to specify a full 256-bit key.
51
52## Connect to a Hidden Network
53
54A hidden network is a normal wireless network that simply does not broadcast
55it's SSID unless solicited. This means that its name cannot be searched and
56must be known from some other source.
57
58Issue the following command to create a connection associated with a hidden
59network &lt;ssid&gt;:
60
61```
62$ nmcli c add type wifi con-name <name> ifname wlan0 ssid <ssid>
63$ nmcli c modify <name> wifi-sec.key-mgmt wpa-psk wifi-sec.psk <password>
64```
65
66Now you can establish a connection by typing:
67
68```
69$ nmcli c up <name>
70```
71
72&lt;name&gt; is an arbitrary name given to the connection and &lt;password&gt;
73is the password to the network. It needs to have between 8-63 characters or 64
74hexadecimal characters in order to specify a full 256-bit key.
75
76## Further Information
77
78You will find further information and more detailed examples on following pages:
79
80* <https://developer.gnome.org/NetworkManager/unstable/nmcli.html>
diff --git a/docs/snap/edit-connections.md b/docs/snap/edit-connections.md
0new file mode 10064481new file mode 100644
index 0000000..0c9d087
--- /dev/null
+++ b/docs/snap/edit-connections.md
@@ -0,0 +1,155 @@
1---
2title: "Edit Connections"
3table_of_contents: True
4---
5
6# Edit Connections
7
8This part will show you how to use a network-manager built-in editor to modify
9the connections as well as provide a reference for setting some of the
10settings.
11
12## Using nmcli Console
13
14Aside from offering the possibility to manage and modify the network connections
15using the command-line, network-manager offers a built-in, interactive
16console to achieve the same. In order to use it type:
17
18```
19$ nmcli connection edit
20```
21
22It will bring up an interactive console. In the first step you will be prompted
23to enter the connection type. The list of valid connection types will be
24displayed on the screen. Once you select one you will be taken to the nmcli
25console where you have the possibility to modify its parameters.
26
27Alternatively, if you know the valid connection types, you could jump straight
28to the nmcli console by providing the type as a parameter:
29
30```
31$ nmcli connection edit type <type>
32```
33
34where &lt;type&gt; must be a valid connection type such as 'wifi'.
35
36An attempt to edit the wifi connection type would look like:
37
38```
39$ nmcli c edit
40
41Valid connection types: generic, 802-3-ethernet (ethernet), pppoe,
42802-11-wireless (wifi), wimax, gsm, cdma, infiniband, adsl, bluetooth, vpn,
43802-11-olpc-mesh (olpc-mesh), vlan, bond, team, bridge, bond-slave, team-slave,
44bridge-slave, no-slave, tun, ip-tunnel, macvlan, vxlan
45Enter connection type: wifi
46
47===| nmcli interactive connection editor |===
48
49Adding a new '802-11-wireless' connection
50
51Type 'help' or '?' for available commands.
52Type 'describe [<setting>.<prop>]' for detailed property description.
53
54You may edit the following settings: connection, 802-11-wireless (wifi),
55802-11-wireless-security (wifi-sec), 802-1x, ipv4, ipv6
56nmcli>
57```
58
59From now on it is possible to edit the wifi connection settings. The list of
60settings is provided as in the example above. The nmcli console offers a set of
61commands that can be used to navigate between settings. To get the list of
62available commands type 'help' or '?'
63
64```
65nmcli> ?
66------------------------------------------------------------------------------
67---[ Main menu ]---
68goto [<setting> | <prop>] :: go to a setting or property
69remove <setting>[.<prop>] | <prop> :: remove setting or reset property value
70set [<setting>.<prop> <value>] :: set property value
71describe [<setting>.<prop>] :: describe property
72print [all | <setting>[.<prop>]] :: print the connection
73verify [all | fix] :: verify the connection
74save [persistent|temporary] :: save the connection
75activate [<ifname>] [/<ap>|<nsp>] :: activate the connection
76back :: go one level up (back)
77help/? [<command>] :: print this help
78nmcli <conf-option> <value> :: nmcli configuration
79quit :: exit nmcli
80------------------------------------------------------------------------------
81nmcli>
82```
83
84## Change Connection Details
85
86This section will show how to change some of the connection details including
87IPv4 and IPv6 settings.
88
89It is important to understand that every option can be modified using either the
90command-line or the editor. The advantage of the editor is that it shows which
91options are availabe for modification in contrast to the command-line which does
92not.
93
94It is possible however to learn about the available settings from the
95command-line by printing the connection details. Type:
96
97```
98$ nmcli c show <name>
99```
100
101where &lt;name&gt; is the connection name.
102
103The above will bring a fairly long list of text on the terminal, therefore it is
104best to either use a pager or grep to make the results manageable.
105
106### IPv4 and IPv6 Options
107
108For example for IPv4 settings one would do:
109
110```
111$ nmcli c show <name> | grep ipv4
112ipv4.method: auto
113ipv4.dns:
114ipv4.dns-search:
115ipv4.dns-options: (default)
116ipv4.addresses:
117ipv4.gateway: --
118ipv4.routes:
119ipv4.route-metric: -1
120ipv4.ignore-auto-routes: no
121ipv4.ignore-auto-dns: no
122ipv4.dhcp-client-id: --
123ipv4.dhcp-timeout: 0
124ipv4.dhcp-send-hostname: yes
125ipv4.dhcp-hostname: --
126ipv4.dhcp-fqdn: --
127ipv4.never-default: no
128ipv4.may-fail: yes
129ipv4.dad-timeout: -1 (default)
130```
131
132For example setting up the DNS server would require typing:
133
134```
135$ nmcli c modify <name> ipv4.dns "8.8.8.8"
136```
137
138The rest of the settings can be modified in the same fashion.
139
140### WiFi Powersave Option
141
142The WiFi powersave option can have one of the following values:
143
144| Value | Meaning |
145|-------|---------------------------------------------------|
146| 0 | Default |
147| 1 | Ignore, do not touch currently configured setting |
148| 2 | Disable |
149| 3 | Enable |
150
151Changing it is as simple as:
152
153```
154$ nmcli c modify <name> 802-11-wireless.powersave 2
155```
diff --git a/docs/snap/enable-ethernet-support.md b/docs/snap/enable-ethernet-support.md
0new file mode 100644156new file mode 100644
index 0000000..1aebf45
--- /dev/null
+++ b/docs/snap/enable-ethernet-support.md
@@ -0,0 +1,38 @@
1---
2title: "Enable Ethernet Support"
3table_of_contents: False
4---
5
6# Enable Ethernet Support
7
8The default netplan configuration files in Ubuntu Core leave management of
9Ethernet devices to networkd. Therefore, to avoid conflicts, the
10network-manager snap does not manage Ethernet devices by default. The user has
11to take care to enable it after installation if desired.
12
13## Configure System for Ethernet Support
14
15Before following the instructions below, backup the contents of /etc/netplan to
16be able to restore it at a later point.
17
18Also, note that this change might lead to a system without properly configured
19network connections, which would lead to problems accessing the device, so be
20careful when doing this.
21
22To enable ethernet support, you have to set the `ethernet.enable` property to
23`true`. See how to do this [here](reference/configuration/ethernet_support.md).
24When this is done, configuration files for netplan are created so
25network-manager is the default netplan renderer. When set to `false` (the
26default), the NM snap explicitly disables the management of ethernet devices to
27avoid conflicts with networkd.
28
29Rebooting the system will be needed for the changes to take effect.
30
31After the reboot, NetworkManager should automatically set up attached Ethernet
32ports or use existing netplan configuration files to setup connections.
33
34Once logged into the system you may check the current connection status by
35
36```
37$ nmcli c show
38```
diff --git a/docs/snap/explore-network-status.md b/docs/snap/explore-network-status.md
0new file mode 10064439new file mode 100644
index 0000000..7b43950
--- /dev/null
+++ b/docs/snap/explore-network-status.md
@@ -0,0 +1,52 @@
1---
2title: "Explore Network Status"
3table_of_contents: False
4---
5
6# Exploring Network Status
7
8This section shows how to use the nmcli command-line tool to examine the status
9of NetworkManager’s connections and devices.
10
11Show the status of devices known to NetworkManager:
12
13```
14$ nmcli d
15```
16
17Show more information for this option:
18
19```
20$ nmcli d --help
21```
22
23Show the current status of each of NetworkManager’s connections:
24
25```
26$ nmcli c
27```
28
29Command “c” is for connections but is a abbreviated form of the real command
30"connections". As for the devices command, “--help” shows more information for
31this option. Finally, we can see the state of radio interfaces, including WiFi
32and WWAN (cellular) with:
33
34```
35$ nmcli r
36WIFI-HW WIFI WWAN-HW WWAN
37enabled enabled enabled enabled
38```
39
40It is important to make sure that WiFi/WWAN radios are enabled so the respective
41connection types can establish a connection (we will specify how to this in
42following sections). As with the other commands, “--help” shows usage information.
43
44Observe NetworkManage activity (changes in connectivity state, devices or
45connection properties):
46
47```
48$ nmcli monitor
49```
50
51See nmcli connection monitor and nmcli device monitor to watch for changes in
52certain connections or devices.
diff --git a/docs/snap/faq.md b/docs/snap/faq.md
0new file mode 10064453new file mode 100644
index 0000000..ede5b21
--- /dev/null
+++ b/docs/snap/faq.md
@@ -0,0 +1,18 @@
1---
2title: "FAQ"
3table_of_contents: False
4---
5
6# FAQ
7
8This section covers some of the most commonly encountered problems and attempts
9to provide solutions for them.
10
11## Ethernet devices are not used
12
13### Possible cause: Ethernet support is disabled for NetworkManager
14
15By default the network-manager snap disables Ethernet support to avoid conflicts
16with networkd/netplan which are used by default on Ubuntu Core 16. See
17*[Enable Ethernet Support](enable-ethernet-support.md)* for details on how to
18enable it.
diff --git a/docs/snap/index.md b/docs/snap/index.md
0new file mode 10064419new file mode 100644
index 0000000..81dcc30
--- /dev/null
+++ b/docs/snap/index.md
@@ -0,0 +1,42 @@
1---
2title: "NetworkManager"
3table_of_contents: False
4---
5
6# About NetworkManager
7
8NetworkManager is a system network service that manages your network
9devices and connections, attempts to keep network connectivity active
10when available. It manages Ethernet, WiFi, mobile broadband (WWAN) and
11PPPoE devices while also providing VPN integration with a variety of
12different VPN serivces.
13
14By default network management on [Ubuntu Core](https://www.ubuntu.com/core) is
15handled by systemd's
16[networkd](https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html)
17and [netplan](https://launchpad.net/netplan). While NetworkManager has some
18support to handle netplan configuration files, Ethernet support is disabled by
19default and has to be turned on explicitly to avoid conflicts with existing
20network configuration.
21
22## What NetworkManager Offers
23
24The upstream NetworkManager project offers a wide range of features which are
25partially available in the snap version. However,
26as the snap should be always delivered in high quality we don't have yet all
27upstream features enabled.
28
29Currently we provide support for the following high level features:
30
31 * WiFi connectivity
32 * WWAN connectivity (together with ModemManager)
33 * Ethernet connectivity
34
35 Currently we do not support the following features:
36
37 * VPN
38
39## Upstream documentation
40
41Existing documentation from the upstream project can be found
42[here](https://wiki.gnome.org/Projects/NetworkManager).
diff --git a/docs/snap/installation.md b/docs/snap/installation.md
0new file mode 10064443new file mode 100644
index 0000000..b031d79
--- /dev/null
+++ b/docs/snap/installation.md
@@ -0,0 +1,62 @@
1---
2title: "Install NetworkManager"
3table_of_contents: True
4---
5
6# Install NetworkManager
7
8The NetworkManager snap is currently available from the Ubuntu Store. It can
9be installed on any system that supports snaps but is only recommended on
10[Ubuntu Core](https://www.ubuntu.com/core) at the moment.
11
12You can install the snap with the following command:
13
14```
15 $ snap install network-manager
16 network-manager 1.2.2-10 from 'canonical' installed
17```
18
19Although the network-manager snap is available from other channels (candidate, beta, edge),
20only the stable version should be used for production devices. Their meaning is internal
21to the development team of the network-manager snap.
22
23All necessary plugs and slots will be automatically connected within the
24installation process. You can verify this with:
25
26```
27$ snap interfaces network-manager
28Slot Plug
29:network-setup-observe network-manager
30:ppp network-manager
31network-manager:service network-manager:nmcli
32- network-manager:modem-manager
33```
34
35**NOTE:** The _network-manager:modem-manager_ plug only gets connected when the
36_modem-manager_ snap is installed too. Otherwise it stays disconnected.
37
38Once the installation has successfully finished the
39NetworkManager service is running in the background. You can check its current
40status with
41
42```
43 $ systemctl status snap.networkmanager
44 ● snap.networkmanager.service - Service for snap application networkmanager
45 Loaded: loaded (/etc/systemd/system/snap.networkmanager.service; enabled; vendor preset: enabled)
46 Active: active (running) since Thu 2017-02-16 09:59:39 UTC; 16s ago
47 Main PID: 1389 (networkmanager)
48 [...]
49```
50
51Now you have NetworkManager successfully installed.
52
53## Next Steps
54
55 * [Enable Ethernet Support](enable-ethernet-support.md)
56 * [Explore Network Status](explore-network-status.md)
57 * [Configure WiFi Connections](configure-wifi-connections.md)
58 * [Configure Cellular Connections](configure-cellular-connections.md)
59 * [Edit Network Connections](edit-connections.md)
60 * [Routing Tables](routing-tables.md)
61 * [Logging Messages](logging-messages.md)
62 * [Enable Debug Support](reference/snap-configuration/debug.md)
diff --git a/docs/snap/logging-messages.md b/docs/snap/logging-messages.md
0new file mode 10064463new file mode 100644
index 0000000..d242808
--- /dev/null
+++ b/docs/snap/logging-messages.md
@@ -0,0 +1,43 @@
1---
2title: "Logging Messages"
3table_of_contents: False
4---
5
6# Logging Messages
7
8This section will show how to modify the logging levels by NetworkManager.
9
10NetworkManager supports on the fly changing of the logging levels and allows for
11a fine control over what is logged.
12
13First check what is the current logging setup, type:
14
15```
16$ nmcli general logging
17```
18
19As a result you will be presented with the information about the current
20configuration:
21
22```
23LEVEL DOMAINS
24INFO PLATFORM,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,INFINIBAND,FIREWALL,ADSL,BOND,VLAN,BRIDGE,TEAM,CONCHECK,DCB,DISPATCH,AUDIT,SYSTEMD
25```
26
27It is possible to change the level either globally or for each domain
28separately. The command to achieve this is:
29
30```
31$ nmcli general logging [level <level> [domain <domain>]]
32```
33
34The &lt;level&gt; is the desired log level. You can choose from the following:
35
36* **ERR:** will log only critical errors
37* **WARN:** will log warnin messages
38* **INFO:** will log various informational messages
39* **DEBUG:** enables verbose logging for debugging purposes
40
41&lt;domain&gt; is the category of messages that shall be logged with given
42severity. **WIFI** will include only WiFi related messages, **IP4** will include
43only IPv4 related messages and so on..
diff --git a/docs/snap/metadata.yaml b/docs/snap/metadata.yaml
0new file mode 10064444new file mode 100644
index 0000000..82bf35f
--- /dev/null
+++ b/docs/snap/metadata.yaml
@@ -0,0 +1,49 @@
1site_title: NetworkManager documentation
2site_logo_url: https://assets.ubuntu.com/v1/c5cb0f8e-picto-ubuntu.svg
3navigation:
4 - title: Introduction
5 children:
6 - title: About NetworkManager
7 location: index.md
8 - title: Install & Configure
9 children:
10 - title: Install NetworkManager
11 location: installation.md
12 - title: Explore Network Status
13 location: explore-network-status.md
14 - title: Configure WiFi Connections
15 location: configure-wifi-connections.md
16 - title: Configure Cellular Connections
17 location: configure-cellular-connections.md
18 - title: Enable Ethernet Support
19 location: enable-ethernet-support.md
20 - title: Edit Connections
21 location: edit-connections.md
22 - title: Routing Tables
23 location: routing-tables.md
24 - title: Logging Messages
25 location: logging-messages.md
26 - title: Reference
27 children:
28 - title: Snap Configuration
29 children:
30 - title: Ethernet Support
31 location: reference/configuration/ethernet_support.md
32 - title: Debug
33 location: reference/snap-configuration/debug.md
34 - title: Wake on WLAN
35 location: reference/snap-configuration/wowlan.md
36 - title: WiFi Powersave
37 location: reference/snap-configuration/wifi-powersave.md
38 - title: Available Commands
39 location: reference/available-commands.md
40 - title: DBUS API
41 location: reference/dbus-api.md
42 - title: Troubleshoot
43 children:
44 - title: FAQ
45 location: faq.md
46 - title: Release Notes
47 location: release-notes.md
48 - title: Report a Bug
49 location: report-bug.md
diff --git a/docs/snap/reference/available-commands.md b/docs/snap/reference/available-commands.md
0new file mode 10064450new file mode 100644
index 0000000..18b3cec
--- /dev/null
+++ b/docs/snap/reference/available-commands.md
@@ -0,0 +1,19 @@
1---
2title: Available Commands
3table_of_contents: true
4---
5
6# Available Commands
7
8The NetworkManager upstream project comes with a few commands which can be used
9to control and manage the NetworkManager service. This page gives a short overview
10of those commands which are available as part of the snap and what they are used for.
11Further details about their usage is given on linked pages.
12
13## nmcli
14
15The nmcli command offers a command-line based way to control and manage the
16NetworkManager service.
17
18An explanatory description of the command and available options are available
19[here](https://developer.gnome.org/NetworkManager/1.2/nmcli.html)
diff --git a/docs/snap/reference/configuration/ethernet_support.md b/docs/snap/reference/configuration/ethernet_support.md
0new file mode 10064420new file mode 100644
index 0000000..fbc5929
--- /dev/null
+++ b/docs/snap/reference/configuration/ethernet_support.md
@@ -0,0 +1,47 @@
1---
2title: Ethernet Support
3table_of_contents: true
4---
5
6# Ethernet Support
7
8*Available since:* 1.2.2-12
9
10The NetworkManager snap provides a configuration option to adjust
11if it should manage ethernet network connections.
12
13By default the NetworkManager snap **does not** manage ethernet network
14devices as it would conflict with the default network management in
15Ubuntu Core which is handled by [netplan](https://launchpad.net/netplan) and
16[networkd](https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html).
17
18## Enable Ethernet Support
19
20To enable management of ethernet network devices the snap provides the
21*ethernet.enable* configuration option.
22
23This configuration option accepts the following values
24
25 * **false (default):** Ethernet support is disabled. All network
26 devices matching the expression 'en*' or 'eth*' will be ignored.
27 * **true:** All ethernet devices available on the system will be
28 managed by NetworkManager. networkd will not manage any of these
29 anymore.
30
31Changing the *ethernet* configuration option needs a reboot of the
32device it's running on.
33
34After the device has rebooted ethernet support is enabled NetworkManager will
35take over management of all available ethernet network devices on the device.
36
37NetworkManager will reuse existing configurations files from */etc/netplan*
38when ethernet support is enabled. Those will marked as immutable inside
39NetworkManager and any changes need to be written manually into the relevant
40files in */etc/netplan*.
41
42Example:
43
44```
45 $ snap set network-manager ethernet.enable=true
46 $ sudo reboot
47```
diff --git a/docs/snap/reference/dbus-api.md b/docs/snap/reference/dbus-api.md
0new file mode 10064448new file mode 100644
index 0000000..7cece10
--- /dev/null
+++ b/docs/snap/reference/dbus-api.md
@@ -0,0 +1,9 @@
1---
2title: "DBUS API"
3table_of_contents: False
4---
5
6# DBUS API
7
8Documentation of the DBus API is provided by the NetworkManager upstream project
9[here](https://developer.gnome.org/NetworkManager/1.2/spec.html).
diff --git a/docs/snap/reference/snap-configuration/debug.md b/docs/snap/reference/snap-configuration/debug.md
0new file mode 10064410new file mode 100644
index 0000000..e16d17c
--- /dev/null
+++ b/docs/snap/reference/snap-configuration/debug.md
@@ -0,0 +1,51 @@
1---
2title: Debug
3table_of_contents: True
4---
5
6# Debug
7
8Debug is a feature that controls the amount of logs produced by the network-manager
9snap. It is useful for collecting information required to either report a bug or
10investigate a network-manager failure (if happens).
11
12It is disabled by default and has to be explicitely turned on for usage.
13
14Note that the debug logs may contain sensitive information.
15
16## Enable Debug
17
18The network-manager snap provides a single configuration option which can be used to
19turn the debug feature either on or off:
20
21 * **debug.enable**
22
23The option takes a boolean value. The meaning of the possible values are:
24
25 * **true:** Enable logging debug information
26 * **false (default):** Disable logging debug information
27
28Changing the **debug** configuration option has immediate effect and also
29affects future executions of the NM daemon.
30
31**Example:** Enable debug feature
32
33```
34$ snap set network-manager debug.enable=true
35```
36
37<br/>
38**Example:** Disable debug feature.
39
40```
41$ snap set network-manager debug.enable=false
42```
43
44## Viewing logs
45
46The debug information, when enabled, will be available in the journal and can
47be viewed with:
48
49```
50$ journalctl --no-pager -u snap.network-manager.networkmanager.service
51```
diff --git a/docs/snap/reference/snap-configuration/wifi-powersave.md b/docs/snap/reference/snap-configuration/wifi-powersave.md
0new file mode 10064452new file mode 100644
index 0000000..8b9e68f
--- /dev/null
+++ b/docs/snap/reference/snap-configuration/wifi-powersave.md
@@ -0,0 +1,38 @@
1---
2title: WiFi Powersave
3table_of_contents: True
4---
5
6# WiFi Powersave
7
8WiFi Powersave is a feature that allows a device to suspend its radio activity
9after a fixed period of inactivity. The device remains idle for a fixed time,
10usualy about 100ms, and once it is reached it wakes up to check if the
11infrastructure has any packets queued up for it.
12
13The NetworkManager snap allows to configure this option by either enabling or
14disabling the powersave feature.
15
16You can read more about the WiFi Powersave feature on the following sites:
17
18*
19<https://wireless.wiki.kernel.org/en/developers/documentation/ieee80211/power-savings>
20
21### Enable WiFi Powersave
22
23To allow users to enable or disable WiFi Powersave, the snap provides a single
24configuration option:
25
26* wifi.powersave
27
28Option can be set via the configuration API snaps provide. See
29<https://docs.ubuntu.com/core/en/guides/build-device/config-hooks> for more
30details.
31
32#### wifi.powersave
33
34This configuration option accepts the following values:
35
36* **disabled (default):** WiFi powersaving is disabled
37* **enabled:** WiFi powersaving is enabled
38
diff --git a/docs/snap/reference/snap-configuration/wowlan.md b/docs/snap/reference/snap-configuration/wowlan.md
0new file mode 10064439new file mode 100644
index 0000000..2ae0791
--- /dev/null
+++ b/docs/snap/reference/snap-configuration/wowlan.md
@@ -0,0 +1,126 @@
1---
2title: Wake on WLAN
3table_of_contents: True
4---
5
6# Wake on WLAN
7
8*Available since:* 1.2.2-11
9
10Wake on WLAN (called WoWLAN in the following) is a feature which allows a device
11to be woken up from standby power states to faciliate device management. It is based
12on the well well-established standard for Wake on LAN. The functionality is not entirely
13equivalent to Wake on LAN and there are some limitations.
14
15The NetworkManager snap allows its users to configure one or more triggers to allow
16the device it operates on to be woken up remotely.
17
18An important precondition for WoWLAN to work is that your device's kernel WiFi driver
19has support for it. If it is has support for WoWLAN it may only support a subset
20of possible triggers.
21
22You can read more about the kernel side implementation on the following sites:
23
24 * <https://wireless.wiki.kernel.org/en/users/documentation/wowlan>
25
26### Enable Wake on WLAN Globally
27
28To allow users to enable or disable WoWLAN, the snap provides two configuration
29options:
30
31 * **wifi.wake-on-wlan**
32 * **wifi.wake-on-wlan-password**
33
34Both options can be set via the configuration API snaps provide. See
35<https://docs.ubuntu.com/core/en/guides/build-device/config-hooks> for more
36details.
37
38Both configuration options will affect all wireless network devices. If you
39want to change it just for a single wireless connection please have a look at
40the chapter [Per Connection Configuration](#per-connection-configuration) below.
41
42
43#### wifi.wake-on-wlan
44
45This configuration option accepts the following values:
46
47 * **disabled (default):** Wake on WLAN is disabled for all wireless network devices.
48 * **any:** Wake on WLAN is enabled and any possible trigger will cause the system to wake up.
49 * **disconnect:** If a connection to a station gets disconnected the device will be woken up.
50 * **magic:** Wake on WLAN is enabled and only a received magic packet will cause the
51 system to wake up. The magic packet has the same structure as the one
52 used for Wake on LAN. For more details see <https://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet>
53 The content of the magic packet can be extended with the
54 wifi.wake-on-wlan-password option to require the client to send a
55 specific byte sequence functioning as a password so that not anyone
56 unpriviledged can wake up the system.
57 * **gtk-rekey-failure:** A failure of a GTK rekey operation will cause the device to wake up.
58 * **4way-handshake:** Reiteration of the 4way handshake will cause the device to wake up.
59 * **rfkill-release:** Release of a rfkill will cause the device to wake up.
60 * **tcp:** Any incoming TCP packet will cause the device to wake up.
61
62Example:
63
64```
65 $ snap set network-manager wifi.wake-on-wlan=magic
66```
67
68#### wifi.wake-on-wlan-password
69
70This configuration option accepts a textual value. If specified, the value will
71be used in addition to the wireless device MAC address to function as a password
72that disallows unpriviledged actors to wake up the device.
73
74Example:
75
76```
77 $ snap set network-manager wifi.wake-on-wlan-password=MyPassword
78```
79</br>
80### Per Connection Configuration
81
82To configure WoWLAN per connection you have to use the *nmcli* utility which comes
83with the NetworkManager snap. It allows you to configure the same two options
84as the snap accepts. However, the *wifi.wake-on-wlan* option takes a numeric value
85instead of a textual one.
86
87The *wifi.wake-on-wlan* option accepts the following values (see above for a detailed
88description of each value)
89
90 * **0:** disabled
91 * **1:** Use global default configuration
92 * **2:** any
93 * **4:** disconnect
94 * **8:** magic
95 * **16:** gtk-rekey-failure
96 * **32:** 4way-handshake
97 * **128:** rfkill-release
98 * **256:** tcp
99
100The *wifi.wake-on-wlan-password* option accepts the same values as the snap
101configuration option.
102
103Example:
104
105```
106 $ nmcli c modify my-connection wifi.wake-on-wlan 2
107 $ nmcli c modify my-connection wifi.wake-on-wlan-password Test1234
108```
109</br>
110### Verify WoWLAN Configuration
111
112NetworkManager will use the kernel to configure WoWLAN on the hardware level.
113The *iw* utility provides a simple way to verify the right option is configured.
114
115If you don't have the *iw* utility on your system you can install it with the
116*wireless-tools* snap.
117
118```
119 $ snap install --devmode wireless-tools
120 $ sudo wireless-tools.iw phy phy0 wowlan show
121 WoWLAN is enabled:
122 * wake up on magic packet
123```
124
125See the help output of the *iw* command for more documentation and available
126options.
diff --git a/docs/snap/release-notes.md b/docs/snap/release-notes.md
0new file mode 100644127new file mode 100644
index 0000000..8a96cee
--- /dev/null
+++ b/docs/snap/release-notes.md
@@ -0,0 +1,35 @@
1---
2title: "Release Notes"
3table_of_contents: False
4---
5
6# Release Notes
7
8The version numbers mentioned on this page correspond to those released in the
9Ubuntu snap store.
10
11You can check with the following command which version you have currently
12installed:
13
14```
15$ snap info network-manager
16name: network-manager
17summary: "Network management based on NeworkManager"
18publisher: canonical
19description: |
20 Network management of wired Ethernet, WiFi and mobile data connection based on
21 NetworkManager and ModemManager
22commands:
23 - nmcli
24tracking: stable
25installed: 1.2.2-10 (73) 5MB -
26[...]
27```
28</br>
29## 1.2.2-11
30
31 * Wake-on-WLAN can be configured via snap/nmcli
32 * Automatic reconfiguration of network devices when device comes back from a
33 low power state
34 * Snap alias available for nmcli
35 * WiFi powersave is configurable via snap configuration
diff --git a/docs/snap/report-bug.md b/docs/snap/report-bug.md
0new file mode 10064436new file mode 100644
index 0000000..ba02a2e
--- /dev/null
+++ b/docs/snap/report-bug.md
@@ -0,0 +1,36 @@
1---
2title: "Report a Bug"
3table_of_contents: False
4---
5
6# Report a Bug
7
8Bugs can be reported [here](https://bugs.launchpad.net/snappy-hwe-snaps/+filebug).
9
10When submitting a bug report, please attach system log coming from the journal:
11
12 * $ journalctl --no-pager > system-log
13
14And the output of the following two commands:
15
16```
17$ nmcli d
18$ nmcli c
19```
20
21It is a good idea to set the log level to DEBUG so that the verbose information
22is provided. To do this for NetworkManager please see the [Logging Messages](logging-messages.md)
23page.
24
25If there is a modem and the modem-manager snap is installed, also add the output
26of
27
28```
29$ sudo modem-manager.mmcli -m <N>
30```
31
32With being <N> the modem number as reported by
33
34```
35$ sudo modem-manager.mmcli -L
36```
diff --git a/docs/snap/routing-tables.md b/docs/snap/routing-tables.md
0new file mode 10064437new file mode 100644
index 0000000..85b4ff8
--- /dev/null
+++ b/docs/snap/routing-tables.md
@@ -0,0 +1,96 @@
1---
2title: "Routing Tables"
3table_of_contents: True
4---
5
6# Routing Tables
7
8This section describes the way to setup routing table as well as it explains the
9logic used to prioritize interfaces.
10
11The routing table is stored in the kernel which merely acts upon it. The route
12itself is set by the user-space tools. There is no preference as any tool
13created for this reason will do. It can be either a DHCP client, ip command or
14route command.
15
16It is important to understand that NetworkManager changes the routing table
17whenever it creates a new connection.
18
19Routing table acts as a junction and is there to show where the different
20network subnets will be routed to. An example of a routing table is shown below.
21
22```
23$ ip route
24default via 10.0.0.1 dev wlp3s0 proto static metric 600
2510.0.0.0/24 dev wlp3s0 proto kernel scope link src 10.0.0.73 metric 600
2610.0.1.0/24 dev lxcbr0 proto kernel scope link src 10.0.1.1
27169.254.0.0/16 dev docker0 scope link metric 1000 linkdown
28172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
29192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown
30```
31
32The first column is the &lt;Destination&gt; subnet with the "default" being a
33wildcard for everything else. The "via" fragment points to the &lt;Gateway&gt;
34however when it is missing it indicates that that network is connected directly
35and instead it describes a source address.
36
37The &lt;Metric&gt; column translates to the number of hops required to reach the
38destination and is used to determine which route shall be preferred when there
39are more than one route available for a specific destination. Since it
40reassembles the concept of distance the lower it's value is the better.
41
42The &lt;Metric&gt; value can be set manually however when NetworkManager creates
43a connection the following defaults are applied:
44
45* Ethernet is preferred over WiFi
46* WiFi is preferred over WWAN
47
48# Editing the Routing Tables
49
50The routing table can be added or modified using the standard *ip* command which
51is available on Ubuntu Core.
52
53You can find more information on it on the following page:
54
55* <https://linux.die.net/man/8/ip?>
56
57Separately it is possible to modify routing information per single connection
58using the nmcli tool. The parameters such as: gateway, routes and metrics can be
59modified.
60
61The following options are responsible:
62
63```
64ipv4.gateway:
65ipv4.routes:
66ipv4.route-metric:
67
68ipv6.gateway:
69ipv6.routes:
70ipv6.route-metric:
71```
72
73These options can be modified in a following way:
74
75```
76$ nmcli connection modify <name> +ipv4.routes <destination> ipv4.gateway <gateway>
77$ nmcli connection modify <name> ipv4.route-metric <metric>
78```
79
80Where &lt;name&gt; is the connection name. You can obtain it by listing
81available connections on the system:
82
83```
84$ nmcli c show
85```
86
87&lt;destination&gt; is the destination network provided as a static IP address,
88subnet or "default". &lt;gateway&gt; is the new gateway information.
89&lt;metric&gt; is the new metric information.
90
91Note that this kind of changes can be made separately for each connection thus
92it is possible to provide a fine grained control over how the packets directed
93to different networks are routed.
94
95It is also important to understand that bringing up and down connections with
96different values set for these options is in fact changing the routing table.
diff --git a/run-tests.sh b/run-tests.sh
0new file mode 10075597new file mode 100755
index 0000000..7ce726e
--- /dev/null
+++ b/run-tests.sh
@@ -0,0 +1,88 @@
1#!/bin/bash
2#
3# Copyright (C) 2016 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17set -ex
18
19TESTS_EXTRAS_URL="https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/tests-extras"
20TESTS_EXTRAS_PATH="tests-extras"
21
22show_help() {
23 exec cat <<'EOF'
24Usage: run-tests.sh [OPTIONS]
25
26This is fetch & forget script and what it does is to fetch the
27tests-extras repository and execute the run-tests.sh script from
28there passing arguments as-is.
29
30When you see this message you don't have the tests-extras repository
31successfully populated in your workspace yet. Please rerun without
32specifying --help to proceed with the initial clone of the git repository.
33EOF
34}
35
36# Clone the tests-extras repository
37clone_tests_extras() {
38 echo "INFO: Fetching tests-extras scripts into $TESTS_EXTRAS_PATH ..."
39 if ! git clone -b master $TESTS_EXTRAS_URL $TESTS_EXTRAS_PATH >/dev/null 2>&1; then
40 echo "ERROR: Failed to fetch the $TESTS_EXTRAS_URL repo, exiting.."
41 exit 1
42 fi
43}
44
45# Make sure the already cloned tests-extras repository is in a known and update
46# state before it is going to be used.
47restore_and_update_tests_extras() {
48 echo "INFO: Restoring and updating $TESTS_EXTRAS_PATH"
49 cd $TESTS_EXTRAS_PATH && git reset --hard && git clean -dfx && git pull
50 cd -
51}
52
53# ==============================================================================
54# This is fetch & forget script and what it does is to fetch the tests-extras
55# repo and execute the run-tests.sh script from there passing arguments as-is.
56#
57# The tests-extras repository ends up checked out in the snap tree but as a
58# hidden directory which is re-used since then.
59
60# Find snap to use in the tests
61snaps=$(find . -maxdepth 1 -type f -name \
62 "network-manager_*_$(dpkg-architecture -q DEB_HOST_ARCH).snap")
63while read -r snap_file; do
64 if [ -n "$snap" ]; then
65 printf "More than one snap revision in the folder\n"
66 exit 1
67 fi
68 snap=$PWD/${snap_file#*/}
69done < <(printf "%s\n" "$snaps")
70
71[ ! -d "$TESTS_EXTRAS_PATH" ] && [ "$1" = "--help" ] && show_help
72
73if [ -d "$TESTS_EXTRAS_PATH" ]; then
74 restore_and_update_tests_extras
75else
76 clone_tests_extras
77fi
78
79# Any project-specific options for test-runner should be specified in
80# .tests_config under EXTRA_ARGS
81if [ -f ".tests_config" ]; then
82 # shellcheck disable=SC1091
83 . .tests_config
84fi
85
86echo "INFO: Executing tests runner"
87# shellcheck disable=SC2086
88cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@" --snap="$snap" $EXTRA_ARGS
diff --git a/snap-common/bin/snap-config.sh b/snap-common/bin/snap-config.sh
index 1c61ddc..7107a2c 100644
--- a/snap-common/bin/snap-config.sh
+++ b/snap-common/bin/snap-config.sh
@@ -119,15 +119,9 @@ _switch_debug_enable() {
119 # We create/remove the file for future executions and also change119 # We create/remove the file for future executions and also change
120 # the logging level of the running daemon.120 # the logging level of the running daemon.
121 if [ "$1" = "true" ]; then121 if [ "$1" = "true" ]; then
122 if [ ! -f "$DEBUG_FILE" ]; then122 touch "$DEBUG_FILE"
123 touch "$DEBUG_FILE"
124 "$SNAP"/bin/nmcli-internal g log level DEBUG
125 fi
126 else123 else
127 if [ -f "$DEBUG_FILE" ]; then124 rm -f "$DEBUG_FILE"
128 rm -f "$DEBUG_FILE"
129 "$SNAP"/bin/nmcli-internal g log level INFO
130 fi
131 fi125 fi
132}126}
133127
@@ -157,6 +151,11 @@ _switch_connectivity_check() {
157# $1: true/false151# $1: true/false
158_switch_defaultrenderer() {152_switch_defaultrenderer() {
159 path=/etc/netplan/00-default-nm-renderer.yaml153 path=/etc/netplan/00-default-nm-renderer.yaml
154
155 # Remove related configuration file from older NM snap versions.
156 # We let netplan do whatever is needed.
157 rm -f "$SNAP_DATA"/conf.d/disable-ethernet.conf
158
160 if [ "$1" = true ] || [ "$1" = yes ]; then159 if [ "$1" = true ] || [ "$1" = yes ]; then
161 if [ ! -f "$path" ]; then160 if [ ! -f "$path" ]; then
162 printf "network:\n renderer: NetworkManager\n" > "$path"161 printf "network:\n renderer: NetworkManager\n" > "$path"
diff --git a/snap-patch/resolvconf.patch b/snap-patch/resolvconf.patch
163new file mode 100644162new file mode 100644
index 0000000..2538bb9
--- /dev/null
+++ b/snap-patch/resolvconf.patch
@@ -0,0 +1,31 @@
1--- a/etc/resolvconf/update.d/libc 2017-11-29 19:26:46.000000000 +0100
2+++ b/etc/resolvconf/update.d/libc 2019-06-07 08:55:49.486028633 +0200
3@@ -18,7 +18,7 @@
4 set -e
5 PATH=/sbin:/bin
6
7-[ -x /lib/resolvconf/list-records ] || exit 1
8+[ -x "$SNAP"/lib/resolvconf/list-records ] || exit 1
9
10 # Default override
11 [ -r /etc/default/resolvconf ] && . /etc/default/resolvconf
12@@ -107,7 +107,7 @@
13 done
14 }
15
16-RSLVCNFFILES="$(/lib/resolvconf/list-records)"
17+RSLVCNFFILES="$($SNAP/lib/resolvconf/list-records)"
18
19 [ -f "$BASEFILE" ] && RSLVCNFFILES="$RSLVCNFFILES
20 $BASEFILE"
21--- a/sbin/resolvconf 2019-05-06 10:39:40.000000000 +0200
22+++ b/sbin/resolvconf 2019-06-07 08:55:49.514029312 +0200
23@@ -63,7 +63,7 @@
24 update_and_exit()
25 {
26 rm -f "$POSTPONED_UPDATE_FLAGFILE"
27- exec run-parts ${1:+--arg="$1"} ${2:+--arg="$2"} /etc/resolvconf/update.d
28+ exec run-parts ${1:+--arg="$1"} ${2:+--arg="$2"} "$SNAP"/etc/resolvconf/update.d
29 }
30
31 # Handle commands that don't require normalized_stdin()
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
index 290ab83..d07b5ed 100644
--- a/snap/snapcraft.yaml
+++ b/snap/snapcraft.yaml
@@ -123,15 +123,14 @@ parts:
123 - --with-dhcpcd=no123 - --with-dhcpcd=no
124 - --with-dhclient=no124 - --with-dhclient=no
125 - --with-dnsmasq=no125 - --with-dnsmasq=no
126 - --with-iptables=/snap/$SNAPCRAFT_PROJECT_NAME/current/sbin/iptables
126 - --with-systemd-journal=yes127 - --with-systemd-journal=yes
127 # from 1.10 deb:128 - --libexecdir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib/NetworkManager
128 - --libexecdir=/usr/lib/NetworkManager129 - --with-pppd=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/sbin/pppd
129 - --with-pppd=/usr/sbin/pppd130 - --with-resolvconf=/snap/$SNAPCRAFT_PROJECT_NAME/current/sbin/resolvconf
130 - --with-resolvconf=no
131 #131 #
132 # TODO: iptables & dnsmasq are used for AP mode; not132 # TODO: dnsmasq is used for AP mode; not
133 # currently supported by the snap:133 # currently supported by the snap:
134 # - --with-iptables=/sbin/iptables
135 # - --with-dnsmasq=/usr/sbin/dnsmasq134 # - --with-dnsmasq=/usr/sbin/dnsmasq
136 - --with-dnssec-trigger=/usr/lib/dnssec-trigger/dnssec-trigger-script135 - --with-dnssec-trigger=/usr/lib/dnssec-trigger/dnssec-trigger-script
137 - --with-systemdsystemunitdir=/lib/systemd/system136 - --with-systemdsystemunitdir=/lib/systemd/system
@@ -175,6 +174,7 @@ parts:
175 # Run all tests NetworkManager ships by default174 # Run all tests NetworkManager ships by default
176 make check175 make check
177 stage-packages:176 stage-packages:
177 - iptables
178 - iputils-arping178 - iputils-arping
179 - libasn1-8-heimdal179 - libasn1-8-heimdal
180 - libdbus-glib-1-2180 - libdbus-glib-1-2
@@ -223,6 +223,12 @@ parts:
223 - libslang2223 - libslang2
224 - libtasn1-6224 - libtasn1-6
225 - libwind0-heimdal225 - libwind0-heimdal
226 - ppp
227 - resolvconf
228
229 override-stage: |
230 snapcraftctl stage
231 patch -p1 < "$SNAPCRAFT_PART_SRC"/snap-patch/resolvconf.patch
226232
227 # Filter files pulled in by stage-packages so they aren't233 # Filter files pulled in by stage-packages so they aren't
228 # included in the final snap. We only need them to build234 # included in the final snap. We only need them to build
@@ -231,21 +237,26 @@ parts:
231 # here are the results of the network manager build.237 # here are the results of the network manager build.
232 filesets:238 filesets:
233 binaries:239 binaries:
240 - sbin/*tables*
241 - sbin/resolvconf
234 - usr/bin/arping242 - usr/bin/arping
235 - usr/bin/nmcli243 - usr/bin/nmcli
236 - usr/bin/nmtui244 - usr/bin/nmtui
237 - usr/bin/nmtui-connect245 - usr/bin/nmtui-connect
238 - usr/bin/nmtui-edit246 - usr/bin/nmtui-edit
239 - usr/bin/nmtui-hostname247 - usr/bin/nmtui-hostname
248 - usr/sbin/pppd
240 - usr/lib/*/NetworkManager249 - usr/lib/*/NetworkManager
241 - usr/lib/pppd/2.4.5/nm-pppd-plugin.so250 - usr/lib/pppd/2.4.5/nm-pppd-plugin.so
242 - usr/lib/NetworkManager251 - usr/lib/NetworkManager
243 - usr/sbin/NetworkManager252 - usr/sbin/NetworkManager
244 configs:253 configs:
245 - etc/NetworkManager/*254 - etc/NetworkManager/*
255 - etc/resolvconf/update.d/libc
246 docs:256 docs:
247 - usr/share/doc/*/copyright257 - usr/share/doc/*/copyright
248 libs:258 libs:
259 - lib/resolvconf/list-records
249 - lib/*/libnewt*260 - lib/*/libnewt*
250 - lib/*/libslang*261 - lib/*/libslang*
251 - usr/lib/libnm*262 - usr/lib/libnm*
@@ -258,6 +269,8 @@ parts:
258 - usr/lib/*/libheimbase*269 - usr/lib/*/libheimbase*
259 - usr/lib/*/libheimntlm*270 - usr/lib/*/libheimntlm*
260 - usr/lib/*/libhx509*271 - usr/lib/*/libhx509*
272 - usr/lib/*/libip4tc*
273 - usr/lib/*/libip6tc*
261 # required for teamdctl274 # required for teamdctl
262 - usr/lib/*/libjansson*275 - usr/lib/*/libjansson*
263 - usr/lib/*/libkrb5*26*276 - usr/lib/*/libkrb5*26*
@@ -267,12 +280,14 @@ parts:
267 - usr/lib/*/libmm-glib*280 - usr/lib/*/libmm-glib*
268 - usr/lib/*/libndp*281 - usr/lib/*/libndp*
269 - usr/lib/*/libnghttp2*282 - usr/lib/*/libnghttp2*
283 - usr/lib/*/libpcap*
270 - usr/lib/*/libpsl*284 - usr/lib/*/libpsl*
271 - usr/lib/*/libroken*285 - usr/lib/*/libroken*
272 - usr/lib/*/librtmp*286 - usr/lib/*/librtmp*
273 - usr/lib/*/libsasl2*287 - usr/lib/*/libsasl2*
274 - usr/lib/*/libteamdctl*288 - usr/lib/*/libteamdctl*
275 - usr/lib/*/libwind*289 - usr/lib/*/libwind*
290 - usr/lib/*/libxtables*
276 unwanted:291 unwanted:
277 # We don't use dhclient so we don't need this helper292 # We don't use dhclient so we don't need this helper
278 - -usr/lib/NetworkManager/nm-dhcp-helper293 - -usr/lib/NetworkManager/nm-dhcp-helper
@@ -288,6 +303,3 @@ parts:
288 - $docs303 - $docs
289 - $libs304 - $libs
290 - $unwanted305 - $unwanted
291
292
293
diff --git a/spread.yaml b/spread.yaml
294new file mode 100644306new file mode 100644
index 0000000..83abb24
--- /dev/null
+++ b/spread.yaml
@@ -0,0 +1,85 @@
1#
2# Copyright (C) 2015, 2016 Canonical Ltd
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License version 3 as
6# published by the Free Software Foundation.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16
17project: network-manager
18
19environment:
20 PROJECT_PATH: /home/network-manager
21 TESTSLIB: $PROJECT_PATH/tests/lib
22 SNAP_NAME: network-manager
23 # Allow the host to pass the channel to use for the test run
24 SNAP_CHANNEL: $(HOST:echo $SNAP_CHANNEL)
25
26backends:
27 qemu:
28 systems:
29 - ubuntu-core-16:
30 username: test
31 password: test
32
33# Put this somewhere where we have read-write access
34path: /home/network-manager
35
36exclude:
37 - .git
38
39prepare: |
40 . $TESTSLIB/prepare-all.sh
41
42prepare-each: |
43 # Cleanup logs so we can just dump what has happened in the debug-each
44 # step below after a test case ran.
45 journalctl --rotate
46 sleep .1
47 journalctl --vacuum-time=1ms
48 dmesg -c > /dev/null
49
50debug-each: |
51 journalctl
52 dmesg | grep DENIED || true
53
54# Default is 15 min but we use a higher one here as we build the entire
55# network-manager snap inside the global prepare step so we need quite
56# some time. Once we can reuse artifacts from other builds we can change
57# this back to the default.
58kill-timeout: 30m
59
60suites:
61 tests/main/:
62 summary: Full-system tests for NetworkManager without ethernet support
63 systems:
64 - ubuntu-core-16
65 prepare: |
66 . $TESTSLIB/prepare.sh
67 restore-each: |
68 . $TESTSLIB/restore-each.sh
69 tests/full/:
70 summary: Full-system tests for NetworkManager being the only network management service
71 systems:
72 - ubuntu-core-16
73 prepare: |
74 . $TESTSLIB/utilities.sh
75 stop_after_first_reboot
76 switch_netplan_to_network_manager
77 . $TESTSLIB/prepare.sh
78 REBOOT
79 restore-each: |
80 . $TESTSLIB/restore-each.sh
81 restore: |
82 . $TESTSLIB/utilities.sh
83 stop_after_first_reboot
84 switch_netplan_to_networkd
85 REBOOT
diff --git a/tests/full/correct-dns-setup/task.yaml b/tests/full/correct-dns-setup/task.yaml
0new file mode 10064486new file mode 100644
index 0000000..9b6dfe0
--- /dev/null
+++ b/tests/full/correct-dns-setup/task.yaml
@@ -0,0 +1,47 @@
1summary: Verify correct DNS setup
2
3execute: |
4 . $TESTSLIB/utilities.sh
5 case $SPREAD_REBOOT in
6 0)
7 # For correct timing if the device has just booted
8 wait_for_network_manager
9
10 # Precondition is a existing network connection
11 /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
12
13 # We get a default nameserver from the gateway
14 if [ "$SPREAD_BACKEND" = "qemu" ] ; then
15 cat /etc/resolv.conf | grep 'nameserver 10.0.2.3'
16 fi
17
18 # Ensure we can resolve a hostname correctly; must give a
19 # valid IP address
20 address=`python3 -c 'import socket; print(socket.gethostbyname("ubuntu.com"))' 2> /dev/null || echo "invalid"`
21 [ "$address" != "invalid" ] && [[ $address =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]
22
23 # Now lets switch to a system where we have a configuration
24 # for ethernet we can change
25 rm /etc/netplan/00-snapd-config.yaml
26 REBOOT
27 ;;
28 1)
29 /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
30 /snap/bin/network-manager.nmcli d | grep -v netplan
31
32 connection=$(/snap/bin/network-manager.nmcli -m multiline -f UUID c show --active | awk '{print$2;exit}')
33 /snap/bin/network-manager.nmcli c modify $connection ipv4.dns 8.8.8.8
34 # We need to bring up the connection again here to get the DNS
35 # server really applied to the system.
36 /snap/bin/network-manager.nmcli c up $connection
37
38 # Give system a moment to settle
39 sleep 1
40
41 grep 'nameserver 8.8.8.8' /etc/resolv.conf
42 address=`python3 -c 'import socket; print(socket.gethostbyname("ubuntu.com"))' 2> /dev/null || echo "invalid"`
43 [ "$address" != "invalid" ] && [[ $address =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]
44 ;;
45 *)
46 ;;
47 esac
diff --git a/tests/full/immutable-netplan-config/task.yaml b/tests/full/immutable-netplan-config/task.yaml
0new file mode 10064448new file mode 100644
index 0000000..c218478
--- /dev/null
+++ b/tests/full/immutable-netplan-config/task.yaml
@@ -0,0 +1,10 @@
1summary: Verify that netplan configuration files are immutable
2
3execute: |
4 # Ensure we're using a configuration generated from netplan
5 test -e /etc/netplan/00-snapd-config.yaml
6 test -e /run/NetworkManager/system-connections/netplan-eth0
7
8 /snap/bin/network-manager.nmcli c | MATCH 'netplan.eth0.*eth0'
9 # Try to change the DNS server used on this connection
10 test ! `/snap/bin/network-manager.nmcli c modify netplan-eth0 ipv4.dns 8.8.8.8`
diff --git a/tests/full/ipv6-address-assignment/task.yaml b/tests/full/ipv6-address-assignment/task.yaml
0new file mode 10064411new file mode 100644
index 0000000..e36ef00
--- /dev/null
+++ b/tests/full/ipv6-address-assignment/task.yaml
@@ -0,0 +1,27 @@
1summary: Verify NetworkManager can assign a static IPv6 address to an interface
2
3restore: |
4 # Ensure that the created virtual network interfaces are removed
5 # in any case when we're done
6 if [ -e /sys/class/net/veth0 ] ; then
7 ip link delete veth0
8 fi
9
10execute: |
11 . $TESTSLIB/utilities.sh
12
13 # Ensure that we have IPv6 support enabled in the kernel
14 test -e /proc/net/if_inet6
15
16 ip link add dev veth0 type veth peer name veth1
17
18 wait_for_network_manager
19
20 connection=veth-ipv6
21 /snap/bin/network-manager.nmcli c add con-name $connection ifname veth0 type ethernet \
22 ip6 abbe::cafe
23 /snap/bin/network-manager.nmcli c up $connection
24
25 # Verify that NetworkManager assigned the correct IPv6 address
26 # to the interface
27 ifconfig veth0 | grep 'abbe::cafe/128'
diff --git a/tests/full/ipv6-router-advertisements/task.yaml b/tests/full/ipv6-router-advertisements/task.yaml
0new file mode 10064428new file mode 100644
index 0000000..4af402b
--- /dev/null
+++ b/tests/full/ipv6-router-advertisements/task.yaml
@@ -0,0 +1,70 @@
1summary: Test IPv6 address assignment via router advertisements
2
3restore: |
4 # Ensure that the created virtual network interfaces are removed
5 # in any case when we're done
6 if [ -e /sys/class/net/veth0 ] ; then
7 ip link delete veth0
8 fi
9
10execute: |
11 . $TESTSLIB/utilities.sh
12
13 # Ensure that we have IPv6 support enabled in the kernel
14 test -e /proc/net/if_inet6
15
16 snap install --devmode se-test-tools
17 snap connect se-test-tools:home core
18 snap connect se-test-tools:network-control core
19
20 # Create virtual ethernet interface pair
21 sudo ip link add dev veth0 type veth peer name veth1
22
23 # As the virtual ethernet devices don't get IPv6 setup
24 # correctly by default we have to do this
25 sudo sysctl -w net.ipv6.conf.veth0.disable_ipv6=0
26 sudo sysctl -w net.ipv6.conf.veth1.disable_ipv6=0
27 veth0_lla=$(mac_to_ipv6 `cat /sys/class/net/veth0/address`)
28 veth1_lla=$(mac_to_ipv6 `cat /sys/class/net/veth1/address`)
29
30 # The radvd daemon will send out router advertisements on veth1
31 # so that we can receive them on veth0 end
32 cat <<-EOF > /home/test/radvd.conf
33 interface veth1 {
34 AdvSendAdvert on;
35 prefix 2001:db8:1:2::/64 {};
36 };
37 EOF
38
39 # To ensure that nobody touches veth1 we tell NetworkManager
40 # explicitly to do that.
41 /snap/bin/network-manager.nmcli d set veth1 managed no
42
43 # Assign our link-local addresses
44 if ! ip addr show dev veth0 | grep 'inet6.*scope link.*' ; then
45 sudo ip addr add dev veth0 scope link $veth0_lla
46 fi
47 if ! ip addr show dev veth1 | grep 'inet6.*scope link.*' ; then
48 sudo ip addr add dev veth1 scope link $veth1_lla
49 fi
50
51 # This will get our router advertisement daemon started and we
52 # now configure NetworkManager
53 sudo se-test-tools.radvd -C /home/test/radvd.conf -n -d 5 -m stderr -p /home/test/radvd.pid &
54
55 # Give things a bit more time to settle
56 sleep 10
57 ip addr show dev veth0
58
59 # At this point veth0 should have now a global IPv6 address
60 # assigned via router advertisements
61 ip addr show dev veth0 | grep 'inet6 2001:db8:1:2:.*/64 scope global'
62 # but veth1 should not have any
63 ip addr show dev veth1 | grep -v 'inet6.*scope global'
64
65 # NetworkManager should report the same addresses for IPv6
66 /snap/bin/network-manager.nmcli d show veth0 | grep 'GENERAL.STATE.*connected'
67 /snap/bin/network-manager.nmcli d show veth0 | grep 'IP6.ADDRESS.*2001:db8:1:2.*/64'
68
69 # Stop the radvd daemon
70 kill -TERM `cat /home/test/radvd.pid`
diff --git a/tests/full/no-netplan-default-config/task.yaml b/tests/full/no-netplan-default-config/task.yaml
0new file mode 10064471new file mode 100644
index 0000000..66a75c6
--- /dev/null
+++ b/tests/full/no-netplan-default-config/task.yaml
@@ -0,0 +1,41 @@
1summary: Verify ethernet is auto-connected when no default netplan configuration exists
2
3prepare: |
4 cp /etc/netplan/00-snapd-config.yaml /etc/netplan/00-snapd-config.yaml.orig
5
6restore: |
7 mv /etc/netplan/00-snapd-config.yaml.orig /etc/netplan/00-snapd-config.yaml
8
9execute: |
10 . $TESTSLIB/utilities.sh
11 case "$SPREAD_REBOOT" in
12 0)
13 # Remove all configuration files from netplan to get a system
14 # without generated configuration files from netplan
15 if [ -e /usr/lib/snapd/generate-network-conf ] ; then
16 echo "" > /etc/netplan/00-snapd-config.yaml
17 else
18 rm /etc/netplan/00-snapd-config.yaml
19 fi
20 REBOOT
21 ;;
22 1)
23 # We should be automatically connected now and not via a configuration
24 # generated from netplan
25 wait_for_network_manager
26 /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
27 networkctl status eth0 | grep unmanaged
28 /snap/bin/network-manager.nmcli c show --active | grep eth0 | grep -v netplan
29
30 # We should only have a single active configuration
31 test `/snap/bin/network-manager.nmcli -m multiline -f UUID c show --active | wc -l` -eq 1
32
33 # Verify that we can modify the automatically created connection
34 connection=$(/snap/bin/network-manager.nmcli -m multiline -f UUID c show --active | awk '{print$2;exit}')
35 /snap/bin/network-manager.nmcli c modify $connection 802-3-ethernet.wake-on-lan magic
36 wol_value=$(/snap/bin/network-manager.nmcli -f 802-3-ethernet.wake-on-lan c show $connection | xargs | cut -d':' -f 2)
37 test "$wol_value" = " magic"
38 ;;
39 *)
40 ;;
41 esac
diff --git a/tests/full/system-network-is-active/task.yaml b/tests/full/system-network-is-active/task.yaml
0new file mode 10064442new file mode 100644
index 0000000..22d7830
--- /dev/null
+++ b/tests/full/system-network-is-active/task.yaml
@@ -0,0 +1,9 @@
1summary: Ethernet network should be managed by NetworkManager
2
3execute: |
4 . $TESTSLIB/utilities.sh
5 # Verify NetworManager handles ethernet and marks it as connected
6 test -e /etc/netplan/00-default-nm-renderer.yaml
7 wait_for_network_manager
8 /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
9 networkctl status eth0 | grep unmanaged
diff --git a/tests/full/wol-enabled-by-default/task.yaml b/tests/full/wol-enabled-by-default/task.yaml
0new file mode 10064410new file mode 100644
index 0000000..9d7d034
--- /dev/null
+++ b/tests/full/wol-enabled-by-default/task.yaml
@@ -0,0 +1,60 @@
1summary: Verify that wake-on-lan is enabled by default for all ethernet connections
2
3execute: |
4 . $TESTSLIB/utilities.sh
5 nmcli=/snap/bin/network-manager.nmcli
6 case "$SPREAD_REBOOT" in
7 0)
8 # For correct timing if the device has just booted
9 wait_for_network_manager
10
11 # The config file needs to be present and have the correct default set
12 test -e /var/snap/network-manager/current/conf.d/enable-wol.conf
13 cat /var/snap/network-manager/current/conf.d/enable-wol.conf | grep '802-3-ethernet.wake-on-lan=64'
14
15 # Precondition is a existing network connection
16 $nmcli d | grep 'eth0.*connected'
17
18 # The netplan configuration file has WoL disabled by default as
19 # the default one the core snap provides does not explicitly
20 # enable WoL.
21 connection=$($nmcli -m multiline -f UUID c show --active | awk '{print$2;exit}')
22 $nmcli -m multiline -f connection.id c show $connection | grep 'netplan-eth0'
23 $nmcli -m multiline -f connection.type c show $connection | grep '802-3-ethernet'
24 $nmcli -m multiline -f 802-3-ethernet.wake-on-lan c show $connection |
25 grep '^802-3-ethernet.wake-on-lan: *--$'
26
27 # Now prepare for the next boot where we will run without a netplan
28 # config to get eth0 correctly configured.
29 rm /etc/netplan/00-snapd-config.yaml
30 REBOOT
31 ;;
32 1)
33 # For correct timing if the device has just booted
34 wait_for_network_manager
35
36 # Precondition is a existing network connection
37 $nmcli d | grep 'eth0.*connected'
38
39 # Connection should have the default wake-on-lan setting
40 connection=$($nmcli -m multiline -f UUID c show | awk '{print$2;exit}')
41 $nmcli -m multiline -f connection.type c show $connection | grep '802-3-ethernet'
42 # wake-on-lan should be set to respect the global defaults here
43 $nmcli -m multiline -f 802-3-ethernet.wake-on-lan c show $connection | grep 'default'
44
45 # We can sadly only verify that the value was correctly applied when
46 # we're running the tests on a real device. QEMU doesn't support setting
47 # the WoL value of the ethernet network device.
48 if [ -z "`cat /proc/cpuinfo | grep QEMU`" ] ; then
49 # Get the tools snap to have the ethtool tool available
50 snap install --devmode --edge se-test-tools
51 snap connect se-test-tools:network core
52 snap connect se-test-tools:network-bind core
53 snap connect se-test-tools:network-control core
54
55 # See `man ethtool` for details; 'g' means 'wakeup when magic packet comes in'
56 # and is the default behavior we want.
57 /snap/bin/se-test-tools.ethtool eth0 | grep 'Wake-up: g'
58 fi
59 ;;
60 esac
diff --git a/tests/lib/prepare-all.sh b/tests/lib/prepare-all.sh
0new file mode 10064461new file mode 100644
index 0000000..fa8fb6b
--- /dev/null
+++ b/tests/lib/prepare-all.sh
@@ -0,0 +1,63 @@
1#!/bin/bash -x
2
3# Create a service to get the mac80211_hwsim driver loaded on system
4# startup so that we don't need to load it again in our tests as
5# load/unload multiple times in a running system can lead to kernel
6# crashes.
7cat << EOF > /etc/systemd/system/load-mac80211-hwsim.service
8[Unit]
9Description=Load mac8022_hwsim driver
10[Service]
11ExecStart=/sbin/modprobe mac80211_hwsim radios=2
12[Install]
13WantedBy=multi-user.target
14EOF
15
16systemctl enable load-mac80211-hwsim
17systemctl start load-mac80211-hwsim
18
19# We don't have to build a snap when we should use one from a
20# channel
21if [ -n "$SNAP_CHANNEL" ] ; then
22 exit 0
23fi
24
25# If there is a network-manager snap prebuilt for us, lets take
26# that one to speed things up.
27if [ -f /writable/system-data/network-manager_*_amd64.snap ]; then
28 mv /writable/system-data/network-manager_*_amd64.snap /home/network-manager/
29fi
30if [ -f /home/network-manager/network-manager_*_amd64.snap ] ; then
31 exit 0
32fi
33
34# Setup classic snap and build the network-manager snap in there
35snap install --devmode --beta classic
36cat <<-EOF > /home/test/build-snap.sh
37#!/bin/sh
38set -ex
39
40export DEBIAN_FRONTEND=noninteractive
41
42# FIXME: Enable propose for now until problems with conflicting systemd
43# packages between the Ubuntu Core image ppa and the archive are fixed.
44echo "deb http://archive.ubuntu.com/ubuntu/ xenial-proposed restricted main universe" > /etc/apt/sources.list.d/ubuntu-proposed.list
45echo "deb http://ppa.launchpad.net/snappy-dev/image/ubuntu xenial main" > /etc/apt/sources.list.d/ubuntu-image-ppa.list
46
47
48# Ensure we have the latest updates installed as the core snap
49# may be a bit out of date.
50apt update
51apt -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' full-upgrade -y --force-yes
52
53apt install -y --force-yes snapcraft
54cd /home/network-manager
55snapcraft clean
56snapcraft
57EOF
58chmod +x /home/test/build-snap.sh
59sudo classic /home/test/build-snap.sh
60snap remove classic
61
62# Make sure we have a snap build
63test -e /home/network-manager/network-manager_*_amd64.snap
diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
0new file mode 10064464new file mode 100644
index 0000000..6565405
--- /dev/null
+++ b/tests/lib/prepare.sh
@@ -0,0 +1,46 @@
1#!/bin/bash
2. $TESTSLIB/utilities.sh
3
4echo "Wait for firstboot change to be ready"
5while ! snap changes | grep -q "Done"; do
6 snap changes || true
7 snap change 1 || true
8 sleep 1
9done
10
11echo "Ensure fundamental snaps are still present"
12. $TESTSLIB/snap-names.sh
13for name in $gadget_name $kernel_name $core_name; do
14 if ! snap list | grep -q $name ; then
15 echo "Not all fundamental snaps are available, all-snap image not valid"
16 echo "Currently installed snaps:"
17 snap list
18 exit 1
19 fi
20done
21
22# Remove any existing state archive from other test suites
23rm -f /home/network-manager/snapd-state.tar.gz
24rm -f /home/network-manager/nm-state.tar.gz
25
26# TODO install from stable once NM 1.10 is released there
27snap_install network-manager --channel=1.10/beta
28
29# Snapshot of the current snapd state for a later restore
30systemctl stop snapd.service snapd.socket
31tar czf $SPREAD_PATH/snapd-state.tar.gz /var/lib/snapd /etc/netplan
32systemctl start snapd.socket
33
34# Make sure the original netplan configuration is applied and active
35# (we do this before re-starting NM to avoid race conditions in some tests)
36netplan generate
37netplan apply
38
39# And also snapshot NetworkManager's state
40systemctl stop snap.network-manager.networkmanager
41tar czf $SPREAD_PATH/nm-state.tar.gz /var/snap/network-manager
42systemctl start snap.network-manager.networkmanager
43
44# For debugging dump all snaps and connected slots/plugs
45snap list
46snap interfaces
diff --git a/tests/lib/restore-each.sh b/tests/lib/restore-each.sh
0new file mode 10064447new file mode 100644
index 0000000..b8cdac1
--- /dev/null
+++ b/tests/lib/restore-each.sh
@@ -0,0 +1,40 @@
1#!/bin/bash
2
3. $TESTSLIB/snap-names.sh
4. $TESTSLIB/utilities.sh
5
6# Remove all snaps not being the core, gadget, kernel or snap we're testing
7for snap in /snap/*; do
8 snap="${snap:6}"
9 case "$snap" in
10 "bin" | "$gadget_name" | "$kernel_name" | core* | "$SNAP_NAME" )
11 ;;
12 *)
13 snap remove "$snap"
14 ;;
15 esac
16done
17
18# Drop any generated or modified netplan configuration files. The original
19# ones will be restored below.
20rm -f /etc/netplan/*
21
22# Ensure we have the same state for snapd as we had before
23systemctl stop snapd.service snapd.socket
24rm -rf /var/lib/snapd/*
25tar xzf $SPREAD_PATH/snapd-state.tar.gz -C /
26rm -rf /root/.snap
27systemctl start snapd.service snapd.socket
28wait_for_systemd_service snapd.service
29wait_for_systemd_service snapd.socket
30
31# Make sure the original netplan configuration is applied and active
32# (we do this before re-starting NM to avoid race conditions in some tests)
33netplan generate
34netplan apply
35
36systemctl stop snap.network-manager.networkmanager
37rm -rf /var/snap/network-manager/*
38tar xzf $SPREAD_PATH/nm-state.tar.gz -C /
39systemctl start snap.network-manager.networkmanager
40wait_for_network_manager
diff --git a/tests/lib/snap-names.sh b/tests/lib/snap-names.sh
0new file mode 10064441new file mode 100644
index 0000000..f15b09a
--- /dev/null
+++ b/tests/lib/snap-names.sh
@@ -0,0 +1,7 @@
1#!/bin/bash
2gadget_name=$(snap list | sed -n 's/^\(pc\|pi[23]\|dragonboard\) .*/\1/p')
3kernel_name=$gadget_name-kernel
4core_name=$(snap list | awk '/^(ubuntu-)?core / {print $1; exit}')
5if [ "$kernel_name" = "pi3-kernel" ] ; then
6 kernel_name=pi2-kernel
7fi
diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
0new file mode 1006448new file mode 100644
index 0000000..6144a89
--- /dev/null
+++ b/tests/lib/utilities.sh
@@ -0,0 +1,166 @@
1#!/bin/sh
2
3snap_install() {
4 name=$1
5 if [ -n "$SNAP_CHANNEL" ] ; then
6 # Don't reinstall if we have it installed already
7 if ! snap list | grep $name ; then
8 snap install --$SNAP_CHANNEL $name
9 fi
10 else
11 # Need first install from store to get all necessary assertions into
12 # place. Second local install will then bring in our locally built
13 # snap.
14 snap install $name $2
15 snap install --dangerous $PROJECT_PATH/$name*_amd64.snap
16 fi
17}
18
19switch_netplan_to_network_manager() {
20 if [ -e /etc/netplan/00-default-nm-renderer.yaml ] ; then
21 return 0
22 fi
23
24 # set 'defaultrenderer' in case the snap is already installed
25 if snap list | grep -q network-manager ; then
26 snap set network-manager defaultrenderer=true
27 # Leave some time for NM wrapper to write netplan config
28 repeat_until_done "test -e /etc/netplan/00-default-nm-renderer.yaml"
29 else
30 cat << EOF > /etc/netplan/00-default-nm-renderer.yaml
31network:
32 renderer: NetworkManager
33EOF
34 fi
35}
36
37switch_netplan_to_networkd() {
38 if [ ! -e /etc/netplan/00-default-nm-renderer.yaml ] ; then
39 return 0
40 fi
41
42 # unset 'defaultrenderer' in case the snap is already installed
43 if snap list | grep -q network-manager ; then
44 snap set network-manager defaultrenderer=false
45 # Leave some time for NM wrapper to remove netplan config
46 repeat_until_done "test ! -e /etc/netplan/00-default-nm-renderer.yaml"
47 else
48 rm /etc/netplan/00-default-nm-renderer.yaml
49 fi
50}
51
52# waits for a service to be active. Besides that, waits enough
53# time after detecting it to be active to prevent restarting
54# same service too quickly several times.
55# $1 service name
56# $2 start limit interval in seconds (default set to 10. Exec `systemctl show THE_SERVICE -p StartLimitInterval` to verify)
57# $3 start limit burst. Times allowed to start the service in start_limit_interval time (default set to 5. Exec `systemctl show THE_SERVICE -p StartLimitBurst` to verify)
58wait_for_systemd_service() {
59 while ! systemctl status $1 ; do
60 sleep 1
61 done
62 # As debian services default limit is to allow 5 restarts in a 10sec period
63 # (StartLimitInterval=10000000 and StartLimitBurst=5), having enough wait time we
64 # prevent "service: Start request repeated too quickly" error.
65 #
66 # You can check those values for certain service by typing:
67 # $systemctl show THE_SERVICE -p StartLimitInterval,StartLimitBurst
68 #
69 if [ $# -ge 2 ]; then
70 start_limit_interval = $2
71 else
72 start_limit_interval=$(systemctl show $1 -p StartLimitInterval | sed 's/StartLimitInterval=//')
73 # original limit interval is provided in microseconds.
74 start_limit_interval=$((start_limit_interval / 1000000))
75 fi
76
77 if [ $# -eq 3 ]; then
78 start_limit_burst = $3
79 else
80 start_limit_burst=$(systemctl show $1 -p StartLimitBurst | sed 's/StartLimitBurst=//')
81 fi
82
83 # adding 1 to be sure we exceed the limit
84 sleep_time=$((1 + $start_limit_interval / $start_limit_burst))
85 sleep $sleep_time
86}
87
88wait_for_network_manager() {
89 wait_for_systemd_service snap.network-manager.networkmanager
90}
91
92stop_after_first_reboot() {
93 if [ $SPREAD_REBOOT -gt 0 ] ; then
94 exit 0
95 fi
96}
97
98mac_to_ipv6() {
99 mac=$1
100 ipv6_address=fe80::$(printf %02x $((0x${mac%%:*} ^ 2)))
101 mac=${mac#*:}
102 ipv6_address=$ipv6_address${mac%:*:*:*}ff:fe
103 mac=${mac#*:*:}
104 ipv6_address=$ipv6_address${mac%:*}${mac##*:}
105 echo $ipv6_address
106}
107
108# Creates an AP using wifi-ap
109# $1: SSID name
110# $2: Passphrase. If present, AP will use WPA2, otherwise it will be open.
111create_ap() {
112 if [ $# -lt 1 ]; then
113 echo "Not enough arguments for $0"
114 return 1
115 fi
116
117 snap install wifi-ap
118 # wifi-ap needs a bit of time to settle down
119 repeat_until_done 'wifi-ap.status | MATCH "ap.active: true"' 0.5
120
121 /snap/bin/wifi-ap.config set wifi.interface=wlan0
122 /snap/bin/wifi-ap.config set wifi.ssid="$1"
123 if [ $# -ge 2 ]; then
124 /snap/bin/wifi-ap.config set wifi.security=wpa2
125 /snap/bin/wifi-ap.config set wifi.security-passphrase="$2"
126 else
127 /snap/bin/wifi-ap.config set wifi.security=open
128 fi
129
130 # NM some times still detects the wifi as WPA2 instead of open, so we need
131 # to re-start to force it to refresh. See LP: #1704085. Before that, we have
132 # to wait to make sure the AP sends the beacon frames so wpa_supplicant
133 # detects the AP changes and reports the right environment to the new NM
134 # instance.
135 sleep 30
136
137 systemctl restart snap.network-manager.networkmanager.service
138 repeat_until_done "busctl status org.freedesktop.NetworkManager &> /dev/null" 0.5
139
140 repeat_until_done "network-manager.nmcli d wifi | MATCH $1" 5
141}
142
143# $1 instruction to execute repeatedly until complete or max times
144# $2 sleep time between retries. Default 1sec
145# $3 max_iterations. Default 20
146repeat_until_done() {
147 timeout=1
148 if [ $# -ge 2 ]; then
149 timeout=$2
150 fi
151
152 max_iterations=20
153 if [ $# -ge 3 ]; then
154 max_iterations=$3
155 fi
156
157 i=0
158 while [ $i -lt $max_iterations ] ; do
159 if $(eval $1) ; then
160 break
161 fi
162 sleep $timeout
163 let i=i+1
164 done
165 test $i -lt $max_iterations
166}
diff --git a/tests/main/aliases/task.yaml b/tests/main/aliases/task.yaml
0new file mode 100644167new file mode 100644
index 0000000..1ae0e05
--- /dev/null
+++ b/tests/main/aliases/task.yaml
@@ -0,0 +1,13 @@
1summary: Verify aliases provided by the snap are correctly enabled
2
3execute: |
4 # FIXME: Aliases should be not in place automatically unless we
5 # have them approved from the store in our snap-declaration assertion.
6 test ! -e /snap/bin/nmcli
7
8 snap alias $SNAP_NAME.nmcli nmcli
9
10 test -e /snap/bin/nmcli
11
12 # Verify the alias works without any problems
13 /snap/bin/nmcli g
diff --git a/tests/main/can-exec-iptables/task.yaml b/tests/main/can-exec-iptables/task.yaml
0new file mode 10064414new file mode 100644
index 0000000..eeffe75
--- /dev/null
+++ b/tests/main/can-exec-iptables/task.yaml
@@ -0,0 +1,11 @@
1summary: Verify the NetworkManager snap is allowed to modify the iptables firewall configuration
2
3execute: |
4 # Running a simple command in the runtime environment of our service
5 # binary will tell us if we're allowed to execute the iptables binary
6 # from the core snap or not.
7 snap run --shell network-manager.networkmanager <<EOF
8 set -ex
9 export LD_LIBRARY_PATH=/snap/network-manager/current/lib:/snap/network-manager/current/usr/lib:/snap/network-manager/current/lib/$(arch)-linux-gnu:/snap/network-manager/current/usr/lib/$(arch)-linux-gnu:/snap/network-manager/current/usr/lib/NetworkManager
10 /snap/network-manager/current/sbin/iptables -L
11 EOF
diff --git a/tests/main/debug-config-option/task.yaml b/tests/main/debug-config-option/task.yaml
0new file mode 10064412new file mode 100644
index 0000000..3ffa20e
--- /dev/null
+++ b/tests/main/debug-config-option/task.yaml
@@ -0,0 +1,27 @@
1summary: Test network-manager snap debug configuration
2
3execute: |
4 . $TESTSLIB/utilities.sh
5
6 test "$(snap get network-manager debug.enable)" = "false"
7 if journalctl --no-pager -u snap.network-manager.networkmanager.service |
8 MATCH "<debug>"; then
9 echo "Debug traces found with disabled debug option"
10 exit 1
11 fi
12
13 snap set network-manager debug.enable=true
14 test "$(snap get network-manager debug.enable)" = "true"
15 # NM will create the file after being re-started by the hook, wait a bit
16 wait_for_network_manager
17 sleep 5
18 test -f /var/snap/network-manager/current/.debug_enabled
19 network-manager.nmcli g log | MATCH "^DEBUG"
20
21 snap set network-manager debug.enable=false
22 test "$(snap get network-manager debug.enable)" = "false"
23 # NM will create the file after being re-started by the hook, wait a bit
24 wait_for_network_manager
25 sleep 5
26 test ! -f /var/snap/network-manager/current/.debug_enabled
27 network-manager.nmcli g log | MATCH "^INFO"
diff --git a/tests/main/documentation-builds/task.yaml b/tests/main/documentation-builds/task.yaml
0new file mode 10064428new file mode 100644
index 0000000..fd2a358
--- /dev/null
+++ b/tests/main/documentation-builds/task.yaml
@@ -0,0 +1,14 @@
1summary: Verify the project documentation is building without errors
2
3execute: |
4 # Need to install in devmode as otherwise the snap can't access our project
5 # home which is outside of the home directory of our current user.
6 snap install --devmode documentation-builder
7
8 outdir=$PROJECT_PATH/docs/snap/build
9
10 cd $PROJECT_PATH/docs/snap
11 /snap/bin/documentation-builder --output-path $outdir
12
13 # Ensure we have some files in the output directory
14 test `find $outdir -type f | wc -l` -gt 0
diff --git a/tests/main/ethernet-managed-by-networkmanager/task.yaml b/tests/main/ethernet-managed-by-networkmanager/task.yaml
0new file mode 10064415new file mode 100644
index 0000000..a3c1b13
--- /dev/null
+++ b/tests/main/ethernet-managed-by-networkmanager/task.yaml
@@ -0,0 +1,16 @@
1summary: When defaultrender is set NM manages ethernet
2
3execute: |
4 . $TESTSLIB/utilities.sh
5 snap set network-manager defaultrenderer=true
6 netplan apply
7 # Whenever we can call netplan from the NM snap, the following line won't
8 # be needed
9 systemctl restart systemd-networkd
10 sleep 5
11 networkctl | grep 'eth0.*unmanaged'
12 wait_for_network_manager
13 /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
14 snap set network-manager defaultrenderer=false
15 netplan apply
16 systemctl restart systemd-networkd
diff --git a/tests/main/installation/task.yaml b/tests/main/installation/task.yaml
0new file mode 10064417new file mode 100644
index 0000000..bdaf48d
--- /dev/null
+++ b/tests/main/installation/task.yaml
@@ -0,0 +1,17 @@
1summary: Test network-manager snap installation was successful
2
3execute: |
4 . $TESTSLIB/utilities.sh
5
6 # Service should be up an running
7 wait_for_network_manager
8
9 # .. and nmcli should be able to reach NetworkManager
10 /snap/bin/network-manager.nmcli g
11
12 # Ensure all necessary plugs/slots are connected
13 snap interfaces | grep -Pzq ":network-setup-observe +[a-z,-]*network-manager"
14 snap interfaces | grep -Pzq ":ppp +[a-z,-]*network-manager"
15 snap interfaces | grep -Pzq ":firewall-control +[a-z,-]*network-manager"
16 snap interfaces | grep -Pzq ":network-setup-observe +[a-z,-]*network-manager"
17 snap interfaces | grep -Pzq "network-manager:service +network-manager:nmcli"
diff --git a/tests/main/set-hostname/task.yaml b/tests/main/set-hostname/task.yaml
0new file mode 10064418new file mode 100644
index 0000000..69b27c8
--- /dev/null
+++ b/tests/main/set-hostname/task.yaml
@@ -0,0 +1,17 @@
1summary: Verify we can modify the hostname of the system
2
3execute: |
4 . "$TESTSLIB/utilities.sh"
5
6 wait_for_network_manager
7
8 # Print out current hostname for nm and hostnamed to have a reference
9 # for debugging later.
10 /snap/bin/network-manager.nmcli general hostname
11 hostnamectl
12
13 expected_hostname=foobar
14 /snap/bin/network-manager.nmcli general hostname $expected_hostname
15 test "`/snap/bin/network-manager.nmcli general hostname`" = "$expected_hostname"
16 test "`hostnamectl status | grep Static`" = " Static hostname: $expected_hostname"
17 test "`hostname`" = "$expected_hostname"
diff --git a/tests/main/static-ip-configuration/task.yaml b/tests/main/static-ip-configuration/task.yaml
0new file mode 10064418new file mode 100644
index 0000000..6c86dda
--- /dev/null
+++ b/tests/main/static-ip-configuration/task.yaml
@@ -0,0 +1,49 @@
1summary: Test static IP configuration
2
3restore: |
4 # Ensure that the created virtual network interfaces are removed
5 # in any case when we're done
6 if [ -e /sys/class/net/veth0 ] ; then
7 ip link delete veth0
8 fi
9
10execute: |
11 . $TESTSLIB/utilities.sh
12
13 ip link add dev veth0 type veth peer name veth1
14
15 wait_for_network_manager
16 # NetworkManager should ignore the other side of our pipe so
17 # that we can configure it statically.
18 /snap/bin/network-manager.nmcli d set veth1 managed no
19 ip addr add 10.0.1.1/24 dev veth1
20
21 connection=veth0-static
22 /snap/bin/network-manager.nmcli c add con-name $connection type ethernet ifname veth0 \
23 ip4 10.0.1.2/24
24 /snap/bin/network-manager.nmcli c up $connection
25 /snap/bin/network-manager.nmcli d | grep 'veth0.*connected'
26
27 # Address should be correctly applied now
28 expected_veth0_address="10.0.1.2/24"
29 /snap/bin/network-manager.nmcli -m multiline -f IP4.ADDRESS c show veth0-static | grep $expected_veth0_address
30 ip addr show dev veth0 | grep 'UP'
31 ip addr show dev veth0 | grep $expected_veth0_address
32
33 # Routing needs to be in place as well
34 expected_veth0_route="10.0.1.0/24 dev veth0 proto kernel scope link src 10.0.1.2 metric 101"
35 ip route | grep "$expected_veth0_route"
36
37 # Disable connection and ensure IP configuration is removed
38 /snap/bin/network-manager.nmcli c down $connection
39 ip addr show dev veth0 | grep -v $expected_veth0_address
40 ip route | grep -v "$expected_veth0_route"
41
42 # Enabling network connection again and removing it should remove
43 # the IP configuration too
44 /snap/bin/network-manager.nmcli c up $connection
45 ip addr show dev veth0 | grep $expected_veth0_address
46 ip route | grep "$expected_veth0_route"
47 /snap/bin/network-manager.nmcli c delete $connection
48 ip addr show dev veth0 | grep -v $expected_veth0_address
49 ip route | grep -v "$expected_veth0_route"
diff --git a/tests/main/wifi-connect-secured-ap/task.yaml b/tests/main/wifi-connect-secured-ap/task.yaml
0new file mode 10064450new file mode 100644
index 0000000..46c2ba6
--- /dev/null
+++ b/tests/main/wifi-connect-secured-ap/task.yaml
@@ -0,0 +1,14 @@
1summary: Test connection to a secured WiFi AP
2
3environment:
4 WIFI_SSID: Ubuntu
5 WIFI_PASSPHRASE: Test1234
6
7execute: |
8 . $TESTSLIB/utilities.sh
9
10 create_ap "$WIFI_SSID" "$WIFI_PASSPHRASE"
11
12 # Connect to the AP and ensure the connection was established
13 /snap/bin/network-manager.nmcli d wifi connect $WIFI_SSID password $WIFI_PASSPHRASE
14 /snap/bin/network-manager.nmcli d | grep 'wlan1.*connected'
diff --git a/tests/main/wifi-powersave-config-option/task.yaml b/tests/main/wifi-powersave-config-option/task.yaml
0new file mode 10064415new file mode 100644
index 0000000..621256e
--- /dev/null
+++ b/tests/main/wifi-powersave-config-option/task.yaml
@@ -0,0 +1,31 @@
1summary: Verify WiFi powersave can be enabled via a snap config option
2
3environment:
4 WIFI_POWERSAVE_CONF_PATH: /var/snap/network-manager/current/conf.d/wifi-powersave.conf
5
6execute: |
7 . $TESTSLIB/utilities.sh
8
9 # The mac80211_hwsim driver does not support the powersave mode
10 # so we can't check this reliable.
11
12 test "`snap get network-manager wifi.powersave`" = "disabled"
13 grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH
14
15 # Try to enable and disable again
16 snap set network-manager wifi.powersave=enabled
17 wait_for_network_manager
18 test "`snap get network-manager wifi.powersave`" = "enabled"
19 grep "wifi.powersave = 3" $WIFI_POWERSAVE_CONF_PATH
20
21 snap set network-manager wifi.powersave=disabled
22 wait_for_network_manager
23 test "`snap get network-manager wifi.powersave`" = "disabled"
24 grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH
25
26 # Specifying no value means the snap should use the default
27 # which is 'disable'
28 snap set network-manager wifi.powersave=
29 wait_for_network_manager
30 test "`snap get network-manager wifi.powersave`" = "disabled"
31 grep "wifi.powersave = 2" $WIFI_POWERSAVE_CONF_PATH
diff --git a/tests/main/wifi-wowlan-config-option/task.yaml b/tests/main/wifi-wowlan-config-option/task.yaml
0new file mode 10064432new file mode 100644
index 0000000..a0e1e0b
--- /dev/null
+++ b/tests/main/wifi-wowlan-config-option/task.yaml
@@ -0,0 +1,77 @@
1summary: Verify WiFi WoWLAN can be enabled via a snap config option
2
3environment:
4 WIFI_WOWL_CONF_PATH: /var/snap/network-manager/current/conf.d/wifi-wowlan.conf
5
6execute: |
7 . $TESTSLIB/utilities.sh
8
9 # The mac80211_hwsim driver does not support WoWLAN so we can't
10 # check this reliable on the hardware level and will only check
11 # in the following that the correct configuration for
12 # NetworkManager itself is written out.
13
14 test `snap get network-manager wifi.wake-on-wlan` = disabled
15 grep "^wifi.wake-on-wlan=0$" $WIFI_WOWL_CONF_PATH
16
17 test "`snap get network-manager wifi.wake-on-wlan-password`" = ""
18 grep -v "^wifi.wake-on-wlan-password=.*$" $WIFI_WOWL_CONF_PATH
19
20 snap set network-manager wifi.wake-on-wlan-password=Test1234
21 wait_for_network_manager
22 grep "^wifi.wake-on-wlan-password=Test1234$" $WIFI_WOWL_CONF_PATH
23 # Setting the password alone should keep the actual WoWLAN value
24 # still unset so that NetworkManager uses its default.
25 grep -v "^wifi.wake-on-wlan=.*$" $WIFI_WOWL_CONF_PATH
26
27 snap set network-manager wifi.wake-on-wlan=magic
28 wait_for_network_manager
29 grep "^wifi.wake-on-wlan=8$" $WIFI_WOWL_CONF_PATH
30 grep "^wifi.wake-on-wlan-password=Test1234$" $WIFI_WOWL_CONF_PATH
31
32 # Test all other possible keys for the wifi.wake-on-wlan option
33 snap set network-manager wifi.wake-on-wlan=disabled
34 wait_for_network_manager
35 grep "^wifi.wake-on-wlan=0$" $WIFI_WOWL_CONF_PATH
36
37 snap set network-manager wifi.wake-on-wlan=any
38 wait_for_network_manager
39 grep "^wifi.wake-on-wlan=2$" $WIFI_WOWL_CONF_PATH
40
41 snap set network-manager wifi.wake-on-wlan=disconnect
42 wait_for_network_manager
43 grep "^wifi.wake-on-wlan=4$" $WIFI_WOWL_CONF_PATH
44
45 snap set network-manager wifi.wake-on-wlan=magic
46 wait_for_network_manager
47 grep "^wifi.wake-on-wlan=8$" $WIFI_WOWL_CONF_PATH
48
49 snap set network-manager wifi.wake-on-wlan=gtk-rekey-failure
50 wait_for_network_manager
51 grep "^wifi.wake-on-wlan=16$" $WIFI_WOWL_CONF_PATH
52
53 snap set network-manager wifi.wake-on-wlan=eap-identity-request
54 wait_for_network_manager
55 grep "^wifi.wake-on-wlan=32$" $WIFI_WOWL_CONF_PATH
56
57 snap set network-manager wifi.wake-on-wlan=4way-handshake
58 wait_for_network_manager
59 grep "^wifi.wake-on-wlan=64$" $WIFI_WOWL_CONF_PATH
60
61 snap set network-manager wifi.wake-on-wlan=rfkill-release
62 wait_for_network_manager
63 grep "^wifi.wake-on-wlan=128$" $WIFI_WOWL_CONF_PATH
64
65 snap set network-manager wifi.wake-on-wlan=tcp
66 wait_for_network_manager
67 grep "^wifi.wake-on-wlan=256$" $WIFI_WOWL_CONF_PATH
68
69 # Not setting any concrete value should remove the configuration
70 snap set network-manager wifi.wake-on-wlan-password=
71 wait_for_network_manager
72 grep -v "^wifi.wake-on-wlan-password=.*$" $WIFI_WOWL_CONF_PATH
73
74 snap set network-manager wifi.wake-on-wlan=
75 wait_for_network_manager
76 grep -v "^wifi.wake-on-wlan=.*$" $WIFI_WOWL_CONF_PATH
77 grep -v "^wifi.wake-on-wlan-password=.*$" $WIFI_WOWL_CONF_PATH
diff --git a/tests/main/wifi-wowlan-enabled-correctly/task.yaml b/tests/main/wifi-wowlan-enabled-correctly/task.yaml
0new file mode 10064478new file mode 100644
index 0000000..8fcaecc
--- /dev/null
+++ b/tests/main/wifi-wowlan-enabled-correctly/task.yaml
@@ -0,0 +1,30 @@
1summary: Verify WiFi WoWLAN can be enabled in NetworkManager globally via a snap config option
2
3execute: |
4 . $TESTSLIB/utilities.sh
5
6 # Enable WoWLAN globally for all new WiFi connections
7 snap set network-manager wifi.wake-on-wlan=any
8 wait_for_network_manager
9
10 # Get us an AP via the wifi-ap we can use to create a connection to
11 create_ap Ubuntu
12
13 # Connect to the AP and ensure the connection was established
14 /snap/bin/network-manager.nmcli d wifi | grep Ubuntu
15 /snap/bin/network-manager.nmcli d wifi connect Ubuntu
16 /snap/bin/network-manager.nmcli d | grep 'wlan1.*connected'
17
18 # Now that we're connected a new connection exists which we can look at
19 # to verify that the WoWLAN key is correctly set.
20 /snap/bin/network-manager.nmcli c show Ubuntu | grep '802-11-wireless.wake-on-wlan:.*0x1 (default)'
21
22 if [ "$SPREAD_SYSTEM" = "hw-ubuntu-core-16" ]; then
23 if ! iw phy phy0 info | grep -q "WoWLAN support:" ; then
24 echo "INFO: Hardware does not support WoWLAN so we're not testing application"
25 echo " of the configuration option on the hardware."
26 exit 0
27 fi
28 iw phy phy0 wowlan show | grep "WoWLAN is enabled"
29 iw phy phy0 wowlan show | grep "wake up on special any trigger"
30 fi

Subscribers

People subscribed via source and target branches