Commit graph

649 commits

Author SHA1 Message Date
Thomas Haller
bb9d4b0ad1 device: use _LOG() logging macros for per-device logging 2015-10-05 13:05:05 +02:00
Thomas Haller
85ac903bb8 device: fix activating slave device when stage1 delays action
When activating for example a team device which is to be enslaved to a
bridge, nm_device_activate_stage1_device_prepare() will postpone
stage 2.

In that case, we didn't register the "master-ready" of the team
device and thus never progressed the slave from stage2.

Reproduce:

  # nmcli connection delete t-br0
  # nmcli connection delete t-team0
  nmcli connection add type bridge con-name t-br0   autoconnect no ifname i-br0 ip4 192.168.177.100/24 gw4 192.168.177.1
  nmcli connection add type team   con-name t-team0 autoconnect no ifname i-team0
  nmcli connection modify id t-team0 connection.master i-br0 connection.slave-type bridge
  nmcli connection up t-team0
2015-10-02 18:45:39 +02:00
Thomas Haller
e427d32ec3 device: use nm_clear_g_signal_handler() to clear master-ready signal handler 2015-10-02 16:42:44 +02:00
Beniamino Galvani
7cf5c326bc device: ensure firewall zone is set on the actual IP interface
For certain types of connection as PPP and WWAN the IP interface is
created during stage3 (IP config) but we are setting the firewall zone
at the beginning of stage3 and thus the zone is only set on the
underlying interface.

Add a check at the start of IP check phase to ensure that the firewall
zone is set again if the device interface is different from IP
interface.

