Commit graph

21312 commits

Author SHA1 Message Date
Thomas Haller
83c2aaf33a all: merge branch 'th/hexstr2bin-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/215
2018-09-30 16:32:04 +02:00
Thomas Haller
3a2504f3ad supplicant: use _nm_utils_hexstr2bin() for parsing hexstr 2018-09-30 16:13:42 +02:00
Thomas Haller
be6c7fa5f6 libnm: cleanup _nm_utils_hexstr2bin*() helper
Add 3 variants of _nm_utils_hexstr2bin*():

  - _nm_utils_hexstr2bin_full(), which takes a preallocated
    buffer and fills it.
  - _nm_utils_hexstr2bin_alloc() which returns a malloc'ed
    buffer
  - _nm_utils_hexstr2bin_buf(), which fills a preallocated
    buffer of a specific size.
2018-09-30 16:13:42 +02:00
Thomas Haller
b537c0388a all: drop _nm_utils_bin2hexstr()
We already have nm_utils_bin2hexstr() and _nm_utils_bin2hexstr_full().
This is confusing.

  - nm_utils_bin2hexstr() is public API of libnm. Also, it has
    a last argument @final_len to truncate the string at that
    length.
    It uses no delimiter and lower-case characters.

  - _nm_utils_bin2hexstr_full() does not do any truncation, but
    it has options to specify a delimiter, the character case,
    and to update a given buffer in-place. Also, like
    nm_utils_bin2hexstr() and _nm_utils_bin2hexstr() it can
    allocate a new buffer on demand.

  - _nm_utils_bin2hexstr() would use ':' as delimiter and make
    the case configurable. Also, it would always allocate the returned
    buffer.

It's too much and confusing. Drop _nm_utils_bin2hexstr() which is internal
API and just a wrapper around _nm_utils_bin2hexstr_full().
2018-09-30 13:36:57 +02:00
Thomas Haller
21df8d38ef libnm: return output buffer from _nm_utils_bin2hexstr_full()
It's just more convenient, as it allows better chaining.

Also, allow passing %NULL as @out buffer. It's clear how
large the output buffer must be, so for convenience let the
function (optionally) allocate a new buffer.

This behavior of whether to
  - take @out, fill it, and return @out
  - take no @out, allocate new buffer, fill and and return it
is slightly error prone. But it was already error prone before, when
it would accept an input buffer without explicit buffer length. I think
this makes it more safe, because in the common case the caller can avoid
pre-allocating a buffer of the right size and the function gets it
right.
2018-09-30 13:36:57 +02:00
Thomas Haller
6714440669 all/trivial: rename hexstr<>bin conversion functions
"bin2str" and "str2bin" are not very clear. These strings are
hex-strings. Rename.
2018-09-30 13:33:46 +02:00
Thomas Haller
474a0dbfbe libnm/macsec: tighten up verification and normalize mka_cak/mka_ckn properties 2018-09-30 13:33:46 +02:00
Thomas Haller
cfa89feb5e libnm: use nm_free_secret() in nm-setting-macsec.c 2018-09-29 11:20:28 +02:00
Thomas Haller
c09081dd2c cli: cleanup of error handling in nmc_property_set_bytes() 2018-09-29 11:20:28 +02:00
Beniamino Galvani
d6db262597 build: meson: merge branch 'bg/rpm-meson'
Add meson support to RPM spec file.

https://github.com/NetworkManager/NetworkManager/pull/212
2018-09-28 18:13:04 +02:00
Beniamino Galvani
295b9d5b81 contrib/rpm: support building with meson
Add support for building with meson, enabled by '--with meson' so that
we can regularly test the whole build+test+install procedure with
meson. I compared the RPM contents of NM, NM-libnm, NM-libnm-devel
packages and they match the autotools ones. It's also faster:

  $ time contrib/fedora/rpm/build_clean.sh -g -Q -f

  real    3m54.239s
  user    11m15.000s
  sys     1m28.456s

  $ time contrib/fedora/rpm/build_clean.sh -g -Q -f -w meson

  real    3m9.938s
  user    9m5.225s
  sys     1m4.392s
2018-09-28 17:25:46 +02:00
Beniamino Galvani
1f18783404 contrib/rpm: remove duplicate documentation
In NetworkManager-libnm-devel we ship the same documentation in two
different places:

 /usr/share/doc/NetworkManager-libnm-devel
 /usr/share/gtk-doc/html/NetworkManager

Remove the former, which was added in commit e01c17523a.

