Commit graph

433 commits

Author SHA1 Message Date
Dan Winship
5fec30d98e Revert :carrier-detect properties and associated code
Ignoring carrier is generally something you want at the machine level
(eg, for a server), not at the connection level.
2013-04-03 10:23:49 -04:00
Dan Winship
0b815ca166 config: add NMConfigDevice
Add NMConfigDevice, which is mostly just a wrapper around
nm_device_get_hw_address() and nm_device_spec_match_list(), and
implement it in NMDevice. This will be used for config options that
match devices. (We can't use NMDevice directly for dependency
reasons.)
2013-04-03 10:23:48 -04:00
Dan Williams
f515df39b5 core: don't crash checking unmanaged specs if device has no hardware address
Not all devices have a hardware address, like WWAN or ADSL.  So don't
unconditionally expect one.
2013-03-25 15:17:35 -05:00
Jiří Klimeš
82fb1978a4 all: use G_VALUE_INIT to initialize GValue variables
It makes the initializations more explicit.
G_VALUE_INIT is available since glib 2.30, and NM now require glib >= 2.32
2013-03-25 08:41:18 +01:00
Dan Williams
6551e9bbc4 core: don't fail IPv6 if otherconf/info-only DHCPv6 fails
Just like we don't fail IPv4 if DHCP fails to get DNS servers,
don't fail IPv6 if we've already got an RA and for some reason
DHCPv6 fails.  otherconf/info-only DHCP is not mandatory, and
lack of results thus should not fail the entire IPv6 config,
since DNS servers can also be passed in the RA.

RFC4861:

1-bit "Other configuration" flag.  When set, it
indicates that other configuration information is
available via DHCPv6.  Examples of such information
are DNS-related information or information on other
servers within the network.
2013-03-14 13:57:52 -05:00
Dan Winship
d9e87d933b core: document some NMDevice methods 2013-03-13 16:45:19 -04:00
Dan Winship
c308e75b92 core: allow marking a device unmanaged by its interface name
Virtual devices often don't have stable hardware addresses. So allow
for marking a device unmanaged via its interface name instead.

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 16:45:19 -04:00
Dan Winship
611df342af core: make nm_device_check_connection_compatible() check interface-name
If an NMConnection specifies an interface-name, it is only compatible
with a device with the same iface.

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 16:45:19 -04:00
Dan Winship
1cc367711d core: simplify nm_device_get_best_auto_connection()
As with the other connection-matching methods, move the loop and the
device-independent bits into NMDevice. By reusing
nm_device_check_connection_compatible(), this means that most device
types now no longer need any type-specific code for this.

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 13:21:59 -04:00
Dan Winship
971bab01ea core: simplify/rename nm_device_connection_match_config()
nm_device_connection_match_config() sounded more generic than it
really was; rename it to nm_device_find_assumable_connection(), which
is what it really does.

