Commit graph

1209 commits

Author SHA1 Message Date
Beniamino Galvani
bb7da812fe device/ethernet: fix crash on 802.1x authentication timeout
Fixes the following:
GLib-GObject-WARNING **: invalid cast from 'NMSimpleConnection' to 'NMSettingsConnection'

Fixes: 06da353242
2016-03-04 11:43:03 +01:00
Thomas Haller
d17aedf91f all: explicitly ignore return values
Coverity warns that usually we check for the return value.
2016-03-04 09:06:21 +01:00
Thomas Haller
2d6cf0df19 device: assert for valid device argument in nm_device_remove_pending_action()
Coverity complains in nm-active-connection.c:

   996        if (priv->pending_activation_id) {
      CID 59368 (#1 of 1): Dereference after null check (FORWARD_NULL)4. var_deref_model: Passing null pointer priv->device to nm_device_remove_pending_action, which dereferences it. [show details]
   997                nm_device_remove_pending_action (priv->device, priv->pending_activation_id, TRUE);
   998                g_clear_pointer (&priv->pending_activation_id, g_free);
   999        }
2016-03-04 08:47:44 +01:00
Thomas Haller
cd4f84b738 all: don't include error->code in log messages
GError codes are only unique per domain, so logging the code without
also indicating the domain is not helpful. And anyway, if the error
messages are not distinctive enough to tell the whole story then we
should fix the error messages.

Based-on-patch-by: Dan Winship <danw@gnome.org>
2016-03-03 18:54:20 +01:00
Thomas Haller
01b9b4104c all: clean-up usage of GError
Functions that take a GError** MUST fill it in on error. There is no
need to check whether error is NULL if the function it was passed to
had a failing return value.

Likewise, a proper GError must have a non-NULL message, so there's no
need to double-check that either.

Based-on-patch-by: Dan Winship <danw@gnome.org>
2016-03-03 18:54:20 +01:00
Thomas Haller
684e80b539 platform: add flags argument to nm_platform_ip4_address_add()
The argument is still always unset. We will need it later to set
IFA_F_NOPREFIXROUTE.
2016-03-01 15:09:16 +01:00
Thomas Haller
be4472bdcd platform: call ethtool functions via platform
When adding namespace support later, we must call ethtool
from the proper namespace, i.e. via a NMPlatform instance.

Avoid calling ethtool directly.
2016-03-01 15:07:04 +01:00
Thomas Haller
60ca6e028f lldp/tests: fix memleaks in test
valgrind complains since commit ae9cc8910d.
2016-03-01 12:41:38 +01:00
Thomas Haller
7f43e0a7b3 platform/trivial: rename NMPlatformIP6Address's "flags" field to "n_ifa_flags"
There are far too many "flags". Rename the "flags" to "n_ifa_flags"
which reminds to "ifa_flags" in 'struct ifaddrmsg', but with a
distinctive "n_" prefix.
2016-02-29 16:27:08 +01:00
Thomas Haller
e18cdc10d3 platform: adjust type of IPv6 address flags to guint
Address flags inside 'struct ifaddrmsg' are uint8_t and they are
extended to uint32_t via IFA_FLAGS.

Change it to be guint32.
2016-02-29 16:27:08 +01:00
Thomas Haller
866925e65c platform/trivial: rename NMPlatformLink's "flags" field to "n_ifi_flags"
There are far too many "flags". Rename the "flags" to "n_ifi_flags"
which reminds to "ifi_flags" in 'struct ifinfomsg', but with a
distinctive "n_" prefix.
2016-02-29 15:56:01 +01:00
Thomas Haller
ae9cc8910d lldp/tests: unref lldp instance in test 2016-02-29 14:23:22 +01:00
Thomas Haller
06252c9863 lldp: handle NULL values in lldp_neighbor_id_hash()
g_str_hash() can not be called with NULL. Ensure that we don't crash.
Thereby, refactor the hashing algorithm because the chassis-id and
port-id are small numbers and xor-ing can cancel them easily.
2016-02-29 14:23:22 +01:00
Thomas Haller
c130a3b39a lldp: don't mix malloc() with g_malloc() 2016-02-29 14:23:22 +01:00
Thomas Haller
2a466216e1 lldp: refactor logging to use _LOG() macros 2016-02-29 14:23:22 +01:00
Thomas Haller
a3f9115c0b lldp: fix calling free on memory returned by systemd
systemd's malloc() must be matched by free() and not g_free().
Thereby, use a cleanup attribute.
2016-02-29 14:08:00 +01:00
Thomas Haller
bd797e9fe1 lldp: refactor process_lldp_neighbors() 2016-02-29 14:08:00 +01:00
Thomas Haller
5805683efc device: fix compile error due to typo
Fixes: 6d409653b1
2016-02-29 13:38:14 +01:00
Thomas Haller
547980d2e4 device/trivial: adjust whitespace for property definitions 2016-02-29 13:13:54 +01:00
atul
6d409653b1 device: use _notify() instead of g_object_notify() for object properties
https://github.com/NetworkManager/NetworkManager/pull/3
2016-02-29 13:10:02 +01:00
Lubomir Rintel
faf70df480 device: the veth should have the same priority as ethernet
It's supposed to be a virtual ethernet.
2016-02-27 20:15:56 +01:00
Lubomir Rintel
f541a17270 device: when activating without cloned-mac-address, set the permanent one
Don't rely on what's already on the device. It could be that the MAC address
set on the device is not meaningful -- the NM crashed while two devices were
teamed together and now they have the same hardware address and now it's
impossible to bond them with mode=5.
2016-02-26 17:35:21 +01:00
Thomas Haller
ec35542cd5 wifi/test: fix bug in test code wpa_flags_for_idx() 2016-02-26 16:32:24 +01:00
Lubomir Rintel
02278d3b8f arping-manager: failure to get a device name should not be fatal
The device could just be removed mid-flight.
2016-02-26 13:37:01 +01:00
Beniamino Galvani
aae6f07fe5 device: trivial: fix indentation and whitespaces 2016-02-25 11:10:52 +01:00
Lubomir Rintel
7d1709d7f6 device: check may_fail when progressing to IP_CHECK
Don't let the device progress to check and then in turn to activated unless all
the required IP configuration is in place.
2016-02-24 16:54:26 +01:00
Lubomir Rintel
9a55f662b9 device/trivial: rename nm_device_check_ip_failed()
This saves 110 bytes (which is 1/29986680757 of the size of the books in the
Library of Congress).

Also, the function is static; not using the nm_device_ prefix is preferred.
2016-02-24 16:54:26 +01:00
Dan Williams
751a37bf43 wifi: ignore monitor interfaces
If a monitor interface is created, NM will grab that interface
and change it to station mode.  That's not very nice.

https://mail.gnome.org/archives/networkmanager-list/2016-February/msg00068.html
2016-02-24 11:43:42 +01:00
Thomas Haller
1b00009169 device: add new NMDeviceType NM_DEVICE_TYPE_VETH
Based-on-patch-by: Jiří Klimeš <jklimes@redhat.com>
2016-02-23 23:15:37 +01:00
Lubomir Rintel
f6d0fc3341 wifi: avoid autoconnecting Ad-Hoc networks with method=auto
This fixes the issue where all Ad-Hoc networks try to connect one after one on
NM startup instead of the managed network that has AP available.

Fixes: e2637760f1
2016-02-22 17:11:01 +01:00
Thomas Haller
c210134bd5 device: revert overruling NM_UNMANAGED_USER_SETTINGS decision
Since commit 87a3df2e57, the unmanaged
flag NM_UNMANAGED_USER_SETTINGS could be overwritten via an explict
user decision (NM_UNMANAGED_USER_EXPLICIT).

It makes sense to allow user configuration from file to be changable
by an explict user action via D-Bus at runtime.

However, it also changes behavior for devices that are currently explicitly
managed. Previously, a reload of the NM_UNMANAGED_USER_SETTINGS would
immediately unmanaged the device:

  - for keyfile: send SIGHUP to reload NetworkManager.conf
  - for ifcfg-rh: `nmcli connection [re]load`

So this change in behavior could negatively affect users who rely
on being able to configure "NM_CONTROLLED=no" and expect to unmanaged
the device immediately. Thus revert the change.

Note that NM_UNMANAGED_USER_SETTINGS is anyway ugly and should be
deprecated:
  - for keyfile, why having the option "keyfile.unmanaged-devices"
    instead of a generic options?
  - for ifcfg-rh, why put per-device configuration in a per-connection
    file?
The preferred way is to configure NM_UNMANAGED_USER_UDEV via
"ENV{NM_UNMANAGED}". Maybe we should also add a new configuration
scheme via NetworkManager.conf.

https://bugzilla.gnome.org/show_bug.cgi?id=762331
2016-02-22 16:24:32 +01:00
Thomas Haller
569cca6595 device: rename NM_UNMANAGED_USER_CONFIG to NM_UNMANAGED_USER_SETTINGS
The NM_UNMANAGED_USER_SETTINGS flags are determined by the settings plugins.
That is, either:
  - keyfile's "unmanaged-devices" configuration option
  - ifcfg-rh's "NM_CONTROLLED" option
  - ifnet's "managed" option

Rename NM_UNMANAGED_USER_CONFIG to NM_UNMANAGED_USER_SETTINGS to reflect
that it this is user configuration determined by the settings plugin.
2016-02-22 16:14:39 +01:00
Thomas Haller
8bace23beb all: cleanup includes and let "nm-default.h" include "config.h"
- All internal source files (except "examples", which are not internal)
  should include "config.h" first. As also all internal source
  files should include "nm-default.h", let "config.h" be included
  by "nm-default.h" and include "nm-default.h" as first in every
  source file.
  We already wanted to include "nm-default.h" before other headers
  because it might contains some fixes (like "nm-glib.h" compatibility)
  that is required first.

- After including "nm-default.h", we optinally allow for including the
  corresponding header file for the source file at hand. The idea
  is to ensure that each header file is self contained.

- Don't include "config.h" or "nm-default.h" in any header file
  (except "nm-sd-adapt.h"). Public headers anyway must not include
  these headers, and internal headers are never included after
  "nm-default.h", as of the first previous point.

- Include all internal headers with quotes instead of angle brackets.
  In practice it doesn't matter, because in our public headers we must
  include other headers with angle brackets. As we use our public
  headers also to compile our interal source files, effectively the
  result must be the same. Still do it for consistency.

- Except for <config.h> itself. Include it with angle brackets as suggested by
  https://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Headers
2016-02-19 17:53:25 +01:00
Lubomir Rintel
89d6fa6aa9 device: don't allways set assumed reason when platform init is done
When the device is transitioning from unmanaged to disconnected for "assumed"
reason, bring_up is not called. This is not a good thing in numerous
instances, e.g.:

1.) vlans that we've created need that to set IFF_UP and read carrier
otherwise they won't be available for connections.

