Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
b6061b3cd5 platform: declare NMPObjectType in nm-types.h
We want to use it outside of NMPlatform, but users should not be required
to include "nmp-object.h".
2015-06-24 16:09:57 +02:00
Thomas Haller
4010d779a7 platform: generate gtype for NMPObjectType enum 2015-06-24 16:09:56 +02:00
Thomas Haller
d48902e605 core: delay handling of link-changed platform event in manager
Backtrace:

    NetworkManager[10972]: <debug> [1435142179.593334] [platform/nm-platform.c:2962] log_ip4_route(): signal: route   4 removed: 0.0.0.0/0 via 192.168.100.1 dev 85 metric 300 mss 0 src user scope global
    NetworkManager[10972]: <debug> [1435142179.593421] [platform/nm-platform.c:2944] log_link(): signal: link removed: 85: bond0 <DOWN;broadcast,multicast,master> mtu 1500 arp 1 bond* init addr 7A:AB:BE:0D:19:3D driver bond
    NetworkManager[10972]: <debug> [1435142179.593446] [nm-manager.c:779] remove_device(): (bond0): removing device (allow_unmanage 1, managed 1)
    NetworkManager[10972]: <debug> [1435142179.596995] [devices/nm-device.c:7232] nm_device_set_unmanaged(): [0x5555559d2a40] (bond0): now unmanaged
    NetworkManager[10972]: (devices/nm-device.c:8040):_set_state_full: runtime check failed: (priv->in_state_changed == FALSE)

    #0  0x00007ffff4a538c3 in g_logv () at /lib64/libglib-2.0.so.0
    #1  0x00007ffff4a53a3f in g_log () at /lib64/libglib-2.0.so.0
    #2  0x00007ffff4a53d56 in g_warn_message () at /lib64/libglib-2.0.so.0
    #3  0x00005555555b9dca in _set_state_full (self=0x5555559d2a40, state=NM_DEVICE_STATE_UNMANAGED, reason=NM_DEVICE_STATE_REASON_REMOVED, quitting=0) at devices/nm-device.c:8040
    #4  0x0000555555626d7b in remove_device (manager=0x5555559631e0, device=0x5555559d2a40, quitting=0, allow_unmanage=<optimized out>) at nm-manager.c:801
    #5  0x00007ffff28b7dac in ffi_call_unix64 () at /lib64/libffi.so.6
    #6  0x00007ffff28b76d5 in ffi_call () at /lib64/libffi.so.6
    #7  0x00007ffff4d4a628 in g_cclosure_marshal_generic () at /lib64/libgobject-2.0.so.0
    #8  0x00007ffff4d49de8 in g_closure_invoke () at /lib64/libgobject-2.0.so.0
    #9  0x00007ffff4d5b70d in signal_emit_unlocked_R () at /lib64/libgobject-2.0.so.0
    #10 0x00007ffff4d63471 in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
    #11 0x00007ffff4d63c78 in g_signal_emit_by_name () at /lib64/libgobject-2.0.so.0
    #12 0x00005555555ce4ea in do_emit_signal (platform=platform@entry=0x55555594c8b0, obj=0x555555a74c50, cache_op=NMP_CACHE_OPS_REMOVED, was_visible=<optimized out>, reason=reason@entry=
        NM_PLATFORM_REASON_INTERNAL) at platform/nm-linux-platform.c:1425
    #13 0x00005555555ce826 in cache_prune_candidates_prune (platform=platform@entry=0x55555594c8b0) at platform/nm-linux-platform.c:1704
    #14 0x00005555555d32d3 in do_request_link (platform=platform@entry=0x55555594c8b0, ifindex=ifindex@entry=85, name=name@entry=0x0, handle_delayed_action=handle_delayed_action@entry=0)
        at platform/nm-linux-platform.c:1951
    #15 0x00005555555d356b in delayed_action_handle_all (ifindex=85, platform=0x55555594c8b0) at platform/nm-linux-platform.c:1491
    #16 0x00005555555d356b in delayed_action_handle_all (platform=0x55555594c8b0) at platform/nm-linux-platform.c:1573
    #17 0x00005555555d356b in delayed_action_handle_all (platform=platform@entry=0x55555594c8b0, read_netlink=read_netlink@entry=0) at platform/nm-linux-platform.c:1588
    #18 0x00005555555d32e2 in do_request_link (platform=platform@entry=0x55555594c8b0, ifindex=ifindex@entry=7, name=name@entry=0x0, handle_delayed_action=handle_delayed_action@entry=1)
        at platform/nm-linux-platform.c:1954
    #19 0x00005555555d5177 in do_change_link (platform=platform@entry=0x55555594c8b0, nlo=nlo@entry=0x55555597f0f0, complete_from_cache=complete_from_cache@entry=1) at platform/nm-linux-platform.c:2753
    #20 0x00005555555d56b4 in link_enslave (platform=0x55555594c8b0, master=0, slave=7) at platform/nm-linux-platform.c:3141
    #21 0x00005555555976de in release_slave (device=0x5555559d2a40, slave=0x5555559c6be0, configure=<optimized out>) at devices/nm-device-bond.c:437
    #22 0x00005555555b7bc3 in nm_device_release_one_slave (self=self@entry=0x5555559d2a40, slave=0x5555559c6be0, configure=configure@entry=1, reason=reason@entry=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED)
        at devices/nm-device.c:1049
    #23 0x00005555555b7f0e in nm_device_master_release_slaves (self=self@entry=0x5555559d2a40) at devices/nm-device.c:1781
    #24 0x00005555555b9592 in nm_device_cleanup (self=0x5555559d2a40, reason=<optimized out>, deconfigure=1) at devices/nm-device.c:7752
    #25 0x00005555555ba161 in _set_state_full (self=self@entry=0x5555559d2a40, state=state@entry=NM_DEVICE_STATE_DISCONNECTED, reason=reason@entry=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED, quitting=quitting@entry=0) at devices/nm-device.c:8128
    #26 0x00005555555bb297 in nm_device_state_changed (self=self@entry=0x5555559d2a40, state=state@entry=NM_DEVICE_STATE_DISCONNECTED, reason=reason@entry=NM_DEVICE_STATE_REASON_CONNECTION_REMOVED)
        at devices/nm-device.c:8319
    #27 0x00005555555bd9a5 in queued_set_state (user_data=<optimized out>) at devices/nm-device.c:8343
    #28 0x00007ffff4a4c79a in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
    #29 0x00007ffff4a4cae8 in g_main_context_iterate.isra.24 () at /lib64/libglib-2.0.so.0
    #30 0x00007ffff4a4cdba in g_main_loop_run () at /lib64/libglib-2.0.so.0
    #31 0x000055555559556f in main (argc=1, argv=0x7fffffffdb88) at main.c:518
