Commit graph

789 commits

Author SHA1 Message Date
Beniamino Galvani
77ded12da4 core: use default value for ipvx.dns-priority
Fall back to system default value for ipvx.dns-priority when it's zero
in the setting. For VPNs the default value is 50; for other
connections is 100, but it depends also on the content of
[connection*] sections in NetworkManager.conf.
2016-05-12 17:13:50 +02:00
Thomas Haller
35a7ea77b0 device: restore IP configuration when link comes up
This is especially important, because changing MTU takes the
link down for a moment. Taking a link down deletes IP routes and
IPv6 addresses. Thus, when the link comes up again, we must restore
them.

Otherwise, we don't call merge_and_apply() until the next DHCP lease
(or possibly never in case of static addressing).

https://bugzilla.redhat.com/show_bug.cgi?id=1309899
2016-05-12 14:50:01 +02:00
Thomas Haller
f50e39fc98 device: improve logging when changing IP configuration
nm_device_set_ip4_config() is called during cleanup and
from ip4_config_merge_and_apply(). The latter, has several
call sites.

It's not easy to track whether we called set_ip4_config with
or without commit (and if we call it without commit, we might
not see a logging line at all).

(same for nm_device_set_ip6_config()/ip6_config_merge_and_apply()).
2016-05-12 14:50:00 +02:00
Thomas Haller
476d4f606a device: re-read carrier-detect capability after bringing device up
https://bugzilla.gnome.org/show_bug.cgi?id=766179
2016-05-12 11:22:06 +02:00
Thomas Haller
5693ba9843 device: fix multiple subscriptions to config-changed signal for ignore-carrier
We would subscribe to config-changed signal during object-realize,
however only unsubscribe during dispose().

Avoid multiple subscributions, and unsubscribe also when unrealizing
the device.

Also, always subscribe to the signal, even without capability
NM_DEVICE_CAP_CARRIER_DETECT. In the next commit, we will re-read
capabilities later on, so just always subscribe.
2016-05-12 11:22:06 +02:00
Thomas Haller
8f77ecad8a device: don't check_carrier() during bring_up()
Don't check the carrier state inside the virtual function bring_up().
2016-05-12 11:21:39 +02:00
Thomas Haller
f3df854333 device: add function to change device capabilites 2016-05-12 11:21:39 +02:00
Thomas Haller
5feea58223 device: use "bool" type for fields in NMDevice
Contrary to gboolean, bool is only one byte in size.
Due to alignment and ordering of the fields, this saves
merely 16 bytes per NMDevicePrivate struct (on x86_64),
still.

Also, bool is coerced by the compiler to be strictly FALSE or
TRUE -- contrary to gboolean, which can be any integer.
Thus, for bool type, "g_assert (NM_IN_SET (value, FALSE, TRUE));"
never fails. That is desirable as well.

While not a large win, it seems favorable to use bool type for
fields of a struct.
2016-05-12 11:21:39 +02:00
Beniamino Galvani
0b66eb298e device: remove pending dhcp actions also in IP_DONE state
When the IP status is IP_DONE and a DHCP transaction succeeds the
'dhcp4' and 'dhcp6' pending actions must be removed. Without this, a
temporary link loss just after the activation would cause a DHCP
restart and those actions would remain set, blocking the startup.

https://bugzilla.redhat.com/show_bug.cgi?id=1330893
2016-05-10 17:56:02 +02:00
Shih-Yuan Lee (FourDollars)
831038a5c7 device: remove unnecessary object reference operations
Since commit 0175056a6d, it is unnecessary
to operate object reference when invoking g_idle_add so it is
unnecessary to operate object reference in GSourceFunc too.

Taking an additional reference to the device during update_ip_config()
was introduced by commit 6fba9fd2e5 to fix
a crash. It seems however the proper fix would have been commit
0175056a6d, to avoid any IP config
change events after disposing of the device starts.

https://mail.gnome.org/archives/networkmanager-list/2016-May/msg00002.html
https://mail.gnome.org/archives/networkmanager-list/2016-May/msg00009.html
2016-05-06 13:50:29 +02:00
Thomas Haller
0175056a6d device: disconnect platform signal handlers first in dispose
Once we start with dispose, we certainly don't want to process any platform
events for the device anymore.