2.) veths that are being managed need to start the deferred carrier check
so that the behavior matches real Ethernet.

3.) Hardware devices that were plugged in while NetworkManager is running
that need the IFF_UP for a carrier check, possibly enqueueing a deferred one.

Fixes: 5637d72af2.
2016-02-19 14:40:16 +01:00
Thomas Haller
7197425137 device: expose NMIP4Config:addresses in stable/defined sort order
Like we already do for IPv6 addresses, we should expose addresses
in a defined, stable sort order.

Clients usually show the addresses in the same order as obtained
via D-Bus.
2016-02-18 21:53:03 +01:00
Beniamino Galvani
86f005ea4b device: fix assertion on unmanaged_mask for slave devices
When executing these commands:

  ip link add br0 type bridge
  ip link set dev br0 up
  ip link add dummy1 type dummy
  ip link set dev dummy1 up
  ip addr add 1.1.1.1/24 dev br0
  brctl addif br0 dummy1
  sleep 1
  ip link del br0
  ip link del dummy1

the following assertion was failing:

  nm_device_master_release_one_slave: runtime check failed: (NM_FLAGS_HAS (slave_priv->unmanaged_mask, NM_UNMANAGED_IS_SLAVE))

  #0  g_logv()
  #1  g_log()
  #2  g_warn_message()
  #3  nm_device_master_release_one_slave()
  #4  nm_device_cleanup()
  #5  _set_state_full()
  #6  nm_device_state_changed()
  #7  nm_device_unrealize()
  #8  _platform_link_cb_idle()
  #9  g_main_context_dispatch()
  #10 g_main_context_dispatch()
  #11 g_main_context_iterate()
  #12 g_main_loop_run()
  #13 main()

