Commit Graph

7207 Commits

Author SHA1 Message Date
Thomas Haller
c822b12cf1 core: add nm_platform_ip4_route_to_string for debugging
Add convenience function to convert an IPv4 route to string.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-26 23:37:36 +02:00
Thomas Haller
fbde824584 core: fail activation when a route cannot be added
Before, when a route failed to be added, NM stopped adding further
routes. However, the activation still continued and the user was not
notified about the error.

Adding a route might fail for example if the gateway is not on one of
the subnets of the interface.

Now, a failure to add a route makes the activaion fail. If the
connection has autoconnect=yes, this might result in some unsuccessful
reconnection attempts.

In the future, we might want to distinguish between manually added routes
and routes from RA/DHCP. So that connecting to a wrongly configured DHCP
server still works for most parts.

https://bugzilla.redhat.com/show_bug.cgi?id=999544

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-26 23:36:38 +02:00
Dan Williams
179dae7c68 core: fix setting is_software for software devices created by NM
These devices don't have a platform device at creation time, thus
is_software wasn't getting set properly.  Move the is_software
decision to constructed() because by this point, the iface and
ifindex (if present) will be known for all cases and thus we can
figure out if it's a software device or not in one place.
2013-08-26 13:14:01 -05:00
Thomas Haller
94dfe2856c core: fix leaking route instance in nm_ip4_config_update_setting
The fix in commit b5b43a6d65 missed the
release of the route instance (because nm_setting_ip4_config_add_route
does not take over the passed route but duplicates it).

So the orginal error was to free the route with the wrong deallocation
method gs_unref_object instead of nm_ip4_route_unref.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-26 10:56:16 +02:00
Thomas Haller
b5b43a6d65 core: fix wrong unref in nm-ip4-config/nm_ip4_config_update_setting
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-23 15:44:31 +02:00
Pavel Šimerda
68e250f86a core: reset ipv6 sysctls only for managed devices
Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
0e1ceaa63a core: implement update_connection() for Ethernet
Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
c1f45eb2df core: match connections to connections instead of devices
This backwards compatible patch adds the possibility to use new
nm_device_generate_connection() API via update_connection() virtual
method implementations in NMDevice subclasses.

Compatibility is achieved by first trying to use the older API and
match_l2_config() virtual method and only then moving on to
update_connection().

The nm_device_generate_connection() calls update_connection() to create
type-specific NMSetting instances and verifies the connection before
returning it. To avoid tinkering with NMSettingConnection in
update_connection() we use a class attribute called connection_type
which is used by nm_device_generate_connection() itself.

Known issues:

* nm_device_generate_connection() method doesn't implement DHCP lease
configuration matching. We shouldn't actually need it but if a use case
for that will come out, we can fix it later.

* nm_device_generate_connection() doesn't fill in the slave-specific
options.

* update_connection() is not implemented and connection_type is not set
in the subclasses. This will be fixed in individual patches.

* NMSetting's compare_property() implementations in combination with
NM_SETTING_COMPARE_FLAG_CANDIDATE are not yet fully ready thus rendering
false negatives in some cases. Same as above.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
155ec4c382 core: implement nm_device_is_software()
Cache the result of nm_platform_link_is_software() in NMDevice.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
7d37b714c8 core: don't return NULL from nm_ip[46]_config_capture()
Checking whether a connection is good enough is done by nm-device.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
5affa446aa core: remove assume from nm-activation-request
Whether an active connection is assumed or connected from scratch is
only important during nm_device_activate(). When the activation process
is set up, there's no difference from any other active connection.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Thomas Haller
34d28376ed core: fix segfault on initialization of macvlan and gre device
The link_changed method expects a valid info parameter.
NMDeviceMacvlan and NMDeviceGre calls link_changed
during construction for initialization.

As it was before, NMDeviceMacvlan and NMDeviceGre passed
NULL as NMPlatformLink, causing NM to segfault.

(Regression was introduced in 0e361e894c)

https://bugzilla.redhat.com/show_bug.cgi?id=997396

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-22 20:40:53 +02:00
Dan Winship
bfce3f7dc8 build: switch from $(INCLUDES) to $(AM_CPPFLAGS) to make automake happy
Unfortunately, $(AM_CPPFLAGS) gets overridden by per-target _CPPFLAGS
variables, which $(INCLUDES) did not, so this requires some additional
changes.