https://bugzilla.redhat.com/show_bug.cgi?id=1110465
2015-09-26 09:47:21 +02:00
Dan Williams
5b374a4a9f device: increase IPv6LL DAD timeout (rh #1101809)
Depending on the network and the values of the 'dad_transmits' and
'retrans_timeout_ms' sysctls, DAD for the IPv6LL address can take
quite a while.  Obviously there must be some upper bound on the
timeout, but 5 seconds seems a bit low.  In this case it was observed
to be ~12 seconds but the sysctl values are unknown.  In any case,
we can't predict the network/config so being a bit more lenient here
makes sense.

https://bugzilla.redhat.com/show_bug.cgi?id=1101809
2015-09-25 11:27:46 -05:00
Thomas Haller
bb7e6c2cd4 firewall: always take a reference to NMFirewallManager during asynchronous operations
Always take a reference to the manager when scheaduling an asynchronous
operations. In fact, all callers want to keep the manager alive as long
as there are operations in progress.
2015-09-25 10:34:03 +02:00
Thomas Haller
94f888a262 firewall: refactor callback handling in NMFirewallManager
Refactor NMFirewallManager to have consistent semantics about
asynchronous calls.

  - the callback is always invoked exactly once, but never
    synchronously when starting the operation.
  - while cancelling the request, the callback is invoked
    synchronously with respect to the cancel operation.
  - you can cancel a request once (and once only).
  - you cannot cancel the request once the callback is invoked.
  - when disposing the object with requests pending, the
    callbacks are invoked synchronously.

- Add a callback argument to nm_firewall_manager_remove_from_zone().
  Otherwise, the user never knows whether a call is still pending and
  cancellable (as complete operations cannot be cancelled).
  In fact, it makes no sense trying to cancel a call if you don't care
  about when it completes.

- get rid of PENDING_CALL_DUMMY. The dummy callback allows cancellation
  any number of times. We want to catch wrong usage by asserting that an
  operation is only cancelled once.

- nm_firewall_manager_cancel_call() doesn't need the manager argument.
  Either the call-id is valid (and has a valid pointer to the manager),
  or there is a bug and it is a dangling pointer.
2015-09-25 10:34:02 +02:00
Thomas Haller
5bc4d7f0f9 firewall: add arguments to NMFirewallManagerAddRemoveCallback
We should return the target object and the call_id.
2015-09-25 10:34:02 +02:00
Thomas Haller
0d33b73e42 firewall/trivial: rename NMFirewallPendingCall to NMFirewallManagerCallId
Matches the naming scheme for other call-ids.
2015-09-25 10:34:02 +02:00
Thomas Haller
f0ea0cd402 device: refactor beginning of _set_state_full()
- Reorder statements, to first g_return_if_fail() and log state-change.

- Also log a message when leaving _set_state_full() early due to missing firmware.
2015-09-21 18:25:50 +02:00
Thomas Haller
5d36910d16 device: log the flags that are set/cleared in _set_unmanaged_flags()
Don't show only the flags that are set/cleared *in addition*.
2015-09-21 16:24:41 +02:00
Jiří Klimeš
73d2bd53c5 device: remove unused ip_iface 2015-09-21 09:09:36 +02:00
Lubomir Rintel
06da353242 core: separate active and applied connection
Clone the connection upon activation. This makes it safe for the user
to modify the original connection while it is activated.

This involves several changes:

- NMActiveConnection gets @settings_connection and @applied_connection.
  To support add-and-activate, we constructing a NMActiveConnection with
  no connection set. Previously, we would set the "connection" field to
  a temporary NMConnection. Now NMManager piggybacks this temporary
  connection as object-data (TAG_ACTIVE_CONNETION_ADD_AND_ACTIVATE).

- get rid of the functions nm_active_connection_get_connection_type()
  and nm_active_connection_get_connection_uuid(). From their names
  it is unclear whether this returns the settings or applied connection.
  The (few) callers should figure that out themselves.

- rename nm_active_connection_get_id() to
  nm_active_connection_get_settings_connection_id(). This function
  is only used internally for logging.

- dispatcher calls now get two connections as well. The
  applied-connection is used for the connection data, while
  the settings-connection is used for the connection path.

- needs special handling for properties that apply immediately
  when changed (nm_device_reapply_settings_immediately()).

Co-Authored-By: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=724041
2015-09-18 17:32:11 +02:00
Thomas Haller
aeaf31b7a8 device/trivial: rename nm_device_get_unmanaged_flag() to nm_device_get_unmanaged()
This way, the function matches the other names like nm_device_set_unmanaged().
Arguably, the name currently makes some sense. But future commits will make
nm_device_get_unmanaged() more to be a counterpart of nm_device_set_unmanaged().
2015-09-18 13:18:05 +02:00
Thomas Haller
ef4aa6c555 device/trivial: rename nm_device_set_initial_unmanaged_flag() to nm_device_set_unmanaged_initial()
That way, the name matches better with related functions named
nm_device_set_unmanaged*()
2015-09-18 13:14:44 +02:00
Thomas Haller
0eebf580c1 device: allow modifying Managed property
https://bugzilla.redhat.com/show_bug.cgi?id=1114685
https://bugzilla.gnome.org/show_bug.cgi?id=746566
Related: https://bugzilla.gnome.org/show_bug.cgi?id=680909
Related: https://bugzilla.gnome.org/show_bug.cgi?id=731014

Based-on-patch-by: Lubomir Rintel <lkundrak@v3.sk>
2015-09-18 13:14:23 +02:00
Beniamino Galvani
d910c94beb policy: update device's metered property when connection changes
If the metered property of a connection is changed, an activated
device associated to the connection must be updated immediately with
the new metered value.

https://bugzilla.gnome.org/show_bug.cgi?id=754409
2015-09-18 11:48:37 +02:00
Thomas Haller
6125523740 device: refactor setting unmanaged based on device-spec 2015-09-16 16:36:55 +02:00
Thomas Haller
fd8dde5c68 device: add explicit NM_UNMANAGED_LOOPBACK flag for not managing "lo" 2015-09-16 16:36:55 +02:00
Thomas Haller
4dd0b69a88 device: add debug log for setting unmanged flags
Only set priv->unmanaged_flags in one place and log
any changes. It is not trivial to understand from the
logfile why a device is unmanged.
2015-09-14 21:50:28 +02:00
Thomas Haller
b89826d874 device/trivial: move local variable closer to where it is used 2015-09-14 18:36:54 +02:00
Thomas Haller
b0815813fa iface-helper: enabled dhcp4/slaac according to IP method
If at the moment when spawning nm-iface-helper dhcp4/slaac
did not yet complete, we would not enable it.

That is wrong. If the connection indicates to use dhcp4/slaac,
it should be used by nm-iface-helper without considering the
current state on the device.

https://bugzilla.redhat.com/show_bug.cgi?id=1260243
2015-09-13 15:50:44 +02:00
Beniamino Galvani
998ab88949 device: retry DHCP after timeout/expiration for assumed connections
If DHCP fails for an assumed connection, NetworkManager would
transition the device to the FAILED and then to the ACTIVATED state
(because it is assumed); hence if the DHCP server goes temporarily
down the device will go into a permanent state without IP
configuration.

Fix this and try DHCP again after some time when the connection
is an assumed one.

https://bugzilla.redhat.com/show_bug.cgi?id=1246496
2015-09-08 13:23:14 +02:00
Lubomir Rintel
1c46ddf196 device: don't reset NM_UNMANAGED_DEFAULT when platform doesn't override this
This would cause the ip_vti0 generic device (that appears upon insertion of
ip_vti module during libreswan ipsec stack init) to go managed and brought UP.
Without addresses assigned the device would cause all the VPN traffic to
disappear in the oblivion.
2015-09-08 12:32:35 +02:00
Beniamino Galvani
b3b0b46250 device: retry creation of default connection after link is initialized
When a new link is detected, NM tries to generate a default "Wired
connection" in nm_settings_device_added(), but if the link has not
been initialized by udev yet the function returns early because
priv->unmanaged_flags = UNMANAGED_PLATFORM_INIT.

To be sure that a default connection is created is such situation, we
need to call again nm_settings_device_added() after link
initialization.

https://bugzilla.redhat.com/show_bug.cgi?id=1254089
2015-09-03 17:59:51 +02:00
Beniamino Galvani
905220b337 device: fix clearing of dhcp6_restart_id in dhcp6_cleanup()
Fixes: abc96ecdfd
2015-08-26 11:46:26 +02:00
Beniamino Galvani
abc96ecdfd device: don't disconnect after DHCP failure when there are static IPs
Don't disconnect the device when the DHCP renewal fails and there are
already configured static IP addresses on the device. Instead, keep
the device up and try DHCP again after some time.

https://bugzilla.redhat.com/show_bug.cgi?id=1168388
2015-08-26 10:48:49 +02:00
Beniamino Galvani
b557f91a1b device: don't clear @master on cleanup when the link is still enslaved
Don't clear NMDevice @master in nm_device_cleanup() if the device link
is still enslaved because this causes an inconsistent state in which
the slave in included in the @slaves field of master device but
@master of slave device is NULL.

In such state, if the master link gets deleted, NM receives a change
event for each slave and a deletion event for the master; the change
events should also remove slaves from @slaves of master device, but
since their @master field is NULL the removal can't be performed.

Later, when the master deletion event is received, @slaves is not empty
in dispose() of NMDevice and the following assertion is triggered:

  dispose: runtime check failed: (priv->slaves == NULL)

https://bugzilla.redhat.com/show_bug.cgi?id=1243371
2015-08-20 08:52:18 +02:00
Beniamino Galvani
1d6e8e8da7 device: accept multiple addresses in a DHCPv6 lease
When the DHCPv6 lease received from the server contains multiple
addresses, dhclient generates a new BOUND event for each of
them. Instead of overwriting the previous IP6 configuration for each
BOUND event, we should try to detect if the new configuration belongs
to the same lease and merge its addresses with the existing one in
such case.

This allows NetworkManager to configure multiple addresses on an
interface via DHCPv6.

https://bugzilla.gnome.org/show_bug.cgi?id=681764
https://bugzilla.redhat.com/show_bug.cgi?id=1244293
2015-08-17 09:52:28 +02:00
Thomas Haller
3cb1ead3af device: log message when constructing NMDevice instance 2015-08-13 10:06:43 +02:00
Lubomir Rintel
688e93fb2a device: avoid a crash during destruction
The ipv4_config might be gone already, _cleanup_generic_post() sets it to NULL.

  NetworkManager[30564]: <info>  caught SIGINT, shutting down normally.

  (NetworkManager:30564): GLib-GObject-CRITICAL **: g_type_instance_get_private: assertion 'instance != NULL && instance->g_class != NULL' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x7ffff4d92f64 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd5e0) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4a738c3 in g_logv (log_domain=0x7ffff4d92f64 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd5e0) at gmessages.c:1046
  #1  0x00007ffff4a73a3f in g_log (log_domain=log_domain@entry=0x7ffff4d92f64 "GLib-GObject", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff4ae173d "%s: assertion '%s' failed")
      at gmessages.c:1079
  #2  0x00007ffff4a73a79 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7ffff4d92f64 "GLib-GObject", pretty_function=pretty_function@entry=0x7ffff4d9aad0 <__FUNCTION__.13620> "g_type_instance_get_private", expression=expression@entry=0x7ffff4d99db8 "instance != NULL && instance->g_class != NULL") at gmessages.c:1088
  #3  0x00007ffff4d8d2ba in g_type_instance_get_private (instance=instance@entry=0x0, private_type=<optimized out>) at gtype.c:4632
  #4  0x00000000004bf774 in nm_ip4_config_get_num_addresses (config=0x0) at nm-ip4-config.c:1418
  #5  0x0000000000458834 in _update_ip4_address (self=self@entry=0xa8a490 [NMDeviceBridge]) at devices/nm-device.c:6069
  #6  0x000000000045e740 in nm_device_set_ip4_config (self=self@entry=0xa8a490 [NMDeviceBridge], new_config=new_config@entry=0x0, default_route_metric=default_route_metric@entry=0, commit=commit@entry=1, routes_full_sync=routes_full_sync@entry=1, reason=reason@entry=0x7fffffffd7cc) at devices/nm-device.c:6558
  #7  0x0000000000466c56 in _cleanup_generic_post (self=self@entry=0xa8a490 [NMDeviceBridge], cleanup_type=cleanup_type@entry=CLEANUP_TYPE_KEEP) at devices/nm-device.c:8108
  #8  0x00000000004671af in dispose (object=0xa8a490 [NMDeviceBridge]) at devices/nm-device.c:9128
  #9  0x00007ffff4d6ea82 in g_object_unref (_object=0xa8a490) at gobject.c:3133
  #10 0x00000000004d1a53 in remove_device (manager=manager@entry=0x8822b0 [NMManager], device=0xa8a490 [NMDeviceBridge], quitting=quitting@entry=1, allow_unmanage=allow_unmanage@entry=1) at nm-manager.c:780
  #11 0x00000000004d7db1 in nm_manager_stop (self=self@entry=0x8822b0 [NMManager]) at nm-manager.c:4199
  #12 0x0000000000445aa9 in main (argc=1, argv=0x7fffffffda88) at main.c:465
  (gdb)