There was also a lot of redundancy/cut+paste in the subclass
implementations of connection_match_config(); Improve things by moving
the looping-over-connections code into NMDevice itself, and also doing
the general-device-compatibility and IP-config checking there, leaving
the device subclasses to just verify L2 properties. Which most of them
aren't doing...

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 13:21:59 -04:00
Dan Winship
a3f6af817b core: simplify nm_device_spec_match_list()
Since NMDevice has a generic get_hw_address() method now, it can do
nm_device_spec_match_list() itself (for everything except ethernet,
which needs to match against s390 subchannels too).

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 13:21:59 -04:00
Jiří Klimeš
cc66b547cf device: do not call nm_system_iface_set_up() with invalid index (rh #920145)
in hw_take_down()

usb 1-3: USB disconnect, device number 6
modem-manager[547]: <info>  (tty/ttyACM0): released by modem /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-3
<info>  (tty/ttyACM0): released by modem /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-3
<info> (ttyACM0): device state change: disconnected -> unmanaged (reason 'removed') [30 10 36]
<info> (ttyACM0): cleaning up...
<info> (ttyACM0): taking down device.
nm_system_iface_set_up: assertion `ifindex > 0' failed
2013-03-13 09:34:51 +01:00
Dan Williams
ec781ff9d5 core: fix leak of StateReason struct
==23089== 38,232 (4,248 direct, 33,984 indirect) bytes in 177 blocks are definitely lost in loss record 5,122 of 5,123
==23089==    at 0x4A0881C: malloc (vg_replace_malloc.c:270)
==23089==    by 0x39B905488E: g_malloc (gmem.c:159)
==23089==    by 0x39B9068CA1: g_slice_alloc (gslice.c:1003)
==23089==    by 0x39B98371B1: g_value_array_new (gvaluearray.c:140)
==23089==    by 0x31FB81B67D: valuearray_constructor (dbus-gvalue-utils.c:771)
==23089==    by 0x42DD8F: get_property (nm-device.c:4675)
==23089==    by 0x39B9819C64: g_object_get_property (gobject.c:1289)
==23089==    by 0x31FB80DA49: object_registration_message (dbus-gobject.c:1322)
==23089==    by 0x363961DA44: _dbus_object_tree_dispatch_and_unlock (dbus-object-tree.c:858)
==23089==    by 0x363960FA82: dbus_connection_dispatch (dbus-connection.c:4685)
==23089==    by 0x31FB80AC44: message_queue_dispatch (dbus-gmain.c:90)
==23089==    by 0x39B904EC54: g_main_context_dispatch (gmain.c:2539)
2013-03-08 09:27:51 -06:00
Dan Winship
6f44b7f3c6 all: remove redundant return-if-fail checks
NM_IS_FOO(x) returns FALSE if x is NULL, so we don't need a separate
(x != NULL) check before it.
2013-03-07 07:32:27 -05:00
Pavel Šimerda
8f758b0af9 cleanup: remove nm-netlink-compat 2013-03-05 23:02:50 +01:00
Dan Williams
47d8db57b5 trivial: plug some memory leaks
(review+ danw)
2013-02-25 16:07:03 +01:00
Mihai Dontu
f96a42b0e2 core: allow '2' when reading startup accept_ra value (bgo #691213)
Otherwise, priv->accept_ra_path would be NULL, which isn't very
useful and  makes nm_utils_do_sysctl() angry.  No reason we shouldn't
always create priv->accept_ra_path in the future though.

https://bugzilla.gnome.org/show_bug.cgi?id=691213
2013-02-20 14:01:24 -06:00
Dan Winship
feeafb8cf1 core: Update device activation for :carrier-detect
Add a "need_carrier" argument to nm_device_is_available(), to allow
distinguishing between "device is not available", "device is fully
available", and "device is available except for not having carrier".

Adjust various parts of NMDevice and NMManager to allow for the
possibility of activating a connection with :carrier-detect = "no" on
a device with no carrier, and to avoid auto-disconnecting devices with
:carrier-detect = "on-activate".

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-02-15 13:40:39 -05:00
Dan Winship
fe307dbd3e core: move carrier-detect NMDeviceState handling into NMDevice
Move some duplicated carrier-handling code into NMDevice (which can
introspect itself to see if it's a subclass that has carrier).

The "mostly ignore carrier" special handling for bridges and bonds is
now also handled as part of the NMDevice-level carrier handling.

https://bugzilla.gnome.org/show_bug.cgi?id=688284
2013-02-15 13:40:38 -05:00
Dan Winship
d04f286327 all: remove pointless NULL checks
g_malloc(), etc, never return NULL, by API contract. Likewise, by
extension, no other glib function ever returns NULL due to lack of
memory. So remove lots of unnecessary checks (the vast majority of
which would have immediately crashed had they ever run anyway, since
g_set_error(), g_warning(), and nm_log_*() all need to allocate
memory).

https://bugzilla.gnome.org/show_bug.cgi?id=693678
2013-02-13 13:38:13 -05:00
Dan Williams
454490c6d5 core: let subclasses find slaves by ifindex 2013-02-04 10:37:47 -06:00
Dan Williams
37febd6228 core: expose IP4 wait state to subclasses
We'll need to this to determine whether or not to retry IP config
from device subclasses.
2013-02-04 10:37:47 -06:00
Dan Williams
479163db59 core: generalize waiting for IP config until slaves are ready
Instead of duplicating the code in bridge and bond, move the
logic to the base class and key it off whether or not the device
is a master.
2013-02-04 10:37:47 -06:00
Dan Williams
e64bcae092 core: add IS_MASTER property to NMDevice
We can't just check whether there are slaves or not, because the
master device may be started before any slaves exist, and the
slaves get added later.
2013-02-04 10:37:46 -06:00
Dan Williams
01acf46df8 trivial: quiet useless log message
Managed/unmanaged status is conveyed by the immediate state change,
so no need to redundantly log it.
2013-02-04 10:37:46 -06:00
Dan Williams
7651c77b78 core: update hardware address when slaves change
The hardware address of a device often changes when slaves change,
for example with bond interfaces, which take the hardware address of
their first slave.  Make sure that's always up-to-date.
2013-02-04 10:37:46 -06:00
Dan Williams
763b6c31d4 core: ignore carrier changes on enslaved interfaces
It's not very helpful to deactivate a slave of a bond or a bridge
port because the carrier is lost.  Carrier failures are normal
operation when using various bonding failover modes.  For bridge
ports, it's probably not very helpful either.  Given that the
masters are all virtual interfaces and have been explicitly
configured and started by a user, the configuration should
generally be left alone unless explicitly deactivated or changed.
2013-02-04 10:37:46 -06:00
Dan Williams
39bd9f893a core: log when last slave is removed 2013-02-04 10:37:46 -06:00
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