Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
dba41ee1e1 cli: return NULL strv array from _ip_config_get_routes() if there are no routes
The property getter for certain properties tries to return
a strv array.

In this case, the result should be identical, whether an
empty strv array or NULL is returned.

Let _ip_config_get_routes() return %NULL if there are no routes.
This should have no practical difference, but it actually exposes
a bug in "cli/common/utils.c", which was previously hidden by
not commonly returning %NULL. This bug will be fixed in the
next commit.
2018-06-15 11:48:16 +02:00
Thomas Haller
b29bf1b079 wifi: merge branch 'wake-on-wlan' (partial)
https://github.com/NetworkManager/NetworkManager/pull/124
2018-06-15 09:47:46 +02:00
Thomas Haller
36e9ec0554 wifi: fix check for valid NMSettingWirelessWakeOnWLan flag 2018-06-15 09:46:26 +02:00
Thomas Haller
8cba4d95df device/wifi: use _LOGD() macros in wake_on_wlan_enable()
_LOGD() is preferred, because it includes a common prefix depending
on the device. This macro requires, that we have a suitable @self
variable in the local scope.
2018-06-15 09:46:26 +02:00
Alfonso Sánchez-Beato
e7d26cd871 NEWS: add note about new WoWLAN settings 2018-06-15 09:46:26 +02:00
Alfonso Sánchez-Beato
cb8003c40d cli: add support for wake-on-wlan properties 2018-06-15 09:46:26 +02:00
Alfonso Sánchez-Beato
ca3bbede74 core: don't shutdown interfaces if they have wowlan enabled
This is to support the S5 case, where usually the NM process is
stopped. If we are stopping and WoWLAN is set for the interface,
we do not deconfigure it and keep the connection alive so we
can receive packages that will potentially wake up the system.

Note that for this work, wpa_supplicant needs to be modified too
so it does not deconfigure the wireless interface either when
stopped. The needed patches for wpa_supplicant can be found in
http://lists.infradead.org/pipermail/hostap/2018-June/038644.html
2018-06-15 09:46:26 +02:00
Simon Fels
ea10016d24 devices: enable wake-on-wlan when device is enabled
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
2018-06-15 09:46:26 +02:00
Simon Fels
1621c79e7b platform: add support for wake-on-wlan
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
2018-06-15 09:46:26 +02:00
Simon Fels
58cdc7b550 libnm-core: add wake-on-wlan configuration items
Co-authored-by: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
2018-06-15 09:46:26 +02:00
Lubomir Rintel
7af1bc7cf0 ovs: only finish waiting for a link when we actually got one
https://bugzilla.redhat.com/show_bug.cgi?id=1546659
2018-06-15 09:44:04 +02:00
Thomas Haller
086eadd5ba device: merge branch 'th/device-reapply-metric' (partial)
https://github.com/NetworkManager/NetworkManager/pull/138
2018-06-15 09:09:54 +02:00
Thomas Haller
6e12e18c15 device: simplify nm_device_hash_check_invalid_keys()
Rather trivial change. Return-early, to completely handle the simpler
case (the success case) first. In the failure case, we only need
extra effort to generate a nice error message.
2018-06-15 09:07:19 +02:00
Thomas Haller
b31bc4fa6c core/trivial: rename local variables to make code clearer 2018-06-15 09:07:19 +02:00
Thomas Haller
79159f61c7 device: check for proxy setting separately in can_reapply_change()
Proxy setting has no property NM_SETTING_IP_CONFIG_ROUTE_TABLE.
It's odd to handle it in the same if-block with IP configs.
2018-06-15 09:07:19 +02:00
Thomas Haller
9586d2794a shared: simplify nm_g_object_ref_set()
Also, assign *_pp before unref-ing the old value. Calling
g_object_unref() on the old value, might invoke callbacks
that are out of control of nm_g_object_ref_set(). During
that time, the pointer should already be assigned the new value,
instead of having an intermediate %NULL value. In most cases,
this would of course not matter, but there is no need to let
anyone see an intermediate %NULL value for a moment.

