Commit graph

649 commits

Author SHA1 Message Date
Dan Williams
13f4a00d4d core: only log about IPv6 Commit the first time
Since IPv6 configuration gets updated every time a router advertisement
comes in, it can lead NM to continuously logging:

NetworkManager: <info> Activation (eth0) Stage 5 of 5 (IPv6 Commit) scheduled...
NetworkManager: <info> Activation (eth0) Stage 5 of 5 (IPv6 Commit) started...
NetworkManager: <info> Activation (eth0) Stage 5 of 5 (IPv6 Commit) complete.

that's annoying.  So after the initial configuration is done, make
subsequent IPv6 Commit log messages debug instead of info.
2014-01-23 16:06:01 -06:00
Dan Williams
6e8345d89b core: don't disable IPv6 when assuming connections (rh #1052157)
Don't disable IPv6 when we're about to assume a connection that may well
have IPv6 already configured on the interface, which removes all addresses
and routes from the interface and generally Breaks Stuff.
2014-01-23 16:05:44 -06:00
Dan Winship
e2ab0eaf75 devices: when disconnecting master, propagate reason to the slaves
When disconnecting a master device, propagate its NMDeviceStateReason
to the slaves. That way, if the reason is USER_REQUESTED, then the
slaves will be blocked from re-autoconnecting as well.
2014-01-23 15:16:09 -05:00
Dan Winship
5cac8dad79 devices: add :master property
Add a property to NMDevice that can be used to tell whether the device
is enslaved, and if so what its master is.

This is currently internal-only, but it could be exported later
perhaps.
2014-01-23 15:16:09 -05:00
Dan Winship
979b8920b4 core: move virtual device autoconnect tracking bits out of NMManager
Virtual devices may be created and destroyed, but we need to keep
their autoconnect state across that. Previously this was handled by
NMManager, but it really belongs with the other autoconnect tracking
in NMPolicy and NMSettingsConnection.

This also fixes a bug where NMPolicy would sometimes decide to
autoactivate a virtual device connection which NMManager would then
have to cancel.
2014-01-23 15:16:09 -05:00
Dan Winship
c4fc72c795 devices: start using the DEACTIVATING state
When a device is disconnected by the user (as opposed to due to
network or hardware error, etc), set it first to DEACTIVATING, which
does nothing but queue a transition to disconnected. This lets other
parts of NM observe the device when it is about-to-disconnect, but
still has an associated connection.
2014-01-23 15:15:00 -05:00
Dan Winship
3d30ff01ef core: remove useless NMSettings::connections-loaded signal
NMSettings (and NMConnectionProvider) had a signal to indicate when it
had loaded the connections, but in reality this always happened before
nm_settings_new() returned (as a side effect of calling
unmanaged_specs_changed()) and so no one else would ever actually see
the signal. So just kill it.
2014-01-23 15:14:49 -05:00
Thomas Haller
2b87dbb2a9 core: cleanup data types for nm_platform_sysctl_get_int32()
The sysctl values in the kernel (for those values for which
nm_platform_sysctl_get_uint() is currently used) are defined as s32.
Change nm_platform_sysctl_get_uint() to nm_platform_sysctl_get_int32()
and ensure, that a matching integer type is used thoroughly.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-22 12:23:58 +01:00
Dan Williams
eb8bc5396e core: respect connection user permissions for activation/deactivation
This appears to be a bug since the original 0.9.0 release when
connection permissions were implemented.

If all the following are true:
- the user is local (as determined by systemd or ConsoleKit)
- the user has been given the NETWORK_CONTROL PolicyKit permission
- the user is not listed in the connection's permissions
- the user knows the D-Bus object path of a connection which they
have no permissions for

then that user may activate/deactivate connections that are not
visible to that user as determined by the connection permissions.
Fix that by ensuring that these operations check whether the user
has permission.