In most places, I have just gotten rid of the per-target _CPPFLAGS
variables; in directories with a single target, the per-target
variable is unnecessary, and in directories with multiple targets, the
per-target variable is often undesirable, since it forces some files
to be compiled twice, even though there ends up being no difference
between the two files.
2013-08-22 11:49:16 -04:00
Jiri Pirko
1a3c2ed1cb team: kill existing teamd for same device name during teamd start phase
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 09:44:05 -04:00
Jiri Pirko
415cd6d853 nm-manager: fix goto in system_create_virtual_device() in team section
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 09:44:05 -04:00
Jiri Pirko
fb454b2c33 nm-manager: do not fail if team device already exists
Similar has been done with bond and bridge

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 09:44:05 -04:00
Jiri Pirko
bd1eaaa4a0 team: use libteamdctl to update port config before enslave
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 09:44:05 -04:00
Jiri Pirko
d55804407d nm-device-team: use libteamdctl
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 09:39:46 -04:00
Jiri Pirko
861e5148d8 ifcfg-rh writer: write DEVICETYPE for all team ports
even for that which does not have settings

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 09:38:11 -04:00
Dan Winship
f201a248c3 ifcfg-rh: minor tweaks to previous patch 2013-08-22 08:58:08 -04:00
Jiri Pirko
dbf9c42578 ifcfg-rh: add test for BOOTPROTO=none reader
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 08:51:51 -04:00
Jiri Pirko
886c760f8b ifcfg-rh: reader: allow device to not have ipv4 setting.
If BOOTPROTO is set to "none", user states that no ipv4 setting should
be set. So respect that.

Introduce helper is_any_ip4_address_defined() along the way to make the
code more readable.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-22 08:51:48 -04:00
Pavel Šimerda
aae48a8557 core: don't use gs_unref_object for nm-ip[46]-address
It's not a GObject subclass.
2013-08-21 23:28:13 +02:00
Jiri Popelka
d9cba44e6c trivial: fix unused variable 'priv'
(cherry picked from commit 64753b9b3a)

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-19 12:35:06 +02:00
Pavel Šimerda
ff6d9b3c0f vpn: fix zero IPv6 address check
Bug introduced by commit d8e6065.

https://bugzilla.gnome.org/show_bug.cgi?id=706286

Reported-by: Nicolas Iooss <nicolas.iooss.2010_nm@m4x.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-19 12:18:34 +02:00
Dan Winship
bc091f2f3e core: add NMManager:startup property
Add a property on NMManager indicating that it is currently starting
up and activating startup-time/boot-time network connections.

"startup" is initially TRUE, and becomes FALSE once all NMDevices
report that they have no pending activity (eg, trying to activate,
waiting for a wifi scan to complete, etc). This is tracked via a new
NMDevice:has-pending-activity property, which is maintained partially
by the device itself, and partially by other parts of the code.
2013-08-16 17:27:34 -04:00
Dan Winship
cee676e704 core: simplify signal disconnection in nm-device-wifi 2013-08-16 17:27:34 -04:00
Dan Winship
32aeed7e2d core: minor device removal simplification/fix
nm-manager.c:remove_one_device() took a GSList as an argument and
returned that GSList with the device removed; but every caller passed
in priv->devices and assigned the result to priv->devices, so just
make it always do that.

Also, rename it to remove_device() to match add_device().

Also, when removing a device, NMManager was only disconnecting one of
the several signal handlers it connected in add_device(). This
generally wasn't a problem since the device would normally be
destroyed immediately after this, but it's good to be correct.
2013-08-16 17:27:34 -04:00
Dan Winship
75ea0b0593 core: remove some dead code in NMDevice 2013-08-16 17:27:34 -04:00
Jiri Pirko
f81e2cbe68 core: spawn teamd for team device connection
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00
Jiri Pirko
dcf5355810 ifcfg-rh: add write support for team devices
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00
Jiri Pirko
db65980328 ifcfg-rh: add read support for team devices
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00
Jiri Pirko
23836e8146 core: add support for team device
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
2013-08-15 10:54:15 -05:00
Martin Pitt
5dc4be54e6 keyfile: Drop owner check
In nm_keyfile_plugin_connection_from_file(), disable the "bad owner"
check.
As root you can read all files anyway, or if necessary even chown them,
and for
other users the standard file permissions will do a fine job.

This fixes running "make check" as root.

https://bugzilla.gnome.org/show_bug.cgi?id=701112
2013-08-13 23:28:54 +02:00
Pavel Šimerda
80c48a62be dhcp: kill dhclient on fatal errors
This helps to avoid dhclient DOSing the network.

https://bugzilla.gnome.org/show_bug.cgi?id=705137
2013-08-13 22:35:00 +02:00
Thomas Haller
6e6b573383 core: minor code cleanup to use preprocessor constants
Use preprocessor constants for signal names NM_PLATFORM_LINK_*
instead of hard coded values.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-12 13:31:33 -05:00
Thomas Haller
e26642c26c trivial: fix spelling errors in code comments
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-12 13:31:07 -05:00
Pavel Šimerda
8d10e8bbe6 platform: ignore multi-hop routes
https://bugzilla.gnome.org/show_bug.cgi?id=705606
2013-08-12 17:35:22 +02:00
Dan Williams
e16e8ab7fb policy: prevent double-deactivation of an NMActiveConnection after it's removed
When a connection is removed from NMSettings, it gets deactivated.  That was
happening once in response to the now-removed connection's visibility changing
to invisible to everyone, and a second time in response to the actual removal
signal.  Unfortunately the second time the NMActiveConnection is already
cleaned up and in the DEACTIVATED state, and has no priv->device, which
causes great hilarity when nm_device_set_state() is called with NULL.