Previously, we disconnect those handlers only later during dispose, so it's
not clear that we would not receive a device_ipx_changed signal after _cleanup_generic_pre().

Fix this possible (or actual) bug.
2016-05-05 12:19:20 +02:00
Thomas Haller
73cec4e912 device: don't cancel queued_ip4_config_id when scheduling activate_stage5_ip4_config_commit
Since commit a47c13a7a2, update_ip4_config() re-schedules
itself in case activate_stage5_ip4_config_commit is pending. Thus, there is no need to
cancel any queued queued_ip4_config_id.

Also as that does not properly fix the issue unlike a47c13a7a.
2016-05-05 12:04:09 +02:00
Thomas Haller
bac06c5ae6 device: ensure not rescheduling IP config changed on initial capture
update_ip4_config() and update_ip6_config() are called from nm_device_capture_initial_config().
At that point, we don't expect any activation-source scheduled, thus the "if" should not
not be hit anyway.

So, this patch should actually make no difference, but it seems clearer
to me. Also, because it would be a bug to re-schedule the idle handler
that is already pending, but from inspecting nm_device_capture_initial_config()
it is not immediately clear that this cannot be the case.
2016-05-05 11:24:54 +02:00
Thomas Haller
ec2a21702a device: add assertions for queued_ip4_config_change() and queued_ip6_config_change() 2016-05-05 11:10:33 +02:00
Thomas Haller
b6a92cbdc3 device: refactor clearing @queued_ip4_config_id and @queued_ip6_config_id 2016-05-05 10:58:10 +02:00
Thomas Haller
c71bd9df82 device: improve error message for failure to reapply 2016-05-03 11:52:40 +02:00
Thomas Haller
a51b947f25 device: fix check for invalid keys during reapply
Was completely wrong and failed to find first_invalid_key.
As a consequence, hit the assertion at the end.
2016-05-03 11:52:40 +02:00
Thomas Haller
b52d25e129 device: clear secrets from applied connection during reapply
The applied connection must have no secrets. It's unclear whether
there are any secrets at this point (possibly). To be sure, clear them.
2016-05-03 11:52:40 +02:00
Thomas Haller
ec840b0331 device: allow reapply with a different connection.uuid 2016-05-03 11:52:40 +02:00
Thomas Haller
ad38a1acb8 device: allow reapply if connection.id differs 2016-05-03 11:52:39 +02:00
Beniamino Galvani
f377e055bf device: add dhcp_schedule_restart() helper 2016-05-02 18:21:19 +02:00
Beniamino Galvani
cf4e2c7ab9 device: retry DHCPv6 when a lease expires
Make DHCPv6 more robust WRT temporary failures of servers by retrying
DHCP for a predefined number of times at regular intervals when the
lease expires.

https://bugzilla.gnome.org/show_bug.cgi?id=741347
2016-05-02 18:21:18 +02:00
Beniamino Galvani
ac52b95684 device: retry DHCPv4 when a lease expires
Make DHCPv4 more robust WRT temporary failures of servers by retrying
DHCP for a predefined number of times at regular intervals when the
lease expires.

https://bugzilla.gnome.org/show_bug.cgi?id=741347
2016-05-02 18:21:18 +02:00
Beniamino Galvani
363d5b33ec device: group DHCP6 private members 2016-05-02 18:21:18 +02:00
Beniamino Galvani
3f5ee827a9 device: group DHCP4 private members 2016-05-02 18:21:18 +02:00
Beniamino Galvani
b84768581e device: fail activation immediately only when may-fail=no
Introduce the nm_device_ip_method_failed() function to check if the
failure of an IP method should cause the activation to fail, and use
it where appropriate.

http://bugzilla.gnome.org/show_bug.cgi?id=741347
2016-05-02 18:21:18 +02:00
Beniamino Galvani
a47c13a7a2 device: postpone updates of IP configuration when a commit is pending
When a new dynamic configuration is received, it is stored in a member
of private structure (e.g. @dhcp6_ip6_config) and a commit is
scheduled. Before the commit is executed, an update_ipx_config() could
be called and it would change the configuration before it is
committed.

