Commit Graph

13873 Commits

Author SHA1 Message Date
Dan Winship
a564dafc35 ifcfg-rh/tests: removed unused connection_from_file_test() args
Don't pass &keyfile, &routefile, and &route6file if we aren't going to
use the return value.

Don't pass &unmanaged if we aren't going to check it. (And when we do
check it, don't g_free() it if we've asserted that it's NULL.)
2014-12-18 11:33:28 -05:00
Dan Winship
1600ed9c68 ifcfg-rh/tests: remove gratuituous checks
A bunch of tests appear to have copy-and-pasted the same unnecessary
check for route6file having been created. Remove them.
2014-12-18 11:33:28 -05:00
Dan Winship
12bfaf5a8d ifcfg-rh: remove "ignore_error" arg from connection_from_file()
Instead of having connection_from_file() return a flag telling its
caller whether to log a warning or not, just have it log the warning
(or not) itself.
2014-12-18 11:33:28 -05:00
Dan Winship
356849f70c ifcfg-rh: split connection_from_file() / connection_from_file_test()
Rather than having the "real" users of connection_from_file() have to
pass a dozen NULL arguments, add a separate
connection_from_file_test() for use by test-ifcfg-rh. (Likewise, since
no test cases care about ignore_error, remove that argument from
connection_from_file_test().)
2014-12-18 11:33:28 -05:00
Dan Williams
5f47182534 core: fix setting initial EXTERNAL_DOWN unmanaged flag (bgo #725647) (rh #1030947) (bgo #740702)
Broken by 5fb20d8038.
2014-12-18 10:26:46 -06:00
Dan Williams
894ca75f3a trivial: add some debug messages on device destruction/removal 2014-12-18 10:23:06 -06:00
Dan Williams
27c1a73ae0 core: don't bounce disable_ipv6 if NM IPv6LL wasn't enabled (bgo #740702)
If NM IPv6LL wasn't enabled then there is no need to bounce disable_ipv6
to tell the kernel to re-enable kernel IPv6LL, because kernel IPv6LL
is already enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=740702
2014-12-17 11:34:55 -06:00
Thomas Haller
b169f222bf platform/tests: for route tests, add test routes with a different metric
If we have NM running, adding a route with metric 20 might conflict
and cause NM to remove the route.

Choose a different (higher) metric that is less likely to cause a
conflict.
2014-12-16 23:55:02 +01:00
Mikko Rapeli
fe95185f6f core: tell systemd to restart NetworkManager.service if it exited with failure (bgo #741587)
Crashed NetworkManager.service was not restarted by systemd.

Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>

https://bugzilla.gnome.org/show_bug.cgi?id=741587
2014-12-16 16:21:15 -06:00
Dan Williams
0d266a6287 merge: don't manage external software devices until IFF_UP or IP config (bgo #725647) (rh #1030947) 2014-12-16 16:09:12 -06:00
Dan Williams
b86c511db5 core: don't bring up devices using assumed connections (bgo #725647) (rh #1030947)
We want to export the IP configuration of interfaces when they have some, but
the kernel doesn't care if they are IFF_UP or not.  Neither should NetworkManager,
so don't force devices IFF_UP just because we're assuming their IP config.
2014-12-16 16:07:50 -06:00
Dan Williams
5fb20d8038 core: don't manage externally created software devices until IFF_UP (rh #1030947) (bgo #725647)
Externally created software devices would be managed/assumed immediately
upon creation, which includes setting them IFF_UP and possibly turning
on NM-managed IPv6LL.

With this commit, expected behavior for external software devices is:

1) created: unmanaged state, no further action
2) IP address added but !IFF_UP: connection assumed, but device is not set IFF_UP
3) slave attached but !IFF_UP: connection assumed, but master is not set IFF_UP
3) set IFF_UP: connection assumed (if any), if not -> DISCONNECTED

This branch ensures that external software devices are not set IFF_UP
by NetworkManager when they are discovered.  It additionally ensures that
they are not set IFF_UP during connection assumption.  They may be set
IFF_UP later through specific user action.

https://bugzilla.gnome.org/show_bug.cgi?id=725647
https://bugzilla.redhat.com/show_bug.cgi?id=1030947
2014-12-16 16:07:49 -06:00
Dan Williams
5f04324f8b core: don't assume connections for INTERNAL or PARENT unmanaged devices
INTERNAL is actually a nop right now because the only thing that
sets it is suspend/resume, which is covered by the preceding
manager_sleeping() call.  But we may use this more in the future,
so add it while we're here.