Also, don't use typeof(**_pp), which would not work with opaque
types (like we commonly have).
2018-06-15 09:07:19 +02:00
Thomas Haller
fe1f5871c8 device: fix crash during reapply
Fixes: bf3b3d444c
2018-06-15 09:07:19 +02:00
Lubomir Rintel
9c0db98094 Revert "example/python: avoid falling back to CLOCK_MONOTONIC"
This breaks client tests on avery old kernel (2.6.32, RHEL 6).

  Traceback (most recent call last):
    File "./clients/tests/test-client.py", line 699, in setUp
      self.srv = NMStubServer(self._testMethodName)
    File "./clients/tests/test-client.py", line 309, in __init__
      start = nmex.nm_boot_time_ns()
    File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 54, in nm_boot_time_ns
      return sys_clock_gettime_ns(CLOCK_BOOTTIME)
    File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 50, in sys_clock_gettime_ns
      return _sys_clock_gettime_ns(clock_id)
    File "/builddir/build/BUILD/NetworkManager-1.11.4/examples/python/nmex.py", line 39, in f
      raise OSError(errno_, os.strerror(errno_))
  OSError: [Errno 22] Invalid argument

This reverts commit 119e828dbe.
2018-06-15 08:36:22 +02:00
Lubomir Rintel
119e828dbe example/python: avoid falling back to CLOCK_MONOTONIC
According to the D-Bus API specification we return CLOCK_BOOTTIME only.
We don't support kernels too old to have it -- the fall back to
CLOCK_MONOTONIC is only there to be able to run unit tests on RHEL 6
kernel and will eventually go away.
2018-06-14 17:30:06 +02:00
Thomas Haller
9a14f9caa5 clients/tests: fix unstable tests for Python2 vs. Python3
Currently, nmcli does not sort the list of available connections
for display. Instead, it shows them in the order as NetworkManager
exposes them on D-Bus.

Previously, test-networkmanager-service.py, would generate the list
of available connections by iterating the connections dictionary.
In Python (at least until Python 3.6), the order when iterating over
dictionaries is undefined. This inconsistancy lets tests behave
differently depending on the python version. Possibly with Python
3.4 and 3.5, tests might even behave differently between individual
runs (since Python there uses siphash with a randomized hash seed).
2018-06-14 16:38:33 +02:00
Thomas Haller
fb5f555a54 clients/tests: add more tests printing wifi details in nmcli 2018-06-14 15:45:34 +02:00
Beniamino Galvani
bb20f2eb61 macsec: enable send-sci by default and make the option configurable
It is safer to enable send-sci by default because, at the cost of
8-byte overhead, it makes MACsec work over bridges (note that kernel
also enables it by default). While at it, also make the option
configurable.

https://bugzilla.redhat.com/show_bug.cgi?id=1588041
2018-06-14 15:13:11 +02:00
Thomas Haller
ed638b7126 clients/tests: document importance of locale for clients tests 2018-06-14 13:57:14 +02:00
Lubomir Rintel
6373196ffd merge: branch 'lr/wwan-ppp-route-rh1585611'
https://github.com/NetworkManager/NetworkManager/pull/132
2018-06-14 10:28:00 +02:00
Lubomir Rintel
650b5fd99e wwan: ensure the route parameters are set on IPv6 only configuration 2018-06-13 16:56:51 +02:00
Lubomir Rintel
267948f2b7 wwan: set the route parameters at the beginning of ip4 config
We set the metric to the routes as we receive them from the PPP plugin. We
ought to let the modem know before it starts IPv4 configuration, not right
before the commit.

https://bugzilla.redhat.com/show_bug.cgi?id=1585611
2018-06-13 16:45:24 +02:00
Andrew Zaborowski
140ada3aad cli: Actually add passwords to the AddAndActivateConnection arguments
Check the wpa_flags and rsn_flags values to see if the network needs the
password added to the 802-11-wireless-security settings.  The current
ap_flags check alone would only trigger the password to be sent for WEP
networks.  Also remove unneeded initialization of the three variables.
2018-06-13 15:59:48 +02:00
Lubomir Rintel
2a7a36494a cli: drop an unused variable
clients/cli/connections.c:1909:3: error: unused variable 'out_indices' [-Werror,-Wunused-variable]
                NMC_OUTPUT_DATA_DEFINE_SCOPED (out);
                ^