2015-08-12 18:18:56 +02:00
Beniamino Galvani
bfb459f8ed device: don't call ioctl to update priv->ip4_address
Just take the first address in priv->ip4_config.
2015-08-11 18:31:46 +02:00
Dan Winship
c050fb7cd2 devices, active-connection: port to gdbus 2015-08-10 09:41:26 -04:00
Lubomir Rintel
c44069c10a device: avoid setting MTU to zero if undefined 2015-08-10 14:10:17 +02:00
Thomas Haller
43e6f6a178 device: only 'ignore-auto-routes' and 'ignore-auto-dns' for certain settings
During merge_and_apply(), we merge several NMIPxConfig into a new
@composite. For 'ignore-auto-routes' and 'ignore-auto-dns', we want to
prevent certain routes/dns-settings to be merged.

But it is wrong to reject settings from all partial configs.
For example, especially ext_ipx_config and vpn_ipx_config contain
routes that we still must merge and preserve.

This was recently changed by 79630c11e5
and previously by ab6548c621. But it was
wrong for a long time already.

Also note, that nm_ip4_config_merge() now also ignores NIS, WINS, and
dns-options.

https://bugzilla.gnome.org/show_bug.cgi?id=752546

Fixes: 79630c11e5
2015-08-06 17:52:55 +02:00
Thomas Haller
f7a8962dd4 core: add @merge_flags argument to nm_ip4_config_merge() and nm_ip6_config_merge()
The new flags are not yet used, so there is no change in functionality.

