Commit graph

405 commits

Author SHA1 Message Date
Dan Williams
b6f8ecb330 core: handle slave deactivation more gracefully
Two things:

1) When the slave was deactivated, nm_device_deactivate() runs before
the master gets the slave's state-changed signal, and thus priv->master
is cleared long before nm_device_notify_enslaved() is called.  Which
would trigger the g_assert (priv->master).

2) If the slave is already deactivated, there's no point in re-queueing
a state change to deactivated.

So just assert that priv->master is valid if the slave is going to be
enslaved, but if the slave is being released, ignore NULL priv->master
which we don't use anyway.  Also ignore redundant state changes.
2013-02-04 10:37:46 -06:00
Dan Williams
c4e519bd78 dhcp: pass device hardware address to DHCP
Gets used for stuff like the interface DUID for DHCPv6.
2013-01-29 10:07:54 -06:00
Dan Winship
0b57fe0c56 core: simplify nm_device_get_best_auto_connection() implementations
Filter out non-autoconnect connections in the generic NMDevice method
rather than requiring each subclass to do it.

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-01-29 10:14:19 -05:00
Pavel Šimerda
92716139ec core: don't return addrlen on failure 2013-01-24 23:28:22 +01:00
Dan Williams
742c3b6695 ip6: use generic device hardware address function 2013-01-24 15:06:05 -06:00
Dan Williams
11d0f68b23 core: add generic way of getting device hardware addresses 2013-01-24 14:56:38 -06:00
Dan Williams
b584446837 core: consolidate reading device hardware addresses
Instead of using a mix of netlink and SIOCGIFHWADDR and doing it
in every device, create a utility function for this and have
everywhere else call that.
2013-01-24 14:53:58 -06:00
Pavel Šimerda
e7caad20c9 device: share implementation of hw_is_up, hw_bring_up and hw_take_down 2013-01-22 18:03:25 +01:00
Dan Williams
e7813c0451 trivial: move code to correct location
Clearing priv->master is a slave operation, not a master one.
Move the code under the right comment.
2013-01-17 17:11:04 -06:00
Dan Williams
6ddc25dcab core: handle some connection timestamp updating in NMActiveConnection
Handle it in the base active connection class instead of in separate
places for the device and the VPN cases.
2012-12-17 17:01:10 -06:00
Dan Williams
84603c2380 core: move most activation request logic to the active connection class
We'll want to use NMActiveConnection more in the manager and also fold
the PendingActivation functionality into it.  All this functionality
applies to the VPN connections too, so it makes sense to have it all
in the base class instead of both NMActRequest and NMVPNConnection.
2012-12-17 17:01:10 -06:00
Jiří Klimeš
1df1e85093 core: don't crash in start_sharing() on failures (if error is NULL) (rh #883142) 2012-12-04 15:55:30 +01:00
Dan Williams
54f9a670f7 core: allow device subclasses to postpone IPv4 or IPv6 configuration
If, for example, a bond interface has dynamic IPv4 configuration
and static IPv6 configuration, then without slaves IPv6 config
can proceed but IPv4 cannot until a slave is present.  Allow
subclasses to postpone a specific IP configuration path until
they're ready, but let others proceed.
2012-11-30 13:21:51 -06:00
Dan Williams
b4a11a86f7 core: rework master/slave handling 2012-11-30 13:21:51 -06:00
Dan Williams
b50a141fb7 core: trivial code reorganization 2012-11-30 13:21:51 -06:00
Dan Williams
6116a84048 core: simplify nm_device_activate()
We don't need to check device state here because the manager, which
is the only thing that calls nm_device_activate() in
internal_activate_device() ensures that the device is deactivated
before starting a new activation request.
2012-11-30 13:21:51 -06:00
Dan Williams
c091415bff core: leave disabled devices up on shutdown
Bridge/bond slaves don't really need to be taken down when we quit.
2012-11-30 13:21:51 -06:00
Dan Williams
3e3cffd0bd core: pass slave connection to master when enslaving 2012-11-30 13:21:50 -06:00
Dan Williams
a021e40e33 core: fix semantics of nm_utils_do_sysctl()
This function gets used for both /proc/sys (ie, sysctl) and for
sysfs attributes.  There are two issues with it:

1) most sysctl values don't care about a trailing LF, but some
sysfs attributes (infiniband) do; so we always have to add the
trailing LF.  Just move that into the function to ensure that
callers don't forget to add it.

