Commit graph

24467 commits

Author SHA1 Message Date
Thomas Haller
bc9baf0fd5 shared: add nm_pint_hash()/nm_pint_equals() utils 2019-11-25 12:58:33 +01:00
Thomas Haller
d0f385ce34 sd: cleanup integrating systemd's event loop with GMainContext
Get rid of the default_source_id global for tracking the default
event. It's not useful to track this.
2019-11-25 12:58:33 +01:00
Rafael Fontenelle
52cd4878a6 po: update Brazilian Portuguese (pt_BR) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/346
2019-11-25 10:24:42 +01:00
Beniamino Galvani
a73efb059f manager: don't activate device if the parent is missing
In multiple places we currently proceed to creating a virtual device
even if the connection specifies a parent device which is
missing. This can be easily reproduced with:

  nmcli con add type vxlan ifname vxlan1 \
                vxlan.parent not-exists \
                id 43 remote 172.25.1.1

which creates a vxlan1 interface without activating any
connection. Add a check to prevent this.

https://bugzilla.redhat.com/show_bug.cgi?id=1774074
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/344
2019-11-25 08:58:27 +01:00
Thomas Haller
0521e06ff1 contrib/rpm: avoid warning in specfile about tokens after %endif
warning: extra tokens at the end of %endif directive in line 717:  %endif # end autotools
warning: extra tokens at the end of %endif directive in line 775:  %endif # end autotools
2019-11-23 17:01:41 +01:00
Thomas Haller
d3c7083f97 dhcp: switch IPv4 "internal" DHCP client to use "nettools" backend instead of "systemd"
Previously, our "internal" DHCPv4 client is based on a fork of
systemd code. This manner of maintaining the fork is problematic.
The solution is to use a proper library: n-dhcp4 from the nettools
project.

We already have these two as undocumented plugins available, by
setting either "dhcp=systemd" or "dhcp=nettools". This is only for
testing. Users are only supposed to use the "internal" plugin.

Up until now, the "internal" DHCPv4 plugin was based on "systemd" code.
Change that to use "nettools" instead.

Possibly this breaks something, and we need to fix it. But do this
early so we have time to test the nettools plugin and identify issues.

For the user, this change should be entirely transparant.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/302
2019-11-23 09:21:55 +01:00
Beniamino Galvani
ccfc3370af iface-helper: accept new DHCP4 leases
The new lease must be accepted or the nettools client will not renew
it.
2019-11-23 09:14:14 +01:00
Thomas Haller
6cf1262ac5 all: merge branch 'th/connectivity-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/343
2019-11-23 08:06:23 +01:00
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