The flags NM_IP_CONFIG_MERGE_NO_ROUTES and NM_IP_CONFIG_MERGE_NO_DNS go
together with the 'ignore-auto-routes' and 'ignore-auto-dns' setting.

Note that for IPv4, NM_IP_CONFIG_MERGE_NO_DNS also ignores NIS, WINS, and dns-options.
This is different from current other places that handle 'ignore-auto-dns'
and only care about nameservers, domains, and searches.
2015-08-06 17:52:55 +02:00
Beniamino Galvani
54d10f0ec1 device: fix memory leak in act_stage3_ip6_config_start()
If linklocal6_start() finds that the device already has an IPv6
link-local address and returns NM_ACT_STAGE_RETURN_FINISH, we don't
need to fill @out_config with an empty configuration. A non-NULL
@out_config is required only for ret = NM_ACT_STAGE_RETURN_SUCCESS.

Fixes: 396dc2b3b4
2015-08-05 18:04:51 +02:00
Dan Winship
22e1a97e12 all: drop includes to <glib/gi18n.h> for "nm-default.h"
The localization headers are now included via "nm-default.h".

Also fixes several places, where we wrongly included <glib/gi18n-lib.h>
instead of <glib/gi18n.h>. For example under "clients/" directory.
2015-08-05 15:35:51 +02:00
Thomas Haller
19c3ea948a all: make use of new header file "nm-default.h" 2015-08-05 15:32:40 +02:00
Lubomir Rintel
f7f9e734aa device: lower serverity of MTU adjustment logging
Warn is probably too harsh, but we still need to log the reason for the change.
2015-08-04 13:43:31 +02:00
Lubomir Rintel
a92d8b0c67 device: don't modify the device MTU if it's unset
The MTU of 0 means default, not zero-length packets:

  <warn>  (wlp3s0): Lowering IPv6 MTU (1472) to match device MTU (0)
  <warn>  (wlp3s0): IPv6 MTU (0) smaller than 1280, adjusting
  <warn>  (wlp3s0): Raising device MTU (0) to match IPv6 MTU (1280)
  <error> [1437068831.306733] [platform/nm-linux-platform.c:2440] sysctl_set(): platform-linux: sysctl: failed to set '/proc/sys/net/ipv6/conf/wlp3s0/mtu' to '1472': (22) Invalid argument