Upon slave removal we unrealize the device, resetting the unmanaged
flags to NM_UNMANAGED_PLATFORM_INIT, then we clean up the device and
call nm_device_master_release_one_slave(), which asserts the presence
of NM_UNMANAGED_IS_SLAVE flag cleared just before.

Drop the check.

Fixes: 87a3df2e57
2016-02-18 14:18:07 +01:00
Thomas Haller
f31954c071 device: don't overwrite get_connection_iface() by default
Factories that overwrite this function are not supposed to chain
up the parent implementation. Thus there is no reason to have
a default implementation and it's clearer to inline it.
2016-02-17 18:43:45 +01:00
Lubomir Rintel
8b016cd9a7 device: remove interface name checks from all classes
Generic check_connection_compatible() already does the check.
2016-02-17 18:43:44 +01:00
Lubomir Rintel
f9ec713641 device: move the interface name check from manager
We not only want to check the device name when creating a virtual device, but
also when determining if the connection can actually be activated there.

Otherwise the device names will mix up if there's more connections that use
virtual devices of the same type.
2016-02-17 18:43:44 +01:00
Lubomir Rintel
cd81e0bd9f device-factory: always use the factory to determine the connection's interface name
This makes things a bit simpler when determining if any connection is
activatable on an existing device.
2016-02-17 18:43:33 +01:00
Lubomir Rintel
fd314ed7f7 device-factory/trivial: rename get_virtual_iface_name() to get_connection_iface() 2016-02-17 18:43:02 +01:00
Beniamino Galvani
206e074863 libnm,core,cli: move dhcp-timeout property to generic NMSettingIPConfig
The property applies to both IPv4 and IPv6 and so it should not be in
NMSettingIP4Config but in the base class.
2016-02-16 11:37:26 +01:00
Thomas Haller
54dc789314 device: fix signature for @flags argument of impl_device_reapply()
Thereby, also adjust the type for libnm's wrapper function -- as
we already broke ABI.
2016-02-16 11:24:49 +01:00
Thomas Haller
62910d19d7 core: add NMDevice's GetAppliedConnection D-Bus call
Expose applied connection in D-Bus API.