Devices that are unmanaged because their parent is unmanaged
probably shouldn't assume connections either, per 4e105c50.
2014-12-16 16:00:48 -06:00
Dan Williams
5a051ad716 core: don't auto-launch logind (bgo #741572)
logind might need the network for login information, and apparently
it fails hard if the network isn't up, and apparently it doesn't
recover when the network does come up.  Since NM doesn't actually
care about suspend/resume until logind is running anyway, don't
auto-launch it.  Just wait until it shows up.

While we're at it, make proxy creation async.

https://bugzilla.gnome.org/show_bug.cgi?id=741572
2014-12-16 09:24:56 -06:00
Dan Winship
8d96273870 libnm: remove __libnm_local section from version script
I had argued for putting the local symbols in their own section, since
it doesn't make sense to have local symbols introduced in 1.2 in the
libnm_1_0_0 section... but apparently even if the section has no
exported symbols, rpm's find-provides still picks it up if it's there,
creating an ugly additional "provides" for libnm. So get rid of that.
2014-12-15 15:49:39 -05:00
Jiří Klimeš
fa94aaf3a5 merge: fix all defects found by coverity (bgo #741122)
https://bugzilla.gnome.org/show_bug.cgi?id=741122
2014-12-15 16:36:14 +01:00
Jiří Klimeš
5252287209 tests: fix NEGATIVE_RETURNS (CWE-394) in tests
Error: NEGATIVE_RETURNS (CWE-394): [#def8]
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:139: negative_return_fn: Function "fork()" returns a negative number.
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:139: var_assign: Assigning: signed variable "pgid" = "fork".
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:163: negative_returns: "pgid" is passed to a parameter that cannot be negative.

Error: NEGATIVE_RETURNS (CWE-394): [#def9]
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:302: negative_returns: A negative constant "-1" is passed as an argument to a parameter that cannot be negative.
NetworkManager-1.1.0/src/tests/test-general-with-expect.c:81:2: neg_sink_parm_call: Passing "sig" to "nm_utils_kill_child_async", which cannot accept a negative number.
NetworkManager-1.1.0/src/NetworkManagerUtils.c:448:2: neg_sink_parm_call: Passing "sig" to "kill", which cannot accept a negative number.
2014-12-15 16:25:27 +01:00
Jiří Klimeš
ce6323d4df tests: mute coverity INFINITE_LOOP error
Error: INFINITE_LOOP (CWE-835): [#def17]
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:93: loop_top: Top of the loop.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:94: loop_bottom: Bottom of the loop.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:93: loop_condition: If "notified" is initially true then it will remain true.

Error: INFINITE_LOOP (CWE-835): [#def18]
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:191: loop_top: Top of the loop.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:192: loop_bottom: Bottom of the loop.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:191: loop_condition: If "result & NOTIFY_MASK" is initially true then it will remain true.
NetworkManager-0.9.11.0/libnm/tests/test-nm-client.c:191: loop_condition: If "result & SIGNAL_MASK" is initially true then it will remain true.
2014-12-15 16:25:27 +01:00
Jiří Klimeš
405d198e7c ifcfg-rh: coverity complained about not checking stat() return value
Error: CHECKED_RETURN (CWE-252): [#def21]
NetworkManager-0.9.11.0/src/settings/plugins/ifcfg-rh/plugin.c:676: check_return: Calling "stat("/etc/hostname", &file_stat)" without checking return value. This library function may fail and return an error code. [Note: The source code implementation of the function has been overridden by a builtin model.]
2014-12-15 16:25:11 +01:00
Jiří Klimeš
4da19b8981 device: mute coverity CHECKED_RETURN (CWE-252)
Error: CHECKED_RETURN (CWE-252): [#def20]
NetworkManager-0.9.11.0/src/devices/nm-device.c:5037: check_return: Calling "g_spawn_async" without checking return value (as is done elsewhere 12 out of 13 times).
2014-12-15 14:11:03 +01:00
Jiří Klimeš
6603e7ffde tests: mute coverity for CHECKED_RETURN (CWE-252) in tests
Error: CHECKED_RETURN (CWE-252): [#def12]
NetworkManager-0.9.11.0/libnm-core/tests/test-general.c:348: check_return: Calling "nm_setting_verify" without checking return value (as is done elsewhere 37 out of 45 times).
...
2014-12-15 14:11:03 +01:00
Jiří Klimeš
afb0e2c53c libnm-core: mute coverity for RESOURCE_LEAK (CWE-772) in g_return_val_if_fail()
Error: RESOURCE_LEAK (CWE-772): [#def10]
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:225: alloc_fn: Storage is returned from allocation function "priority_map_new_from_str".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:154:4: alloc_fn: Storage is returned from allocation function "g_malloc0".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:154:4: var_assign: Assigning: "p" = "g_malloc0(8UL)".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:164:2: return_alloc: Returning allocated memory "p".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:225: var_assign: Assigning: "item" = storage returned from "priority_map_new_from_str(map, str)".
NetworkManager-0.9.11.0/libnm-core/nm-setting-vlan.c:226: leaked_storage: Variable "item" going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK (CWE-772): [#def11]
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2056: alloc_fn: Storage is returned from allocation function "crypto_make_des_aes_key".
NetworkManager-0.9.11.0/libnm-core/crypto.c:405:2: alloc_fn: Storage is returned from allocation function "g_malloc0".
NetworkManager-0.9.11.0/libnm-core/crypto.c:405:2: var_assign: Assigning: "key" = "g_malloc0(digest_len + 1U)".
NetworkManager-0.9.11.0/libnm-core/crypto.c:407:2: noescape: Resource "key" is not freed or pointed-to in function "crypto_md5_hash".
NetworkManager-0.9.11.0/libnm-core/crypto.c:769:24: noescape: "crypto_md5_hash(char const *, gssize, char const *, gssize, char *, gsize)" does not free or save its pointer parameter "buffer".
NetworkManager-0.9.11.0/libnm-core/crypto.c:415:2: return_alloc: Returning allocated memory "key".
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2056: var_assign: Assigning: "key" = storage returned from "crypto_make_des_aes_key("DES-EDE3-CBC", &salt[0], salt_len, in_password, &key_len, NULL)".
NetworkManager-0.9.11.0/libnm-core/nm-utils.c:2057: leaked_storage: Variable "key" going out of scope leaks the storage it points to.
2014-12-15 14:10:55 +01:00
Jiří Klimeš
bcd5b2cdc1 cli: fix DEADCODE (CWE-561) found by coverity
Error: DEADCODE (CWE-561): [#def3]
NetworkManager-0.9.11.0/clients/cli/utils.c:488: cond_notnull: Condition "input", taking true branch. Now the value of "input" is not "NULL".
NetworkManager-0.9.11.0/clients/cli/utils.c:517: notnull: At condition "input", the value of "input" cannot be "NULL".
NetworkManager-0.9.11.0/clients/cli/utils.c:517: dead_error_condition: The condition "input" must be true.
NetworkManager-0.9.11.0/clients/cli/utils.c:517: dead_error_line: Execution cannot reach the expression """" inside this statement: "g_set_error(error, 1U, 0, d...".
2014-12-12 22:43:33 +01:00
Jiří Klimeš
ed088b0df7 cli: mute coverity for Error: DEADCODE (CWE-561)
It can't recognize that the variables are set when parsing arguments.
2014-12-12 22:43:33 +01:00
Dan Williams
471375a3e1 release: remove "nano" version
Now that NM is >= 1.0 there is no need for a "nano" version.
2014-12-12 15:06:39 -06:00
Dan Williams
fa6a9e9dbf release: bump version to 1.1 (development) 2014-12-12 14:33:10 -06:00
Thomas Haller
86b6fd01cb team: only proceed with stage2 when team device is STATE_PREPARE
The team device might already be in a different state because
activation failed. In this case, we don't want to proceed with
stage2.
2014-12-12 18:42:37 +01:00
Dan Williams
1172178ce6 core: better handle DHCP expiry/nak during initial lease acquisition (bgo #739482)
When dhclient trieds to request a previous lease and the server NAKs that
lease, dhclient emits the EXPIRE state.  dhcpcd has also been known to emit
the 'nak' state for the same reason.

(systemd's DHCP client code does not push a NAK up to NetworkManager, but
jumps to the REBOOT state instead, so it is unaffected by this issue.)

NetworkManager saw the expire during IP configuration and treated that as
full activation failure.  The connection would be restarted, the same lease
requested, and the same NAK delivered, over and over.  Before a lease is
acquired, there is (by definition) no lease to expire, so these events
should be ignored.

We do, however, still want to handle abnormal failures, which is why
this patch splits the EXPIRE case from the FAIL case and handles them
separately.

https://bugzilla.gnome.org/show_bug.cgi?id=739482
2014-12-12 11:00:00 -06:00
Jiří Klimeš
77bfcdc2e7 utils: add missing va_end macro in nm_utils_uuid_generate_from_strings()
Error: VARARGS (CWE-237): [#def19]
NetworkManager-0.9.11.0/src/NetworkManagerUtils.c:1748: va_init: Initializing va_list "args".
NetworkManager-0.9.11.0/src/NetworkManagerUtils.c:1758: missing_va_end: va_end was not called for "args".

Fixes: 9a08d8602c
2014-12-12 16:22:57 +01:00
Dan Williams
9337a13a87 core: fix attaching managed slaves to master devices (rh #1141266)
Broken by 25387cd1ff

When an activation request comes in via D-Bus for a slave, the
slave device's priv->master is set in stage1 in master_ready_cb().
Then nm_device_bring_up() is called on the slave, which triggers
link_changed_cb() and device_link_changed().  That then executes
this code:

if (priv->master)
	nm_device_enslave_slave (priv->master, self, NULL);

which enslaves the slave, but due to the NULL will not configure
the slave.

This code was only meant to be run for externally triggered
master/slave changes.
2014-12-11 17:56:04 -06:00
Dan Williams
7d5c0db53a core: fix warning when releasing slaves on exit (rh #1169936)
NetworkManager[30304]: <info>  (virbr0): bridge port virbr0-nic was detached
NetworkManager[30304]: (devices/nm-device.c:962):nm_device_release_one_slave: runtime check failed: (reason == NM_DEVICE_STATE_REASON_NONE)
NetworkManager[30304]: <info>  (virbr0-nic): released from master virbr0

If the slave is removed, then the master is already cleaned up so NM
doesn't need to do anything.  5dd48f fixed that but forgot to update
the !configure case, causing the warning but no other problems.

Fixes: 5dd48f7527
2014-12-11 16:22:32 -06:00
Jiří Klimeš
da4a98bfbb man: allow installing pre-built manual pages if we can't build it
If we have ENABLE_GTK_DOCS, but not BUILD_SETTING_DOCS, nm-settings.5
nm-settings-keyfile.5 and nm-settings-ifcfg-rh.5 would not be installed.

(It happened on RHEL 7 build, due to missing BuildRequires: pygobject3-base)
2014-12-11 17:05:36 +01:00
Dan Williams
a1f4794c86 core: clean up half-done IP operations when re-entering NEED_AUTH state (bgo #741342)
When the device decides it needs re-auth during IP config and returns
to the NEED_AUTH state, make sure we clean up any half-done IP operations
since they will be re-started after auth is completed and the
IP_CONFIG state is re-entered.

https://bugzilla.gnome.org/show_bug.cgi?id=741342
2014-12-11 09:24:48 -06:00
Dan Williams
67bf5cb1a3 build: add --enable-lto to enable Link Time Optimization (bgo #741140)
Takes about 3x as long to build with gcc 4.8, but gcc 4.9
is supposed to speed that up considerably.

Name           Before   After   Saved
-------------------------------------
NetworkManager  1734744  1689728   3%
libnm           1263536   808816  36%
nm-iface-helper  931136   906496   3%
libnm-util       441264   437168   1%
libnm-glib       297064   292960   2%

https://bugzilla.gnome.org/show_bug.cgi?id=741140
2014-12-11 09:21:28 -06:00
Lubomir Rintel
53380159dd platform: Fix build with LIBNL_INET6_ADDR_GEN_MODE
platform/nm-linux-platform.c: In function 'setup':
  platform/nm-linux-platform.c:4364:2: error: 'object' undeclared (first use in this function)
    object = nl_cache_get_first (priv->link_cache);
    ^

Fixes 2b8060b9b3
2014-12-11 15:20:08 +01:00
Lubomir Rintel
1f1aebebea platform,device: merge branch 'lr/bridge-rh1141266'
Assume connections for bridges with slaves, and associated fixes for bridges.

https://bugzilla.redhat.com/show_bug.cgi?id=1141266
2014-12-11 11:49:48 +01:00
Lubomir Rintel
62ad694421 device: assume connections for device with slaves
If a bridge/team/bond has slaves, assume it's connected. Recheck as devices
appear.

https://bugzilla.redhat.com/show_bug.cgi?id=1141266
2014-12-11 11:49:29 +01:00
Lubomir Rintel
25387cd1ff device: set the master on device addition
Otherwise we won't notice the device is a slave on NM startup until someone
changes the link or tries to activate the device.
2014-12-11 11:49:29 +01:00
Lubomir Rintel
81553b6978 device: release and enslave an interface if its master changed
In case of an atomic master change, we'd not notice that the master changed:

  ip link set dummy0 master bridge0
  ip link set dummy0 master bridge1
2014-12-11 11:49:29 +01:00
Lubomir Rintel
8b77b93169 Revert "platform: increase NL buffer for systems with lots of interfaces (rh #1141256)"
This reverts commit efd09845c4.

It turns out that the socket space might not be the only buffer that may get
too full. 128K ought to be enough for it and we should resynchronize with the
kernel now if needed.
2014-12-11 11:49:29 +01:00
Lubomir Rintel
2b8060b9b3 platform: resynchronize with kernel when we're out of buffer space
Kernel can return ENOBUFS in variety of reasons. If that happens, we know we've
lost events and should pick up kernel state.

Simple reproducer that triggers an ENOBUFS condition no matter how big our
netlink socket buffer is:

  ip link add bridge0 type bridge
  for i in seq $(0 1023); do ip link add dummy$i type dummy; \
    ip link set dummy$i master bridge0; done
  ip link del bridge0
2014-12-11 11:49:29 +01:00
Lubomir Rintel
85b811cc7c platform: refactor the object comparison logic into a separate function
One from libnl is not good enough (see comment).
2014-12-11 11:49:29 +01:00
Lubomir Rintel
ed78d3b3dc platform: ensure all objects in link cache are of AF_UNSPEC family
We assume that in nm_nl_cache_search() and correctly set that in
get_kernel_object(), but we rtnl_link_alloc_cache() can initialize the cache
with devices of other families.

The consequence is that we don't notify when the bridge changes to IFF_UP as we
fail to match and remove the old downed object from the cache:

  nm_device_bring_up(): [0xf506c0] (bridge0): bringing up device.
  nm_platform_link_set_up(): link: setting up 'bridge0' (12)
  link_change_flags(): link: change 12: flags set 'up' (1)
  get_kernel_object(): get_kernel_object for link: bridge0 (12, family 7)
  log_link(): signal: link   added: 12: bridge0 <UP> mtu 1500 bridge driver 'bridge' udi '/sys/devices/virtual/net/bridge0'
  get_kernel_object(): get_kernel_object for link: bridge0 (12, family 7)
  log_link(): signal: link changed: 12: bridge0 <UP> mtu 1500 bridge driver 'bridge' udi '/sys/devices/virtual/net/bridge0'
  log_link(): signal: link changed: 12: bridge0 <UP> mtu 1500 bridge driver 'bridge' udi '/sys/devices/virtual/net/bridge0'
  (bridge0): device not up after timeout!
  (bridge0): preparing device
2014-12-11 11:49:29 +01:00
Lubomir Rintel
8019a51a0e device: merge branch 'lr/assumed-activation-rh1141264'
Avoid tearing down assumed connection when their re-activation fails, proceed
with whatever configuration we have.

https://bugzilla.redhat.com/show_bug.cgi?id=1141264
2014-12-11 11:47:10 +01:00
Lubomir Rintel
4b3ad7709d device: don't fail activation when IP config is unavailable and unneeded
If we didn't start IPv4 and IPv6, but they're allowed to fail, progress
the activation without failing it. Also, progress assumed connections to
check-ip with whatever configuration that is available.

https://bugzilla.redhat.com/show_bug.cgi?id=1141264
2014-12-11 11:46:43 +01:00
Lubomir Rintel
55af4add90 device: don't disconnect assumed connections
Transition them to activated status when they fail.

https://bugzilla.redhat.com/show_bug.cgi?id=1141264
2014-12-11 11:46:43 +01:00
Lubomir Rintel
063ab8da5c device: turn nm_d_ip_config_should_fail to get_ip_config_may_fail
Has a cleaner semantics and will be useful later on. Also, make it static --
it's not used outside nm-device.c.
2014-12-11 11:46:42 +01:00
Jiří Klimeš
d19770102e tests: fix setting MAC address in tests
MAC address properties are strings now. The change has been done by commit
3a54d05098. But this place was not updated.

Reported by lrintel in copr.
2014-12-11 11:33:32 +01:00
Lubomir Rintel
d9806a9cae core,cli,agent-mangager: merge branch 'lr/vpn-fixes'
Various VPN-related fixes.

https://bugzilla.gnome.org/show_bug.cgi?id=740525
2014-12-11 11:18:23 +01:00
Lubomir Rintel
9a3cc60d9b cli: expose the vpn.persistent property 2014-12-11 11:15:53 +01:00