Commit graph

14236 commits

Author SHA1 Message Date
Thomas Haller b875ac34be man: clarify DEVICE_IFACE vs. DEVICE_IP_IFACE in man NetworkManager 2016-02-22 20:08:56 +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 79b0a4361c device: merge branch 'th/device-unmanaged-settings-bgo762331'
https://bugzilla.gnome.org/show_bug.cgi?id=762331
2016-02-22 16:30:18 +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 d3e776b0e2 ifcfg-rh: fix leaking unmanaged_spec/unhandled_spec in NMIfcfgConnection 2016-02-22 15:36:12 +01:00
Thomas Haller 1f46ae57c4 logging: merge branch 'th/logging-format-bgo762009'
https://bugzilla.gnome.org/show_bug.cgi?id=762009
2016-02-21 18:42:40 +01:00
Thomas Haller 1b8cc4b9c5 logging: always print the timestamp and align location
Change the logging format. For syslog, we will now always
print the timestamp (also for <info> and <warn> messages).
Also, when printing the file location, we will always
align it.

For journal logging, also enable the timestamp. While the timestamp
is already captured separately by journal, most of the time a user
will look at the syslog like output from journal, so we want the
timestamps there too.
2016-02-21 18:37:49 +01:00
Thomas Haller c01d1b0513 logging: add LOG_FORMAT_FLAG_ALIGN_LOCATION flag 2016-02-21 18:37:49 +01:00
Thomas Haller 1905862e26 logging: add logging-format-flags
No functional change.
2016-02-21 18:37:49 +01:00
Thomas Haller d22b3fabc5 core: use nm_utils_parse_debug_string() instead of g_parse_debug_string() 2016-02-21 18:31:39 +01:00
Thomas Haller a51a1cde36 utils: add nm_utils_parse_debug_string() to replace g_parse_debug_string()
g_parse_debug_string() interprets the string "help" special and accepts
an "all" tag to invert the result. We don't want that.
2016-02-21 18:31:39 +01:00
Thomas Haller 6ee744f41d dispatcher: minor cleanup ignoring dispatcher scripts by filename 2016-02-21 18:31:39 +01:00
Thomas Haller 4eb5ba8b02 macros: split macro NM_GOBJECT_PROPERTIES_DEFINE() in two
Sometimes we don't need the _notify() helper which results in a
unused-function warning.
2016-02-19 19:59:05 +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 6d5e55870a shared: fix nm_sprintf_buf() macro to allow plain string
Use non-portable gcc extension to allow for zero variadic
arguments so that you can pass a plain string as argument.
2016-02-19 01:42:29 +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
Thomas Haller 328c733a6a platform: expose nmp_utils_ip4_address_is_link_local() function 2016-02-18 20:21:27 +01:00
Thomas Haller b76d4b6b09 Revert "build: fix detection of NSS library on Debian"
Sorry, it was not Debian's fault. It is only libnss-devel package on
Ubuntu 12.04/Precise [1].

Revert the workaround and avoid the failure by dropping the version check altogether.
NSS 3.11 is from 2006, it's unlikely a user tries to build current NetworkManager
against such an old version of the library.

[1] https://bugs.launchpad.net/ubuntu/+source/nss/+bug/1547147

This reverts commit d48790cbec.
2016-02-18 19:50:51 +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 d48790cbec build: fix detection of NSS library on Debian
Debian added an epoch "2" to the version of NSS library. Fix configure
to account for that.

Related: https://launchpad.net/debian/sid/+source/nss
2016-02-18 12:44:21 +01:00
Thomas Haller c38c4dce3e ifcfg-rh/tests: pass arguments to tests via nmtst_add_test_func()
And call all tests via g_test_run().
2016-02-18 01:46:56 +01:00
Dan Williams 304575e671 ifcfg-rh: more testcase cleanups 2016-02-17 16:43:13 -06:00
Lubomir Rintel 0aed7b5be6 cli: disable colors on dumb terminals
Nothing too sophisticated; just a simple way to get an color-less output on a
pty that wouldn't confuse the test suite.
2016-02-17 19:04:39 +01:00
Lubomir Rintel 3f669444ce manager: don't proceed with activation when there's no master device
Since the device-for-all merge it's a sin (trips an assert) to create an
activation request with NULL device.

