Commit graph

24459 commits

Author SHA1 Message Date
Thomas Haller
21845ae4e3 build/meson: cleanup "meson-post-install.sh"
- the variables in meson.build and in the meson-post-install.sh script
  should have the same names.

- the positional command line arguments should be assigned to variables,
  because the variable name acts like a documentation what the variable
  means (contrary to the argument number).

- the boolean flags should not map to other special values, like
  "enable_docs ? 'install_docs' : ''". The name "enable_docs" is
  good already, it shall be either passed as 1 or 0 and use the name
  consistently.
2019-11-22 16:07:02 +01:00
Thomas Haller
6d7270e222 build/meson: cleanup configuration_data() for paths
We don't need such data duplicated. The build setup should
have only one configuration_data() for patching such values.

Now we only have one global, immutable data_conf dictionary with
configuration values. Note that none of the users of data_conf uses all
entries, but as the entries are basically only dependent on the
meson/configure option and valid for the entire project, this simplifies
to handling.
2019-11-22 15:59:31 +01:00
Thomas Haller
18c5ce50fb build: create base directories for install-data-hook first
The dependencies of make are exectured in the order as they appear.
We probably should start by creating the directories, before invoking
other install hooks. Currently there is no difference, because none of
the other hooks depend on the base directories. Still split it to
a special target.
2019-11-22 15:59:31 +01:00
Thomas Haller
d1eb52f8ce build: cleanup Makefile.am by moving "data_edit" first
$(data_edit) will be used later at an earlier place in the
makefile (to edit "clients/cloud-setup/nm-cloud-setup.service",
which will be handled earlier). Move it.

Also minor cleanups, like allowing to incrementally build
systemdsystemunit_DATA variable.
2019-11-22 15:59:31 +01:00
Thomas Haller
033c2b82c2 core: move _LOG*() macros to "shared/nm-glib-aux/nm-logging-fwd.h"
We preferably should use our convenience macros like _LOGD().
Since those macros expand to _NMLOG() (which needs to be defined
separately), we can move it to "nm-logging-fwd.h" and reuse.
2019-11-22 15:32:52 +01:00
Thomas Haller
c24f122e22 connectivity: fix using curl_multi_strerror() for CURLMcode error code 2019-11-22 15:32:52 +01:00
Thomas Haller
0871c9533f connectivity: don't use the GIOChannel but poll the file descriptor directly
I guess, if you write portable applications, then GIOChannel makes a lot of sense.
But we know that this is on Linux. We don't need to pretend that we
cannot poll on the file descriptor directly.
2019-11-22 15:32:52 +01:00
Thomas Haller
05c31da4d9 connectivity: don't cancel curl timerfunction from timeout
Curl documents about CURLMOPT_TIMERFUNCTION:

  The timer_callback will only be called when the timeout expire time is
  changed.

That means, we should not cancel the timeout when it happend, but
only when the callback is called again (or during cleanup).

See-also: https://curl.haxx.se/libcurl/c/CURLMOPT_TIMERFUNCTION.html
2019-11-22 15:32:52 +01:00
Thomas Haller
ec868916c8 shared: move nm_utils_ip._address_clear_host_address() helpers to shared 2019-11-22 15:32:52 +01:00
Thomas Haller
2ef5014f98 shared: add nm_clear_g_source_inst()
glib really likes the numeric source IDs. That is, g_idle_add(), g_timeout_add(),
etc. return those IDs, that can then be destroyed with g_remove_source() (or
nm_clear_g_source()).

I think these numeric IDs are really not great.

