Commit Graph

9633 Commits

Author SHA1 Message Date
Thomas Haller
a814b96ebf ppp: don't log newlines 2017-06-09 15:42:49 +02:00
Thomas Haller
3f64910b52 ppp: refactor ppp_exit_code() to split out error to string conversion
ppp_exit_code() does too much or too little. Either it should log
about all reasons why pppd exited, including signals, or it should
just do the status to string conversion. Split it.
2017-06-09 15:42:49 +02:00
Thomas Haller
5c5fbe0a9f ppp/trivial: fix whitespace 2017-06-09 15:42:49 +02:00
Thomas Haller
0f16649ba2 ppp: inline and drop trivial function remove_timeout_handler() 2017-06-09 15:42:49 +02:00
Beniamino Galvani
aa099906f9 device: apply route metric penality only when the default route exists
It's useless (and in some cases also harmful) to commit the
configuration to update the default route metric when the device has
no default route. Also, don't commit configuration for externally
activated devices.

https://bugzilla.redhat.com/show_bug.cgi?id=1459604
2017-06-09 13:52:03 +02:00
Thomas Haller
0c26ffd638 device: suppress logging and return error reason from nm_device_generate_connection()
Don't log in a function that basically just inspects state, without
mutating it. Instead, pass the reason why a connection could not be
generated to the caller so that we have one sensible log message.
2017-06-08 21:50:23 +02:00
Thomas Haller
962f8f42d9 manager: cleanup logging message during recheck_assume_connection()/get_existing_connection()
recheck_assume_connection() calls get_existing_connection(). We want *one* logging
message telling what's happening. Let get_existing_connection() log "assume:"
messages and remove duplicate messages from recheck_assume_connection().
2017-06-08 21:50:23 +02:00
Thomas Haller
cc47a6a8b2 device: remove logging for emitting RECHECK_ASSUME signal
The device's RECHECK_ASSUME signal has only NMManager as subscriber
and it immediately calls recheck_assume_connection().

With the previous commit, recheck_assume_connection() always logs
a debug message, so we don't need this duplicate message anymore.
2017-06-08 21:50:23 +02:00
Thomas Haller
94534e0327 manager: add more logging to recheck_assume_connection()
and give all lines a logging prefix.
2017-06-08 21:50:23 +02:00
Thomas Haller
dd53c879d2 manager: add "rfkill" prefix to related logging messages 2017-06-08 21:50:23 +02:00
Thomas Haller
6962f14d4a manager: add logging macro _NMLOG3() for logging connection messages
It unifies the way how we print the logging prefix, but also it
passes the con_uuid down for structured logging.
2017-06-08 21:50:23 +02:00
Thomas Haller
1f6078bcf5 manager: add logging macro _NMLOG2() for logging device messages
It unifies the way how we print the logging prefix, but also it
passes the ifname down for structured logging.
2017-06-08 21:50:23 +02:00
Thomas Haller
2ae891b592 logging: add LOG3 macros 2017-06-08 21:50:23 +02:00
Thomas Haller
4b15df2656 device: expose nm_device_state_to_str() function for NMDeviceState 2017-06-08 21:50:23 +02:00
Thomas Haller
f10b958806 device: rework device's _NMLOG() logging macro
- if the interface-name is NULL, print [null], to distinguish
  it from (ifname).
- evaluate the ifname only once.
2017-06-08 21:50:23 +02:00
Thomas Haller
729de7d7f0 manager: fix preserving assume state during activation
Originally 850c977 "device: track system interface state in NMDevice",
intended that a connection can only be assumed initially when seeing
a device for the first time. Assuming a connection later was to be
prevented by setting device's sys-iface-state to MANAGED.

That changed too much in behavior, because we used to assume external
connections also when they are activated later on. So this was attempted
to get fixed by
  - acf1067 nm-manager: try assuming connections on managed devices
  - b6b7d90 manager: avoid generating in memory connections during startup for managed devices

It's probably just wrong to prevent assuming connections based on the
sys-iface-state. So drop the check for sys-iface-state from
recheck_assume_connection(). Now, we can assume anytime on managed,
disconnected interfaces, like previously.
Btw, note that priv->startup is totally wrong to check there, because
priv->startup has the sole purpose of tracking startup-complete property.
Startup, as far as NMManager is concerned, is platform_query_devices().

