Commit Graph

15047 Commits

Author SHA1 Message Date
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
Lubomir Rintel
dfdcbfe115 core: don't wipe out VPN secrets if we're changing the connection
The VPN secret properties are hashes and thus the default property value does
not work with them.
2014-12-11 11:15:53 +01:00
Lubomir Rintel
a3f9e51927 agent-manager: don't ever fail the secrets requests from GetSecrets()
VPN connections always return true for nm_connection_need_secrets(), but the
documented behavior of GetSecrets() is just to return any secrets we have
(otherwise nmcli c --show-secrets would not be useful for VPN connections).
2014-12-11 11:15:53 +01:00
Thomas Haller
5849c97c03 platform: avoid conflicts when reinstalling the device-route
Since f32075d2fc, we remove the kernel
added IPv4 device route, and re-add it with appropriate metric.

This could potentially replace existing, conflicting routes. Be more
careful and only take any action when we don't have a conflicting
route and when we add the address for the first time.

The motivation for this was libreswan which might install a VPN route
for a subnet that we also have configured on an interface. But the route
conflict could happen easily for other reasons, for example if you
configure a conflicting route manually.

Don't replace the device route if we have any indication that
a conflict could arise.

https://bugzilla.gnome.org/show_bug.cgi?id=723178
2014-12-11 10:07:00 +01:00
Thomas Haller
e439478ccd device: add logging macro _LOGT() 2014-12-09 16:17:46 +01:00
Thomas Haller
37361a038f dispatcher: refactor constructing environment variables from strv
This also avoids warnings with -O2 -Wstrict-overflow (gcc-4.8.3):

    make[4]: Entering directory `./NetworkManager/callouts'
      CC       libtest_dispatcher_envp_la-nm-dispatcher-utils.lo
    nm-dispatcher-utils.c: In function 'construct_ip6_items':
    nm-dispatcher-utils.c:283:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^
    nm-dispatcher-utils.c: In function 'construct_ip4_items':
    nm-dispatcher-utils.c:144:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^
    nm-dispatcher-utils.c:168:8: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
         if (i != 0)
            ^

https://bugzilla.gnome.org/show_bug.cgi?id=741168
2014-12-08 19:14:31 +01:00
Thomas Haller
937a5639fc libnm: return 0 for empty address in hwaddr_binary_len()
Motivated by avoiding compiler warning with -O2 -Wstrict-overflow (gcc-4.8.3):

    make[4]: Entering directory `./NetworkManager/libnm-core'
      CC       nm-utils.lo
    ../libnm-core/nm-utils.c: In function 'nm_utils_hwaddr_valid':
    ../libnm-core/nm-utils.c:2725:14: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (length == 0 || length > NM_UTILS_HWADDR_LEN_MAX)
                  ^
    ../libnm-core/nm-utils.c: In function 'nm_utils_hwaddr_canonical':
    ../libnm-core/nm-utils.c:2755:14: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
       if (length == 0 || length > NM_UTILS_HWADDR_LEN_MAX)
                  ^

