Commit Graph

7207 Commits

Author SHA1 Message Date
Thomas Haller
9a8d9a0d85 device: implement slave property in parent device class
Instead of reimplementing the slave property in bond, bridge
and team, just add the property to the parent class. It's not
that the parent class would be agnostic to the master/slave
implementation, all the slaves are known to the every device
type implementation.

Also, the derived class doesn't know the correct time when
to invoke the notify-changed for the slaves property.
E.g. it should be only invoked after nm_device_slave_notify_enslave()
when other components also consider the slave as enslaved.
Later this will be fixed so that the SLAVES property correspond
to what other master/slave related properties say.
2015-12-05 19:34:06 +01:00
Thomas Haller
f9404d36fd wifi: fix supplicant_connection_timeout_cb() using settings-connection
(gdb) bt
    #0  0x00007fc1c920681b in g_logv () at /lib64/libglib-2.0.so.0
    #1  0x00007fc1c920698f in g_log () at /lib64/libglib-2.0.so.0
    #2  0x00007fc1c9523237 in g_type_check_instance_cast () at /lib64/libgobject-2.0.so.0
    #3  0x00007fc1bdef10ed in supplicant_connection_timeout_cb (user_data=0x561a52451600) at nm-device-wifi.c:2207
    #4  0x00007fc1c9200893 in g_timeout_dispatch () at /lib64/libglib-2.0.so.0
    #5  0x00007fc1c91ffe3a in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
    #6  0x00007fc1c92001d0 in g_main_context_iterate.isra () at /lib64/libglib-2.0.so.0
    #7  0x00007fc1c92004f2 in g_main_loop_run () at /lib64/libglib-2.0.so.0
    #8  0x0000561a511583f3 in main (argc=1, argv=0x7ffc033f1e28) at main.c:488
2015-12-05 19:34:06 +01:00
Beniamino Galvani
6e990cf97b core: strip trailing dot from domain search list
dhclient adds a trailing dot to domain search list entries received
from the server, while the same domains received by other means
(dhcpcd on RA) don't have the final dot. The result is that
resolv.conf can be populated with duplicated entries.

Fix this by stripping the trailing dot when a new search domain is
added to a IP configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=758777
2015-12-05 09:55:03 +01:00
Thomas Haller
e7a8607695 device: don't return error from release_slave()
release_slave() should do the right thing and handle errors as
good as it can. There is no value in propagating the error and
it's not clear what the caller should do in face of a failure
during release.
2015-12-04 18:28:00 +01:00
Thomas Haller
a39dc1cd4b device/trivial: rename master related function of nm-device
We have the master/slave related functions
    - for master device:
      - nm_device_master_add_slave()
      - nm_device_master_release_slaves()
      - nm_device_release_one_slave()
      - nm_device_enslave_slave()
    - for slave device:
      - nm_device_slave_notify_enslave()
      - nm_device_slave_notify_release()

Rename the two that didn't match the pattern to
      - nm_device_master_release_one_slave()
      - nm_device_master_enslave_slave()
2015-12-04 18:28:00 +01:00
Thomas Haller
b9f31f326c device/trivial: rename fields to have unique names 2015-12-04 18:28:00 +01:00
Thomas Haller
b9b65e7d48 utils: save duplicate lookup of path in nm_utils_g_value_set_object_path_array() 2015-12-04 18:28:00 +01:00
Lubomir Rintel
d6d343ef65 policy: add a friendly warning
We don't want to admin CAP_SYS_ADMIN to our capability set in our .service
file: If we're running with systemd then hostnamed should be used to manage the
hostname, otherwise we likely have all capabilities anyway.

Let the user know.

Really, use systemd-hostnamed. Use it.
2015-12-04 18:03:30 +01:00
Thomas Haller
546272b216 core: subscribe recheck_assume_connection() early when adding device
It's clearer to (always) subscribe early to the NM_DEVICE_RECHECK_ASSUME signal
instead of during realize. Also, because a device can be realized several times.
Just make sure that recheck_assume_connection() doesn't do anything if it shouldn't
handle the event.
Only downside is some unnecessary work when there is nothing to do.

