Commit Graph

21088 Commits

Author SHA1 Message Date
Thomas Haller
16e75d4db5 wifi: configure wifi-backend per device
This allows to configure the wifi-backend per device, like

  [device-wifi-backend-eth0]
  match-device=interface-name:wlan0
  wifi-backend=iwd
2017-12-27 09:18:54 +01:00
Thomas Haller
6295865e0f core: add nm_config_data_get_device_config_by_pllink() to lookup per-device config
... by platform link.

One caveat is that without having a NMDevice instance, matching by
several paramters won't work. Like, matching against the driver would
require us to look it up via ethtool. When having an NMDevice instance,
the driver is cached there, it's unclear we want to call ethtool for
lookup in this case -- though it could be done.

For other options, it's more complicated. Like, the type basically
depends on the NMDevice class. Usually that also works without a
netdev known to kernel (like bluetooth).

The inconsistency that certain matches are not implemented is ugly
indeed. But the effect is as if the spec doesn't match.
2017-12-27 09:18:54 +01:00
Thomas Haller
00c1e560f9 core: add nm_match_spec_device_by_pllink()
Add a variant of nm_device_spec_match_list() that looks up the match
paramters from a platform link instance.

Usually, we have a NMDevice instance that we use for matching.
However, at some places (like inside the device factory's
create_device() method), we might not have a NMDevice instance
to get the match paramters.

Add an alternative form, that gets the match paramters from a platform
link instance.

The code is placed inside src/NetworkManagerUtils.c, because
src/nm-core-utils.c is supposed to be independent of platform.
2017-12-27 09:18:54 +01:00
Thomas Haller
02a26de6f8 contrib/rpm: conditionally enable iwd Wi-Fi plugin 2017-12-27 09:18:54 +01:00
Thomas Haller
bbcd0e9018 core: merge branch 'th/bus-manager-cleanup'
https://github.com/NetworkManager/NetworkManager/pull/45
2017-12-24 18:11:46 +01:00
Thomas Haller
36d7a3cf21 core: use CList instead of GHashTable for tracking connections on PrivateServer
There were no places where we actually looked up an instance
in the hash-table. All we did was iterating the list.

CList is faster with iterating, has less memory over-head (in this
particular case), and can also do O(1) insert and removal. It's
more suited in every way.
2017-12-24 17:18:57 +01:00
Thomas Haller
c313d64802 core: disconnect new-connection handler for private server
I don't think this was an actual problem. But to be sure, disconnect
the signal handler before destroying the PrivateServer instance.
2017-12-24 17:17:58 +01:00
Thomas Haller
53fe565f56 core: inline creation of private server in nm_bus_manager_private_server_register()
private_server_free() had only one caller: nm_bus_manager_private_server_register().

The only thing that nm_bus_manager_private_server_register() did in
addition was to check for duplicate server tags.

Merge the two functions.
2017-12-24 17:17:58 +01:00
Thomas Haller
6a317d9037 core: use CList to track private server list in NMBusManager 2017-12-24 17:17:58 +01:00
Thomas Haller
8342a66cb6 shared/compat: minor refactoring of compat code
Don't cache the entire GPtrArray, just the plain strv.
Also, use parentheses for sizeof().
2017-12-22 15:53:22 +01:00
Jan Alexander Steffens (heftig)
76207194d1 shared/compat: Fix memory handling of nm_setting_vpn_get_*_keys (v2)
The compat implementations return a (transfer none) strv instead of a
(transfer container) one. This has caused double frees in nm-applet:
https://bugs.archlinux.org/task/56772

We still need to copy the keys because nm_setting_vpn_foreach_* provides
us with copies that are freed after the iteration.

Fix this by handing out a duplicate of the array.

Fixes: 272439cb20

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00070.html
2017-12-22 15:53:05 +01:00
Jan Alexander Steffens (heftig)
64fcfc62bb Revert "shared/compat: fix memory handling of nm_setting_vpn_get_*_keys"
This reverts commit 8ac8c01162.

The fix was bad because the keys do not come from NMSettingVpn's hash
table but are copies that are freed by nm_setting_vpn_foreach_* before
it returns.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00069.html
2017-12-22 15:52:41 +01:00
Thomas Haller
60d4b370ba wifi/iwd: merge branch 'pr/42'
https://github.com/NetworkManager/NetworkManager/pull/42
2017-12-21 11:19:17 +01:00
Thomas Haller
c1fbf7ee86 iwd: fix coding style to use curly braces for multi-line if()
Our convention is that when the body of an if() or for() spawns
more then one line, then it needs curly braces. If it's only one
line, it should have no curly braces. The latter part seems sometimes
a bit inconvenient, because changing

  if (some_condition)
      do_something ();