These operations are *not* affected, and have always checked user
permissions before allowing the operation:
- modifying any connection details
- requesting any secrets or passwords for the connection
- deleting the connection
2014-01-21 12:18:49 -06:00
Dan Williams
91eafe95a3 core: fix stale DHCPv6 information for dispatcher lease-change events (bgo #721002)
dhcp6_lease_change() needs to be called *after* updating the DHCP config
object to ensure that the dispatcher gets the new values.
2014-01-06 16:08:06 -06:00
Scott Shambarger
a30030b82b core: fix stale DHCPv4 information for dispatcher lease-change events (bgo #721002)
dhcp4_lease_change() needs to be called *after* updating the DHCP config
object to ensure that the dispatcher gets the new values.
2014-01-06 16:07:57 -06:00
Dan Winship
0e3432fbea logging: tweak logging-enabled functions
Rather than having separate nm_logging_level_enabled() and
nm_logging_domain_enabled(), have just nm_logging_enabled() that
checks both.
2013-12-20 09:57:13 -05:00
Dan Winship
f2413ae498 devices: don't try to capture resolv.conf if not managing it (rh #1035861)
If NM is not explicitly managing resolv.conf (either due to the "dns"
NetworkManager.conf setting, or because resolv.conf is immutable),
then don't try to parse nameservers out of it when capturing a
connection, since there's no reason to believe that the name servers
there are related to any particular connection.
2013-12-20 09:28:01 -05:00
Jiří Klimeš
44bd2275e7 device: add 'mtu' property 2013-12-20 11:37:54 +01:00
Dan Williams
5ef3d9027d trivial: show interface name in IPv6 rdisc log message 2013-12-19 12:06:54 -06:00
Dan Williams
5f1a62877c rdisc: clear domain list when updating from RA
Appears to be a simple oversight.  If the IPv6 router changes the
domain list, old domains could stick around.
2013-12-19 12:06:54 -06:00
Jiří Klimeš
1e3edc176b device: add missing state-change reasons to reason_to_string() 2013-12-19 10:00:00 +01:00
Jiří Klimeš
7e95d03f44 device: fix compilation in nm_device_add_pending_action()
The function doesn't return any value.
2013-12-19 10:00:00 +01:00
Thomas Haller
813ea5995b core: allow dynamic strings for pending action names
Use a GSList of the string values, instead of an array of GQuarks.
Using GQuarks does not allow to add arbitrary strings, because they
would leak the internalized strings.  The next patch will begin
using unique, non-const action strings.

Given the rather small number of expected pending states, a singly
linked list seems appropriate.

Signed-off-by: Thomas Haller <thaller@redhat.com>

(some fixes and simplifications by dcbw based on patch reviews)
2013-12-18 12:35:44 -06:00
Thomas Haller
bb9deec9ef core: fix NMDevice.ip6_use_tempaddr to avoid buffer overrun for zero char in config file
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-13 20:49:27 +01:00
Dan Williams
2556aa32ed core: ensure 'activation' pending action encompasses full activation process
The NMActiveConnection class tracks the full activation request, and internal
activation requests go through the same process as external ones, including
some authentication.  Sometimes that means activation is scheduled, control
returns to the mainloop, and then the activation proceeds from an idle
handler.

Unfortunately, that means that adding a pending "activation" action from
nm-device.c doesn't always work, since there is a short window between when
the activation is started in nm-manager.c (in nm_manager_activate_connection())
and when the device actually changes state.  Inside that window, the pending
actions may drop to zero, and startup will be declared complete before the
device actually starts activating.

Instead, ensure that the pending action is added when the internal activation
is actually started (eg, when NMActiveConnection receives the NMDevice object).
2013-12-12 11:16:51 -06:00
Dan Williams
61463ed2ab core: delay startup complete until carrier is found or timeout (rh #1034921) (rh #1030583)
Carrier state is only valid if the network interface is IFF_UP, because drivers
are not required to do carrier detection if the device is not up.  Thus, if NM
is the first process to set the interface IFF_UP, there may be a short delay
while the driver performs carrier detection.  NetworkManager must suppress
"startup complete" during this delay to ensure that the carrier state is known
before making startup property decisions.

Previously, when NetworkManager set the interface IFF_UP, the interface would
not have a carrier for a few seconds until the driver's carrier detection was
done.  Since the interface had no carrier, NetworkManager could not begin
connection activation on the interface, and the interface would not suppress
the "startup complete" transition.  Thus, NetworkManager would declare that
startup was complete prematurely and anything depending on startup network
connectivity would fail as no interfaces were active.

https://bugzilla.redhat.com/show_bug.cgi?id=1034921
https://bugzilla.redhat.com/show_bug.cgi?id=1030583
2013-12-12 11:16:51 -06:00
Dan Williams
b2cec90b79 core: convert pending actions from a counter to a GArray
This lets us do two things:

1) ensure that pending actions are unique and not doubly added/removed
2) we can (eventually) print out the pending action list for debugging

However, since we cannot have two pending actions with the same name at
the same time, we need to change the queued device state actions to
include the state name.  But that makes debugging even more descriptive
so it's a bonus.
2013-12-12 11:16:51 -06:00
Jiří Klimeš
d0c2a24b71 device: do not remove software devices on initial disconnected (rh #1035814)
When a device is initialized to be managed, it will transition through states
unmanaged -> unavailable -> disconnected. We don't want to remove software
devices during this initial transition to disconnected, because it prevents
auto-activation.

Test case:
$ nmcli con add type vlan ifname myvlan dev eth0 id 123
NM should immediately create myvlan interface and automatically activate it.

https://bugzilla.redhat.com/show_bug.cgi?id=1035814
2013-12-04 14:08:30 +01:00
Dan Williams
ea5c30b1d9 core: generated slave connections should not have IP settings
Slaves have no IP configuration and should not have any IP settings.
This fixes connection comparison between generated slave connections
and persistent slave connections, as persistent slave connections won't
have any IP configuration.
2013-12-02 15:32:31 -06:00
Dan Williams
038e45d29a Revert "device: bind the generated loopback connection to 'lo' interface"
This reverts commit 9a019f1fb5.

Generic connections should be bound to their interface names in a more generic
way instead of in nm-device.c.  The Generic device itself should set the
attributes it needs when generating the connection, like other device types do.
This will be done in a following commit.
2013-12-02 15:32:23 -06:00
Dan Winship
ff93ed672b devices: if IP4 and IP6 config both fail right away, fail the device
Previously, the device activation would stall in this case, because
the code wasn't expecting it to happen. In particular, this happens
when trying to assume a device that is up but has no IP config.

https://bugzilla.gnome.org/show_bug.cgi?id=715181
2013-11-27 08:54:18 -05:00
Dan Williams
12d96c30f2 core: capture DNS configuration from resolv.conf when generating connections
If the interface who's IP configuration is being captured has the default
route, then read DNS servers from resolv.conf into the NMIP[4|6]Config.

This allows NetworkManager to repopulate resolv.conf if anything changes.
For example, if the system does not define a persistent hostname, then
when a device which has generated a connection activates, a hostname
lookup will be performed.  The results of that lookup may change resolv.conf,
and thus NetworkManager must rewrite resolv.conf.  Without capturing
DNS information at startup when generating connections, an empty
resolv.conf would be written.
2013-11-22 15:01:10 -06:00
Dan Williams
7994778723 core: ignore RA-provided default routes (rh #1029213)
The router has no idea what the local configuration or user preferences are,
so sending routes with a prefix length of 0 is at best misinformed and at
worst breaks things.  The kernel also ignores plen=0 routes in its in-kernel
RA processing code in net/ipv6/ndisc.c.

https://bugzilla.redhat.com/show_bug.cgi?id=1029213
2013-11-20 14:24:38 -06:00
Jiří Klimeš
f93c154161 device: remove invalid assertion in slave_state_changed()
When activating a team slave and 'teamd' binary is not installed, the
priv->state of master device will be NM_DEVICE_STATE_FAILED, which is greater
than NM_DEVICE_STATE_ACTIVATED.

<info> Activation (nm-team) Stage 1 of 5 (Device Prepare) started...
<warn> Activation (nm-team) to start teamd: not found
<info> (nm-team): device state change: prepare -> failed (reason 'none') [40 120 0]
...
<debug> master_state_cb(): (0x81d6968): master ActiveConnection [0x91d69d0] 'team0' failed
<info> (eth1): device state change: config -> failed (reason 'dependency-failed') [50 120 50]
...
<debug> slave_state_changed(): (nm-team): slave eth1 state change 50 (config) -> 120 (failed)
--- ASSERTION ---
2013-11-18 14:24:10 -06:00
Dan Williams
63d486b4de trivial: fix some prototypes 2013-11-18 12:06:10 -06:00
Dan Winship
65737d9e48 devices: use disable_ipv6 as appropriate
Set and clear disable_ipv6 on devices as needed to ensure that:

  1) devices never get IPv6 link local addresses until they are
     actually activated

  2) devices always lose their IPv6 link local addresses when they are
     deactivated

  3) slaves never get IPv6 link local addresses at all