https://bugzilla.gnome.org/show_bug.cgi?id=741168
2014-12-08 19:02:55 +01:00
Dan Winship
5bfb4c8c23 tui: fix deletion of slaves with master (rh #1131574)
We wait for each deletion to complete, so the connections were getting
removed from the connections array as we edited it (unlike with the
old transfer-container GSList-based code). Fix this by copying the
slaves out into their own list first.
2014-12-05 16:16:53 +01:00
Thomas Haller
820e41645f libnm: fix wrong g_return_if_fail() in nm_utils_file_search_in_paths()
Fixes: 6399170ff3
https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 15:01:01 +01:00
Thomas Haller
490eb51f0a libnm: merge branch 'th/libnm-version-script-bgo741069'
https://bugzilla.gnome.org/show_bug.cgi?id=741069
2014-12-05 11:56:55 +01:00
Thomas Haller
2788c344c3 libnm/build: add versioning to linker script
https://bugzilla.gnome.org/show_bug.cgi?id=741069
2014-12-05 11:56:37 +01:00
Thomas Haller
256662f701 build: adjust tools/check-exports.sh
Now that the version scripts might have different
sections, the previous check-exports.sh script no
longer works.
2014-12-05 11:56:37 +01:00
Thomas Haller
005b83de47 libnm: fix gtkdoc annotations for nm_utils_file_search_in_paths()
Fixes: 6399170ff3
2014-12-05 11:53:29 +01:00
Thomas Haller
540a30ef96 libnm: merge branch 'th/file_search_in_path_bgo740783'
https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 11:09:21 +01:00
Thomas Haller
cb8af29f0b core: implement nm_utils_find_helper() based on nm_utils_file_search_in_paths()
This also changes behavior in that we now only find files that
are executable.

https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 11:07:42 +01:00
Thomas Haller
6399170ff3 libnm: add function nm_utils_file_search_in_paths()
We now also use a similar function in VPN plugins. It makes
sense to provide a generic implementation in libnm.

Signed-off-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=740783
2014-12-05 11:07:42 +01:00
Thomas Haller
cd025f05f7 libnm: normalize connections in nm_simple_connection_new_from_dbus()
Before we would just call verify() and only return valid connections
without attempting to fix them.

It is better to use normalize(), because that function is especially there to
accept and repair deprecated configurations that would no longer verify().

This changes behavior in the way that the function now accepts connections
that would have been rejected before.

Since commit b88715e05b normalize() also
adds a missing UUID. Hence this also affects the DBUS method 'AddConnection'
in that it now accepts connections without UUID. Previously, clients were
required to set a UUID for the new connection, now NM core can create a random
one if no UUID is set.

https://bugzilla.gnome.org/show_bug.cgi?id=740813
2014-12-05 11:04:20 +01:00
Jiří Klimeš
9e2203c418 merge: fix number of defects found by Coverity scan (bgo #741122)
https://bugzilla.gnome.org/show_bug.cgi?id=741122
2014-12-05 09:39:12 +01:00
Jiří Klimeš
49bbafbb16 utils: fix converting milliseconds to microseconds
Coverity:
Defect type: CONSTANT_EXPRESSION_RESULT
/src/NetworkManagerUtils.c:726: result_independent_of_operands: "18446744073709551615UL /* 9223372036854775807L * 2UL + 1UL */ < (gulong)sleep_duration_msec * 1000UL" is always false regardless of the values of its operands. This occurs as the logical first operand of '?:'.
2014-12-05 09:38:40 +01:00
Jiří Klimeš
448b073bda bluetooth: the code cannot be reached
because either GSM or CDMA is present. It is checked just above.

Coverity:
Defect type: DEADCODE
src/devices/bluetooth/nm-device-bt.c:312: dead_error_line: Execution cannot reach this statement: "fallback_prefix = dcgettext...".
2014-12-05 09:38:40 +01:00
Jiří Klimeš
b11416de6a libnm: check pspec before accessing it in handle_property_changed()
Fixes: 1f8ec6122e

Coverity:
libnm/nm-object.c:926: var_deref_op: Dereferencing null pointer "pspec".
libnm/nm-object.c:924: var_deref_op: Dereferencing null pointer "pspec".
2014-12-05 09:38:40 +01:00
Jiří Klimeš
28599331e3 callout: ignore waitpid() return value
Coverity:
Defect type: CHECKED_RETURN
2014-12-05 09:38:40 +01:00
Jiří Klimeš
43b4c8f826 platform: ignore nm_platform_ip4_route_add/delete return value
Coverity:
Defect type: CHECKED_RETURN
2014-12-05 09:38:40 +01:00
Jiří Klimeš
7744bd0f85 utils: initialize timespec structure
Coverity:
Defect type: UNINIT
src/NetworkManagerUtils.c:1906: uninit_use_in_call: Using uninitialized value "tp.tv_nsec" when calling "monotonic_timestamp_get".
src/NetworkManagerUtils.c:1879: uninit_use_in_call: Using uninitialized value "tp.tv_nsec" when calling "monotonic_timestamp_get".
src/NetworkManagerUtils.c:1852: uninit_use_in_call: Using uninitialized value "tp.tv_nsec" when calling "monotonic_timestamp_get".
src/NetworkManagerUtils.c:1825: uninit_use_in_call: Using uninitialized value "tp.tv_nsec" when calling "monotonic_timestamp_get".
2014-12-05 09:38:40 +01:00
Jiří Klimeš
d80bb52872 tui: width and height parameters was swapped, but they are ignored anyway
Coverity: Defect type: SWAPPED_ARGUMENTS
clients/tui/newt/nmt-newt-section.c:328: swapped_arguments: The positions of arguments in the call to "nmt_newt_widget_size_request" do not match the ordering of the parameters: * "&border_height" is passed to "width" * "&border_width" is passed to "height"
2014-12-05 09:38:40 +01:00
Jiří Klimeš
f93128194e tui: set GError so that it is not NULL later
Coverity:
Defect type: FORWARD_NULL
clients/tui/nmtui-edit.c:467: var_deref_op: Dereferencing null pointer "error".
2014-12-05 09:38:40 +01:00
Jiří Klimeš
0da3b96ab5 libnm-core: do not access array if it is NULL
Coverity:
Defect type: FORWARD_NULL
libnm-core/nm-setting-8021x.c:1684: var_deref_op: Dereferencing null pointer "array".
2014-12-05 09:38:40 +01:00