Reported-by:  Jan Alexander Steffens <jan.steffens@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=752508
2015-08-04 13:43:31 +02:00
Beniamino Galvani
9ce005da34 device: add audit support 2015-08-04 09:32:12 +02:00
Dan Williams
e8139f56c2 core: split device creation and device setup (bgo #737458)
Future patches will create devices long before they are backed by
kernel resources, so we need to split NMDevice object creation from
actual setup based on the backing resources.

This patch combines the NMDeviceFactory's new_link() and
create_virtual_device_for_connection() class methods into a single
create_device() method that simply creates an unrealized NMDevice
object; this method is not expected to fail unless the device is
supposed to be ignored.  This also means that the NMDevice
'platform-device' property is removed, because a platform link
object may not be available at NMDevice object creation time.

After the device is created, it is then "realized" at some later
time from a platform link (for existing/hardware devices via the
realize() method) or from an NMConnection (for newly created software
devices via the create_and_realize() NMDeviceClass methods).

https://bugzilla.gnome.org/show_bug.cgi?id=737458
2015-07-31 14:06:09 -05:00
Dan Winship
94078a139a core: port NMDhcp4Config/NMDhcp6Config to GVariant
In the gdbus port, the :options properties will be GVariant-valued
(and thus immutable), so having APIs that let you repeatedly modify
them would make things complicated. Since we actually only ever set
all the options at once, just change the APIs to do that, rather than
setting the options one-by-one.

Since nm-dispatcher already works in terms of GVariant, it makes
things simpler there if NMDhcp[46]Config can return its options as a
GVariant. And since we'll need it to be a GVariant internally later
anyway, just port everything to GVariant now, and convert it to a
GHashTable for dbus-glib only in get_property().
2015-07-24 13:25:47 -04:00
Dan Winship
c1dd3b6eed core: move D-Bus export/unexport into NMExportedObject
Move D-Bus export/unexport handling into NMExportedObject and remove
type-specific export/get_path methods (export paths are now specified
at the class level, and NMExportedObject handles the counters for all
exported types automatically).

Since all exportable objects now use the same get_path() method, we
can also add some helper methods to simplify get_property()
implementations for object-path and object-path-array properties.
2015-07-24 13:25:47 -04:00
Dan Winship
6fcc1deee0 core: add an NMExportedObject base class
Add NMExportedObject, make it the base class of all D-Bus-exported
types, and move the nm-properties-changed-signal logic into it. (Also,
make NMSettings use the same properties-changed code as everything
else, which it was not previously doing, presumably for historical
reasons).

(This is mostly just shuffling code around at this point, but
NMExportedObject will be more important in the gdbus port, since
gdbus-codegen doesn't do a very good job of supporting objects that
export multiple interfaces [as each NMDevice subclass does, for
example], so we will need more glue/helper code in NMExportedObject
then.)
2015-07-24 13:25:47 -04:00
Dan Winship
3452ee2a0e all: rename nm-glib-compat.h to nm-glib.h, use everywhere
Rather than randomly including one or more of <glib.h>,
<glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include
"nm-glib-compat.h" most of the time), rename nm-glib-compat.h to
nm-glib.h, include <gio/gio.h> from there, and then change all .c
files in NM to include "nm-glib.h" rather than including the glib
headers directly.

