Commit Graph

18368 Commits

Author SHA1 Message Date
Thomas Haller
c292f3ed85 device: hide nm_device_factory_get_supported_types() function
The simple link-types/setting-types mechanism doesn't really cut it
because for the bluetooth NAP connection.type is "bluetooth", but
it shall be primarily handled by the bridge factory.

It's internal API that allows for a basic matching of the factory.
It is however not sophisticated enough for the full complexity.
Make it as internal API only.
2017-06-07 09:07:17 +02:00
Thomas Haller
88c2ccfb4c libnm: avoid assertion with invalid connections in _nm_connection_find_base_type_setting()
Functions should behave gracefully with connections that don't verify.
Especially, as _normalize_connection_type() calls
_nm_connection_find_base_type_setting() precisely with an unknown
connection.type.
2017-06-07 09:07:17 +02:00
Thomas Haller
1d6b717401 libnm: downgrade assertions in _nm_register_setting_impl() to nm_assert()
This is entirely internal API. We have unit tests that execute these
code paths. No need to have these assertions in production code.
2017-06-07 09:07:17 +02:00
Thomas Haller
837a8c1ca5 libnm: distinguish INVALID priority setting from NM_SETTING_PRIORITY_CONNECTION 2017-06-07 09:07:17 +02:00
Thomas Haller
488029d74b libnm: use enum for setting priorities 2017-06-07 09:07:17 +02:00
Thomas Haller
a973eacb3b libnm: add enum for setting priorities
Using plain numbers make it cumbersome to grep for
setting types by priority.

The only downside is, that with the enum values it
is no longer obvious which value has higher or lower
priority.

Also, introduce NM_SETTING_PRIORITY_INVALID. This is what
_nm_setting_type_get_base_type_priority() returns. For the moment
it still has the same numerical value 0 as before. Later, that
shall be distinct from NM_SETTING_PRIORITY_CONNECTION.
2017-06-07 09:07:17 +02:00
Thomas Haller
c7e9f97800 libnm/trivial: rename _nm_register_setting function to _nm_register_setting_impl
Avoid having the function _nm_register_setting() shadowed by a macro
of the same name, but different behavior/arguments.
2017-06-07 09:07:17 +02:00
Thomas Haller
11d852a148 core: minor refactoring condition in validate_activation_request() 2017-06-07 09:07:17 +02:00
Thomas Haller
f387614b91 core: print the connection.type in nm_utils_log_connection_diff() 2017-06-07 09:07:17 +02:00
Beniamino Galvani
7415ad778e libnm-core: fix typo in 802.1x doc comment 2017-06-06 09:28:59 +02:00
Thomas Haller
02e7476e9f device: mark device as sys-iface-state=external when assuming connection
Since commit 74dac5f (nm-manager: try assuming connections on managed devices),
and commit f4226e7 (manager: avoid generating in memory connections
during startup for managed devices), recheck_assume_connection() also
assumes connections on devices that are currently not in sys-iface-state
"external".

That is correct, as also for fully managed devices (which are currently
in disconnected state), we want to assume external connections. However,
when doing that, we must reset the sys-iface-state to external.

https://bugzilla.redhat.com/show_bug.cgi?id=1457242
2017-06-05 18:31:17 +02:00
Beniamino Galvani
4be0cdd358 bond: merge branch 'bg/bond-option-normalize-rh1457909'
Normalize bond options to ensure a correct connection matching upon
daemon restart.

https://bugzilla.redhat.com/show_bug.cgi?id=1457909
2017-06-05 17:46:28 +02:00
Beniamino Galvani
056a973a4f bond: add only supported options to the generated connection
Upstream commit [1] changed in the kernel the default value of
tlb_dynamic_lb bond from 1 to 0 when the mode is not tlb. This is not
wrong, as the option value doesn't really matter for other modes, but
it breaks the connection matching because we read back a 0 value when
we expect a default of 1.

Fix this in a generic way by ignoring altogether options that are not
relevant for the current bond mode, because they are removed from the
connection during normalization.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8b426dc54cf4056984bab7dfa48c92ee79a46434