https://bugzilla.gnome.org/show_bug.cgi?id=700414
https://bugzilla.redhat.com/show_bug.cgi?id=1004255
2013-11-15 10:50:45 -05:00
Dan Winship
7496cc3db2 devices: enable/disable kernel IPv6 autoconf at the appropriate times
Set accept_ra and use_tempaddr to "0" when managing a device (and
restore them to their original values after unmanaging it) to ensure
that calling nm_device_bring_up() on a managed device won't ever cause
kernel IPv6 autoconf to happen. Remove some other redundant accept_ra
setting.

Fix up the deconfigure case of dispose() to clear the device's IP6
config as well as its IP4 config.

https://bugzilla.gnome.org/show_bug.cgi?id=700414
2013-11-15 10:49:43 -05:00
Dan Winship
29dc6d1ebe devices: clean up accept_ra/use_tempaddr handling
update_accept_ra_path() and update_ip6_privacy_save() were freeing
their path variables if they failed to read the existing values, but
if this ever actually happened it would cause problems later since
other code assumed that the variables were always set. Use
"priv->ip6_accept_ra_save = -1", etc, instead to indicate that the
value couldn't be read (and so shouldn't be restored later).

Merge the accept_ra and use_tempaddr code save/restore code together,
since they're always called together.

Fix the accept_ra-restoring code to correctly handle an original value
of "2".