Also fix the signature of the NM_DEVICE_RECHECK_ASSUME handler recheck_assume_connection().
NM_DEVICE_RECHECK_ASSUME signal returns void. We should not subscribe recheck_assume_connection()
which returns gboolean.
2015-12-04 17:36:16 +01:00
Thomas Haller
0b12a4213b utils: assert for valid flags description in nm_utils_flags2str() 2015-12-04 16:58:21 +01:00
Thomas Haller
b1453fc7ef platform: use NM_UTILS_FLAGS2STR_DEFINE() macro 2015-12-04 16:31:15 +01:00
Thomas Haller
531f07b06a utils: add NM_UTILS_FLAGS2STR_DEFINE() macro
Make it neater to implement a nm_utils_flags2str() function.
2015-12-04 16:28:43 +01:00
Thomas Haller
3b6602b656 device: expose nm_device_set_autoconnect() function 2015-12-04 15:46:04 +01:00
Thomas Haller
4f5cd099be device: return the unmanaged flags from nm_device_get_unmanaged_flags() 2015-12-04 15:46:04 +01:00
Thomas Haller
4c9ffa8dba core/trivial: rename functions 2015-12-04 15:46:04 +01:00
Thomas Haller
f9b4d6fcd3 core/trivial: move code 2015-12-04 15:46:04 +01:00
Thomas Haller
26a2b38938 device: reorder unmanaged-flags
A later commit will rename several flags. So reorder them now to
make the following diff smaller (and easier to understand).
2015-12-04 15:45:54 +01:00
Thomas Haller
01a644a05b manager: fix clearing weak-ref in platform_link_added()
We must always clear the weak-ref.

Fixes: 4dbaac4ba2
2015-12-04 14:13:40 +01:00
Dan Williams
f2256af5bc core: allow multiple devices with the same interface name
But, of course, only one realized device can have the same
interface name at a time.

This commit effectively reverts most of:

1b37cd0340
core: allow ActiveConnections to be created without a device

But it's not easy to do a separate revert of that code due to
interdependencies with nm-manager.c.

Creating devices when they are defined by a connection also makes
makes it possible to require the NMDevice to be present when
activating it, which means we can remove a bunch of code from
NMManager that had to handle software devices not existing yet at
the time of the activation request.

But it also means we must be more careful when finding master
interfaces during slave activation, since we cannot simply match
by interface name alone.  Instead we must find the master which
matches both the interface name and can control slaves of the type
which is being activated.
2015-12-04 12:16:41 +01:00
Dan Williams
5da37a129c api/manager: add GetAllDevices() method and AllDevices property
Returns both realized and un-realized devices.
2015-12-04 12:16:41 +01:00
Dan Williams
20906ca7a3 core: ensure platform links are compatible with the NMDevice
Ensure the platform link with the same interface name as the
NMDevice is actually compatible with it before using the link
for initialization of device properties.  If not, remove the
NMDevice and create a new one since there are kernel resources
with a different type.
2015-12-04 12:16:41 +01:00
Dan Williams
4dbaac4ba2 core: create devices first and realize them later
Unrealized devices aren't backed by kernel resources and so won't know
all of their attributes.  That means three things:

1) they must update their attributes when they become realized
2) they must clear those attributes when unrealized
3) they must be looser in checking compatible connections until
they are realized

This requires that the setup() function be split into two parts, start & finish,
because finish must be run after add_device()