(Public headers files still have to include the real glib headers,
since nm-glib.h isn't installed...)

Also, remove glib includes from header files that are already
including a base object header file (which must itself already include
the glib headers).
2015-07-24 13:25:47 -04:00
Lubomir Rintel
063677101a ip4-config: 0.0.0.0 is a valid gateway too
It makes sense for point-to point links.

https://bugzilla.redhat.com/show_bug.cgi?id=1244483
2015-07-22 13:49:17 +02:00
Thomas Haller
bebeff69e8 device: always assume default-route for generate-assumed-connections
Commit d51975e changed, that we treat assumed and non-assumed
connections the same with respect to the default route. This is
certainly wrong, if we have an nm-generated-assumed connection
at hand. In this case, NM just generated a connection based on what
was configured on the system. Looking at that result and re-enforcing
the default-route is wrong.

We want to manage the default-route for assumed, persistent connections.
If the connection was assumed and generated, we do not.

This commit reverts d51975ed for nm-generated-assumed connection and
restores the previous behavior.

https://bugzilla.redhat.com/show_bug.cgi?id=1244483

Fixes: d51975ed92
2015-07-22 13:45:28 +02:00
Thomas Haller
cbd246c9b0 device: move setting v4_commit_first_time/v6_commit_first_time to the end of merge_and_apply() 2015-07-22 13:33:01 +02:00