Call update_ip6_properties_paths() from nm_device_set_ip_iface()
rather than act_stage3_ip6_config_start(), since set_ip_iface() is
when the paths actually change. Also, split the default-value-saving
code out into a separate function, since we only care about doing that
at construct time; if the IP6 property paths change later (because
iface != ip_iface), then we don't need to save and restore the values
on the ip_iface, since the interface will go away when we're done with
it.

https://bugzilla.gnome.org/show_bug.cgi?id=700414
2013-11-15 10:49:43 -05:00
Dan Winship
ee2b50fce8 devices: rename ip6_privacy_tempaddr_* vars to match sysctl
Rename ip6_privacy_tempaddr_path and ip6_privacy_tempaddr_save to
ip6_use_tempaddr_*, to match the sysctls, for consistency with the
accept_ra variables.
2013-11-15 10:49:43 -05:00
Dan Winship
46295e8fa1 devices: "deactivate" devices when going from UNMANAGED->UNAVAILABLE
We used to call nm_device_deactivate() when moving a device from
UNMANAGED to UNAVAILABLE (unless we were assuming the existing
connection), but this got lost when default-unmanaged was added. Fix
it to do this again, so the device will be in a known-clean state when
it is activated.
2013-11-15 10:49:43 -05:00
Dan Winship
7bc7da83ec core: remove redundant sysctl utilities
NMDevice was still using the old sysctl functions from
NetworkManagerUtils rather than the new NMPlatform ones. Fix it, and
remove the old functions.
2013-11-15 10:49:43 -05:00
Jiří Klimeš
9a019f1fb5 device: bind the generated loopback connection to 'lo' interface
It is useful to bind the loopack connection to the loopback interface,
and it also allows activating it.
$ nmcli con up lo

