Commit Graph

4279 Commits

Author SHA1 Message Date
Dan Winship
ba96409f72 ifcfg-rh: remove a stray reference to bridges and vlans being unsupported 2013-10-29 14:14:26 -04:00
Jiří Klimeš
912152cf85 ifcfg-rh: fix crash when doing managed->unmanaged transition
Testcase:
* add 'NM_CONTROLLED=no' to /etc/sysconfig/network-scripts/ifcfg-ABC
* sudo nmcli con reload
* ... NM asserts ...

We need to ref() 'existing' connection before nm_settings_connection_signal_remove(),
because the function  unref()s ithe connection via connection_removed_cb().

Backtrace:
 ...
 #4  0x00007fbcf0ea0cba in g_assertion_message_expr (domain=domain@entry=0x0,
     file=file@entry=0x7fbcf4e5805d "nm-dbus-manager.c", line=line@entry=848,
     func=func@entry=0x7fbcf4e585e0 <__FUNCTION__.15088> "nm_dbus_manager_unregister_object", expr=expr@entry=0x7fbcf4e5820b "G_IS_OBJECT (object)")
     at gtestutils.c:2293
 #5  0x00007fbcf4de69d9 in nm_dbus_manager_unregister_object (
     self=0x7fbcf6fdc9c0, object=0x7fbcf70235c0) at nm-dbus-manager.c:848
 #6  0x00007fbcf4dd6a23 in nm_settings_connection_signal_remove (
     self=<optimized out>) at settings/nm-settings-connection.c:1541
 #7  0x00007fbce6fee884 in connection_new_or_changed (
     self=self@entry=0x7fbcf7006f80,
     path=path@entry=0x7fbcf70c3f80 "/etc/sysconfig/network-scripts/ifcfg-ABC",
     existing=existing@entry=0x7fbcf70235c0,
     out_old_path=out_old_path@entry=0x7fff2b7b8988) at plugin.c:327
 #8  0x00007fbce6feeca2 in read_connections (plugin=0x7fbcf7006f80)
     at plugin.c:453
 #9  0x00007fbcf4dd8e98 in impl_settings_reload_connections (
     self=0x7fbcf6fd98c0, context=0x7fbcf70bcb30) at settings/nm-settings.c:1262
 ...
2013-10-29 15:21:49 +01:00
Thomas Haller
3f3f2a82d0 bond: use platform functions for writing sysfs
Refactor writing the bonding options, to use again the platform
function for the sysfs options.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-25 22:32:47 +02:00
Thomas Haller
4b85408e34 bond: handle bond options more gracefully
Support new bonding options and set them carefully. The options cannot
be set arbitrarily because they interfere with each other.

This commit is forward-ported from rhel-6.5, see patch
rh901662-bond-more-options.patch, originally written by Dan Williams.

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