gets change to

  if (some_condition) {
      do_something ();
      do_something_else ();
  }

the diff shows 3 lines changed, although really only one changed.

But well, that's how it is...
2017-12-21 11:11:47 +01:00
Andrew Zaborowski
a6c3ffd62e iwd: For 8021x networks verify they're IWD Known Networks
Verify that an 8021x network is preprovisioned on IWD side before
declaring a connection as "available" or "compatible".

Also move the Infrastrucure mode check and the Hidden SSID check in
check_connection_available earlier because even if a compatible AP is
available and the connection can be used with wpa_supplicant, it can't
be used with IWD at this time.
2017-12-21 11:07:56 +01:00
Andrew Zaborowski
228508a88c iwd: Don't require secrets for IWD Known Networks
This is mainly to enable using 8021x networks, which have to be
preprovisioned as an IWD config file to be supported and can not be
configured by asking the user for secrets over DBus, this is an IWD's
design choice.

Note that this assumes that secrets are only used during the Stage 2 of
the activation, i.e. for the wifi handshake, not in the later stages.
2017-12-21 11:07:56 +01:00
Andrew Zaborowski
b2ee8e8704 iwd: Track IWD Known Networks
Keep a list of IWD's Known Networks which are networks that have their
configurations stored by IWD including the secrets, either because they
have been connected to before or because they were preprovisioned on the
machine.
2017-12-21 11:07:55 +01:00
Andrew Zaborowski
ab8fc07640 iwd: Remove a stray return and a newline 2017-12-21 11:07:55 +01:00
Thomas Haller
2e58982697 ifnet: merge branch 'th/setting-plugin-ifnet'
Drop the "ifnet" settings plugin that was used on Gentoo.
It's unmaintained and unused for a long time.

https://github.com/NetworkManager/NetworkManager/pull/43
2017-12-21 10:50:33 +01:00
Thomas Haller
0474441e22 settings: drop unmaintained ifnet settings plugin of Gentoo
Even Gentoo disables this plugin since before 0.9.8 release
of NetworkManager. Time to say goodbye.

If somebody happens to show up to maintain it, we may resurrect it
later.

If "$distro_plugins=ifnet" was set, configure.ac would use that
to autodetect --with-hostname-persist=gentoo. Replace that autodetect
part by checking for /etc/gentoo-release file.
2017-12-21 10:50:33 +01:00
Thomas Haller
298d156e36 build: drop --enable-ifcfg-suse configure option
The option is deprecated together with the ifcfg-suse settings plugin.
Selecting the plugin has no effect at runtime, beside logging a warning.

Drop the configure option.

Note, that if $distro_plugins was set to "ifcfg-suse", it was also used to
autodetect --with-hostname-persist=suse. Now, autodetect the hostname
persist mode based on presence of /etc/SuSE-release file.
2017-12-21 10:50:33 +01:00
Thomas Haller
7bc2195721 build/meson: drop option for deprecated ifcfg-suse setting plugins 2017-12-21 10:50:33 +01:00
Thomas Haller
68fa0ea8eb man: document all setting plugins in NetworkManager.conf manual
although they are deprecated and unused, document them.
2017-12-21 10:50:33 +01:00
Beniamino Galvani
aa820e9386 all: add more meaningful error code for unsupported IP method
Add a new device state reason code for unsupported IP method. It is
returned, for example, when users select manual IP configuration for
WWAN connections:

 # nmcli connection mod Gsm ipv4.method manual ipv4.address 1.2.3.4/32
 # nmcli connection up Gsm
 Error: Connection activation failed: The selected IP method is not
 supported

compared to the old:

 Error: Connection activation failed: IP configuration could not be
 reserved (no available address, timeout, etc.)

Note that we could instead fail the connection validation if the
method is not supported by the connection type, but adding such
limitation now could make existing connections invalid.

https://bugzilla.redhat.com/show_bug.cgi?id=1459529
2017-12-21 10:02:07 +01:00
Thomas Haller
c72df50b6d libnm: reuse nm_utils_strdict_get_keys() to implement NMSettingVpn's get_keys() 2017-12-21 09:52:14 +01:00
Jan Alexander Steffens (heftig)
8ac8c01162 shared/compat: fix memory handling of nm_setting_vpn_get_*_keys
The compat implementations return a (transfer none) strv instead of a
(transfer container) one. This has caused double frees in nm-applet:
https://bugs.archlinux.org/task/56772