If we get here, it's probably that the master device exists, but is not ready
for activation (it's in UNMANAGED state in the process of being created).
2016-02-17 19:04:05 +01:00
Lubomir Rintel 84543df1db merge: branch 'th/lr/conn-device-ifname'
https://bugzilla.gnome.org/show_bug.cgi?id=762154
2016-02-17 19:03:35 +01:00
Thomas Haller e93abf0552 device: optimize nm_manager_get_connection_iface() 2016-02-17 18:43:45 +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
Thomas Haller ca0dbefb02 manager: reused the factory looked up in nm_manager_get_connection_iface()
Only lookup the factory once and pass it down to find_parent_device_for_connection().
2016-02-17 18:43:44 +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 adc9895ebe manager: export nm_manager_get_connection_iface()
We'll need the actual device name that should be used for a connection
activated on a given device when checking the connection availability.
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
Thomas Haller 8c1a9bbb8c utils: fix NM_UTILS_ENUM2STR_DEFINE() which always returned the last element
Fixes: 174b25d98c
2016-02-17 15:17:11 +01:00
Thomas Haller e13925597f platform: add IN6_ADDR_GEN_MODE_RANDOM to nm_platform_link_inet6_addrgenmode2str()
There is a new address generation mode.
2016-02-17 14:19:19 +01:00
Thomas Haller c6849be179 platform: use nm_platform_link_inet6_addrgenmode2str() in link-to-string
Reuse the to-string function nm_platform_link_inet6_addrgenmode2str() to print the
addrgenmode for nm_platform_link_to_string().

Also, now we support NM_IN6_ADDR_GEN_MODE_STABLE_PRIVACY.
2016-02-17 14:01:49 +01:00
Thomas Haller c205ee6ce0 platform: stack-allocate temporary string in nm_platform_link_tun_get_properties_ifname() 2016-02-17 13:39:55 +01:00
Thomas Haller 0685780566 contrib/rpm: add README, improve usage output and rename --no-build option to --no-dist 2016-02-17 11:44:09 +01:00
Thomas Haller 6dc431b0c9 shared: move definition of "bool" to nm-macros-internal.h
"nm-default.h" should only include all the relevant header files based
on NETWORKMANAGER_COMPILATION. It should not contain definitions on
it's own.

Move the definition of "bool" to "nm-macros-internal.h".
2016-02-16 20:18:25 +01:00
Beniamino Galvani b8c677a0eb manager: fix typo in error message
Fixes: 1762d58a8c
2016-02-16 16:22:50 +01:00
Thomas Haller 433d4fed6a platform: merge branch 'th/platform-recvmsgs-fixes-bgo761959'
https://bugzilla.gnome.org/show_bug.cgi?id=761959
2016-02-16 14:14:58 +01:00
Thomas Haller 3d759b1f11 platform: during @abort_parsing goto stop in event_handler_recvmsgs()
Now, that we no longer overwrite @err, we can jump to stop: instead
of out:.
2016-02-16 14:13:25 +01:00
Thomas Haller 329ac02d38 platform: don't set @err during stop: in event_handler_recvmsgs()
If we break the loop normally, @err must be already set to zero.
The only other way this can happen is when the credentials are
invalid. Move setting @err to there.
2016-02-16 14:13:25 +01:00
Thomas Haller 3f00899bde platform: continue reading in event_handler_recvmsgs() when not handling events
If @handle_events is FALSE, we want to drain the socket. In that case
even when encountering an error error we don't want to abort, but instead
continue reading the next message.
2016-02-16 14:13:25 +01:00
Thomas Haller dc97a3b39b platform: fix error handling in event_handler_recvmsgs()
@abort_parsing is set TRUE at two places, which also explicitly
set @err to something. We don't want to reset @err and got to the
next @hdr. Instead error out first.
2016-02-16 14:13:25 +01:00
Thomas Haller 43381f9b85 platform: downgrade logging message to TRACE level in event_handler_recvmsgs()
Doesn't seem important and might be triggered by other processes.
2016-02-16 14:13:25 +01:00
Thomas Haller 9254cbe875 platform: don't return number of messages from event_handler_recvmsgs()
The value is not used by the callers. Also, with @handle_events set
to false, it is not clear what the value really means because we skip
over errors.
2016-02-16 14:13:25 +01:00
Thomas Haller 04805f659f platform: simplify event_handler_recvmsgs() by using cleanup attribute 2016-02-16 14:13:25 +01:00