Co-Authored-By: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-25 22:32:47 +02:00
Jiří Klimeš
75723221f2 wifi: use NM_SETTING_WIRELESS_MODE_* constants for mode property
and thus fix "infra" -> "infractructure"
2013-10-25 13:46:42 +02:00
Dan Winship
0a557ac01d core: fix crash when activating a never-default IPv4 connection 2013-10-24 15:15:02 -04:00
Jiří Klimeš
5bbde1b87e core: fix an error message - connection ID vs. interface name 2013-10-24 12:19:20 +02:00
Jiří Klimeš
f4dbf27410 core: track autoconnect for removed software devices (rh #1005913)
When an interface is manually disconnected NM remembers that, and prevents
automatic activation of the device.
However, software devices are removed when they are disconnected, and thus
the state of the device is lost. We need to track autoconnect outside the
device - hash table of interface names not allowed to activate automatically.

Without that the device would be auto-activated again and again, even if
explicitly disconnected.
Test case:
$ nmcli con add type bond ifname bb con-name bb-con
$ nmcli con add type bond-slave ifname em1 con-name b1-con master bb
$ nmcli dev disconnect bb

https://bugzilla.redhat.com/show_bug.cgi?id=1005913
2013-10-24 11:58:18 +02:00
Jiří Klimeš
1a67f8df03 ifcfg-rh: always read (and write) static IP addresses (rh #998135)
Static IP addresses were only read from ifcfg-* file when IP method was
'manual' (BOOTPROTO=none|static). This was to match the legacy initscripts
behaviour. However, NetworkManager supports using additional static IPs in
addition to automatically obtained (DHCP, etc.) addresses. So we now read
static IPs even for automatic methods to be able to use this feature.

https://bugzilla.redhat.com/show_bug.cgi?id=998135
2013-10-24 10:09:57 +02:00
jvoisin
00ffb78c8d core: add support for EAP-PWD authentication 2013-10-23 21:07:30 -05:00
Thomas Haller
3eb1d5e902 core: cleanup freeing of glib collections of pointers
When freeing one of the collections such as GArray, GPtrArray, GSList,
etc. it is common that the items inside the connections must be
freed/unrefed too.

The previous code often iterated over the collection first with
e.g. g_ptr_array_foreach and passing e.g. g_free as GFunc argument.
For one, this has the problem, that g_free has a different signature
GDestroyNotify then the expected GFunc. Moreover, this can be
simplified either by setting a clear function
(g_ptr_array_set_clear_func) or by passing the destroy function to the
free function (g_slist_free_full).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Thomas Haller
1c93b24829 core: fix memory leak in nm-agent-manager
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Thomas Haller
35b19dcfc3 core: fix memory leak in nm-dhcp-dhclient
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:53:57 +02:00
Thomas Haller
94bcecdb14 keyfile: always chain-up parent constructor in keyfile dispose method
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 19:22:59 +02:00
Thomas Haller
c38be4ef4b core: keep nm_connection_provider_get_connections in private instead of static data
nm_connection_provider_get_connections returns an internally kept
constant list to simplify handling for the users. Do not cache this
list in a static variable, instead put it in a private field.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 18:45:22 +02:00
Thomas Haller
c67f978df0 core: fix compiler warnings -Werror=shadow by trivial renaming of variables
https://bugzilla.gnome.org/show_bug.cgi?id=710497

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 18:45:22 +02:00
Dan Winship
00b29b6c61 core: fix NMManager:primary-connection when a VPN has the default route
If a VPN had the default route, :primary-connection would become NULL,
which is exactly what it's not supposed to do. Fix it to have the
value it's supposed to.

https://bugzilla.gnome.org/show_bug.cgi?id=710207
2013-10-21 16:18:11 -04:00
Pavel Šimerda
8e17fc2aa4 device: remove unused 'dev_state' variable
Reported-by: Julien Nabet <serval2412@yahoo.fr>
2013-10-20 18:24:26 +02:00
Pavel Šimerda
f7ff042819 platform: use translated VLAN flags
The internal VLAN flags were translated into the kernel VLAN flags but
finally the internal ones were passed to the kernel instead.

Reported-by: Julien Nabet <serval2412@yahoo.fr>
2013-10-20 18:20:53 +02:00
Yuri Chornoivan
61de24ba35 Fix typos
https://bugzilla.gnome.org/show_bug.cgi?id=710505
2013-10-19 11:49:18 -04:00
Thomas Haller
72da550f68 bluez: remove created NAP connection together with NMBluezDevice
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 20:12:10 +02:00
Thomas Haller
4ba86e2cc8 bluez: fix calling of bdaddr added/removed signals in nm-bluez4-adapter
Fix several issues with emitting the BDADDR_ADDED/BDADDR_REMOVED
signals:

 - when removing a device, the handlers were never disconnected from
   the device's notify::usable and initialized signals.
 - ensure that the signals BDADDR_ADDED/BDADDR_REMOVED only get emitted
   in a consistent way (toggeling). Before, there was a bug, that the
   signal BDADDR_REMOVED was emitted for devices that were never added
   and never usable.

Co-Authored-By: Dan Williams <dcbw@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Thomas Haller
28a6f11b2c bluez: use GDBus instead of dbus-glib in nm-bluez-device.c
Refactor nm-bluez-device.c to use GDBus both to connect to
BlueZ 4 and BlueZ 4.

Also remove the unused property RSSI.

Also prefix every logline with the dbus path of the device.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Thomas Haller
bf5a6ad443 bluez: enable both BlueZ4 and 5 and select it dynamically at runtime
NMBluezManager is now a proxy and only delegates to either
NMBluez4Manager or NMBluez5Manager. It detects the running BlueZ
version at runtime, and once it decides for one version, it cannot be
changed anymore as long NetworkManager is running.

This means, when switching from BlueZ4 to BlueZ5 or vice versa you have
to restart NetworkManager. This should be acceptable, because it is
not a common use case (most systems won't have both versions installed
anyway) and it greatly simplifies implementation.

Also note that NMBluez4Manager and NMBluez5Manager do not implement a
common interface. NMBluezManager delegates to the correct manager.
Having them share an common interface or base class would not simplify
the code, because NMBluezManager not only delegates, but it also acts as
a proxy until it is decided which BlueZ version is running. So, this
proxy-like behaviour would still be needed. The alternative would be to
merge the functionality of all three NMBluez*Manager classes into one.

This also removes the --enable-bluez4 configure switch, because both
versions are now always enabled.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Thomas Haller
3344ce9ff6 bluez: copy bluez-manager file for version 4 and 5
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Thomas Haller
ef8501096f bluez: rename BlueZ 4 adapter to make the BlueZ version explicit
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Thomas Haller
e8e8031676 bluez: support BlueZ 4 and 5 together in nm-bluez-device.c
Do no longer separate nm-bluez-device at compile time with the
WITH_BLUEZ4 preprocessor flag.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Thomas Haller
b3ec1587d3 bluez: rename variables in nm-bluez-common.h for BlueZ 4 vs. 5
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Thomas Haller
e46722b72b core: make callback argument in nm_settings_connection_commit_changes/_delete optional
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-18 19:56:37 +02:00
Dan Williams
6b8bf26b79 platform: don't treat unrecognized WiMAX devices as Ethernet
If the WiMAX plugin isn't installed, or the WiMAX device isn't
recognized, NetworkManager shouldn't treat the interface as
regular ethernet since the device requires specific setup to
be ready for IP configuration, which of course NetworkManager
can't do because the WiMAX plugin isn't loaded.  Ignore them
instead.
2013-10-18 11:28:01 -05:00
Jiří Klimeš
33f8218023 trivial: fix indentation in nm_manager_activate_connection() 2013-10-18 09:02:26 +02:00
Dan Williams
de45e49eb8 settings: document nm_settings_add_connection() 2013-10-17 13:04:37 -05:00
Dan Williams
1fe5c197d2 settings: clarify ownership of objects returned from plugin's add_connection() hook
Plugin owns the object and callers must reference it if they wish to use it outside
of the function they called "add" from.  Likewise, callers of the ConnectionProvider's
add_connection method must also reference the returned object if they wish to
continue using it.
2013-10-17 13:03:39 -05:00
Jiří Klimeš
fbf2ca9ec3 dhcp: don't crash when no DHCP client is available (rh #1015809)
Print a warning instead.

https://bugzilla.redhat.com/show_bug.cgi?id=1015809
2013-10-17 15:10:09 +02:00
Thomas Haller
bc092bcf44 core: announce device removal even for udev events with no ifindex property
Actually, this case should no longer happen, but just to be sure:
when a udev remove event without ifindex comes, get the ifindex from
the cache and announce the device removal.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-17 10:56:57 +02:00
Dan Winship
d59311b095 platform: fix srcdir != builddir build after last change 2013-10-16 13:44:54 -04:00
Dan Williams
473018d8b2 platform: detect non-mac80211 WiFi devices as WiFi (rh #1015598)
Before NMPlatform landed, the old NMManager code looked at either
DEVTYPE=wlan or asked the internal wifi utilities whether the
device was WiFi or not.  This got lost when moving to NMPlatform.

It turns out that only mac80211-based drivers set the DEVTYPE=wlan
flag in sysfs, while older WEXT, out-of-tree, and staging drivers
often do not (though they should).

To avoid breaking recognition of these crappy drivers that used
to work, re-add the wifi utils checks.
2013-10-16 12:35:37 -05:00
Dan Winship
79407f0c37 settings: normalize and verify connections on update
When a connection is updated (either by its plugin or via D-Bus), we
need to normalize and verify it before accepting the changes.
2013-10-16 13:27:23 -04:00
Jiří Klimeš
a6944e157b platform: fix getting "ifindex" for devices on 'remove' udev action
We have to get IFINDEX using g_udev_device_get_property() instead of
g_udev_device_get_sysfs_attr().

On removal the IFINDEX in sysfs may not be available - this didn't caused
problems because such an event was ignored. But sometimes the sysfs IFINDEX
in 'remove' action was present, but *wrong*. It contained IFINDEX of a newly
created device of the same name, and thus it triggered removal of the new
device instead of the old one.

Logs (grepped):
...
NetworkManager[30628]: <info> Auto-activating connection 'b1'.
NetworkManager[30628]: <debug> [1381930187.149545] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (328)
NetworkManager[30628]: <debug> [1381930187.937222] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'add' subsys 'net' device 'bb' (328)
NetworkManager[30628]: <debug> [1381930187.937662] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (328)
NetworkManager[30628]: <info> (bb): deactivating device (reason 'user-requested') [39]
NetworkManager[30628]: <debug> [1381930193.266097] [platform/nm-platform.c:397] nm_platform_link_delete(): link: deleting 'bb' (328)
NetworkManager[30628]: <debug> [1381930193.279324] [platform/nm-platform.c:1777] log_link(): signal: link removed: bb (328)
NetworkManager[30628]: <debug> [1381930193.348167] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'remove' subsys 'net' device 'bb' (unknown)
NetworkManager[30628]: <info> Auto-activating connection 'b1'.
NetworkManager[30628]: <debug> [1381930193.561106] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (330)
NetworkManager[30628]: <debug> [1381930194.217300] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'add' subsys 'net' device 'bb' (330)
NetworkManager[30628]: <debug> [1381930194.217548] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (330)
NetworkManager[30628]: <info> (bb): deactivating device (reason 'user-requested') [39]
NetworkManager[30628]: <debug> [1381930216.329118] [platform/nm-platform.c:397] nm_platform_link_delete(): link: deleting 'bb' (330)
NetworkManager[30628]: <debug> [1381930216.344442] [platform/nm-platform.c:1777] log_link(): signal: link removed: bb (330)
NetworkManager[30628]: <info> Auto-activating connection 'b1'.
NetworkManager[30628]: <debug> [1381930216.598636] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (332)

This line is bad:
NetworkManager[30628]: <debug> [1381930217.79182] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'remove' subsys 'net' device 'bb' (332)

NetworkManager[30628]: <debug> [1381930217.81009] [platform/nm-platform.c:1777] log_link(): signal: link removed: bb (332)
NetworkManager[30628]: <info> (bb): deactivating device (reason 'removed') [36]
NetworkManager[30628]: <debug> [1381930217.95192] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'add' subsys 'net' device 'bb' (332)
NetworkManager[30628]: <debug> [1381930217.95492] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (332)
NetworkManager[30628]: <info> Auto-activating connection 'b1'.
...
2013-10-16 19:00:45 +02:00
Jiří Klimeš
8ecbe53f37 platform: log links in event_notification() in debug mode 2013-10-16 17:28:04 +02:00
Thomas Haller
1d0a26e19d core: print ifindex when logging UDEV event
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-15 19:45:42 +02:00
Dan Winship
f03635e5ac core: don't have IP4 and IP6 configs on slaves
Although it's convenient in some places to have IP configs on all
connections, it makes more sense in other places to not have IP
configs on slaves. (eg, it's confusing for nmcli, etc, to report a
full NMSettingIP4Config on a slave device). So revert parts of the
earlier patch. However, it's still safe to assume that s_ip4 != NULL
if method != DISABLED, so some of the earlier simplifications can
stay.

Also, add nm_utils_get_ip_config_method(), which returns the correct
IP config method for a connection, whether the connection has IP4 and
IP6 settings objects or not, and use that to keep some more of the
simplifications from the earlier patch.
2013-10-14 12:07:37 -04:00
Thomas Haller
8a046bedbb core: fix crash for bridge-slave with missing NMSettingBridgePort setting
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-11 19:53:33 +02:00
Dan Winship
0a77cf6320 ifcfg-rh: fix handling of minimal ifcfg files
ifcfg-rh had the rule that if an ifcfg file had no BOOTPROTO and no
IPv4 addresses, then it should be treated as method=auto for
compatibility. But in fact, current ifup treats it as method=disabled,
so we should too.

https://bugzilla.gnome.org/show_bug.cgi?id=708875
2013-10-11 12:24:34 -04:00
Dan Winship
68f12b4e9c settings: make connections always have s_ip4 and s_ip6
Make sure that all connections returned from NMSettings or created via
AddAndActivateConnection have an NMSettingIP4Config and an
NMSettingIP6Config, with non-NULL methods, and get rid of
now-unnecessary checks for those.

Also move the slaves-can't-have-IP-config checks into the
platform-independent code as well. This also gets rid of spurious
"ignoring IP4/IP6 configuration" warnings in ifcfg-rh when reading a
slave ifcfg file.

Partly based on a patch from Pavel.

https://bugzilla.gnome.org/show_bug.cgi?id=708875
2013-10-11 12:24:34 -04:00
Dan Williams
09bde40f02 core: fix PropertiesChanged signals for IP-related properties
To present a consistent API to clients, the IP-related properties
are only valid when the device has finished IP configuration.  But
they are set before that happens, and their change notifications
were emitted before the IP configuration was considered valid.
Re-emit the change notifications when the device enters the IP_CHECK
state (and thus has IP configuration) and also when the device
deactivates to enusre clients have up-to-date IP-related property
information.

For the changes to has_ip_config(), the priv->ipX_state checks are
not necessary since the device will have valid IP configuration
when it enters the IP_CHECK state.  The other checks can be
consolidated into a single statement.

Acked-by: Dan Winship
2013-10-09 13:59:42 -05:00
Dan Williams
b5fa0fec1c trivial: remove unnecessary warning 2013-10-09 09:39:57 -05:00
Dan Williams
9543e45afe core: allow IPv4 to proceed if IPv6 is globally disabled but set to "auto" (rh #1012151)
If the user disabled IPv6 support in the kernel with "ipv6.disable=1" on the
kernel boot line, then any attempts to open IPv6 sockets (which libndp does)
will fail.  This failed the entire connection, even if IPv6's "may-fail"
property was TRUE.  Instead, just fail IPv6 and allow IPv4 to proceed.  If
IPv4 fails or is disabled, then other logic will fail the entire connection.
2013-10-07 11:53:18 -05:00
Jiří Klimeš
2af8c08f65 ifcfg-rh: ignore default routes in route6 file (rh #991807)
Base on patch from Francesco Prelz <Francesco Prelz mi infn it>:
https://mail.gnome.org/archives/networkmanager-list/2013-January/msg00095.html

https://bugzilla.redhat.com/show_bug.cgi?id=991807
2013-10-07 18:10:27 +02:00
Dan Williams
87041545b4 ifcfg-rh: fix ignoring updates that don't change anything
connection_from_file() requires the 'error' parameter.  Not passing a
valid 'error' parameter causes the function to fail and return NULL,
which mean that commit_changes() would always re-write the connection
instead of ignoring commits where nothing has actually changed.

connection_from_file() no longer requires the unmanaged, keyfile,
or routefile parameters, so remove them.
2013-10-04 23:43:25 -05:00