2) neither sysfs or sysctl support partial writes, while the
existing function did partial writes.  Practically, both the
write handlers for sysfs and sysctl should always handle all
the data, but if they don't, partial writes are wrong.  So
instead, try three times to write all the data.
2012-11-30 13:21:50 -06:00
Dan Williams
0a71cea59f core: allow state change queuing from inside queued state handler
Clear the queued state struct before triggering the state change, instead
of after, since the state change may queue another state change.
2012-11-30 13:21:50 -06:00
Stefan Brüns
357f312cea trivial: fix typos, wrong log domain in DHCPv4 2012-11-20 08:59:55 -06:00
Pavel Šimerda
20d4125cfc dhcp: store NetworkManager-specific dhclient leases in /var/lib/NetworkManager/
DHCP lease file names are built by NetworkManager and contain connection UUID
which makes them NM-specific. Their new location belongs to NetworkManager and
doesn't have to be guessed. With no guessing, we don't need distribution-specific
conditionals.

Note: This change may require modifications to the selinux policy. But after all
these files actually belong to NetworkManager as well as the instance of dhclient
that uses them.
2012-11-16 15:27:22 -06:00
Aleksander Morgado
8aac52bce3 device: clear nm_device_state_changed() re-entry check on early exit 2012-10-10 11:03:50 -05:00
Dan Williams
14e87a583a trivial: warn if we ever re-enter nm_device_state_changed()
Motivated by ba48be3a34.
2012-10-06 12:38:41 -05:00
Dan Winship
0fdf2e7438 core: implement NMDevice::state-changed more idiomatically
Rather than having NMDevice subclasses connect to their own
::state-changed signal, fix up the signal definition so they can just
override the class handler.
2012-10-02 15:46:08 -04:00
Dan Winship
565c43e91d core: remove "real_" prefix from method implementation names
The idea was copied from gtk, but it's only used there in cases where
the method's wrapper function and default implementation would
otherwise have the same name, which never happens in NM because our
method implementations aren't prefixed with the type name, so it's
just noise here.
2012-10-02 15:43:24 -04:00
Dan Winship
0a30843caa core: don't try to create VLANs on devices that don't support them
VLANs are only supported on certain kinds of devices, so don't try to
create them on other devices. (In fact, NM currently assumes that
VLANs are only created on Ethernet devices, so we need to be even more
picky than that.)
2012-09-27 13:57:47 -04:00
Pavel Šimerda
3ada5b5a6a distro: remove nm_backend_ipv6_use_tempaddr()
This function was *not* distribution specific and was used only in one place.
2012-09-25 16:44:12 -05:00
Pavel Šimerda
110888c782 device: remove useless ipv6 route addition
Link-local multicast routes are handled by kernel. Just try pinging
ff02::1%eth0 on a clean system without IP configuration.
2012-09-25 15:03:32 -05:00
Jiří Klimeš
07fc3dcb90 api: add NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED reason and use that 2012-09-24 10:38:26 +02:00
Jiří Klimeš
ece5e209cd core: VPN autoconnect feature (bgo #560471) (rh #483120)
We go through the SECONDARIES state where we check if there are some secondary
(VPN or other) UUIDs that are to be activated before progressing to ACTIVATED.
In case of an error with a secondary UUID or its activation, the base connection
can't activate successfully.
2012-09-24 10:38:26 +02:00
Dan Williams
29fe6ec830 wifi: add SSID_NOT_FOUND reason and use it when we can
When the supplicant starts connecting, or gets disconnected, track
whether it ever starts talking to an AP.  Then if the connection fails
as a result of an initial connection timeout or a link timeout, we
can use SSID_NOT_FOUND when we're reasonably sure the AP doesn't
exist.  Clients can use this to show better error messages.

Note that SSID_NOT_FOUND may only be reported when using nl80211
drivers, as WEXT drivers don't provide the status necessary to
determine whether the network exists or not.
2012-09-20 10:11:36 -05:00
Dan Williams
1966aba8e9 core: determine whether connection timestamps are set or not
Currently there's no way to differentiate between a connection that has
never been activated, and a connection that has never been *successfully*
activated.  In both cases nm_settings_connection_get_timestamp() returns
zero.  But it's useful to know whether a connection hasn't even been
tried yet, so enhance the timestamp code to return whether or not the
timestamp has been found in the timestamp cache or not, and make the
NMDevice core set an explict timestamp of 0 if the connection failed
on the first attempt.

We'll use this later to conditionally autoconnect WiFi connections
depending on whether they've ever successfully connected or not, but
still allow preloaded connections without a timestamp to autoconnect
as they always have.
2012-09-20 10:11:36 -05:00
Dan Williams
15ca7cd56c core: add dispatcher callbacks and simplify dispatcher function prototypes
Remove unused args for the non-VPN cases to cut down on the NULL NULL NULL
stuff since we're also adding two more arguments.  Add the ability for
callers to give a callback that should be called when the dispatcher is
done.
2012-09-11 17:06:16 -05:00
Dan Williams
cf255aa83b core: split dispatcher into its own file 2012-09-11 17:06:16 -05:00
Jiří Klimeš
ddc3f727d0 core: fix a regression causing that driver and firmware versions are not set
Regression caused by 6ba93343e6
2012-09-03 16:18:54 +02:00
Dan Williams
2318b3c525 wired: ensure carrier changes clear queued state where appropriate
Buggy kernel drivers sometimes default the carrier to ON when they
are capable of link-detection but the carrier is actually off, and
they quickly switch the carrier OFF when they determine actual
carrier state (cdc-ether, for example).

The initial carrier ON event would trigger a queued state change
from UNAVAILABLE to DISCONNECTED, which may auto-activate the
device.  But before that state change happens, if a carrier OFF
event comes in, that queued state was not getting cleared and
the device would transition to DISCONNECTED even though the
carrier was off.

To ensure that never happens, and that we don't enter states that
aren't valid when the carrier is off, we need to clear any queued
state changes that wouldn't be valid in the new carrier state.
2012-08-30 16:04:13 -05:00
Dan Williams
e6061a1e96 api: add a "ModemManager unavailable" device state reason
To be used when MM quits unexpectedly, or isn't running and the
device needs MM.
2012-08-29 17:39:33 -05:00
Dan Williams
6ba93343e6 core: fix possible uninitialized memory usage 2012-08-24 12:06:22 -05:00
Jiří Klimeš
b39804ae6b trivial: use dashes in "br2684-bridge-failed" to match other reason strings 2012-08-22 13:40:46 +02:00
Nathanael D. Noblet
808136ac02 core: add AvailableConnections property for NMDevice objects
Implements a new property that provides a list of currently
available connections a device could connect to. For example
if a connection for a particular wireless connection exists and
that wireless network appears in the scan list it would show in the
AvailableConnections property of the device.

(dcbw: found a slightly cleaner way to do this; it's a lot like the
check_connection_compatible class method, except it deals with
live network data too.  So convert the subclass methods to
just check additional live network data, and have the base
device class handle adding the connection to the hash and all
the associated signalling.  Also fix a bug where the available
connections were not updated when a device moved from UNAVAILABLE
to available, its available connections were not updated)
2012-08-15 16:50:49 -05:00
Dan Williams
346a1dc957 core: suppress a warning when a connection is assumed
When NM takes over a device's existing connection, it'll jump right
from "unavailable" to "ip-config" states, thus leading to the
warning.
2012-07-24 12:12:18 -05:00
Pavel Šimerda
a1659adec0 ip4: fix connection assumption 2012-07-24 10:17:47 -05:00
Dan Williams
c2e25dfedc core: move failure logging to device superclass 2012-06-28 16:34:08 -05:00
Pavel Šimerda
e88aa72e6a ip6: rename defgw to gateway
This was suggested by Dan Winship but it didn't get to commit
8a059b1 by mistake.
2012-06-26 23:50:19 -05:00
Dan Williams
5003153297 core: move DNS change handling to the policy and optimize DNS updates (bgo #676778)
Consolidate all the DNS handling in the policy instead of sprinkling
it around in the device and vpn code.  This allows us to batch the
updates and thus reduce the number of times resolv.conf needs to
be written.  It's also easier to follow when and why the changes
occur.
2012-06-12 10:00:03 -05:00
Dan Williams
e48c681bb0 core: add device IPv4 and IPv6 config change signals
We'll use these later to pull the DNS manager code out of the device
class and into the policy.
2012-06-12 10:00:03 -05:00
Jiří Klimeš
af0eb9e7ad core: don't default to IPv6 temp addr while completing connection (bgo #633233)
Enabling NM_SETTING_IP6_CONFIG_PRIVACY_PREFER_TEMP_ADDR in
nm_device_complete_connection() made IPv6 temp address enabled for connections
created via AddAndActivateConnection() D-Bus call. But it is disabled for other
connections. That is not much consistent. So, do not enable IPv6 privacy when
completing connections and leave it up to users, who would like to use IPv6
Privacy Extensions, to enable it manually.
2012-06-11 09:32:49 +02:00
Jiří Klimeš
25592950e9 core: add driver-version, firmware-version properties to NMDevice (bgo #636124)
The info is extracted via SIOCETHTOOL ioctl() syscall using ETHTOOL_GDRVINFO.
This works for most drivers but not all, e.g. for modems. We may figure out how
to get the info for specific devices, and enhance the solution by implementing
specific functions for particular device types later.
2012-06-08 08:55:15 +02:00
Dan Williams
4692c00be2 core: re-implement device disconnect using generic auth request signal 2012-06-01 17:05:00 -05:00