https://bugzilla.redhat.com/show_bug.cgi?id=1457909
2017-06-05 17:46:10 +02:00
Beniamino Galvani
f25e008e2f libnm-core: remove unsupported bond options during normalization
In an ideal world, we should not validate connections containing
options not valid for the current bond mode. However adding such
restriction now means that during an upgrade to the new NM version
some connections that were valid before become invalid, possibly
disrupting connectivity.

Instead, consider invalid options as a normalizable error and remove
them during normalization.

Converting the setting to a "canonical" form without invalid options
is important for the connection matching logic, where such invalid
options can cause false mismatches.
2017-06-05 17:46:10 +02:00
Thomas Haller
14529f5b46 wifi: merge branch 'th/wifi-ap-hidden'
https://github.com/NetworkManager/NetworkManager/pull/22
2017-06-05 17:32:39 +02:00
Thomas Haller
8870b7ab12 wifi: change logging about probe-scanning SSIDs
The SSID is not "hidden". It is the wildcard SSID.

See build_hidden_probe_list().
2017-06-03 17:46:06 +02:00
Thomas Haller
c5fb410998 wifi: fix completing Wi-Fi connection for AP mode
In AP mode we should not look up an access point. It is wrong to
do, and it ends up marking the connection as hidden.

It seems wrong to me that if the client explicitly set
hidden=FALSE before AddAndActivate(), that complete_connection()
would still set it to TRUE if it cannot find the access
point. That is, because complete_connection() does not know
whether hidden was omitted or set intentionally by the user.
2017-06-03 17:42:22 +02:00
Thomas Haller
74335004f3 wifi: exclude AP mode wifi connection from hidden-scan list
It makes no sense to scan for those.
2017-06-03 17:39:28 +02:00
Thomas Haller
de0da1df32 device: merge various device cleanups 2017-06-02 21:06:08 +02:00
Thomas Haller
c79a97657b device: transform NM_DEVICE_IS_MASTER gobject property to field in NMDeviceClass
We don't need this flexibility of having a full fledged GObject
property for is-master. The property value only depends on the
device's class.
2017-06-02 21:06:08 +02:00
Thomas Haller
c3aa52530c core: add nm_device_spec_match_list_full()
This gives a third return value: whether the device did not
match.
2017-06-02 21:06:08 +02:00
Thomas Haller
f2f9a635ff device: rename activate_stage5_ip4_config_commit() to activate_stage5_ip4_config_result()
We have nm_device_activate_schedule_ip4_config_result(). The name
should match.

Note, this affects logging, as we log the function name.
2017-06-02 21:06:08 +02:00
Thomas Haller
10efbc5887 device: prefix log messages related to carrier
It's easier to search in the logfile.
2017-06-02 21:06:08 +02:00
Thomas Haller
fe9c61239a device: minor cleanup of NMDeviceEthernet:get_link_speed()
A better name is link_speed_update(), because it re-reads and
sets the speed value.

Also, move _notfiy() after logging. It doesn't matter in this
case, but we should first log, and then do actions that have potentially
complex side-effects.
2017-06-02 21:06:07 +02:00
Thomas Haller
158e852604 device: rework listening to carrier changes for DCB in NMDeviceEthernet
Now, that NMDeviceClass:carrier_changed_notify() is no longer called as
deferred action, we can check for DCB state there, instead or registering
to the NM_DEVICE_CARRIER notifications.
2017-06-02 21:06:07 +02:00
Thomas Haller
7f79b59330 device: move carrier_changed_notify() notification to nm_device_set_carrier()
Note that:

 - carrier_changed_notify() has only one implementation: NMDeviceEthernet
   to call get_link_speed() when carrier comes back.

 - currently, calling carrier_changed_notify() with carrier=FALSE
   has no effect, because NMDeviceEthernet only acts on carrier=TRUE.

  - when carrier appears, nm_device_set_carrier() will call
    carrier_changed() right away. We only call carrier_changed()
    with carrier=TRUE only at one place. The change merley moves
    carrier_changed_notify() out of the function. Apart from
    that it has no effect.

  - when carrier disappears, previoulsy we would delay action for
    4 seconds. Hence, we would delay carrier_changed_notify() as well
    -- although it has no effect.