Don't copy the keys and don't free the container later.

[thaller@redhat.com: patch adjusted to avoid compiler warning]

Fixes: 272439cb20
2017-12-21 09:51:10 +01:00
Beniamino Galvani
e7968b0048 wwan: merge branch 'bg/modem-default-route-rh1527934'
https://bugzilla.redhat.com/show_bug.cgi?id=1527934
2017-12-21 09:39:37 +01:00
Beniamino Galvani
5d372fd30e wwan: clear idle source id when the callback runs
Fixes: f0996d0eb8
2017-12-21 09:35:40 +01:00
Beniamino Galvani
ec32edb21f wwan: add default route even if modem didn't return a gateway
If the modem didn't return a gateway, add a device route.

Fixes: 5c299454b4
2017-12-21 09:35:40 +01:00
Beniamino Galvani
8ddc6caf98 wwan: fix checks on IP configuration
Don't call nm_utils_parse_inaddr_bin() if the string returned by
mm_bearer_ip_config_get_address() and mm_bearer_ip_config_get_gateway()
is NULL, as the function requires a valid pointer. Throw an error if the
address is NULL, but allow an empty gateway.

Fixes: 7837afe87f
2017-12-21 09:35:40 +01:00
Beniamino Galvani
5fff928a6b settings: clear unsaved flag on new settings-connection
When a new settings-connection is populated with the actual settings
read from disk by the plugin, calling nm_settings_connection_update()
with KEEP mode also marks it as unsaved, which should not happen on a
new connection just written to (or read from) disk.

Introduce a new KEEP_SAVED persist mode that is similar to KEEP but
clears the UNSAVED flag.

Fixes: 023ce50d21

https://bugzilla.redhat.com/show_bug.cgi?id=1525078
2017-12-20 15:38:57 +01:00
Thomas Haller
4277bc0ee0 core: persist aspired default route-metric in device's state file
NMManager tries to assign unique route-metrics in an increasing manner
so that the device which activates first keeps to have the best routes.

This information is also persisted in the device's state file, however
we not only need to persist the effective route-metric which was
eventually chosen by NMManager, but also the aspired metric.

The reason is that when a metric is chosen for a device, the entire
range between aspired and effective route-metric is reserved for that
device. We must remember the entire range so that after restart the
entire range is still considered to be in use.

Fixes: 6a32c64d8f
2017-12-20 13:48:13 +01:00
Thomas Haller
7deb3b4fb5 settings: drop unused define for HOSTNAME_FILE
Fixes: 5bfb7c3c89
2017-12-20 12:10:59 +01:00
Beniamino Galvani
98ac0f404e settings: avoid assertion when deleting connections
If a volatile connection is deleted by user when it was already being
deleted internally because the device vanished, we may hit the
following failed assertion:

 file src/settings/nm-settings-connection.c: line 2196
 (nm_settings_connection_signal_remove): should not be reached

The @removed flag keeps track of whether we already signaled the
connection removal. Instead of throwing an assertion if we try to emit
the signal again, just return without action because this can happen
in the situation described above.

While at it, remove the @allow_reuse argument from
nm_settings_connection_signal_remove(): we should never emit the
signal twice. Instead, we should reset the @removed flag when the
connection is added.

Fixes: a9384452ed

https://bugzilla.redhat.com/show_bug.cgi?id=1506552
2017-12-20 10:39:23 +01:00
Thomas Haller
2499d3bdc6 core: ensure that the default route-metric bumps at most 50 points
First check that the limit of 50 metric points is not surpassed.
Otherwise, if you have an ethernet device (aspired 100, effective
130) and a MACSec devic (aspired 125, effective 155), activating a
new ethernet device would bump it's metric to 155 -- more then
the 50 points limit.

It doesn't matter too much, because the cases where the limit of
50 could have been surpassed were very specific. Still, change
it to ensure that the limit is always honored as one would expect.

Fixes: 6a32c64d8f
2017-12-19 10:31:53 +01:00
Lubomir Rintel
6713ab4d6c man/openvswitch: fix type in examples
"conn.type" doesn't allow type aliases. Use "type" instead.