This race condition causes failures in assigning the addresses
received through DHCPv6 when the internal client is used (but
potentially other clients and methods are affected).

To fix it, postpone updates of IP configurations when a commit is
already pending.
2016-04-29 17:16:25 +02:00
Thomas Haller
6bf022359f core/trivial: rename "source" field of addresses and routes
The "source" field of NMPlatformIPRoute (now "rt_source") maps to the
protocol field of the route. The source of NMPlatformIPAddress (now
"addr_source") has no direct equivalent in the kernel.

As their use is different, they should have different names. Also,
the name "source" is used all over the place. Hence give the fields
a more distinct name.
2016-04-28 12:53:21 +02:00
Thomas Haller
161f86b5b3 dns: merge the dns "mode" and "rc-manager"
Already previously, the mode and rc-manager were intertwined in a complicated
way:

  - dns=none effectively disables rc-manager.

  - if resolv.conf was immutable, it would disable the rc-manager
    by setting "resolv_conf_mode=NM_DNS_MANAGER_RESOLV_CONF_UNMANAGED".

  - resolv_conf_mode was anyway a redundant piece of information to
    rc_manager.

Now there are only two relevant settings: priv->plugin and
priv->rc_manager. And they can be set independently from each other.
Before that was not possible. For example, you could not set a
dns plugin with rc-manager=unmanaged (the only way to achive that
was via an immutable resolv.conf or by having rc-manager=symlink
and let resolv.conf link somewhere else.
2016-04-26 13:58:28 +02:00
Thomas Haller
ee3ac13e50 lldp: fix crash in nm_device_update_dynamic_ip_setup() due to uninitialized @error
Fixes: 07a9364d9c
2016-04-25 12:07:21 +02:00
Thomas Haller
2158d6a5a8 manager: fix wrongly removing DNS configuration on shutdown
When NetworkManager exits, it must preserve the DNS configuration of
devices that are left up.

Fixes: 9498ea507e
2016-04-20 17:53:58 +02:00
Lubomir Rintel
a93807c288 infiniband: remove the partitions on unrealizing
The infiniband drivers don't implement the rtnetlink link deletions.
Therefore we unrealize the NMDevice instance but the backing resources
stay around, preventing us from ever realizing the device again.
2016-04-20 10:49:01 +02:00
Thomas Haller
4697376f99 device: fix preserving the default-route during _cleanup_generic_post()
When we want to preserve the default-route on cleanup, we must first
set it to assumed, before clearing it. Otherwise, NMDefaultRouteManager's
update() will delete the default route.

This is the oposite of the deconfigure case, where we first set it to
!has && !assumed, to force the route-manager to delete the route.
2016-04-15 18:09:48 +02:00
Thomas Haller
b2f794fe1e device: refactor clearing default-route in NMDevice
Add a function _update_default_route() to set the default_route
flags and call update() in one step.

Also, if there are no changes, skip the call to NMDefaultRouteManager's
update().
2016-04-15 18:07:01 +02:00
Thomas Haller
2079f8361c device: fix wrongly deleting default-route on exit
We must preserve the default-route on shutdown.

Thus it must first be announced as "assumed", and only removed
in a second step.

Fixes: 9498ea507e
2016-04-15 17:39:09 +02:00
Beniamino Galvani
53dfaddda2 device: apply MTU setting also to devices without IPv4 configuration
Usually the MTU in the ethernet.mtu property is applied to the device
during the commit of IPv4 configuration.  For devices with
ipv4.method=disabled or slave devices that phase is skipped and so the
setting does not have effect.  Apply the MTU explicitly in such cases.

https://bugzilla.redhat.com/show_bug.cgi?id=1303968
https://bugzilla.redhat.com/show_bug.cgi?id=1303731
2016-04-14 15:19:11 +02:00
Thomas Haller
8c86648313 device: drop available_connections_notify() and call _notify() directly 2016-04-14 12:17:35 +02:00
Thomas Haller
14ee5dd2f8 platform: change @plen field of NMPlatformIPxRoute to type guint8
On netlink layer, this field is uint8_t/uchar.

A larger (signed) plen makes no sense. Adjust the signatures
to have only guint8.
2016-04-11 11:26:36 +02:00
Beniamino Galvani
9b7f9af077 device: take care of default route of DHCP generated-assumed connections
In general we don't touch the externally set default route on devices
that use a generated-assumed connection. When the IP method is AUTO
(or DHCP), this means that we are not able to restore the default
route after a temporary expiration of the lease which removes
addresses/routes from the device.

Change this, and let NM update the default route for generated-assumed
devices using dynamic addressing.

https://bugzilla.redhat.com/show_bug.cgi?id=1265239
2016-04-08 21:28:57 +02:00
Beniamino Galvani
c84fd50287 device: don't update applied connection for generated assumed devices
The applied connection must describe the configuration that was
initially activated on the device. Even if the IP configuration
changes, we shouldn't reset the applied connection for devices using a
generated-assumed connection, otherwise we would lose information on
the IP method we're trying on the device.
2016-04-08 21:28:57 +02:00
Thomas Haller
2e34d34cf0 device: let managed by user-udev overwrite external-down
An externally configured software device is considered external-down until
it is IF_UP and has IP configuration.

When the user explicitly manages the device via UDEV rule, that decision
should overrule external-down.
2016-04-08 11:37:38 +02:00
Lubomir Rintel
9498ea507e manager: ensure IP config of device is cleared before removal
If the manager removes the device, the IP config objects must
be cleared. The reason is that NMPolicy registers to the IP config
changed signal and passes these object on to NMDnsManager.

If the INTERNAL_DEVICE_REMOVED signal is emited with IP configuration
object pending, those objects will be leaked.

This partly redoes commit f72816bf10,
which was reverted.

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

https://bugzilla.gnome.org/show_bug.cgi?id=764483
2016-04-04 23:10:20 +02:00
Thomas Haller
47c6b6db07 device: remove ignored dummy variable 2016-04-04 15:47:21 +02:00
Beniamino Galvani
35059ed48e device: allow NM-owned device to be assumed
Software devices created by NM should be kept up when quitting so that
they can be assumed upon restart. But now we consider devices created
by NM (those with the @is_nm_owned flag) not capable of assuming
connections and therefore we tear them down and deconfigure when
quitting.

Change this and ignore @is_nm_owned when deciding if a device can be
re-assumed.
2016-04-04 15:33:17 +02:00
Thomas Haller
e1edcda317 device: consider external devices as unmanaged until they have an IP address 2016-04-04 15:33:16 +02:00
Lubomir Rintel
a6fb37bae2 Revert "manager: don't remove the device before policy learns of ip config change"
This doesn't unexport the connection on disconnect (as opposed to device
removal).