https://bugzilla.gnome.org/show_bug.cgi?id=760884
2016-02-16 11:24:49 +01:00
Thomas Haller
6898e2169e all: add version-id argument to device's Reapply method
This breaks API and ABI for the functions related to Reapply,
which got introduced in the current 1.1 development phase.

The version-id is here to allow users to error out if the connection
on the device was changed by a concurrent action.

https://bugzilla.gnome.org/show_bug.cgi?id=761714
2016-02-16 11:24:49 +01:00
Thomas Haller
b96a40c2ec core: add version-id to NMActiveConnection
This field will be later used by NMDevice's Reapply and
GetAppliedConnection methods. The usecase is to first fetch
the currently applied connection, adjust it and reapply it.
Using the version-id, a concurrent modification can be detected
and Reapply can reject the invocation.
2016-02-16 11:24:49 +01:00
Thomas Haller
5637d72af2 device: fix wrongly managing external devices by assuming on PLATFORM_INIT
Otherwise, a tun device from external openvpn service will be managed by
NetworkManager.

  <debug> [1455615148.716529] [devices/nm-device.c:9082] _set_unmanaged_flags(): [0x55e6f5756070] (tun7): unmanaged: flags set to [!sleeping,!loopback,!platform-init,!user-config,!external-down=0x0/0xa19/managed, set-managed [platform-init=0x10], reason managed, transition-state)
  <info>  (tun7): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]

Fixes: 87a3df2e57
2016-02-16 10:44:42 +01:00
Beniamino Galvani
10b222288e wifi: don't touch by default current powersave setting
Some drivers (or things outside NM like 'powertop') may turn powersave
on, so don't touch it unless explicitly configured by user.

To achieve this, add new 'default' and 'ignore' options; the former
can be used to fall back to a globally configured setting, while the
latter tells NM not to touch the current setting.

When 'default' is specified, a missing global default configuration is
equivalent to 'ignore'.

It is possible to enable Wi-Fi power saving for all connections by
dropping a file in /etc/NetworkManager/conf.d with the following
content:

 [connection]
 wifi.powersave=3

https://bugzilla.gnome.org/show_bug.cgi?id=760125
2016-02-16 00:18:06 +01:00
Thomas Haller
87a3df2e57 device: remove default-unmanaged and refactor unmanaged flags
Get rid of NM_UNMANAGED_DEFAULT and refine the interaction between
unmanaged flags, device state and managed property.

Previously, the NM_UNMANAGED_DEFAULT was special in that a device was
still considered managed if it had solely the NM_UNMANAGED_DEFAULT flag
set and its state was managed. Thus, whether the device (state) was managed,
depended on the device state too.

Now, a device is considered managed (or unmanaged) based on the unmanaged
flags and realization state alone. At the same time, the device state
directly corresponds to the managed property of the device. Of course,
while changing the unmanaged flags, that invariant is shortly violated
until the state transistion is complete.

Introduce more unmanaged flags whereas some of them are non-authorative.
For example, the EXTERNAL_DOWN flag has only effect as long as the user
didn't explicitly manage the device (NM_UNMANAGED_USER_EXPLICIT). In other
words, certain flags can render other flags ineffective. Whether the device
is considered managed depends on the flags but also at the explicitly unset flags.
In a way, this is similar to previous where NM_UNMANAGED_DEFAULT was ignored
(if no other flags were present).

Also, previously a device that was NM_UNMANAGED_DEFAULT and in disconnected
state would transition back to unmanaged. No longer do that. Once a device is
managed, it stays managed as long as the flags indicate it should be managed.
However, the user can also modify the unmanaged flags via the D-Bus API.

Also get rid or nm_device_finish_init(). That was previously called
by NMManager after add_device(). As we now realize devices (possibly
multiple times) this should be handled during realization.

https://bugzilla.gnome.org/show_bug.cgi?id=746566
2016-02-15 21:40:02 +01:00
Thomas Haller
2a17dbf48b device/trivial: rename nm_device_set_unmanaged_flags() 2016-02-15 21:33:32 +01:00