https://bugzilla.redhat.com/show_bug.cgi?id=1519173
2017-12-19 10:02:12 +01:00
Iñigo Martínez
ffec7f0105 build: Enable unused-but-set warning in meson
The unused-but-set warning has recently been enabled in autotools
(e912b36d95), so this also modifies
meson to enable it.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00063.html
2017-12-18 20:50:01 +01:00
Iñigo Martínez
123aa38ffe build: Move default path values to options file
Since meson 0.44 there is a new option type called `array`, which
allows to use an array with different values in those options.

These fits the needs of different options that are used to pass
binary paths, which have multiple paths as an alternate locations.

meson's version has been bumped to 0.44 and different options have
been changed to `array` type options.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00062.html
2017-12-18 20:48:16 +01:00
Iñigo Martínez
cc692a6976 build: Remove documentation generation workarounds
Documentation was not working in meson due to problems with files
generated in `libnm`. To avoid these problems, workarounds were
used. This problems have been recently fixed so these workarounds
are not necessary anymore.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00061.html
2017-12-18 20:46:03 +01:00
Iñigo Martínez
25d5384c30 build: Drop HAVE_VLAN_FLAG_LOOSE_BINDING
Both meson and autotools define HAVE_VLAN_FLAG_LOOSE_BINDING to 1 or
0 depending if a small code snippet is compiled. However, this define
is not used anymore.

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00060.html
2017-12-18 20:43:52 +01:00
Thomas Haller
41f608dd91 dns: rework write_to_netconfig()
The compiler warns when we ignore the return value from write().
And assigning it to an unused variable, causes another warning.
Make some use of it, at least to handle EINTR. All other errors
are still ignored.

While at it, rework the write code to first write to a buffer
in memory.
2017-12-18 15:46:41 +01:00
Thomas Haller
ad3bbda8e3 core: avoid compiler warnings in write_to_netconfig() and ifnet_update_parsers_by_connection()
src/dns/nm-dns-manager.c: In function ‘write_to_netconfig’:
    src/dns/nm-dns-manager.c:387:8: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
      write (fd, str, strlen (str));
            ^

    src/settings/plugins/ifnet/nms-ifnet-connection-parser.c: In function ‘ifnet_update_parsers_by_connection’:
    src/settings/plugins/ifnet/nms-ifnet-connection-parser.c:2600:26: error: variable ‘pppoe’ set but not used [-Werror=unused-but-set-variable]
      gboolean wired = FALSE, pppoe = TRUE;
                              ^~~~~

While at it, don't log line breaks in ifnet_update_parsers_by_connection().

Fixes: e912b36d95
2017-12-18 15:03:43 +01:00
Lubomir Rintel
9d95e1f175 clients/cli: use a nicer password prompt
Makes sense in order for the user to know that they're actually typing
the password (edited just to illustrate the point, the actual output was
shamefully messy and perhaps needs fixing too):

  $ nmcli c up Wrathmosphere
  Passwords or encryption keys are required to access the wireless network 'Wrathmosphere'.
  Password (802-1x.password): *********
2017-12-18 14:47:37 +01:00
Lubomir Rintel
9e4de97967 libnm-core: move detection of UTF-8 capable terminals to clients/
Having it in libnm doesn't make any sense and prevents using it for more
internal functionality.

Too bad nm_utils_wifi_strength_bars() is already a public API.
No problem -- replace it with a compatible yet dumber equivalent.
2017-12-18 14:47:37 +01:00
Lubomir Rintel
7c3e1d926a clients/cli: don't store a password in history
History is probably even not useful at all outside the interactive edit
mode, but that is another story. This just avoids awkward surprises,
such as:

https://bugzilla.gnome.org/show_bug.cgi?id=791200
2017-12-18 14:47:31 +01:00
Lubomir Rintel
e912b36d95 build: enable unused-but-set warning
It was disabled for shady reasons (not checking write() return value)
that are long gone. Worse even, it hid some real bugs.
2017-12-18 13:29:32 +01:00
Lubomir Rintel
6672c5e92e all: get rid of a handful of unused-but-set variables 2017-12-18 13:29:32 +01:00
Lubomir Rintel
0ae44fe7e2 ifcfg-rh: remove the watch on finalize 2017-12-18 13:29:32 +01:00
Lubomir Rintel
16f8651908 libnm/vpn: fix secret comparison
One setting may contain a superset or subset of the another. Be sure not
to ignore the presence of extra secret properties.
2017-12-18 13:29:32 +01:00
Lubomir Rintel
99fea5f380 manager: fix connectivity-check-enabled property 2017-12-18 13:29:32 +01:00