Also, remove the same documentation from NetworkManager-glib-devel
since it's already present in NetworkManager-libnm-devel.
2018-09-28 17:25:46 +02:00
Beniamino Galvani
34ffd9fcab build: meson: install ifcfg-rh files and directory 2018-09-28 17:25:46 +02:00
Beniamino Galvani
24fc3c54a3 build: meson: fix install script
Fix directory paths and modes.

Fixes: 98b4a19a53
2018-09-28 17:25:46 +02:00
Beniamino Galvani
dcfddeef7a build: meson: fix generation of api docs
We need to copy all introspection files to the same directory when
building the documentation.

Note that we only require Meson 0.44, but for the documentation at
least 0.46 is needed because of a new functionality of
gnome.gdbus_codegen(). In this way we can still build on Travis CI
(without documentation).
2018-09-28 17:25:46 +02:00
Beniamino Galvani
929298333e build: meson: add missing man file
Fixes: 9f9609555d
2018-09-28 17:23:23 +02:00
Beniamino Galvani
e22c7150e0 build: meson: ifcfg-rh plugin should not enable ibft
This is not the case with autotools.
2018-09-28 17:23:23 +02:00
Beniamino Galvani
f744e29dd3 device: fix crash in nm_device_generate_connection()
Fixes: 89d1c9fb30

https://bugzilla.redhat.com/show_bug.cgi?id=1631741
2018-09-27 18:08:46 +02:00
Thomas Haller
7729555a59 acd: make NMAcdManager no GObject
NMAcdManager is a rather simple instance.

It does not need (thread-safe) ref-counting, in fact, having
it ref-counted makes it slighly ugly that we connect a signal,
but never bother to disconnect it (while the ref-counted instance
could outlife the signal subscriber).

We also don't need GObject signals. They have more overhead
and are less type-safe than a regular function pointers. Signals
would make sense, if there could be multiple independent listeners,
but that just doesn't make sense.

Implementing it as a plain struct is less lines of code, and less
runtime over head.

Also drop the possiblitiy to reset the NMAcdManager instance.
It wasn't needed and I think it was buggy because it wouldn't
reset the n-acd instance.

https://github.com/NetworkManager/NetworkManager/pull/213
2018-09-27 17:36:42 +02:00
Beniamino Galvani
6b5790a05e device: set token only after router discovery was started
Kernel complains with:

  platform-linux: link: change 10: token: set IPv6 address generation token to ::bbbb
  platform-linux: do-change-link[10]: failure changing link: failure 22 (Invalid argument)

if we try to set an IPv6 token in ip_config_merge_and_apply() and we
haven't set accept_ra=1 yet. Since the flag is set when starting
router discovery, ensure that we don't try to set a token before that.

https://github.com/NetworkManager/NetworkManager/pull/214
https://bugzilla.redhat.com/show_bug.cgi?id=1560652
2018-09-27 17:21:29 +02:00
Beniamino Galvani
1e43ae9e77 supplicant: fix memory leak
Fixes: 17da42704a
2018-09-27 15:24:28 +02:00
Beniamino Galvani
5d97e76c7d wifi: support hidden ssid in AP mode
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/48
2018-09-27 13:35:53 +02:00
Beniamino Galvani
0ba0f52cb7 dhcp: dhclient: fix memory leak
Fixes: c263f5355c
2018-09-27 09:23:54 +02:00
Thomas Haller
a4de56a3d1 dns: fix sort order of DNS configurations by type
Fixes: d7017005e1
2018-09-27 08:01:35 +02:00
Andrew Zaborowski
bfacd24f83 wifi/iwd: handle IWD Station interface disappearing
The net.connman.iwd.Station interface, unlike the Device interface, can
go away and come back when the device changes modes or goes DOWN and UP.
The GDbusProxy for the interface becomes invalid after the interface
disappeared and reappeared.  This would make the IWD backend stop
working after rfkill was used or after suspend/resume (provided the
suspend/resume events are detected, without them everything works and is
really fast too).

Redo the handling of the Powered property changes, corresponding to
device UP state, to get a new GDBusProxy when the Station interface
reappears.  Simplify some checks knowing that priv->can_scan implies for
example that the Station interface is present, and that priv->enabled
implies the NM device state is >= DISCONNECTED.

https://github.com/NetworkManager/NetworkManager/pull/211
2018-09-26 13:47:03 +02:00
Thomas Haller
365079c09e wifi: log warning when active scanning for hidden networks
When there are profiles with wifi.hidden=yes, NetworkManager
will actively scan for these SSIDs. This makes the scan request
(and thus the user) recognizable and trackable.