However, the problem is that we only assume connections (contrary to
doing external activation) when we have a connection-uuid from the state
file or with guess-assume during startup.

When assuming a master device, it can fail with

  (nm-bond): ignoring generated connection (IPv6LL-only and not in master-slave relationship)

thus, for internal reason the device cannot be assumed yet.

Fix that by attatching the assume-state to the device, so that on multiple
recheck_assume_connection() calls we still try to assume. Whenever we try
to assume the connection and it fails due to external reasons (like, the connection
no longer matching), we clear the assume state, so that we only try as
long as there are internal reasons why assuming fails.

https://bugzilla.redhat.com/show_bug.cgi?id=1452062
2017-06-08 21:46:34 +02:00
Thomas Haller
6a7b51f79b core: allow assuming connections on "nm-owned" software devices
Especially now we load the nm-owned flag from run-state. We very much want to
assume connections on such devices.
2017-06-08 21:45:17 +02:00
Thomas Haller
d83848be9d device: only set nm-owned from statefile during initial setup
The state file should only be read initially when NM starts, that is:
during NMManager's platform_query_devices().

At all later points, for example when a software device gets destroyed
and re-realized, the state file is clearly no longer relevant.

Hence, pass the set-nm-owned flag from NMManager to realize_start_setup().

This is very much the same as with the NM_UNMANAGED_FLAG_USER_EXPLICT flag,
which we also read from the state-file.
2017-06-08 21:44:22 +02:00
Beniamino Galvani
c66995ad4d device: check connectivity on the IP interface
curl must bind to the interface that has IP configuration, not the
underlying device. Without this commit, connectivity check fails on
certain connection types (PPPoE, WWAN).

Fixes: 9d43869e47
2017-06-08 11:01:05 +02:00
Beniamino Galvani
5600a27c2a bond: check for NULL bond mode value in update_connection()
Don't crash if the bond mode can't be read from sysfs - for example
when the interface disappears. The generated connection will be bogus,
but at that point it doesn't matter because the in-memory connection
will be destroyed.

Fixes: 056a973a4f

https://bugzilla.redhat.com/show_bug.cgi?id=1459580
2017-06-08 09:44:47 +02:00
Thomas Haller
f07dca941d ppp: unexport NMPPPManager instance on dispose()
Let's explicitly unexports on dispose(). Probably that already
happened, because NMExportedObject asserts that it is unexported
during !quitting.

During quitting, we probably don't tear down the manager.

Anyway, we should always unexport.
2017-06-07 17:07:12 +02:00
Thomas Haller
7b5251b35c ppp: cast int argument for variadic g_signal_emit(NM_PPP_MANAGER_STATE_CHANGE) call 2017-06-07 16:09:18 +02:00
Beniamino Galvani
cf9ba271e6 manager: restore the previous persistent nm-owned state of devices
After a daemon restart, any software device is considered !nm-owned,
even if it was created by NM. Therefore, a device stays around even if
the connection which created it gets deactivated or deleted.

Fix this by remembering the previous nm-owned state in the device
state file.