This reverts commit f72816bf10.
2016-04-04 12:52:56 +02:00
Lubomir Rintel
f72816bf10 manager: don't remove the device before policy learns of ip config change
First let the device know it's being removed soon so that it has a
chance to clean up the IP configuration early.

If the manager removes the device fist, the policy never learns of
config removal and doesn't unhook it from the DNS manager resulting in a
IPConfig leak and possible wrong DNS configuration in effect.

Also adjust the route manager to skip over devices without IP
configuration when determining the best connection; it is perhaps
just due to being removed.

https://bugzilla.gnome.org/show_bug.cgi?id=764483
2016-04-04 12:40:40 +02:00
Nikolay Martynov
28e9ec499a device: renew dhcp leases on awake for software devices
This makes sure that devices like bond get their dhcp renewed

[thaller@redhat.com: original patch modified to rename
 now-public function update_dynamic_ip_setup()]

https://bugzilla.gnome.org/show_bug.cgi?id=764398
2016-03-31 16:31:34 +02:00
Thomas Haller
3c8ffa766c device: refactor by adding set_unmanaged_external_down() function
No functional change.
2016-03-31 10:38:39 +02:00
Thomas Haller
f7523ae6e2 device: refactor setting unmanaged flag EXTERNAL_DOWN
This should not actually change how we handle EXTERNAL_DOWN
unmanaged devices.
2016-03-31 10:38:38 +02:00