Else "Error: no device found for connection 'lo'" is returned, because
connection_compatible() in libnm-glib/nm-device-generic.c wants the
connection to have an interface-name set.
2013-11-14 13:53:44 +01:00
Dan Williams
0e2457d71d core: don't up devices during IP configuration stages
Assumed connections shouldn't require touching the device, and the
device should was already set IFF_UP during stage2 (which is
skipped for assumed connections).  Instead, what the code was really
trying to do, was to ensure tha the IP interface the device was
going to use was up.

The only cases where the IP interface might *not* be up after stage2
is where the IP interface is different than the device's interface,
like for Bluetooth, ADSL, WWAN, and PPPoE.  Move the call to
nm_platform_link_set_up() into nm_device_set_ip_iface() which all
those device types will call.

Thus, only the device types that really need to up their IP interface
will do so, but other devices (including when activating assumed
connections) that don't need to do this, won't do it.
2013-11-08 16:46:45 -06:00
Dan Williams
0d8015cc98 core: don't generate connections for some devices
If the device has no IP configuration, is not a slave, and is not
a master, there's no point in generating a connection for it and
assuming that connection.

Fixes a problem where tun devices created by vpnc would be activated
with an empty assumed connection before NetworkManager could assign
the VPN IP config to it, and since IPv6 link-local timed out, the tun
device would be deactivated and VPN would be useless.
2013-11-08 16:46:45 -06:00
Dan Williams
93ad84a498 core: slaves have configuration by definition
The mere fact that a device is a slave means it has configuration
that NetworkManager should try to read.
2013-11-08 16:46:45 -06:00
Dan Williams
76ca47e6b3 core: make assumed activations go through all the stages
Assumed slave connections need to be added to their master devices,
which didn't used to happen because the devices activating assumed
connections jumped directly to stage3, bypassing all the master/slave
handling stuff.

Instead, make all assumed connections go through all activation stages,
but make sure that things which touch the device don't get done for
assumed connections.  This requires moving the master/slave code out
of the override-able class methods because we need to call the
master/slave code for assumed connections, but we don't want to call
the override-able class activation methods.
2013-11-08 16:46:45 -06:00
Dan Williams
e7567859c9 core: allow devices to activate their generated connections
If the device has a valid generated connection, it's already applied
and the device is already "activated" outside NM, so let activation
happen inside NM regardless of whether the device is available or not
according to NM.
2013-11-08 16:46:44 -06:00
Dan Williams
ffea69e06b trivial: refine connection generation logging 2013-11-08 16:46:44 -06:00
Dan Williams
0321073b3c core: capture initial device DHCP IP configuration
At least gives us DNS servers and definite gateway.
2013-11-08 16:46:44 -06:00
Pavel Šimerda
10f9b6c58b core: support slave devices in nm_platform_generate_connection()
Ask each device class to update the slave configuration for their
type of slave.
2013-11-08 16:46:43 -06:00
Dan Williams
60b88d526c core: slaves should have empty captured IP configuration 2013-11-08 16:46:43 -06:00
Dan Williams
b54a9868fd core: clean up legacy connection matching; remove match_l2_config
All previous users of this API are gone, so remove it.
2013-11-08 16:46:22 -06:00
Dan Winship
3de7ede146 trivial: fix a comment cut-and-paste-o 2013-11-08 08:27:30 -05:00
Dan Williams
7206306456 core: fix hanlding of IPv6LL address if interface already has one
act_stage3_ip6_config_start() expects a non-NULL NMIP6Config if the
sub-method returns NM_ACT_STAGE_RETURN_SUCCESS.
2013-11-07 21:38:08 -06:00