It seems generally a bad idea to use hidden networks, as they
compromise either the privacy or usablity for the clients.

Log a (rate-limited) warning about this.
2018-09-26 12:50:35 +02:00
Beniamino Galvani
b1a6454b6c core: merge branch 'bg/preserve-routes-down-rh1626004'
https://bugzilla.redhat.com/show_bug.cgi?id=1623740
https://bugzilla.redhat.com/show_bug.cgi?id=1626004

https://github.com/NetworkManager/NetworkManager/pull/210
2018-09-26 11:50:28 +02:00
Beniamino Galvani
f069c98cc9 device: don't remove routes when the interface is down
In update update_ext_ip_config() we remove from various internal
configurations those addresses and routes that were removed externally
by users.

When the interface is brought down, the kernel automatically removes
routes associated with it and so we should not consider them as
"removed by users".

Instead, keep them so that they can be restored when the interface
comes up again.
2018-09-26 11:49:37 +02:00
Beniamino Galvani
8f07b3ac4f ip-config: add @intersect_routes argument to intersect functions
In some cases we want to intersect two IP configurations without
considering routes.
2018-09-26 11:49:37 +02:00
Beniamino Galvani
46ed756112 device: fix updating device information after link change
device_link_changed() can't use nm_device_update_from_platform_link()
to update the device private fields because the latter overwrites
priv->iface and priv->up, and so the checks below as:

  if (info.name[0] && strcmp (priv->iface, info.name) != 0) {

and:

  was_up = priv->up;
  priv->up = NM_FLAGS_HAS (info.n_ifi_flags, IFF_UP);
  ...
  if (priv->up && !was_up) {

never succeed.

Fixes: d7f7725ae8
2018-09-26 11:49:37 +02:00
Beniamino Galvani
3b49d1075d core: improve nm_ip_config_dump()
Previously we had nm_ip{4,6}_config_dump() for debugging purposes, but
they were inconveniently printing to stdout and so the output was not
ordered in the journal.

Implement a unified nm_ip_config_dump() that logs through the usual
logging mechanism.
2018-09-26 11:49:37 +02:00
Thomas Haller
d7017005e1 dns: use NM_CMP_*() macros sorting IP config in DNS manager 2018-09-26 11:24:09 +02:00
Thomas Haller
ad10e79ae4 dns: drop redundant call to clear_domain_lists() in update_dns()
It does nothing.
2018-09-26 09:55:50 +02:00
Lubomir Rintel
60007d7cbd connectivity: fix a wrong comparision
Thanks clang 7.

Fixes: cbfe6aa973
2018-09-24 15:57:43 +02:00
Lubomir Rintel
fa6e4c7eb0 merge: branch 'lr/conn-check-af'
https://github.com/NetworkManager/NetworkManager/pull/157
2018-09-24 15:44:11 +02:00
Lubomir Rintel
cbfe6aa973 connectivity: create a multi-handle for all requests
This is dead ugly and works around what probably is a libcurl (7.59) bug:
It shares the resolver cache among easy handles in a multi handle when
it shouldn't:

When we create two easy handles, one for IPv4 and one for IPv6 in a
single mhandle:

  curl_easy_setopt (ehandle6, CURLOPT_RESOLVE,
    "fedoraproject.org:2605:bc80:3010:600:dead:beef:cafe:feda"
    "fedoraproject.org:2604:1580:fe00:0:dead:beef:cafe:fed1")
  curl_easy_setopt (ehandle4, CURLOPT_RESOLVE,
    "fedoraproject.org:8.43.85.67"
    "fedoraproject.org:152.19.134.198")
  curl_multi_add_handle (mhandle, ehandle6);
  curl_multi_add_handle (mhandle, ehandle4);

Both end up connecting to the same (either v4 or v6) address. None of
CURLOPT_FORBID_REUSE(3), CURLOPT_FRESH_CONNECT(3),
CURLOPT_DNS_USE_GLOBAL_CACHE(3) and CURLOPT_DNS_CACHE_TIMEOUT(3) make
any difference. Nor does CURLOPT_DNS_LOCAL_IP[46].
2018-09-24 15:38:16 +02:00
Lubomir Rintel
de7a159e69 cli: print per-device & per-AF connectivity status 2018-09-24 15:38:08 +02:00
Lubomir Rintel
276a197c57 libnm: add support for per-device & per-AF connectivity status 2018-09-24 15:37:56 +02:00
Lubomir Rintel
d8971fcbcd device: expose connectivity check result on a device
Separate properties for IPv4 and IPv6.
2018-09-24 15:36:19 +02:00
Lubomir Rintel
9664f284a1 connectivity: allow limiting the connectivity check to a specified AF
Nothing changes practically, as the NMDevice still starts this with
AF_UNSPEC. That is going to change in the following commit.

The ugly part:

priv->concheck_x[0] in few places. I believe we shouldn't be using union
aliasing here, and instead of indexing the v4/v6 arrays by a boolean it
should be an enum. I'm not fixing it here, but I eventually plan to if
this gets an ACK.
2018-09-24 15:17:02 +02:00
Lubomir Rintel
2cec94bacc connectivity: use systemd-resolved for resolving the check endpoint
This allows us to use the correct DNS server for the particular interface
independent of what the system resolver is configured to use.

The ugly part:

Unfortunately, it is not all that easy. The libc's libresolv.so API does
not provide means for influencing neither interface nor name servers used
for DNS resolving.

Curl can also be compiled with c-ares resolver backend that does provide
the necessary functionality, but it requires and extra library and the
Linux distributions don't seem to enable it. (Fedora doesn't, which is a
good sign we don't have an option of relying on it.)

systemd-resolved does provide everything we need. If we take care to
keep its congfiguration up to date, we can use it to do the resolving on
a particular interface with that interface's DNS configuration. Great!

There's one more problem: Curl doesn't provide callbacks for resolving
host names.  It doesn't, however, allow us to pass in the pre-resolved
hostnames in form of an CURLOPT_RESOLVE(3) option. This means we have to
parse the host name out of the URL ourselves. Fair enough I guess...
2018-09-24 15:17:02 +02:00
Lubomir Rintel
753ffdbca8 connectivity: improve curl error messages 2018-09-24 15:17:02 +02:00
Lubomir Rintel
d4eb4cb45f dns: allow loading nm-dns-systemd-resolve alongside other DNS plugins
Even when the system resolver is configured to something else that
systemd-resolved, it still is a good idea to keep systemd-resolved up to
date. If not anything else, it does a good job at doing per-interface
resolving for connectivity checks.

If for whatever reasons don't want NetworkManager to push the DNS data
it discovers to systemd-resolved, the functionality can be disabled
with:

  [main]
  systemd-resolved=false
2018-09-24 15:17:02 +02:00
Lubomir Rintel
ecde3e9034 initrd/cmdline-reader: fix whitespace errors
Detected by checkpatch.pl
2018-09-24 13:21:12 +02:00
Lubomir Rintel
66ddc92135 checkpatch: detect some whitespace errors
Vim's trademark.
2018-09-24 13:21:12 +02:00
Thomas Haller
511709c54d dns: fix creating resolv.conf content
g_string_new_len() allocates the buffer with length
bytes. Maybe it should be obvious (wasn't to me), but
if a init argument is given, that is taken as containing
length bytes.

So,

    str = g_string_new_len (init, len);

is more like

    str = g_string_new_len (NULL, len);
    g_string_append_len (str, init, len);

and not (how I wrongly thought)

    str = g_string_new_len (NULL, len);
    g_string_append (str, init);

Fixes: 95b006c244
2018-09-21 13:12:05 +02:00
Andrei Dziahel
0ce7327550 Do not manage Docker bridge interfaces
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/15
2018-09-21 11:18:00 +02:00
Thomas Haller
121e2dea12 dns: merge branch 'th/dns-stub-resolv-conf'
https://github.com/NetworkManager/NetworkManager/pull/200
2018-09-21 11:15:09 +02:00
Thomas Haller
cddb91324c dns: always write "/var/run/NetworkManager/resolv.conf"
Previously, if "main.rc-manager" was set to "unmanaged"
and "/etc/resolv.conf" was symlink to our internal file
"/var/run/NetworkManager/resolv.conf", NM would not rewrite
the file, in an attempt to honor the requirement of NetworkManager
not changing resolv.conf.

No longer special case this. I think it was wrong and inconsistent.
If the user specifies rc-manager unmanaged, he also should manage
/etc/resolv.conf accordingly. And if the user decided to symlink
it to our internal file, that is fine. It should not stop NM from
updating that file.

Also, this was the only cases, where NM would not write our internal
resolv.conf (errors aside). It was inconsitent, and also not documented
behavior. Instead, it is documented that `man NetworkManager.conf`:

  Regardless of this setting, NetworkManager will always write
  resolv.conf to its runtime state directory
  /var/run/NetworkManager/resolv.conf.
2018-09-21 11:12:47 +02:00
Thomas Haller
320461c062 dns: minor rewording of main.dns in man NetworkManager.conf 2018-09-21 11:12:47 +02:00