The last point is at least ugly. Fix it by moving
carrier_changed_notify() to nm_device_set_carrier().
2017-06-02 21:06:07 +02:00
Lubomir Rintel
1d35fd0103 clients: respond to the secret requests that we can't service
Otherwise the daemon would hang waiting for us while we respond with awkward
silence. That is not a healthy kind of communication.
2017-06-02 20:52:16 +02:00
Thomas Haller
238efbbb12 settings: refactor nm_settings_connection_read_and_fill_timestamp()
Coverity complains about not checking the return value:

  src/settings/nm-settings-connection.c:2329: check_return: Calling "g_key_file_load_from_file" without checking return value (as is done elsewhere 6 out of 7 times).

While at it, refactor the code and check whether the timestamp
is valid.
2017-06-02 20:17:30 +02:00
Thomas Haller
c7c47575ce tests: work around coverity false-positives 2017-06-02 20:00:56 +02:00
Thomas Haller
6f1ea8b8ee supplicant: work-around coverify false-positive for check_return: g_async_initable_init_finish()
NetworkManager-1.8.0/src/supplicant/nm-supplicant-interface.c:232: check_return: Calling "g_async_initable_init_finish" without checking return value (as is done elsewhere 7 out of 8 times).
2017-06-02 19:53:44 +02:00
Thomas Haller
7087956870 supplicant/tests: work-around coverify false-positive in test
NetworkManager-1.8.0/src/supplicant/tests/test-supplicant-config.c:528: check_return: Calling "nm_setting_802_1x_set_ca_cert" without checking return value (as is done elsewhere 13 out of 16 times).
2017-06-02 19:51:11 +02:00
Thomas Haller
f1eb1619f1 connectivity: fix scheduling periodic connectivity checks
commit a955639 (connectivity: don't do periodic checks on interval=0)
broke scheduling connectivity checks.

That is because the timer is on only scheduled if
nm_connectivity_check_enabled(), which in turn only returns TRUE
if curl_mhandle is set. However, nm_connectivity_init() would only
initialize curl_mhandle after update_config(), missing to schedule
the periodic task.

https://mail.gnome.org/archives/networkmanager-list/2017-May/msg00076.html

Fixes: a95563996f
2017-06-02 19:15:30 +02:00
Thomas Haller
ea6648cea1 all: replace uses of inet_aton() and friends
rpmdiff complains about uses of inet_aton, inet_makeaddr, inet_netof,
inet_ntoa under the IPv6 section:

   usr/sbin/NetworkManager on aarch64 i686 x86_64 ppc ppc64 ppc64le s390 s390x uses function inet_aton, which may impact IPv6 support

I think the warning is bogus, but refactor our code to avoid it.

Note that systemd code still uses them, so it don't avoid the rpmdiff
warning. But let's not diverge our systemd import from upstream for this.

- for NMSettingBond:validate_ip() also avoid g_strsplit_set() which
  allocates a full strv. Instead, we can do with one g_strdup().

- for test-resolvconf-capture.c, replace the functions with macros.
  Macros should be avoided usually, but for test asserts they are
  more convenient as they preserved the __FILE__:__LINE__ of where
  the assertion fails.
2017-06-02 14:07:10 +02:00
Lubomir Rintel
c0419257e7 all: reject duplicate keys in JSON
Teamd is not happy about them and would fail anyway. Worse even, if we
json_loads() such a JSON, which is precisely what happens when we inject the
"hwaddr" key, we turn bad JSON into a good one in a lossy matter. Not good.

https://bugzilla.redhat.com/show_bug.cgi?id=1455130
2017-06-01 13:30:21 +02:00
Thomas Haller
484d666485 build: fix nm binutils tool when building with LTO
When building with -flto, we need to use linker plugins.
In case of binutils' nm, it means to prefer gcc-nm if
available.

Like for ranlib and ar, prefer gcc-nm.

- replace AC_PATH_TOOL() by AC_CHECK_TOOLS(). That is consistent
  with what we do for ar,ranlib and suggested on bgo#783311.
- instead of using the variable $BINUTILS_NM, replace it by
  $NM, which is more common according to bgo#783311.
- Keep recognizing $BINUTILS_NM environment, which was introduced
  by commit 8bc88bcc7c. This is purely to keep previous build
  scripts working. Originally I named it "$BINUTILS_NM" because
  using $NM in NetworkManager seemed confusing. But well...

https://bugs.gentoo.org/show_bug.cgi?id=620052
https://bugzilla.gnome.org/show_bug.cgi?id=782525
https://bugzilla.gnome.org/show_bug.cgi?id=783311
2017-06-01 12:51:31 +02:00
Lubomir Rintel
afebdc795d build: add a missing test artifact to dist
Fixes: ba05819c89
2017-06-01 12:47:43 +02:00
Lubomir Rintel
f9b1bc16e9 merge: branch 'lr/bluetooth-nap'
https://bugzilla.gnome.org/show_bug.cgi?id=783013
2017-06-01 12:37:02 +02:00
Lubomir Rintel
bf7e86128c bridge: move the Bluetooth NAP logic to bridge device
The Bluetooth NAP functionality seems only useful for the bridges. Move
it away from NMDevice.
2017-06-01 11:57:42 +02:00
Thomas Haller
b0f9571d3d libnm: add _nm_connection_get_setting_bluetooth_for_nap()
If there is value in such a helper function (there is), then
it should go alongside the other nm_connection_get_setting*()
helpers. NMDevice is already large enough.
2017-06-01 11:28:57 +02:00
Thomas Haller
1be01bd51f device: don't include header of bluetooth plugin in nm-device.h
The plugins may use stuff from core, but not the other way around.
Including "bluetooth/nm-bluez-common.h" is wrong.

The UUID argument is always "nap" in the NAP case. We don't need
the flexibility that it might be anything else. Just drop it.

As far as NMDevice is concerned, it anyway wouldn't (or shouldn't
know what the uuid is. It says register, and NMBluez5Manager should
figure out the details.
2017-06-01 11:28:57 +02:00
Lubomir Rintel
29a0876db6 bluetooth: emit component-added when a network server is added 2017-06-01 11:28:57 +02:00
Lubomir Rintel
d6f2a2e73c bluetooth: expose known HCI adapters to devices
They may register the Bluetooth NAP enabled bridges for Bluez to enslave their
BNEP links to.
2017-06-01 11:28:57 +02:00
Lubomir Rintel
53482c38e2 device: register a bridge for Bluetooth NAP with Bluez
Bluez needs to know about then so that it can eventually enslave the BNEP links
for PANU client connections to it.
2017-05-31 20:18:24 +02:00
Lubomir Rintel
b866a12667 device: retry autoactivation upon a component addition
It might have changed circumstances that were blocking the autoactivation.
2017-05-31 20:18:12 +02:00
Lubomir Rintel
805d3240f9 devices/factory: allow announcing a NULL component
We'll use this to let the devices know they can retry autoactivation
because some component became available without actually having any
data that would be useful for that device.

Adjust the comment.
2017-05-31 20:17:54 +02:00
Lubomir Rintel
aedeb3cbf4 clients: add support for Bluetooth NAP type 2017-05-31 20:17:42 +02:00
Lubomir Rintel
ab46c9c70c clients: allow bridge settings for Bluetooth devices
Will be useful for Bluetooth NAP.
2017-05-31 20:17:39 +02:00
Lubomir Rintel
63292b5c41 core/connection: normalize bridge settings into bluetooth NAP connections
For the Bluetooth NAP we need a Bridge link for the BlueZ to assign the BNEP
links for PANU client connections into.

Let's disable STP by default -- it adds extra delay for the Bridge when the
BNEP link is assigned and is likely not useful for a typical client.
2017-05-31 20:17:16 +02:00
Lubomir Rintel
7c5a2be966 core/bluetooth: add NAP type 2017-05-31 20:15:52 +02:00
Lubomir Rintel
2c1a178f5b core: negotiate the best base setting
When the two base settings are present, use one of higher priority.

This will pick the "bridge" setting when both "bridge" and "bluetooth" are
present for a Bluetooth NAP connection.
2017-05-31 20:15:24 +02:00