2015-06-24 15:17:16 +02:00
Jiří Klimeš
84b5fa21ed device: split IP config changes signal handling to IPv4 and IPv6
So that we don't process IPv4 changes for IPv6 and vice versa.
2015-06-24 15:08:05 +02:00
Jiří Klimeš
0a00eb67dd device: split ensure_ipx_config() into IPv4 and IPv6 (bgo #751430)
Without that we can remove addresses from con-ip6-config due to external
changes *before* it is applied and thus manual IPv6 addresses are not applied
together with ipv6.method=auto.

Testcase:
$ nmcli con add type ether con-name AAA ifname eth0 autoconnect no
$ nmcli con mod AAA ipv4.addresses 1.1.1.1/24 ipv6.addresses 99::99/64
$ nmcli con up AAA

Fixes:Beaker:NetworkManager_Test37_run_once_new_connection
Fixes:Beaker:NetworkManager_Test84_ipv6_addresses_no_when_static_switch_asked

https://bugzilla.gnome.org/show_bug.cgi?id=751430
2015-06-24 15:07:18 +02:00
Jiří Klimeš
b77fba3939 platform: (trivial) rename @managed to @unmanaged in link_get_unmanaged()
It returns unmanaged state (reads NM_UNMANAGED from udev), so "managed" was
very misleading.

Fixes: 85ee1f4a9c
2015-06-24 14:43:09 +02:00
Thomas Haller
2170804213 platform: prettify and line-wrap route_to_string() print statements 2015-06-23 16:46:09 +02:00
Thomas Haller
80a0ec76b9 route-manager/logging: fix wording in logging statement 2015-06-23 16:46:09 +02:00
Thomas Haller
4eb48d8c87 test: add NMTST_BUSY_WAIT() util 2015-06-23 16:46:09 +02:00
Jiří Klimeš
eebfe56a90 examples: python: add an D-Bus example creating and activating a bond 2015-06-23 15:06:31 +02:00
Jiří Klimeš
1e923cb923 examples: add wifi-hotspot.py script to Makefile.am
Fixes: 1af8e2f132
2015-06-23 15:04:43 +02:00
Lubomir Rintel
2e958baceb nmcli: don't hang activation of masters that progress beyond ip-config
Some master connetions are able to progress beyond activating/ip-config -- the
slaves might have appeared during the activation, or the connection doesn't
need slaves to obtain the configuration (it could be method=manual or shared).
2015-06-23 12:44:49 +02:00
Lubomir Rintel
33f954e251 manager: fix a typo when iterating possible master connection
Compare against the interface of the candidate master connection, not the slave
connection itself.

Fixes: 179d56c73c
2015-06-22 18:49:44 +02:00
Lubomir Rintel
14bfd55361 platform: g_hash_table_add doesn't return a value before 2.40 2015-06-22 17:04:22 +02:00
Lubomir Rintel
2a6e8d9f3f glib-compat: include string.h
Needed for memmove().
2015-06-22 16:24:34 +02:00
Lubomir Rintel
a1868dcfc3 platform: fix build on 32-bit systems
The decimal literals are signed by default and these are too large to fit in a
signed 32-bit int.
2015-06-22 13:13:05 +02:00
Thomas Haller
083327b830 trivial: fix spelling error in code comment 2015-06-21 15:29:30 +02:00
Thomas Haller
0a38352470 platform: don't assert for valid ifindex in nm_platform_link_get()
It's not uncommon to lookup a platform parameter with invalid
ifindex or ifname. Be more resilient and just return "no link found".

Fixes: e8e455817b
2015-06-21 15:07:57 +02:00
Thomas Haller
e8e455817b platform: refactor virtual methods for link objects in NMPlatform
Change nm_platform_link_get() to return the cached NMPlatformLink
instance. Now what all our implementations (fake and linux) have such a
cache internal object, let's just expose it directly.
Note that the lifetime of the exposed link object is possibly quite
short. A caller must copy the returned value if he intends to preserve
it for later.
Also add nm_platform_link_get_by_ifname() and modify nm_platform_link_get_by_address()
to return the instance.

Certain functions, such as nm_platform_link_get_name(),
nm_platform_link_get_ifindex(), etc. are solely implemented based
on looking at the returned NMPlatformLink object. No longer implement
them as virtual functions but instead implement them in the base class
(nm-platform.c).
This removes code and eliminates the redundancy of the exposed
NMPlatformLink instance and the nm_platform_link_get_*() accessors.
Thereby also fix a bug in NMFakePlatform that tracked the link address
in a separate "address" field, instead of using "link.addr". That was
a case where the redundancy actually led to a bug in fake platform.

Also remove some stub implementations in NMFakePlatform that just
bail out. Instead allow for a missing virtual functions and perform
the "default" action in the accessor.
An example for that is nm_platform_link_get_permanent_address().
2015-06-21 12:53:48 +02:00
Thomas Haller
ae824f582b nmp-object: check for non-empty ifname in _vt_cmd_obj_is_visible_link() 2015-06-20 18:50:27 +02:00
Thomas Haller
1bfade833a platform: fix ip4_check_reinstall_device_route() implementation
We must check if a conflicting route/address is configured on
*any* interface, not only on the target ifindex.

This at least restores the previous behavior. Note that this whole
check_reinstall_device_route() still has problems and it might
be better to move it all to NMRouteManager.

Fixes: 470bcefa5f
2015-06-19 17:16:39 +02:00
Thomas Haller
518cf76de7 platform/trivial: rename ObjectType to NMPObjectType
After doing all the refactoring, rename the ObjectType enum to NMPObjectType.
I didn't do this earlier to avoid problems with rebasing. But since I will
backport the platform changes to nm-1-0, this is the right time to get
the name right.
2015-06-19 16:24:20 +02:00
Thomas Haller
55a67ec787 platform: add nm_platform_process_events() function 2015-06-19 15:38:41 +02:00
Dan Williams
86abc34e26 trivial: move some code around in nm-device.c 2015-06-19 14:17:20 +02:00
Jiří Klimeš
2dc27a99d7 all: fix additional compiler warningis about function declarations
warning: function declaration isn’t a prototype [-Wstrict-prototypes]

In C function() and function(void) are two different prototypes (as opposed to
C++).
function()     accepts an arbitrary number of arguments
function(void) accepts zero arguments
2015-06-19 13:06:37 +02:00
Jiří Klimeš
b18f328967 merge: activate slaves when master is activated (bgo #735052) (rh #1158529)
When a master connection is activated, check all its slaves and decide whether
they should be activated as well. This is done according to the
connection.autoconnect-slaves property.

https://bugzilla.gnome.org/show_bug.cgi?id=735052
https://bugzilla.redhat.com/show_bug.cgi?id=1158529
2015-06-19 09:58:17 +02:00
Jiří Klimeš
f05d41d358 man: mention that connection.autoconnect-slaves property supports default value 2015-06-19 09:32:58 +02:00
Jiří Klimeš
f4582d812c core: activate slaves when master is activated (bgo #735052) (rh #1158529)
When a master connection is activated, check all its slaves and decide whether
they should be activated as well. This is done according to the
autoconnect-slaves property.

https://bugzilla.gnome.org/show_bug.cgi?id=735052
https://bugzilla.redhat.com/show_bug.cgi?id=1158529
2015-06-19 09:32:58 +02:00
Jiří Klimeš
c3093d9391 cli: add support for connection.autoconnect-slaves property 2015-06-19 09:32:58 +02:00
Jiří Klimeš
2a497eeadc ifcfg-rh: read/write autoconnect-slaves property as AUTOCONNECT_SLAVES
AUTOCONNECT_SLAVES is an NetworkManager extension. initscripts always activate
slaves with the master connection for bond and team, and doesn't activate
automatically slaves for bridge.
NetworkManager behaviour is controlled by this variable. If the variable is
missing the default value from configuration file is used.
2015-06-19 09:32:58 +02:00
Jiří Klimeš
6caafab258 libnm: add autoconnect-slaves property to NMSettingConnection
The property is used for controlling whether slaves should be brought up with
a master connection. If 0, activating the master will not activate slaves.
But if set to 1, activating the master will bring up slaves as well.
The property can have the third state (-1), meaning that the value is default.
That is either a value set in the configuration file for the property, or 0.
2015-06-19 09:32:58 +02:00
Lubomir Rintel
203e48033b vxlan: o.fd.NM.Device.Proxy is a boolean 2015-06-18 22:26:36 +02:00
Lubomir Rintel
2bfbf33720 manager: use proper reason when stealing a connection
The user-requested reason is not really appropriate and blocks autoreconnect.
We added a new reason precisely for that.

Fixes: 4cb97cf66f
2015-06-18 15:45:15 -04:00
Thomas Haller
6849050ad9 default-route-manager: fix syncing routes to consider non-synced routes
We already protected route-metrics that are configured as default-routes
in platform. For most cases, that list is identical to our internal list
of non-synced routes.
But if for some reason that is not the case, we must also protect the
metric of routs that we currently track as "non-synced".
2015-06-18 18:39:12 +02:00
Thomas Haller
8f9dac01ac platform: fix lookup addresses and routes for any ifindex and refactor NMPCacheIdType
After refactoring platform, nm_platform_ipx_route_get_all() and
nm_platform_ipx_address_get_all() was broken for calling with a
non-posititive ifindex (which has the meaning: ignore ifindex).

While fixing that, also refactor the NMPCacheIdType so that it matches
better the supported id-types.

Fixes: 470bcefa5f
2015-06-18 17:19:00 +02:00
Thomas Haller
04caae735f device: delay handling of link-changed platform event
When inside a state-change, we set for example the device up.
This triggers a link-changed event, which then causes further
state-changes of the devices.
A state-change in process of a device is not reentrant, so we must
delay the handling of the link-changed event.
2015-06-18 10:33:30 +02:00
Thomas Haller
8da17c3a19 default-route-manager: disambiguate logging statements 2015-06-17 18:17:49 +02:00
Thomas Haller
5ecfbf18c2 settings: print filename of loaded setting plugins 2015-06-17 17:48:33 +02:00
Thomas Haller
972f61fcd7 macros: add NM_PRINT_FMT_QUOTED() macro 2015-06-17 17:46:54 +02:00
Thomas Haller
3be5e2908c settings: close module if loading of plugins fails 2015-06-17 17:46:54 +02:00
Thomas Haller
fba17e5c84 platform: add g_return_val_if_fail() check to nm_platform_sysctl_set_ip6_hop_limit_safe() 2015-06-17 15:00:10 +02:00
Lubomir Rintel
5e8182279a utils: _get_ip_config_method(): don't assert a connection has IP config
nm_utils_get_shared_wifi_permission() that is called for each AddAndActivate
uses this and triggers an assertion failure for InifnibandConnections which
don't have IPv4 configuration:

NetworkManager[54006]: nm_utils_get_ip_config_method: assertion 's_ip4 != NULL' failed

  #2  0x000055555562b833 in nm_utils_get_ip_config_method (connection=connection@entry=0x5555559c3b60, ip_setting_type=93824996202304) at NetworkManagerUtils.c:1329
  #3  0x000055555562b914 in nm_utils_get_shared_wifi_permission (connection=0x5555559c3b60) at NetworkManagerUtils.c:1105
  #4  0x00005555555fc012 in nm_active_connection_authorize (self=0x5555559b30a0, result_func=0x55555561b980 <_add_and_activate_auth_done>, user_data1=0x555555957210, user_data2=0x555555a055f0)
      at nm-active-connection.c:683
  #5  0x0000555555621b21 in impl_manager_add_and_activate_connection (self=0x555555957210, settings=<optimized out>, device_path=<optimized out>, specific_object_path=0x0, context=0x555555a055f0)
      at nm-manager.c:3495
2015-06-17 13:17:14 +02:00
Thomas Haller
35dcd8ac33 platform: merge branch 'th/platform_refact_caching-bgo747981'
Refactor caching of NMPlatform and the way how to load objects
via libnl/netlink.

https://bugzilla.gnome.org/show_bug.cgi?id=747981
https://bugzilla.gnome.org/show_bug.cgi?id=747985
https://bugzilla.redhat.com/show_bug.cgi?id=1211133
2015-06-17 11:50:53 +02:00
Thomas Haller
68a4ffb4e2 platform: drop nm_platform_get_error()
For NMPlatform instances we had an error reporting mechanism
which stores the last error reason in a private field. Later we
would check it via nm_platform_get_error().

Remove this. It was not used much, and it is not a great way
to report errors.

One problem is that at the point where the error happens, you don't
know whether anybody cares about an error code. So, you add code to set
the error reason because somebody *might* need it (but in realitiy, almost
no caller cares).
Also, we tested this functionality which is hardly used in non-testing code.
While this was a burden to maintain in the tests, it was likely still buggy
because there were no real use-cases, beside the tests.

Then, sometimes platform functions call each other which might overwrite the
error reason. So, every function must be cautious to preserve/set
the error reason according to it's own meaning. This can involve storing
the error code, calling another function, and restoring it afterwards.
This is harder to get right compared to a "return-error-code" pattern, where
every function manages its error code independently.

It is better to return the error reason whenever due. For that we already
have our common glib patterns

    (1) gboolean fcn (...);
    (2) gboolean fcn (..., GError **error);

In few cases, we need more details then a #gboolean, but don't want
to bother constructing a #GError. Then we should do instead:

    (3) NMPlatformError fcn (...);
2015-06-17 11:44:16 +02:00
Thomas Haller
baec894139 device: drop logging platform error on failure to set permanent MAC address
The platform error is in many cases not meaningful anyway.
2015-06-17 11:44:16 +02:00
Thomas Haller
c1a945b95d platform: signal missing firmware in nm_platform_set_up()
Don't use nm_platform_get_error() anymore.
2015-06-17 11:44:16 +02:00
Thomas Haller
8334171a4e device: don't check for NM_PLATFORM_ERROR_NOT_FOUND in set_nm_ipv6ll()
Unconditionally log a warning if the function fails.
We are about to drop nm_platform_get_error(), it's anyway unclear
why we don't want to log a warning about non-existing interface.
2015-06-17 11:44:16 +02:00
Thomas Haller
d7fe907c32 platform: return NMPlatformError from link-add functions
Later remove nm_platform_get_error() and signal errors via return
error codes.

Also, fix nm_platform_infiniband_partition_add() and
nm_platform_vlan_add() to check the type of the existing link
and fail with WRONG_TYPE otherwise.
2015-06-17 11:44:16 +02:00
Thomas Haller
f7fb68755c platform: rework NMPlatformError codes
- rename "NONE" to "SUCCESS", what it really is.
- change the to-string result not to contain spaces
  and being closer the name of the enum value.
- add new error reasons "UNSPECIFIED" and "BUG".
- remove the code comments around the enum definition.
  They add no further description about why this error
  happens and only paraphrase the name of the enum.
- reserve negative integers for 'errno'. This is neat
  because if we get a system error we can pass on the
  underlying errno as cause.
2015-06-17 11:44:16 +02:00
Thomas Haller
b74e620f2d platform: expose GUdevDevice instance for platform links 2015-06-17 11:44:16 +02:00