https://bugzilla.redhat.com/show_bug.cgi?id=1376199
2017-06-07 10:27:02 +02:00
Beniamino Galvani
3fbbbb62f0 config: allow persisting the device nm-owned state 2017-06-07 10:27:02 +02:00
Beniamino Galvani
8cce037bf8 device: rename priv->is_nm_owned to priv->nm_owned
Only a matter of taste, but nm_device_get_is_nm_owned() sounds
strange.
2017-06-07 10:27:02 +02:00
Thomas Haller
c855ebf943 bluetooth: assert against registering same device multiple times 2017-06-07 09:07:18 +02:00
Thomas Haller
6ecf78a19b bluetooth/trivial: rename NetworkServer's network_servers field
The list field should have a unique name and not the same as the
list head. This avoids

    c_list_link_before (&priv->network_servers, &network_server->network_servers);

    c_list_for_each_entry (network_server, &priv->network_servers, network_servers) {
2017-06-07 09:07:18 +02:00
Thomas Haller
40a2955647 bluetooth: split _find_network_server() in two functions
Instead of having a complex _find_network_server() function with several
arguments, split it.

Having multiple optional arguments to a find() function is fine,
if all arguments consistently narrow down the search.
For example nmp_cache_lookup_link_full(), where each argument is
optional, and it restricts the search.
For _find_network_server() that was not the case, because setting
"addr" and "device" together would be non-sensical.
2017-06-07 09:07:18 +02:00
Thomas Haller
113e8ad6e6 device: inline bluetooth function in nm-device-bridge.c
The 3 bluetooth NAP hooks are called each only once. Inline them.
It is still very easy to understand where the bluetooth related
functions are invoked: grep for nm_bt_vtable_network_server.

In deactivate(), don't bother checking whether the current active
connection is a bluetooth type. Just always call unregister_bridge().
It's fast, and does nothing in case the bridge isn't registered.

I change it because I disagree with the previous naming.

For example bt_network_server_available() would not only call
is_available(). Instead, it checks whether the connection can
activate regarding availability of the bluetooth connection
(meaning, it returns TRUE if it's not a bluetooth connection or
if the bluez manager gives green light). In the bridge case,
it doesn't check any network-server availability.
There is already a function with a meaningful name for this behavior:
check_connection_available().

Same with bt_network_server_register(). It would indicate success,
if the applied connection is not a bluetooth connection. In cases,
where it didn't actually register anything. A function called
bt_network_server_register() should only return success if it actually
registered anything.
2017-06-07 09:07:18 +02:00
Thomas Haller
abdf9a3673 all: change handling of connection.type for bluetooth NAP and in general
Branch f9b1bc16e9 added bluetooth NAP
support. A NAP connection is of connection.type "bluetooth", but it
also has a "bridge" setting. Also, it is primarily handled by NMDeviceBridge
and NMBridgeDeviceFactory (with help from NMBluezManager).

However, don't let nm_connection_get_connection_type() and
nm_connnection_is_type() lie about what the connection.type is.
The type is "bluetooth" for most purposes -- at least, as far as
the client is concerned (and the public API of libnm). This restores
previous API behavior, where nm_connection_get_connection_type()
and nm_connection_is_type() would be simple accessors to the
"connection.type" property.

Only a few places care about the bridge aspect, and those places need special
treatment. For example NMDeviceBridge needs to be fully aware that it can
handle bluetooth NAP connection. That is nothing new: if you handle a
connection of any type, you must know which fields matter and what they
mean. It's not enough that nm_connection_get_connection_type() for bluetooth
NAP connectins is claiming to be a bridge.

Counter examples, where the original behavior is right:

src/nm-manager.c-        g_set_error (error,
src/nm-manager.c-                     NM_MANAGER_ERROR,
src/nm-manager.c-                     NM_MANAGER_ERROR_FAILED,
src/nm-manager.c-                     "NetworkManager plugin for '%s' unavailable",
src/nm-manager.c:                     nm_connection_get_connection_type (connection));

the correct message is: "no bluetooth plugin available", not "bridge".

src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c:   if (   (   nm_connection_is_type (connection, NM_SETTING_WIRED_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c:           && !nm_connection_get_setting_pppoe (connection))
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c:       || nm_connection_is_type (connection, NM_SETTING_VLAN_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c:       || nm_connection_is_type (connection, NM_SETTING_WIRELESS_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c:       || nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c:       || nm_connection_is_type (connection, NM_SETTING_BOND_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c:       || nm_connection_is_type (connection, NM_SETTING_TEAM_SETTING_NAME)
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c:       || nm_connection_is_type (connection, NM_SETTING_BRIDGE_SETTING_NAME))
src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c-        return TRUE;

the correct behavior is for ifcfg-rh plugin to reject bluetooth NAP
connections, not proceed and store it.
2017-06-07 09:07:17 +02:00
Thomas Haller
c74a6b305c device: remove duplicate check for NMDeviceFactory's _add_factory()
The duplicate check is based only on the link-types and setting-types.
However, that doesn't really cut it because in case of bluetooth
NAP connections, NMBridgeDeviceFactory is responsible for the connection,
although connection.type is "bluetooth".

This is only here to catch loading invalid plugins. But at the point
where we load an invalid plugin, the process is hosed. This is at best
an assertion, but rather pointless really.
2017-06-07 09:07:17 +02:00
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
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
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
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
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
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
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
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