2018-06-13 15:58:20 +02:00
Lubomir Rintel
74c2a0aca4 device: drop an unused variable
src/devices/nm-device.c:7764:25: error: unused variable 'stable_hwaddr' [-Werror,-Wunused-variable]
        gs_unref_bytes GBytes *stable_hwaddr = NULL;
                               ^
2018-06-13 15:56:27 +02:00
Lubomir Rintel
4bb1130ce6 merge: branch 'lr/cli-wifi-list-rescan'
https://github.com/NetworkManager/NetworkManager/pull/128
2018-06-13 15:34:04 +02:00
Lubomir Rintel
34412a8d3d cli/devices: rescan the Wi-Fi network if the AP list is not fresh enough 2018-06-13 14:48:23 +02:00
Lubomir Rintel
ca29761212 cli/devices: parse "nmcli d wifi list" arguments with next_arg()
For no reason at all.
2018-06-13 14:44:42 +02:00
Lubomir Rintel
e6abc96e13 cli/utils: make next_arg() recognize arguments that are not in "--option" form
This is going to make it possible to parse and complete argument lists in one go:

  -nmc_complete_strings (*argv, "ifname", "bssid", NULL);
  -next_arg (nmc, &argc, &argv, NULL);
  -if (strcmp (*argv, "ifname") == 0)
  -...
  -else if (strcmp (*argv, "bssid") == 0)
  -...
  +option = next_arg (nmc, &argc, &argv, "ifname", "bssid", NULL)
  +switch (option) {
  +case 1:
  +...
  +case 2:
  +...

Beautiful.
2018-06-13 14:44:18 +02:00
Lubomir Rintel
c00e17578f wifi: expose the LastScan property
This is the time when the last Wi-Fi scan finished. It will help clients
decide whether the AP list is fresh enough.
2018-06-13 14:44:06 +02:00
Thomas Haller
c2932dd7db clients/tests: better document how to re-generate files for clients tests 2018-06-13 08:50:46 +02:00
Thomas Haller
97bb298f58 dhcp: merge branch 'th/dhcp-client-id'
https://github.com/NetworkManager/NetworkManager/pull/133
2018-06-12 15:39:59 +02:00
Thomas Haller
fd878d8261 examples: add ipv4.dhcp-client-id and ipv6.dhcp-duid to 30-anon.conf example 2018-06-12 14:45:40 +02:00
Thomas Haller
92b8161578 libnm: avoid allocating GBytes in _nm_utils_dhcp_duid_valid()
In a lot of cases, we don't require the GBytes out-argument. This
is the case when called from NMSettingIP6Config's verify().
Avoid allocating the GBytes instance and also don't heap allocate
the temporary buffer in that case.

Also, being called from NMSettingIP6Config's verify(), at which
point the string value contains untrusted data. Of course, we
do very badly in general protecting against the user creating
huge settings, which could trick NetworkManage to allocate
large amounts of memory (and being killed by glib's out of memory
handling). We should handle such cases better in general, but
just avoid it here.

Since we know that the buffer must hold at most 128+2 bytes,
we can stack allocate it. Later, in case we really need to
return the value, we can create a GBytes instance of the right
size.
2018-06-12 14:45:40 +02:00
Thomas Haller
988cecb6d3 device: log generated ipv4.dhcp-client-id in <debug> mode 2018-06-12 14:45:40 +02:00
Thomas Haller
67ffd17b6c device: unify logging of ipv6.dhcp-duid by giving common prefix
For better or worse, the logging done for ipv4.dhcp-client-id
is prefixed with ipv4.dhcp-client-id. Let ipv6.dhcp-duid follow
that pattern.

Also, generate_duid_from_machine_id() would log at two places,
it should use the same logging prefix.

Also, it logs the value of "duid" variable. Ensure, that "duid"
is not %NULL at that point.

Also, fix leak of nm_dhcp_utils_duid_to_string() value during logging.
2018-06-12 14:45:40 +02:00
Thomas Haller
374d147421 device: refactor generate_duid_from_machine_id() to have a straight forward code path
Previously, there were two blocks

  if (NM_IN_SET (duid, "ll", "llt")
     preprocess_hwaddr()
  else if (NM_IN_SET (duid, "stable-ll", "stable-llt", "stable-uuid"))
     preprecess_stable_id()

  if (nm_streq (duid, "ll")
     generate_ll()
  else if (nm_streq (duid, "llt"))
     generate_llt()
  else if (nm_streq (duid, "stable-ll")
     generate_stable_ll()
  ...

That is, the latter block depends on the execution of the previous
block, while the previous block is guarded by a particular condition,
slighlty different than the condition in the later block.

It is confusing to follow. Instead, check for our cases one by one, and
when we determined a particular DUID type, process it within the same block
of code. Now the code consists of individual blocks, that all end with a "goto
out*". That means, it's easier to understand the flow of the code.

Also, don't initialize duid_error variable and separate between
"out_error" and "out_good". This allows that the compiler gives
a warning if we missed ot initialize duid_error.
2018-06-12 14:45:40 +02:00
Thomas Haller
6d06a0e1b0 device: handle failure in generate_duid_from_machine_id() in dhcp6_get_duid()
dhcp6_get_duid() already handles failure to generate the DUID in a
sensible manner. No reason to duplicate the error handling in
generate_duid_from_machine_id().

Especially, because generate_duid_from_machine_id() used to cache the
random DUID in memory and reuse it from then on. There is no reason to do
that, /etc/machine-id must be available to NetworkManager. We still
handle such a grave error gracefully by generating a random DUID.
2018-06-12 14:45:40 +02:00
Thomas Haller
8bb1aed2ad device: fix enforcing ipv6.dhcp-duid for binary DUID 2018-06-12 13:30:36 +02:00
Thomas Haller
5df4c17ba1 device: handle failure to generate ipv4.dhcp-client-id by fallback to random client-id
First of all, generating the client-id is not expected to fail. If it fails,
something is already very wrong. Maybe, a failure to generate a client-id
should result in failing the activation. However, let's not go full
measure in this question.

Instead:
- ensure that we log a warning and a reason why the client-id could not
  be generated.
- fallback to a random client id. Clearly, we were unable to generate
  the requested client-id, hence, we should fallback to a default value
  which does not make the host easily identifyable. Of course, that means
  that the generated DHCP client-id is not at all stable. But note that
  something is already very wrong, so when handling the error we should do
  something conservative (that is, protecting the users privacy).

This is also what happens for a failure to generate the ipv6.dhcp-duid.
2018-06-12 13:30:36 +02:00
Thomas Haller
d9488417e7 device: obtain current MAC address from platform for generating ipv4.dhcp-client-id=mac
In practice, there should be no difference between peeking into
the platform cache, or using the cached value from nm_device_get_hw_address().

Prefer the hardware address from the platform, because:
- we also pass the current MAC address to nm_dhcp_manager_start_ip4().
  For not particularly strong reason, it uses the MAC address obtained
  from platform. At the least, it makes sense that we use the same
  addresses for the client-id as well.
- ipv6.dhcp-duid also gets the address from platform. Again,
  no strong reason either way, but they should behave similar
  in this regard.
2018-06-12 10:23:40 +02:00
Andrew Zaborowski
e8a197506c client: cli: Fix message in connect callback
https://github.com/NetworkManager/NetworkManager/pull/134
2018-06-12 08:09:48 +02:00
Thomas Haller
ea23010baa contrib/rpm: fix dependency for /sbin/update-alternatives
Fixes: 28d2c07661
2018-06-11 22:07:35 +02:00
Thomas Haller
65869314c2 clients/tests: merge branch 'th/more-clients-tests' 2018-06-11 19:31:46 +02:00
Thomas Haller
d739247e9f clients/tests: minor cleanup iterating over various nmcli output modes 2018-06-11 19:30:50 +02:00
Thomas Haller
acdc9df824 clients/tests: add tests for nmcli device wifi list output
This test shows how

  $ nmcli device wifi list bssid "$BSSID"

is broken.
2018-06-11 19:30:50 +02:00