Commit graph

649 commits

Author SHA1 Message Date
Dan Williams
42b4323902 platform: work around missing kernel netlink notifications of default route changes
It appears the kernel does not send notifications via netlink if the
default route is removed in some cases.  This causes the platform
route cache to become stale, and thus when the default route is
reset by NM the platform thinks the route already exists, and does
not add it.  But the route doesn't exist, becuase the kernel silently
removed it without telling anyone.

Fix that with a big hammer by flushing/refilling the route cache when
devices are deactivated (deletion of their addresses causes the default
route to be removed by the kernel) and when the default route is
updated by NM itself.

Pavel: if we find a more granular method, we should probably revert
this as the cache refill can be expensive.
2013-07-31 12:14:52 -05:00
Pavel Šimerda
a560148d27 core: use address lifetimes from router discovery 2013-07-30 11:40:19 +02:00
Pavel Šimerda
0e361e894c core: turn link_changed() into a proper virtual function 2013-07-29 13:51:13 +02:00
Dan Williams
fe5f0d2070 core: let device classes indicate their HW address will never change (bgo #701744)
Bluetooth device hardware addresses won't change during the lifetime
of the object (since that would mean a completely new device) and
they also won't have an ifindex because they aren't netdevices.

Various bits of the core periodically call nm_device_update_hw_address()
to update a device's hardware address, but this function expects that
any device with a hardware address also has an ifindex.  Except that
Bluetooth devices don't because they aren't netdevices.

Modify the get_hw_address_length() function to return a boolean
indicating whether or not the address can ever change, and set that
for BT devices.  nm_device_update_hw_address() then exits early if
there's no point in re-checking the hardware address, avoiding the
assertion.

https://bugzilla.gnome.org/show_bug.cgi?id=701744
2013-07-22 15:56:34 -05:00
Dan Winship
17e91fd46a core: change the rules for ignore-carrier
The previous ignore-carrier rules did not work well with dynamic IP
(dhcp/slaac) connections. Change the rule so that only static IP
connections can be activated when carrier is not present (but both
static and dynamic connections will remain up when carrier is lost).
2013-07-22 11:30:21 -04:00
Pavel Šimerda
bd1c7fbece device: use internal router discovery implementation 2013-07-20 17:08:01 +02:00
Pavel Šimerda
f7b2443035 core: always commit ip[46]-config to nm-platform
This is necessary to update the address lifetimes.
2013-07-20 15:30:09 +02:00
Pavel Šimerda
d8e6065f63 core: switch nm-ip4-config's NMIP[46]Address to NMPlatformIP[46]Address 2013-07-20 15:30:08 +02:00
Pavel Šimerda
74621a8f5c core: replace nm_ip[46]_config_diff()
Callers of these functions now only care whether two IP configs are
different and not what specific property changed, so we can simplify
this code down to a simple comparison for equality, based on the hashing
that's already done for the DNS manager.
2013-07-20 15:30:08 +02:00
Dan Williams
c370c04fee core: fix trailing semicolon that caused all IP6 configs never to get applied 2013-07-15 17:10:45 -05:00
Pavel Šimerda
d42f99f590 device: clean up ip6 configuration flow
IP6 configuration is now stored in ac_ip6_config and dhcp6_ip6_config
and passing them as function arguments is avoided. Written with Dan
Williams.
2013-07-15 15:53:43 +02:00
Pavel Šimerda
19747082b2 trivial: remove unused tried_ipv6 2013-07-09 12:29:47 +02:00
Pavel Šimerda
019dd1b7d8 trivial: remove unused system.h includesl 2013-07-05 17:22:34 +02:00
Pavel Šimerda
253906ecd2 trivial: simplify nm_ip[46]_config_diff() result check
nm_ip[46]_config_diff() explicitly checks for NULL arguments.
2013-07-04 18:15:08 +02:00
Pavel Šimerda
8de1b1732e trivial: move merge_ip6_configs() to nm-ip6-config 2013-07-04 13:37:26 +02:00
Pavel Šimerda
7967a6524a trivial: move a couple of functions to nm-ip[46]-config
Note that this patch doesn't effectively change any code.

Functions moved from nm-system:

* nm_system_apply_ip?_config → nm_ip?_config_commit
* ip?_dest_in_same_subnet → nm_ip?_config_destination_is_direct

Functions moved from NetworkManagerUtils:

* nm_utils_merge_ip?_config → nm_ip?_config_merge_setting

Functions renamed (and moved down to form one group):

* nm_ip?_config_new_for_interface → nm_ip?_config_capture

(The rationale for the rename is that from the achitectural point of
view it doesn't matter whether the function creates a new object or
updates an existing one. After the rename, it's obvious that
nm_ip?_config_capture() and nm_ip?_config_commit() are counterparts of
each other.)
2013-07-03 16:12:23 +02:00
Jiří Klimeš
e2b7c4824d core: fix IP_DONE vs. IP_FAIL states
0652d9c596 changed IP states like this:
        |        old behaviour          |  new behaviour
---------------------------------------------------------
success | IP_DONE && config is not NULL |    IP_DONE
failure | IP_DONE && config is NULL     |    IP_FAIL

But some failure paths was not updated.
2013-07-03 10:48:14 +02:00
Pavel Šimerda
ca6b360089 core: don't use flags for nm_system_apply_ip[46]_config
nm_platform_*_sync() functions check the cached kernel configuration
items (addresses, routes) before adding addresses to the kernel.
Therefore we don't need to be so careful about pushing NetworkManager
configuration to the kernel.

This patch helps to avoid having to compare nm_ip[46]_config objects,
which should only be created when a configuration change is being
performed.
2013-07-02 22:49:56 +02:00
Pavel Šimerda
f548a49782 trivial: clarify has_ip_config()
Make it more explicit that it returns TRUE for UNMANAGED state.
2013-07-02 20:12:54 +02:00
Jiří Klimeš
5e9ab28c5a core: call nm_device_queue_state() instead of direct state transition
in nm_device_start_ip_check(), because it is called from the state handler
(nm_device_state_changed()).

Errors:
(devices/nm-device.c:5585):nm_device_state_changed: runtime check failed: (priv->in_state_changed == FALSE)
<info> (eth0): device state change: ip-check -> secondaries (reason 'none') [80 90 0]
2013-07-02 15:36:46 +02:00
Pavel Šimerda
0652d9c596 core: use ip[46]_state for IP configuration status
Don't assume that NULL ip[46]_config means anything specific.
2013-06-27 18:33:18 +02:00
Pavel Šimerda
7218b8d069 core: always commit DHCPv4 config
DHCPv4 config can change even during connection assumption.
2013-06-27 16:14:33 +02:00
Pavel Šimerda
52dca880cc core: clarify nm_device_set_ip?_config()
The 'assume' parameter was misused for stuff that has nothing to do with
connection assumption. The 'commit' argument with reversed logic is much
clearer.
2013-06-26 23:52:58 +02:00
Pavel Šimerda
57df4ce5ed core: use nm-platform for route management 2013-06-25 09:52:12 +02:00
Pavel Šimerda
48670c0156 core: use nm-platform for address management 2013-06-25 09:50:36 +02:00
Dan Williams
ab8ca2dbe2 core: fix flushing of routes and updating legacy IPv4 address property
We can't clear the ip_iface until after all the routes and addresses
are updated and flushed, because the addresses and routes are
identified by the ip_iface, and if we clear the ip_iface, we don't
know which things to flush anymore.

Example: 'hso' modems have an 'iface' of 'ttyHS4' (a serial port) and
an ip_iface of 'hso0' (an ethernet port).  If we clear the ip_iface too
soon, then ip_iface/ip_ifindex is invalid and thus NM has no idea what
to remove, and the default route pointing to 'hso0' sticks around.

This could also happen with other devices where the ip_iface is
different than the iface, like modems, ADSL/ATM devices, etc.
2013-06-24 22:47:57 -05:00
Dan Williams
8ce4250d8e core: ping the gateway during the IP_CHECK state (bgo #702515)
Using the new gateway-ping-timeout property, send pings to the first
gateway address until it replies or the timeout is reached, to deal
with dumb hardware that indicates carrier on but doesn't actually
pass traffic.

https://bugzilla.gnome.org/show_bug.cgi?id=702515
2013-06-21 16:18:49 -05:00
Colin Walters
c1d3d3f2e9 device: queuing two transitions to the same state is not an error
Just ignore this, since it happens in the current code and is
harmless.  While we're here, improve the warning in the case where it
does occur to say whiich state we're overwriting.  This should help
debug any future cases.
2013-06-19 18:06:16 -05:00
Dan Williams
cf1d2f81f2 core: rename nm_device_hw_* to nm_device_*
Now that we only have one set of is_up/bring_up/take_down functions
lets rename the _hw_ variants.
2013-06-14 13:45:39 -05:00
Dan Williams
17ce00ff27 core: remove bring_up, take_down, is_up device class methods
These turn out to be pretty useless, since their functions are already
covered by each device's state-changed handler or can be done in other
places like deactivate().

https://bugzilla.gnome.org/show_bug.cgi?id=702190
2013-06-14 13:45:32 -05:00
Dan Winship
77dda53b50 devices: use NMPlatform to find the hardware address length
For device types that don't override it, make
nm_device_get_hw_addr_len() use NMPlatform to find out the actual
hardware address length, rather than just defaulting to ETH_ALEN.
Fixes warnings in the logs when using tun or gre devices.
2013-06-11 09:27:45 -03:00
Dan Winship
6975645497 core: Use length-based hwaddr functions
Use nm_utils_hwaddr_aton_len() and nm_utils_hwaddr_ntoa_len(), to
simplify code, and (eventually) better support non-ethernet,
non-infiniband devices.
2013-06-11 09:27:45 -03:00
Dan Williams
790c102fff wired: ignore carrier state for manual/static bridge and bond connections
NM is supposed to ignore carrier and slave states for manual/static
connections when bringing up bonds and bridges, on the theory that
since static configuration does not require connectivity, there's
no need to wait for that connectivity to happen. This wasn't
happening during the IP configuration phase, but was happening
before getting to the IP config phase where the device waits
for slaves before starting IP configuration if the method
requires connectivity.
2013-06-07 15:22:24 -05:00
Dan Winship
1dac0722d1 devices: fix a small bug in earlier commit that causes warnings 2013-06-06 08:46:45 -03:00
Dan Winship
b322c0dc81 devices: make constructors take an NMPlatformLink
Rather than passing UDI, ifname, and driver name to the device
constructors as separate arguments, just pass the NMPlatformLink
instead and let it parse them out.

Virtual types still take UDI and ifname separately, since we create
fake NMDevices for them for autoactivating connections. That's weird
in other ways too though, so perhaps this should be revisted.
2013-06-05 17:49:25 -03:00
Dan Winship
b15fb8641e core: split NMRfkillManager out of NMUdevManager
Split the rfkill-monitoring parts of NMUdevManager into a separate
class. Now NMUdevManager only handles device enumeration.
2013-06-05 17:49:24 -03:00
Dan Winship
add316a403 platform, devices: add support for tun and tap devices 2013-06-04 10:01:13 -03:00
Dan Williams
cae49f0422 core: not all callers of hw_bring_up care about firmware 2013-05-31 15:34:40 -05:00
Pavel Šimerda
5074898591 core: use nm-platform for link management 2013-05-24 19:14:50 +02:00
Martin Pitt
fd4709fa27 core: add option for running from the build tree
Add hidden command line option --run-from-build-dir; with that, helpers
like nm-avahi-autoipd.action and nm-dhcp-helper will be called from the
build tree instead of libexecdir, which allows testing without having to
install first.

Helper paths are now stored in global variables instead of macros, and
get modified with that new option.

https://bugzilla.gnome.org/show_bug.cgi?id=698752
2013-05-22 16:17:23 +02:00
Dan Winship
fd2a3a7561 devices: fix recursive-state-change check
nm_device_state_changed() had a check to make sure it wasn't entered
recursively (which had been a source of bugs in the past), but it was
global rather than per-device, so it caused errors when VLANs changed
state in response to their parent device changing state. Fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=698619
2013-05-20 16:38:34 -03:00
Dan Winship
2bb5178897 devices, platform: fix up carrier-detection detection
Some devices aren't expected to support carrier detection, so there's
no reason to have NMDevice log about it. Move that message into
NMDeviceEthernet, where failure to support carrier-detect really is
worth mentioning.

Also, make NMDeviceEthernet use NMPlatform for carrier-detection
detection (and move the MII carrier-detect-support check from
NMDeviceEthernet into NMLinuxPlatform).

Finally, have NMDeviceGeneric actually check whether the device
supports carrier detect, rather than just always assuming it doesn't.
2013-05-20 16:38:34 -03:00
Dan Williams
be807819b0 core: clean up and simplify device capabilities handling
This is really, really old 2007-era code.  Any NMDevice that gets
created is already supported, so there's no reason to have every
device set NM_DEVICE_CAP_NM_SUPPORTED.  For those subclasses that
only set that capability, we can remove the subclass method
entirely.  Next, it turns out that the "type capabilities" code
wasn't used anywhere, so remove that too.  Lastly, "cipsec"
interfaces haven't been used on linux in about 5 years (they
were created by the Cisco binary-only IPSec kernel module for
Cisco VPNs long before vpnc and openswan came around) so we can
remove that code too.
2013-05-20 16:38:34 -03:00
Dan Winship
82222d3898 core: move carrier handling to NMDevice
Move carrier handling for most device types into NMDevice.

Based on an earlier patch by Pavel Šimerda.
2013-05-20 16:38:33 -03:00
Dan Winship
5a223b9089 core: make nm-properties-changed-signal always export the right properties
Change the way that nm-properties-changed-signal works, and parse the
dbus-binding-tool-generated info to get the exact list of properties
that it's expected to export.

This makes NM_PROPERTY_PARAM_NO_EXPORT unnecessary, and also fixes the
problem of properties like NMDevice:hw-address being exported on
classes where it shouldn't be.
2013-05-20 16:38:33 -03:00
Dan Williams
4ca885f5e3 core: fix list manipulation when removing multiple slaves
nm_device_release_one_slave() may change the list head, but the
for loop in nm_device_master_release_slaves() can't handle that.
Use a while loop instead.
2013-05-15 14:39:16 -05:00
Dan Winship
43c4a45c4d devices: fix a bug in activation logic
It *is* legitimate to (re-)activate a connection on an already-active
device, so remove the newly-added "sanity check" preventing that.
Pointed out by jklimes.
2013-05-13 10:57:38 -04:00
Dan Winship
2a8023ef3d devices: fix the dbus glue naming inconsistency for NMDevice 2013-05-08 17:15:47 -04:00
Dan Winship
3ab82ea20e core: move devices into a subdirectory
We have lots of device types and will soon have lots more, so let's
put them in their own directory.
2013-05-08 15:07:22 -04:00
Renamed from src/nm-device.c (Browse further)