- API like g_idle_add() and g_remove_source() only works with the g_main_context_get_default()
  instance. That means, you cannot use this API for any other contexts. If you'd insist on using
  numeric IDs, you'd need to call g_main_context_find_source_by_id() on the right context
  first (but you'd also have to track the context alongside the ID).
- g_remove_source() requires first a call to g_main_context_find_source_by_id(). This involves
  taking a mutex and doing an extra hash lookup.

Instead, it often seems preferable to use the GSource instance directly. It works
with any context, it can be referenced and unreferenced, and it can be destroyed, and
avoids the overhead of g_main_context_find_source_by_id().

The only downside really is that keeping a GSource pointer takes one pointer size, while
the guint source ID is usually only 4 bytes.

Anyway, I think we should deal more with GSource instances directly. Hence, add this
convenience macro, that works like nm_clear_g_source().
2019-11-22 15:32:52 +01:00
Thomas Haller
c40ff42ae6 shared: add nm_g_*_source_new() and nm_g_source_attach() helpers
Small utilities to make is more convenient to create and attach GSource
instances.
2019-11-22 15:32:52 +01:00
Thomas Haller
9c5741ccd2 shared/nm-glib: add compat implementation for G_SOURCE_FUNC()
G_SOURCE_FUNC() was only added in glib 2.58.
2019-11-22 15:32:52 +01:00
Thomas Haller
0f4819ab36 contrib/rpm: use proper check for nmtui conditional build 2019-11-22 15:32:52 +01:00
Thomas Haller
09e5a0e805 dhcp/nettools: fix format-nonliteral warning for printf in nettools_log()
../src/dhcp/nm-dhcp-nettools.c:1048:27: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
                    msg = g_strdup_vprintf (fmt, ap);
                                            ^~~

Fixes: 97a8785148 ('nettools: enable logging')
2019-11-22 14:34:01 +01:00
Thomas Haller
b733d477e8 gitlab-ci: run tests on extra distributions only manually
For the moment, we use docker images from dockerhub, which require
a lot of extra overhead to prepare and install the test environment.
This should be improved, by using more suitable container images.

Anyway, for now to alleviate the pressure on the freedesktop gitlab
infrastructure, disable most test to only run manually.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/241#note_282521
2019-11-22 13:46:22 +01:00
Thomas Haller
339df56887 gitlab-ci: use Fedora 30 to build documentation and archived tarball 2019-11-22 13:46:22 +01:00
Thomas Haller
c1dca47619 ifcfg: merge branch 'th/ifcfg-8021x-system-ca-certs' 2019-11-22 11:44:38 +01:00
Thomas Haller
5028206ec4 ifcfg: various cleanup in ifcfg writer
svUnsetValue (ifcfg, KEY);
    if (condition)
         svSetValue* (ifcfg, KEY, ...);

is not good. It requires first clearing the value, before setting
it again.

Various cleanup to fix such uses.
2019-11-22 11:39:47 +01:00
Thomas Haller
2a4fb75d3b ifcfg: add support for "802-1x.system-ca-certs" setting 2019-11-22 11:39:47 +01:00
Thomas Haller
87af96a9d6 ifcfg: add svSetValueBoolean_cond_true() helper 2019-11-22 11:39:47 +01:00
Beniamino Galvani
234cb5a923 dhcp: merge branch 'bg/nettools-log'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/337
2019-11-22 10:36:20 +01:00
Beniamino Galvani
97a8785148 nettools: enable logging 2019-11-22 10:24:49 +01:00
Beniamino Galvani
72270b9e0e n-dhcp4: log outgoing packets
Add log messages for outgoing packets.

https://github.com/nettools/n-dhcp4/pull/8
2019-11-22 10:24:49 +01:00
Beniamino Galvani
440f541672 n-dhcp4: log incoming packets
Add log messages for incoming packets.

https://github.com/nettools/n-dhcp4/pull/8
2019-11-22 10:24:49 +01:00
Beniamino Galvani
87a26ea594 n-dhcp4: add logging API
In some cases it is useful to have the library log what it is doing
for debugging purposes; add a simple API that allows setting a
syslog-style logging level and specifying a logging function.

https://github.com/nettools/n-dhcp4/pull/8
2019-11-22 10:24:49 +01:00
Beniamino Galvani
d99c91a05a merge: branch 'bg/carrier-rh1722024'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/306
https://bugzilla.redhat.com/show_bug.cgi?id=1722024
2019-11-22 10:21:17 +01:00
Beniamino Galvani
b232b5013f introspection: deprecate Carrier properties
Deprecate the 'Carrier' property present in some Device sub-interfaces
in favor of the 'Carrier' flag in the InterfaceFlags property, which
is more general as it is available for all interfaces.
2019-11-22 10:18:27 +01:00
Beniamino Galvani
2b7def052f all: add device carrier flag
Add a new 'carrier' flag to the InterfaceFlags property of devices to
indicate the current carrier state.

The new flag is equivalent to the 'lower-up' flag for all devices
except the ones that use a non-standard carrier detection mechanism
like NMDeviceAdsl.
2019-11-22 10:18:27 +01:00
Beniamino Galvani
62c811b2bd cli: print interface flags 2019-11-22 10:18:26 +01:00
Beniamino Galvani
e397582cca libnm: export interface flags
Add libnm support for the new InterfaceFlags property of NMDevice.
2019-11-22 10:18:26 +01:00
Beniamino Galvani
1b90ad41bb core: export interface flags of devices
Add a new read-only "InterfaceFlags" property to the Device interface
to export via D-Bus kernel flags and possibly other NM specific
flags. At the moment IFF_UP and IFF_LOWERUP are implemented.
2019-11-22 10:18:26 +01:00
Beniamino Galvani
6c86f68ac4 device: remove useless doc comment
D-Bus properties are already documented in the introspection xml
files.
2019-11-22 10:18:26 +01:00
Thomas Haller
037aa02aba dhcp/nettools: fix assertion failure to calculate lease lifetimes
Fixes: 0108d74866 ('dhcp/nettools: exactly calculate lease lifetimes')
2019-11-21 13:48:31 +01:00
Beniamino Galvani
838e5b87c2 ethernet: wait for carrier before starting supplicant
After we set link parameters (auto-negotiation, speed, duplex) in
stage1, the carrier can go down for several seconds because the
Ethernet PHY needs to renegotiate the link. Wait that carrier goes up
before starting the supplicant or the EAPoL start packet can be lost
causing an authentication failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1759797
2019-11-21 10:20:47 +01:00
Beniamino Galvani
4b4f18e77b device: check for disconnected state before activating NMActRequest
When a new activation request comes and the device is currently
activated, we move the device state to 'deactivating' and wait that it
reaches 'disconnected' before starting the new activation request.

In the meantime, a carrier change could happen but still we have to
wait that device finishes any pending deactivation.

https://bugzilla.redhat.com/show_bug.cgi?id=1772960

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/339
2019-11-21 10:08:20 +01:00
Thomas Haller
2025e3585f device: allow reapply of all "user" settings
[user] are arbitrary strings that can be attached to a connection.
NetworkManager itself does not care about them, they are only here
for other applications.

Allow reapplying changes to the user setting. Usually the reason to
reject reapplying a setting is because it's either not implemented
or not possible to change (without a full reactivation of the device).
In this case there is nothing to implement, and of course it's possible
to do so.
2019-11-20 17:48:03 +01:00
Beniamino Galvani
52c0304bbd n-dhcp4: fix state transitions on timer dispatch
Currently in any of the BOUND, RENEWING and REBINDING states the probe
checks the expiration of T1, T2 and lifetime. This is not correct
because, for example, if the timer fires in the RENEWING state, the
probe must not transition to RENEWING again (i.e. check again that
now >= T1). Note that there is no guarantee that the timer triggers
exactly once for T1, T2 and lifetime expirations because the timer is
also used for the retransmission logic in NDhcp4CConnection.

Therefore, add some checks to ensure that only correct transitions are
allowed.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/341

https://bugzilla.redhat.com/show_bug.cgi?id=1773456
2019-11-20 15:14:35 +01:00
Thomas Haller
a8f31aa23f dhcp/nettools: merge branch 'th/dhcp-lifetime'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/342
2019-11-20 15:03:28 +01:00
Thomas Haller
0108d74866 dhcp/nettools: exactly calculate lease lifetimes
Now that we can not only get the expiry timestamp of the lease
(n_dhcp4_client_lease_get_lifetime()), but also the base timestamp,
we can calculate the lifetime exactly.

Previously, we had to guess the base time by assuming that we just
received the lease *now*. This wasn't exact.
2019-11-20 14:54:39 +01:00
Thomas Haller
a8d46492b3 dhcp/nettools: don't trim the "expiry" timestamp to 32 bit
The "expiry" is the Unix timestamp when the lease expires.
This is not at all a useful parameter, in particular because
the system's clock can be reset. Instead, we should expose
the lease receive time stamp (in CLOCK_BOOTTIME), and the lease
lifetime.

Anyway. So, we somehow need to express infinite lifetimes. Previously,
we would use the special value 4294967295 (2^32-1). However, that value
does not seem so great, because it's also the Unix timestamp of
2106-02-07T06:28:15+0000. While that is quite far in the future, it's
a valid timestamp still. Of course, the code worked around that by never
setting a timestamp larger than 4294967295-1, but it still limits the
range of what we can expose.

Note that for the lifetime "dhcp_lease_time", we do express infinity
with 4294967295. That's fine, it also does not contradict what we
receive in the DHCP lease on the wire because the lifetime there is
expressed by a 32 bit integer.

Instead, for the "expiry" timestamp, don't perform such triming.
The expiry timestamp is just the start timestamp plus the lease
lifetime. If that is larger than 2106-02-07, so be it.
On the other hand, express infinity by omitting the "expiry" field.
2019-11-20 14:54:39 +01:00
Thomas Haller
42026f9fb3 shared: add nm_utils_monotonic_timestamp_from_boottime() util
We sometimes have a CLOCK_BOOTTIME and need to convert it
to NetworkManager's monotonic timestamps.
2019-11-20 14:54:39 +01:00
Thomas Haller
7040a4f93a n-dhcp4: merge branch 'lease-time'
Import the downstream addition for lease-time [1].
These are not merged upstream yet, but let's use
the patches already. If the patches that get merged
upstream eventually differ, we still can adjust our fork
easily.

[1] https://github.com/nettools/n-dhcp4/pull/5
2019-11-20 10:59:27 +01:00
Thomas Haller
d688019bf8 lease: add n_dhcp4_client_lease_get_basetime()
The API already had n_dhcp4_client_lease_get_lifetime(), which is the CLOCK_BOOTTIME
when the lease expires (or ((uint64_t)-1)). But it might be interesting to
know the actual lease duration and when the lease was received (and the
time started to count).

Expose an API for that. With this, one can also calculate the original, exact lease
lifetime, by subtracting n_dhcp4_client_lease_get_basetime() from n_dhcp4_client_lease_get_lifetime(),
while taking care of ((uint64_t)-1).
2019-11-20 10:58:51 +01:00
Thomas Haller
d29c8b615a incoming: don't handle 0xFFFFFFFF timestamps special in n_dhcp4_incoming_query_u32()
First of all, from the naming of n_dhcp4_incoming_query_u32() it is
confusing to coerce 0xFFFFFFFF to zero. It should just return the
plain value.

Also note that n_dhcp4_incoming_query_u32() only has three callers:
n_dhcp4_incoming_query_lifetime(), n_dhcp4_incoming_query_t1() and
n_dhcp4_incoming_query_t2().

Looking further, those three functions only have one caller:
n_dhcp4_incoming_get_timeouts(). Note how the code there already tries
to handle UINT32_MAX and interprets it as infinity (UINT64_MAX).
But as it was, UINT32_MAX never actually was returned.

It seems that RFC [1] does not specially define the meanings of
0xFFFFFFFF and 0. It sounds reasonable to assume that 0 just means
0 lifetime, and 0xFFFFFFFF means infinity. On the other hand, compare
this to systemd's code [2], which coerces 0 to 1. This does not seem
right to me though. Note how systemd returns 0xFFFFFFFF as-is.

Drop the special handling of 0xFFFFFFFF from n_dhcp4_incoming_query_u32().
It now just returns the plain value and it's up to n_dhcp4_incoming_get_timeouts()
to make sense of that. This will fix behavior, so that 0xFFFFFFFF will be
reported as infinity, and not as zero.

[1] https://tools.ietf.org/html/rfc2132#section-9.2
[2] 68c2b5ddb1/src/libsystemd-network/sd-dhcp-lease.c (L553)
2019-11-20 10:58:51 +01:00
Thomas Haller
ce5c8db175 probe: unconditionally pass ownership of message in n_dhcp4_client_probe_dispatch_io()
It is error prone when a function consumes an input only in certain
cases (and telling the caller via the return code). At least in these
cases, the message is never used afterwards, and we can always pass
it on.
2019-11-20 10:58:51 +01:00
Thomas Haller
499b0785d8 probe: fix leaking message during client probe 2019-11-20 10:58:51 +01:00
David Rheinsberg
1061ad485a n-dhcp4: ci: drop broken armv7hl
Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>

e4a01f5870
2019-11-20 10:50:17 +01:00
Beniamino Galvani
101e65d2bb ovs: allow changing mac address of bridges and interfaces
Allow changing the cloned MAC address for OVS bridges and
interfaces. The MAC address set on the bridge is propagated by ovs to
the local interface (the one with the same name as the bridge), while
all other internal interfaces use the address defined in the interface
connection.

https://bugzilla.redhat.com/show_bug.cgi?id=1763734
https://bugzilla.redhat.com/show_bug.cgi?id=1740557

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/321
2019-11-20 10:44:06 +01:00
Beniamino Galvani
508c7679cf ovs: fix memory leak 2019-11-20 10:44:06 +01:00
David Rheinsberg
9f1d6ce1a7 n-dhcp4: util/link: suppress gcc warning
Avoid strncpy() and suppress a gcc warning about a truncated
0-terminator.

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>

2546aa2c80
2019-11-20 10:42:57 +01:00