_deactivate_if_active() should only try to deactivate NMActiveConnections
that actually are active.
2013-08-09 00:54:58 -05:00
Dan Williams
b5170903c0 settings: correctly handle connection deletion after unsaved and monitor-connection-files
Plugins that could save connections to disk previously depended on inotify
events from the kernel to know when to signal connection removal; that is
in response to a 'delete' request they would unlink the backing filesystem
resources, get the inotify signal, and cause NM_SETTINGS_CONNECTION_REMOVED
to be emitted.

Unsaved connections don't have any backing resources, so they would never
get the signal emitted, and NMSettings would never forget about them.

Also, when monitor-connection-files=false in the configuration, obviously
the inotify signals will never come in because they aren't set up.

Given that we can no longer rely on inotify, it's best to just explicitly
send out the NM_SETTINGS_CONNECTION_REMOVED signal whenever a connection
is deleted via the D-Bus interface or internally.
2013-08-09 00:54:58 -05:00
Stanislaw Gruszka
dd9cf657ef wifi: change bgscan threshold parameter
We do not need to increase periodical scanning frequency when AP signal
strength is good enough. Signal level of -45dBm is considered as good,
change the threshold to -65dBm.
2013-08-08 10:52:39 -05:00
Dan Williams
119345d90a core: fix double-free C&P error 2013-08-08 10:14:38 -05:00
Dan Williams
37efd55699 platform: fix some bogus compiler warnings
platform/nm-linux-platform.c: In function 'delete_object':
platform/nm-linux-platform.c:102:13: error: 'cached_object' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  if (object && *object) {
             ^
platform/nm-linux-platform.c:1019:35: note: 'cached_object' was declared here

Except that it won't be, but I guess the gsystem auto* stuff is
confusing the compiler.
2013-08-07 15:47:47 -05:00
Dan Williams
b637c6a101 platform: don't assert on multi-hop routes (rh #989022)
It only matters that there's at least one next hop, not that there
is only one.
2013-08-07 14:47:22 -05:00
Dan Williams
ead39cb421 core,platform: don't completely ignore WWAN pseudo-ethernet interfaces
The platform still needs to know about them, becuase the ethernet interface
is what gets configured and used for IP.  But the Manager doens't want to
create a full new NMDevice for them, because there's already a Modem
device that "owns" that WWAN interface.  So keep WWAN devices visible
to the platform, but just make the manager ignore them when creating
NMDevices.

Also, many WWAN pseduo-ethernet drivers set NOARP becuase they really
are point-to-point and thus ARP is pointless, and in this case, they
won't have any arptype of ARPHRD_ETHER.  So determining the NMLinkType
from udev must take that into account.
2013-08-07 14:39:00 -05:00
Thomas Haller
ac24000650 core: takeover existing virtual devices in system_create_virtual_device
If a virtual device is about to be added and it already exists, it gets
reused.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-07 12:53:24 -05:00
Dan Williams
1f084567f0 ifcfg-rh: don't require an error for read_mac_address()
No reason to; the caller knows success/failure from the return value
and might want to ignore the error.
2013-08-07 12:53:24 -05:00
Dan Williams
0c8d8b4da3 core: update UDI when it's available
Software devices don't have a UDI until udev finds them, and since we need
to know about the software devices before udev finds them the UDI will be
missing.  Instead of requiring a UDI on NMDevice creation, update the
property from the NMPlatform link change signal when udev does find the
device.

Now that a UDI is no longer required for device creation, software devices
added by NM would be created in the platform_link_added_cb() signal
handler triggered by the various software device creation methods in
system_create_virtual_device() (eg nm_platform_bridge_add() etc).  Then
the NMDevice created in system_create_virtual_device() would be a duplicate
and cause problems when it was added.  Since system_create_virtual_device()
needs to do setup on some devices, suppress the device creation from the
platform link added handler in this function.

Much of this is a hack which should be cleaned up later.
2013-08-07 12:53:24 -05:00
Thomas Haller
81ed5307d3 fixup! core: fix cleanup of NMDevices that fail construction
The unref in finalize is not needed, because the hash table gets already freed
in dispose.

Note that setting available_connections to NULL in dispose is not really
needed, because (altough dispose might be called more than once) there
is a guarded by "priv->disposed = TRUE;". But leave it for clearity in
case somebody tries to access the pointer (which shouldn't happen).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-07 12:53:24 -05:00
Dan Winship
588547b343 core: fix cleanup of NMDevices that fail construction
We were leaving signal handlers attached to devices that failed in
constructor() (and also leaking the available_connections hash). Fix
that.
2013-08-06 16:36:51 -05:00