Also, we can simplify whether to pay attention to 'recheck-assume', which
is now dependent on priv->is_nm_owned, because the only case where NM should
*not* listen for the 'recheck-assume' signal is when the device is a
software device created by NM itself.  That logic was previously spread
across the callers of add_device() but is now consolidated into
nm-manager.c::device_realized() and nm-device.c::nm_device_create_and_realize().
2015-12-04 12:16:40 +01:00
Thomas Haller
b7eb622c24 ip-tunnel: don't update_properties() during update_connection()/check_connection_compatible()
The device properties are obtained via netlink, thus we get proper
platform notifications whenever they change. So the device properties
always reflect the platform state and there is no need to refresh
it during update_connection()/check_connection_compatible().
2015-12-04 12:15:12 +01:00
Thomas Haller
2b51ecc9e5 ip-tunnel: let update_properties_from_ifindex() clear properties on failure 2015-12-04 12:15:12 +01:00
Thomas Haller
8bbc6899b9 ip-tunnel: refactor update_properties in NMDeviceIPTunnel
let update_properties_from_ifindex() also support clearing
the properties to make it usable from unrealize().
2015-12-04 12:15:12 +01:00
Dan Williams
0be66bb1eb core: add class function for device unrealization
When a device is unrealized, its class-specific properties must also be cleared
since the device is no longer valid.
2015-12-04 12:15:12 +01:00
Dan Williams
d6f9230beb core: add "real" NMDevice property
This property is TRUE for devices that exist either as a kernel device
or are backed by some other resource (eg, ModemManager object, Bluez
device, etc).  It will eventually be FALSE for software devices that
are not yet instantiated.
2015-12-04 12:15:12 +01:00
Thomas Haller
7c4b5a4412 device: let NM_DEVICE_MASTER be equal to nm_device_get_master()
There is only one user of the NM_DEVICE_MASTER property (NMActiveConnection).
device_master_changed() uses the property for change notifications,
but returns early if !nm_device_get_master().

We might emit the "notify::master" signal too often, even when nothing
changed (because currently we always emit it when priv->master changes).
If we would fix that to only emit the signal when nm_device_get_master()
actually changes, it would still be correct, because device_master_changed()
doesn't care about notifications when the master is unset.

Hence, the only user doesn't care about the difference. So change it because
it's unexpected that the property and function are not completely equal.
2015-12-04 12:15:12 +01:00
Thomas Haller
7d9f819aa1 utils: construct paths array directly in nm_utils_g_value_set_object_path_array()
nm_utils_g_value_set_object_path_array() is used at several places, so that
this optimazation makes some sense.
2015-12-04 12:15:12 +01:00
Dan Williams
15d305c07f utils: add @filter_func argument to nm_utils_g_value_set_object_path_array() 2015-12-04 12:15:12 +01:00
Thomas Haller
9e36ccbe28 device: split new_device_added() out of component_added()
Commit cd3df12c8f reused the
virtual function component_added() to notify the vlan device
about a possibly new parent.

This reuse of the virtual function for another purpose is confusing.
Clean that up by splitting the implementation and add a new
virtual function nm_device_notify_new_device_added() which gets
(only implemented by NMDeviceVlan).
2015-12-04 12:15:12 +01:00
Thomas Haller
2e1e7ff0e6 device: fix disconnecting slave-device when master gets deleted
When deleting a master-device either via `nmcli device delete`
or `ip link delete`, the slave-device would hang.

This seems to be broken for a very long time already.

This is due to the following:

  #0  0x00005555555f548c in nm_device_slave_notify_release (self=0x555555dc1300, reason=NM_DEVICE_STATE_REASON_NONE) at devices/nm-device.c:2175
  #1  0x00005555555d6de2 in nm_device_release_one_slave (self=0x555555de3dd0, slave=0x555555dc1300, configure=0, reason=NM_DEVICE_STATE_REASON_NONE) at devices/nm-device.c:1117
  #2  0x00005555555f02b7 in device_link_changed (self=0x555555dc1300) at devices/nm-device.c:1460

Previously, nm_device_slave_notify_release() being called with reason
"NONE" did not actually transition the device-state, thus keeping the
device wrongly in activated state.

There were two callers that passed configure=FALSE to nm_device_release_one_slave(),
(and thus reason=NONE to nm_device_slave_notify_release()):

  - (1) device_link_changed():
      nm_device_release_one_slave (priv->master, self, FALSE, /*wrong reason NONE*/);
  - (2) nm_device_removed():
      nm_device_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_REMOVED);

We should always change the device-state during nm_device_slave_notify_release()
regardless of the reason.

