Commit graph

26 commits

Author SHA1 Message Date
Dan Williams
6c3178c7e2 wired: wait for carrier on master devices before proceeding with IP config
If the IP configuration requires slaves/ports, starting IP configuration
before the master device has a carrier (which means at least one slave
or port has a carrier and the device is initialized) is pointless, and
will just take longer or fail.  Recent kernels have cleaned up carrier
handling on bridge/bond devices and the carrier is now a reliable
indication of whether or not the master device is ready to send/receive
traffic.  Thus, if we don't have a carrier, obviously no IP configuration
that depends on connectivity is going to work.
2013-02-04 10:37:47 -06:00
Dan Williams
8aee650cd1 core: allow Wired device subclasses to override carrier handling
Bond devices, for example, don't want carrier state to affect
connection state.  Allow subclasses to override the Wired class'
handling if they want.
2013-02-04 10:37:46 -06:00
Dan Williams
d4f5c40abe core: emit NMDeviceWired carrier change after logging it
Less confusing in the logs to see the change logged before listeners
have a chance to emit other log messages that may depend on the new
carrier state.
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
c8eba44cfa core: fix GObject parent method calling for hw_is_up()
Broken by e7caad20c9.

Admittedly, GObject is opaque in this area.  But here's the
equivalent concepts in C++:

*_GET_CLASS (object)->function(object):
   - call youngest implementation of virtual function; checks current
     object for implementation and calls it, if not overridden by the
     child, walks up the inheritance chain and calls parent,
     grandparent, etc.  C++ equivalent is calling foo::function().

*_CLASS (object_parent_class)->function(object):
   - call named parent class implementation, *not* including current
     object.  C++ equivalent is calling ParentClass::function().

Using _GET_CLASS()->function() inside the child implementation of
function() recursively calls the child implementation of function()
and overflows the call stack.
2013-01-25 08:44:42 -06:00
Dan Williams
cd5da9bf88 wired: move hardware address handling back to NMDeviceWired subclasses
The code flow is actually somewhat simpler this way since the
subclasses don't have to ask NMDeviceWired for the address
every time.  Plus then NMDeviceWired doesn't have to know
anything about its subclasses in the constructor.
2013-01-24 14:56:38 -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
Thomas Graf
cfff5a63d9 bridge: add bridge device type
This adds a new device type 'bridge'. Kernel devices are created
on demand.
2012-11-30 13:21:51 -06: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 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
331b6562cb core: don't print carrier messages if device is unmanaged 2012-05-16 18:10:24 -05:00
Dan Williams
a091c7aa0f core: ensure carrier is always on for devices that don't support detection (rh #816719)
We broke this when splitting NMDeviceWired out of NMDeviceEthernet.
2012-04-28 11:48:01 -05:00
Dan Williams
b44b0321a0 core: fix carrier-triggered state re-entrancy issue (rh #800690)
Carrier checking can be synchronous, like when bringing up the device.
If the carrier changes as a result of the sync carrier state checking,
the code might change state.  Unfortunately brining up a device
happens in response to a state change already, and we can't change
state from within handlers for the device state change signal, so
we need to queue up the new state change that results from a
carrier change.
2012-03-14 12:20:23 -05:00
Dan Williams
58227d0136 wired: check carrier immediately after bringing device up
Virtual devices that we might create when their slave is started
(like bonds) have a virtual carrier that often isn't set on when
until the device is brought up.  The device is brought up during
creation, but the initial carrier check happens before the device
is up, so the initial carrier state from the constructor isn't
quite accurate in some cases.

Since we want to use virtual interfaces that we create right after
we create them, we want them to be available too, and that usually
requires the carrier to be on.  So recheck the carrier right after
bringing the interface up, so that the carrier state is accurate
immediately after the device is created.
2012-03-01 17:40:17 -06:00
Dan Williams
29672c3f7d core: move IP config matching to NMDevice superclass
It's useful for more than just NMDeviceWired and subclasses.
2012-03-01 17:40:17 -06:00
Dan Williams
0109ed62e9 core: const-ify nm_device_wired_get_hwaddr() 2012-02-23 00:03:50 -06:00
Dan Williams
0c61a51614 bond: move bond master interfaces to NMDeviceBond
This way clients know it's a bond master, and it allows us to more
cleanly separate the code for bonding and non-bonding cases.
2012-02-16 15:20:50 -06:00
Jiří Klimeš
617af3b49d trivial: use proper return type in g_return_val_if_fail() 2012-01-17 14:45:27 +01:00
Jiří Klimeš
9f75f91f3a wired: emit Speed value in PropertiesChanged signal, when changed (bgo #667091)
Speed is gotten via ethtool on 'carrier on' event. If there is a more suitable
netlink event we should use it instead. Nonetheless, it appears to be working
fine with carrier change, because interface speed change does emit carrier offi
and on events.
2012-01-17 14:30:45 +01:00
Thomas Graf
200a7e142a wired: allow devices to be reassumed when ip4 config is disabled
Wired connections acting as bonding slave will have their ip4
config disabled. Allow such connections to reassume devices.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
2011-12-08 10:33:21 -06:00
Dan Williams
2ade420479 netlink: consolidate netlink monitor error handling and initialization
The fact that any of this code was in main.c was a hangover from
a long time ago and it should really go with the rest of the
netlink monitor code.
2011-12-03 17:38:07 -06:00
Dan Williams
da8e21a7d7 core: kill NMDeviceInterface 2011-12-02 13:30:07 -06:00
Dan Williams
f8852bf4a4 core: kill nm_device_interface_get_state() 2011-12-02 13:30:06 -06:00
Dan Winship
5366c3d6d4 wired: split NMDeviceWired out of NMDeviceEthernet and add NMDeviceInfiniband 2011-12-02 13:09:16 -06:00