Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
332420ffec core: fix activation of slave when master is not active, but device exists
NM fails to activate a slave if the master device already exists
but has not active connection.

One way to reproduce, create a bond master/slave configuration and
ensure that the master device exists (e.g. by activating the bond, and
killing NM without taking down the device, or externally via `ip link add`).

If you try to activate the slave it will fail with the following message
(in nmcli):
  "Error: Connection activation failed: The active connection on MASTER is not a valid master for 'SLAVE'"
although MASTER is not active.

This also triggers the following assertion:

    #0  0x0000003370c504e9 in g_logv () from /lib64/libglib-2.0.so.0
    #1  0x0000003370c5063f in g_log () from /lib64/libglib-2.0.so.0
    #2  0x000000000047646a in is_compatible_with_slave (master=0x0, slave=slave@entry=0xc4aa60) at nm-manager.c:2193
    #3  0x000000000047e289 in ensure_master_active_connection (self=self@entry=0xc8d150, subject=0x7f23b80059e0, connection=connection@entry=0xc4aa60, device=device@entry=0xcac380, master_connection=master_connection@entry=0x0,
        master_device=master_device@entry=0xc9e800, error=error@entry=0x7fffa5cc4958) at nm-manager.c:2395
    #4  0x000000000047eb4a in _internal_activate_device (self=self@entry=0xc8d150, active=active@entry=0xcc33b0, error=error@entry=0x7fffa5cc4958) at nm-manager.c:2665
    #5  0x000000000047ecf2 in _internal_activate_generic (self=self@entry=0xc8d150, active=active@entry=0xcc33b0, error=error@entry=0x7fffa5cc4958) at nm-manager.c:2712
    #6  0x000000000047ef2b in _internal_activation_auth_done (active=0xcc33b0, success=<optimized out>, error_desc=0x0, user_data1=0xc8d150, user_data2=<optimized out>) at nm-manager.c:2848
    #7  0x0000000000466fa1 in auth_done (chain=0xcef020, error=0x0, unused=<optimized out>, user_data=<optimized out>) at nm-active-connection.c:603
    #8  0x00000000004753da in auth_chain_finish (user_data=0xcef020) at nm-manager-auth.c:88
    #9  0x0000003370c492a6 in g_main_context_dispatch () from /lib64/libglib-2.0.so.0
    #10 0x0000003370c49628 in g_main_context_iterate.isra () from /lib64/libglib-2.0.so.0
    #11 0x0000003370c49a3a in g_main_loop_run () from /lib64/libglib-2.0.so.0
    #12 0x0000000000429e65 in main (argc=1, argv=0x7fffa5cc4e48) at main.c:678

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-16 19:18:57 +02:00
Thomas Haller
d041775501 keyfile: assert that the connection to be written verifies
Related: https://bugzilla.redhat.com/show_bug.cgi?id=979425

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-16 13:27:26 +02:00
Jiří Klimeš
1553607223 man: clarify an nmcli example for adding static addresses in nmcli-examples 2014-06-16 12:48:04 +02:00
Dan Williams
7545db508f merge: some settings plugin refcounting and use-after-free fixes (bgo #731534) 2014-06-13 15:32:10 -05:00
Dan Williams
c44556a1d5 ifnet: fix use-after-free and refcounting of invalid changed connections
If a valid connection was updated and still valid, and then was
updated and become invalid, the connection would not be properly
removed from the ifnet plugin's priv->connections hash, and thus
would never be disposed.

This was due to using the direct pointer to the connection's UUID
as the key for the hash table.  When a connection is updated and
its settings are replaced, the old UUID is freed and replaced with
a new pointer.  But the ifnet plugin hash table still uses the
old (now freed) UUID pointer as the key.  Thus when the connection
is updated and becomes invalid, looking up the UUID in the hash
table fails to find the connection, and the connection is not
removed from the hash.

This bug could cause a crash in some cases, if two keys of the
GHashTable hashed to the same value, in which case GLib would
call g_str_equal() on the freed pointer.

Since code other than in the ifnet plugin replaces settings,
we cannot be guaranteed that the pointer won't change.  Avoid all
that and just strdup() the UUID when using it as a key.
2014-06-13 15:19:13 -05:00
Dan Williams
72fb1f897f example: fix possible invalid refcounting when changing connections
Since the pointer to the connection's path could change any time
commit_changes() is called, it's not safe to use it as the hash
table key directly.  strdup it instead.
2014-06-13 15:18:47 -05:00
Dan Williams
95e4b6fc1e keyfile: clean up logging connection verify errors
Prevents:

Connection failed to verify: (unknown)
   invalid or missing connection property 'blah blah/foo bar'

Simply removing the warning in reader.c is fine, because callers that
care already log the warning themselves.  Also make the warning in
update_connection() the same as the warning in new_connection().
2014-06-13 15:18:47 -05:00
Dan Williams
3aedc94fa6 keyfile: fix use-after-free and refcounting of invalid changed connections
If a valid connection was updated and still valid, and then was
updated and become invalid, the connection would not be properly
removed from the keyfile plugin's priv->connections hash, and thus
would never be disposed.

This was due to using the direct pointer to the connection's UUID
as the key for the hash table.  When a connection is updated and
its settings are replaced, the old UUID is freed and replaced with
a new pointer.  But the keyfile plugin hash table still uses the
old (now freed) UUID pointer as the key.  Thus when the connection
is updated and becomes invalid, looking up the UUID in the hash
table fails to find the connection, and the connection is not
removed from the hash.

This bug could cause a crash in some cases, if two keys of the
GHashTable hashed to the same value, in which case GLib would
call g_str_equal() on the freed pointer.

Since code other than in the keyfile plugin replaces settings,
we cannot be guaranteed that the pointer won't change.  Avoid all
that and just strdup() the UUID when using it as a key.

(also collapses _internal_new_connection() into its only caller)
2014-06-13 15:18:47 -05:00
Thomas Haller
f0cd5bb866 vpn: fix printf format string for PID by casting to (long)
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-13 16:58:44 +02:00
Dan Winship
f4f4ecf159 settings: remove an unnecessary check
Coverity gets confused and thinks we are potentially leaking bssid_str
here. Given that nm_utils_hwaddr_ntoa() never returns NULL anyway,
just drop the check.
2014-06-12 17:13:56 -04:00
Dan Winship
3c13d9e3fd misc: remove some dead code
The G_DISABLE_CHECKS version of g_return_if_reached() still returns,
it just doesn't log. So don't include a manual return after a
return-if-reached.
2014-06-12 17:13:56 -04:00
Thomas Haller
9f114f661a build: remove libndp location in summary of ./configure
This is a left-over from the early days of libndp when
the libarary was optionally a git-submodule of NetworkManager.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-12 14:58:48 +02:00
Swapnil Nagarkar
2e3523bb43 nmcli autocomplete tab display : rename ERROR to ERR
The nmcli auto completation shows log levels as ERROR.
But giving ERROR it does not work. This should renamed
from ERROR to ERR

https://mail.gnome.org/archives/networkmanager-list/2014-June/msg00019.html

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-12 14:29:13 +02:00
Jiří Klimeš
948a27257a bluetooth: don't crash when switching off bluetooth (rh #1059494)
When connected to a phone via bluetooth and turning bluetooth off on the
computer NetworkManegr crashed due to accessing invalid device.

Reproducer:
- activate bluetooth on a computer and a phone
- pair the devices
- $ nmcli con add type blue con-name phone bt-type panu addr 00:17:EA:84:E7:41
- turn off bluetooth on computer (either with a hardware or software switch)

https://bugzilla.redhat.com/show_bug.cgi?id=1059494
2014-06-12 13:52:45 +02:00
Yegor Yefremov
c62639d572 nm-dispatcher: explicitly include gio/gio.h
Without this header Buildroot's build complains about unknown
types like GFile etc.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-11 18:53:13 +02:00
Jiří Klimeš
9ee3ac20b0 ifcfg-rh: accept IPv6 routes without "via" in route6 file (bgo #697525)
Routes without nexthop are legal and should be treated as a device route
(direct route).

https://bugzilla.gnome.org/show_bug.cgi?id=697525
2014-06-11 10:44:18 +02:00
Jiří Klimeš
e70d5579af cli: don't accept prefix 0 for routes 2014-06-11 10:07:02 +02:00
Jiří Klimeš
4e9fc8ad61 cli: don't accept default route entries, NM handles the default route itself 2014-06-11 09:58:44 +02:00
Jiří Klimeš
700f5ec0ef cli: allow missing next hop for routes (bgo #727615)
https://bugzilla.gnome.org/show_bug.cgi?id=727615
2014-06-11 09:58:39 +02:00
Dan Williams
e8fb3864d1 examples: add Python D-Bus and GI examples for updating IPv4 setting method 2014-06-10 16:20:35 -05:00
Dan Winship
cdd09286d7 core: fix metrics of user-added routes
Adding a route with a metric of 0 to an IP4 or IP6 setting used to
implicitly mean "use the default metric for the device", but this got
broken by 722c9034. Fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=731402
2014-06-10 09:14:48 -04:00
Dan Williams
7c256586da contrib/rpm: misc specfile updates
Unify the obsoletes so they don't have to be changed every time.

Clarify the WWAN package description, since it really applies to
2G/3G/4G devices, not just 3G.

Also sync the glib and dbus-glib required versions with actual
NetworkManager requirements from configure.ac.
2014-06-09 10:45:29 -05:00
Jiří Klimeš
3dccef6631 contrib/rpm: update NetworkManager description in spec file
Text by dcbw.
2014-06-09 11:07:00 +02:00
Jiří Klimeš
1b55014468 libnm-util: don't append NULL in g_string_append() 2014-06-09 10:36:54 +02:00
Jiří Klimeš
b4544182a2 examples: fix get-active-connections-dbus-glib.c example 2014-06-09 10:16:09 +02:00
Jiří Klimeš
a7eae7a553 trivial: typo in the NEWS 2014-06-09 09:15:40 +02:00
Thomas Haller
63ef089f69 platform: pass optional padding to _rebase_relative_time_on_now()
_rebase_relative_time_on_now() is used both by _address_get_lifetime()/nm_platform_ip[46]_address_sync()
and the to_string() functions.

In the latter case, we want to print the original value, without padding. Otherwise in
the addresses are printed in the logs with an additional 5 seconds
padding, which is confusing.

For adding addresses in platform however, we still want to keep the
padding. So pass it on as additional parameter.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-07 11:35:22 +02:00
Thomas Haller
b633711572 libnm-glib: don't use deprecated nm_access_point_get_hw_address()
nm_access_point_get_hw_address() is already deprecated since
pre-0.9.0-beta3 (f30e15a04d). However,
it also is defined as NM_DEPRECATED_IN_0_9_10, because there
are no deprecated macros for previous version.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-07 11:19:02 +02:00
Thomas Haller
8366d7cd1b platform: fix setting preferred time off-by-one in _init_ip_address_lifetime()
This error was introduced only recently with commit
8310a039d8.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-07 11:18:51 +02:00
Thomas Haller
2af20f9389 release: bump version to 0.9.11.0 (development) 2014-06-07 02:09:00 +02:00
Dan Williams
c817409fc0 release: bump version to 0.9.9.95 (0.9.10-beta1) 2014-06-06 18:28:21 -05:00
Dan Williams
3470b3aafd release: update NEWS 2014-06-06 18:28:21 -05:00
Dan Williams
351ab1d76f libnm-glib-vpn: bump soname (1.1.0 -> 1.2.0) for API additions 2014-06-06 18:28:20 -05:00
Dan Williams
08faaf1170 libnm-glib: bump soname (4.7.0 -> 4.8.0) for API additions 2014-06-06 18:28:20 -05:00
Dan Williams
5e9904f451 libnm-util: bump soname (2.5.0 -> 2.6.0) for added API 2014-06-06 18:28:20 -05:00
Dan Williams
33e5e1c500 dispatcher: don't warn on non-critical missing directory error 2014-06-06 18:28:03 -05:00
Thomas Haller
fb88ec99f1 build: create dispatcher directories pre-down.d and pre-up.d
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-07 01:17:16 +02:00
Dan Williams
9433a0bfe0 libnm-util: fix an error noticed by coverity 2014-06-06 17:25:36 -05:00
Dan Williams
dacee1485a cli: fix a couple errors noticed by coverity 2014-06-06 17:25:36 -05:00
Dan Williams
e5ccc30e3c core: suppress missing MAC address warning during connection matching
One of the connetions may not have a MAC address, so don't expect one.
2014-06-06 16:37:03 -05:00
Thomas Haller
bcb9f6c910 cli: fix error parsing input arguments in non-interactive mode
Causes the following failure:

   $ /bin/nmcli connection add type ethernet con-name connie ifname '*'

   (process:13883): GLib-CRITICAL **: g_strchug: assertion `string != NULL' failed
   (process:13883): GLib-CRITICAL **: g_strchomp: assertion `string != NULL' failed
   Error: invalid connection type; '' not among [generic, ...].

Regression introduced by commit bfb1200b4f.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 23:19:49 +02:00
Thomas Haller
5fa1248a2f build: update gitignore file after renaming nm-dispatcher.action executable to nm-dispatcher
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 23:09:16 +02:00
Dan Winship
c4ca23137e core: fix lag in NMManager:state moving to CONNECTED_GLOBAL
Something changed at some point so that NMManager was now recomputing
its state after a connection was activated, but before NMPolicy had
decided whether to give that connection the default route, meaning
NMManager would set the state to CONNECTED_LOCAL rather than
CONNECTED_GLOBAL.

Fix this by watching the active connection :default and :default6
properties too, so we do the right thing regardless of what order the
AC properties change in.
2014-06-06 15:33:03 -04:00
Dan Williams
67b228d16b merge: add blocking dispatcher pre-up and pre-down events (bgo #387832)
https://bugzilla.gnome.org/show_bug.cgi?id=387832
https://bugzilla.redhat.com/show_bug.cgi?id=1048345
https://bugzilla.redhat.com/show_bug.cgi?id=982734
2014-06-06 14:15:21 -05:00
Dan Williams
02252224e2 dispatcher: bump overall timeout to 10 minutes (rh #982734) (rh #1048345)
Since NM now handles long-running dispatcher scripts better, allow them
to run for really long times.
2014-06-06 13:43:47 -05:00
Dan Williams
fd5761ecb2 dispatcher: don't use NULL error domains
glib doesn't like it, plus we don't use the error anyway, so just
return the constant error string.
2014-06-06 13:43:47 -05:00
Dan Williams
df601ad68c dispatcher: enhance debug logging
Attach a request ID to every request, and print that out in the debug
messages so you can see which results match up with which dispatcher
requests.
2014-06-06 13:43:47 -05:00
Dan Williams
1383f4bc14 dispatcher: use separate directories for pre-up/pre-down events
To ensure that NetworkManager does not block needlessly for events
which have no scripts, require scripts that respond to blocking
events to opt into the action.
2014-06-06 13:43:46 -05:00
Dan Williams
7eaaa6a475 core: block on dispatcher scripts when quitting
Like VPN connections, block on dispatcher scripts when quitting.  Since
the event loop is no longer running we can't schedule callbacks.
2014-06-06 13:43:46 -05:00
Dan Williams
38e6b7387f core: implement PRE_UP dispatcher actions 2014-06-06 13:43:46 -05:00