(2) was added by commit c83b40aca7, later
refined by commit 5dd48f7527. In a way
change the second fix to perform some of the configuration (but still
not unenslaving the device).
2015-12-04 12:10:26 +01:00
Jiří Klimeš
d944a0f134 dhcp: lifetimes are unsigned integers, use %u printf specifier (rh #1268911)
https://bugzilla.redhat.com/show_bug.cgi?id=1268911
2015-12-03 15:25:54 +01:00
Beniamino Galvani
bde713b8e2 platform/tests: adding missing checks for loaded modules
Check if 'ipip' and 'ip6_tunnel' modules are loaded when trying to
perform link tests that require them and skip the tests if the modules
are not available.

Fixes: 133724d958
Fixes: 1a3448b43b
2015-12-02 10:18:38 +01:00
Beniamino Galvani
8361fbf010 device/ip-tunnel: add support for IP6TNL tunnels 2015-12-01 17:39:41 +01:00
Beniamino Galvani
8d2aa13534 device/ip-tunnel: add support for IPIP tunnels 2015-12-01 17:39:41 +01:00
Beniamino Galvani
d1b389bfa8 device/ip-tunnel: add support for SIT tunnels 2015-12-01 17:39:41 +01:00
Beniamino Galvani
3dfeec75e5 device: remove NMDeviceGre
As per previous commit, GRE tunnels are now represented as generic IP
tunnel devices.
2015-12-01 17:39:41 +01:00
Beniamino Galvani
570fdce93f device: add NMDeviceIPTunnel
The new object type represents tunnels over IPv4 and IPv6.

We have a single setting type (NMSettingIPTunnel) for tunnels and it
can't be shared among different device factories. So we define also a
single device type for all tunnels.

This new object will also represent GRE tunnels, which before were
instantiated as NMDeviceGre and had a ".Device.Gre" D-Bus
interface. This commit introduces a change in behavior.
2015-12-01 17:39:41 +01:00
Beniamino Galvani
1a3448b43b platform/tests: test IP6TNL links 2015-12-01 17:39:41 +01:00
Beniamino Galvani
133724d958 platform/tests: test IPIP links 2015-12-01 17:39:41 +01:00
Beniamino Galvani
3063f40e9a platform/tests: test SIT links 2015-12-01 17:39:41 +01:00
Beniamino Galvani
0d606a187b platform/tests: test GRE links also using platform code 2015-12-01 17:39:41 +01:00
Beniamino Galvani
32f6e1ef2e platform: add IP6TNL links support 2015-12-01 17:39:41 +01:00
Beniamino Galvani
30e648f981 platform: add IPIP links support 2015-12-01 17:39:41 +01:00
Beniamino Galvani
0754280b9f platform: add SIT links support 2015-12-01 17:39:41 +01:00
Beniamino Galvani
91bf0efaa7 platform: add GRE links creation support 2015-12-01 17:39:41 +01:00
Lubomir Rintel
604711488d libnm: avoid loosing signals
D-Bus has an upper limit on number of Match rules and it's rather easy
to hit as the proxy likes to add one for each object. Let's remove the Match
rule the proxy added and ensure a less granular rule is present instead.

Ideally, we should be able to tell glib not to hook its rules.
Related: https://bugzilla.gnome.org/show_bug.cgi?id=758749

https://bugzilla.gnome.org/show_bug.cgi?id=758751
2015-12-01 14:51:13 +01:00
Jiří Klimeš
7e93ceb640 wifi: only try adding supplicant interface 5 times on errors (bgo #753971)
When wpa_supplicant keeps returning an error, NetworkManager was trying over
and over again. Which resulted in endless messages:
<error> [1448462154.584916] [supplicant-manager/nm-supplicant-interface.c:879] interface_add_cb(): (AAA): error adding interface: wpa_supplicant couldn't grab this interface.
NetworkManager[17073]: <info>  (AAA): supplicant interface state: starting -> down

Testcase:
$ iw list | grep -A 3 "interface combinations"
	interface combinations are not supported
	HT Capability overrides:
		 * MCS: ff ff ff ff ff ff ff ff ff ff
		 * maximum A-MSDU length
$ sudo iw wlan0 interface add AAA type managed
...
$ sudo iw dev AAA del

Fixes: 3a2e6de0d3

https://bugzilla.gnome.org/show_bug.cgi?id=753971
2015-11-30 14:50:30 +01:00
Thomas Haller
27835ba73c Revert "systemd: fix potential memory leaks"
@random_data is declared as _cleanup_free_.

Freeing it is unnecessary and freeing without clearing the
pointer leads do a double free.

This reverts commit 3d1557eaad.
2015-11-28 22:53:31 +01:00