Commit Graph

13873 Commits

Author SHA1 Message Date
Lubomir Rintel
688e93fb2a device: avoid a crash during destruction
The ipv4_config might be gone already, _cleanup_generic_post() sets it to NULL.

  NetworkManager[30564]: <info>  caught SIGINT, shutting down normally.

  (NetworkManager:30564): GLib-GObject-CRITICAL **: g_type_instance_get_private: assertion 'instance != NULL && instance->g_class != NULL' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x7ffff4d92f64 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd5e0) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4a738c3 in g_logv (log_domain=0x7ffff4d92f64 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd5e0) at gmessages.c:1046
  #1  0x00007ffff4a73a3f in g_log (log_domain=log_domain@entry=0x7ffff4d92f64 "GLib-GObject", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff4ae173d "%s: assertion '%s' failed")
      at gmessages.c:1079
  #2  0x00007ffff4a73a79 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7ffff4d92f64 "GLib-GObject", pretty_function=pretty_function@entry=0x7ffff4d9aad0 <__FUNCTION__.13620> "g_type_instance_get_private", expression=expression@entry=0x7ffff4d99db8 "instance != NULL && instance->g_class != NULL") at gmessages.c:1088
  #3  0x00007ffff4d8d2ba in g_type_instance_get_private (instance=instance@entry=0x0, private_type=<optimized out>) at gtype.c:4632
  #4  0x00000000004bf774 in nm_ip4_config_get_num_addresses (config=0x0) at nm-ip4-config.c:1418
  #5  0x0000000000458834 in _update_ip4_address (self=self@entry=0xa8a490 [NMDeviceBridge]) at devices/nm-device.c:6069
  #6  0x000000000045e740 in nm_device_set_ip4_config (self=self@entry=0xa8a490 [NMDeviceBridge], new_config=new_config@entry=0x0, default_route_metric=default_route_metric@entry=0, commit=commit@entry=1, routes_full_sync=routes_full_sync@entry=1, reason=reason@entry=0x7fffffffd7cc) at devices/nm-device.c:6558
  #7  0x0000000000466c56 in _cleanup_generic_post (self=self@entry=0xa8a490 [NMDeviceBridge], cleanup_type=cleanup_type@entry=CLEANUP_TYPE_KEEP) at devices/nm-device.c:8108
  #8  0x00000000004671af in dispose (object=0xa8a490 [NMDeviceBridge]) at devices/nm-device.c:9128
  #9  0x00007ffff4d6ea82 in g_object_unref (_object=0xa8a490) at gobject.c:3133
  #10 0x00000000004d1a53 in remove_device (manager=manager@entry=0x8822b0 [NMManager], device=0xa8a490 [NMDeviceBridge], quitting=quitting@entry=1, allow_unmanage=allow_unmanage@entry=1) at nm-manager.c:780
  #11 0x00000000004d7db1 in nm_manager_stop (self=self@entry=0x8822b0 [NMManager]) at nm-manager.c:4199
  #12 0x0000000000445aa9 in main (argc=1, argv=0x7fffffffda88) at main.c:465
  (gdb)
2015-08-12 18:18:56 +02:00
Thomas Haller
96cacc07e8 macros: use short-circuit evaluation in NM_IN_SET()
All current users of NM_IN_SET() would rather use short-circuit evalation
(or don't care). It seems that doing it by default seems favorable.

The only downside is, that this might have somewhat unexpected behavior
to a user who expects a regular function (which would evaluate always
all arguments).

Fixes: 7860ef959a
2015-08-12 16:04:17 +02:00
Thomas Haller
7860ef959a macros: rework NM_IN_SET() macro to expand to a plain logical expression
Let the preprocessor do more work, but generate a simple expression that
the compiler can optimize (presumably) better.
2015-08-12 14:30:18 +02:00
Thomas Haller
edb0cc235a systemd: merge branch 'systemd' into master 2015-08-12 12:54:05 +02:00
Thomas Haller
8f4e617526 systemd: update code from upstream
This is a direct dump from systemd git on 2015-08-12, git commit
3f1818cf70ac34c.

======

SYSTEMD_DIR=../systemd
COMMIT=3f1818cf70ac34cf93f1f033b4f1bbb7a89b3dff

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/ipv4ll-internal.h"
nm_copy_sd "src/libsystemd-network/ipv4ll-internal.h"
nm_copy_sd "src/libsystemd-network/ipv4ll-network.c"
nm_copy_sd "src/libsystemd-network/ipv4ll-packet.c"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
2015-08-12 12:51:11 +02:00
Thomas Haller
3ae6f9d793 config/tests: fix tests after introducing NMExportedObject class
The config-tests contain a NMTestDevice which derives from NMDevice.
However, for testing, it just skips the constructor and destructor of
NMDevice. This caused also the destructors of NMExportedObject to be skipped
and thus valgrind complained about leaked memory.

Fixes: 6fcc1deee0
2015-08-12 12:14:19 +02:00
Thomas Haller
286455bfda dhcp/tests: fix memleaks in dhcp-tests
These are old leaks, reported by valgrind runs. Strange that they didn't
show up earlier...
2015-08-12 11:25:12 +02:00
Thomas Haller
641ca3d5d2 dhcp/tests: fix memleaks in tests (test_vendor_option_metered)
Fixes: 1e39b2320d
2015-08-12 11:22:22 +02:00
Thomas Haller
514059aa62 core: fix memleak in nm_exported_object_class_add_interface()
Fixes: 073991f5a8
2015-08-12 11:10:05 +02:00
Dan Winship
c699f8c32e contrib: add emacs config for hacking on NM
https://bugzilla.gnome.org/show_bug.cgi?id=753411
2015-08-11 13:42:26 -04:00
Thomas Haller
f0ada4b534 core: merge branch 'bg/ethtool-load-module-rh1247156'
Calling ethtool on a non-existing interface name, might cause
the loading of a kernel module. Avoid that, by checking first
whether such an interface exists.

https://bugzilla.redhat.com/show_bug.cgi?id=1247156
2015-08-11 18:31:46 +02:00
Beniamino Galvani
44fee0f6ff udev-rules: only invoke ethtool for existing interfaces
ethtool may cause the auto-loading of a kernel module for non-existing
interface-names. Avoid that by checking whether such an interface exists.

This is inherently racy.
2015-08-11 18:31:46 +02:00
Beniamino Galvani
ab41c13b06 core: avoid ioctls on non existent devices
Performing an ioctl on a non existent device may cause the automatic
load of a kernel module if the device name matches a module
alias. Check if the device actually exists before calling the ioctl.
2015-08-11 18:31:46 +02:00
Beniamino Galvani
bfb459f8ed device: don't call ioctl to update priv->ip4_address
Just take the first address in priv->ip4_config.
2015-08-11 18:31:46 +02:00
Thomas Haller
633deb0a98 utils: add nm_utils_is_valid_path_component() 2015-08-11 18:31:46 +02:00
Thomas Haller
a4c7176fe9 platform: optimize event_notification() not to create full nmp-objects for delete-events
For delete-events, we only need a shallow object with the key fields
set. That sufficies to lookup in the cache and find the object to
delete.

One other issue is that _nmp_vt_cmd_plobj_init_from_nl_link() and
link_extract_type() might call to ethtool for the already deleted
instance. Just avoid that.

https://bugzilla.redhat.com/show_bug.cgi?id=1247156
2015-08-11 18:31:46 +02:00
Jiří Klimeš
9f6cc732f5 merge: respect DEVTIMEOUT when device is not udev initialized (rh #1192633)
https://bugzilla.redhat.com/show_bug.cgi?id=1192633
2015-08-11 18:16:26 +02:00
Thomas Haller
6608331aec ifcfg-rh: reorder checks in nm_ifcfg_connection_check_devtimeout()
Move the check for a platform link before devtimeout_from_file(). The
check in the platform cache should be more performant and yield success
in most cases.

This can save reading and parsing the ifcfg-rh file.
2015-08-11 18:11:55 +02:00
Jiří Klimeš
ecdf7cba6b ifcfg-rh: respect DEVTIMEOUT if link is not announced by udev yet (rh #1192633)
If NIC related initialization takes a long time in udev processing, but we have
an ifindex from kernel, we still want to wait until udev is finished and the
device is really usable.
Check that by calling nm_platform_link_get_by_ifname() and checking @initialized,
which means udev is finished.

Based on a patch by t-nishimura@hf.jp.nec.com
Improved by thaller@redhat.com

https://bugzilla.redhat.com/show_bug.cgi?id=1192633
2015-08-11 18:11:55 +02:00
Quentin Glidic
a6e3a60844 configure.ac: do not hardcode pkg-config
Always use $PKG_CONFIG instead

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>

https://bugzilla.gnome.org/show_bug.cgi?id=753502
2015-08-11 13:42:31 +02:00
Lubomir Rintel
4b68c88023 tests: don't use a local address for testing a gateway route
Doesn't work on RHEL 7 kernel:

https://bugzilla.redhat.com/show_bug.cgi?id=1252067
2015-08-10 17:46:52 +02:00
Dan Winship
3cf736b9e0 all: merge branch 'danw/gdbus-bgo622927'
Port the remaining parts of src/ to gdbus.

(Note that most of the individual commits on this branch do not
compile; they are split up for ease of comprehension, but all depend
on each other.)

https://bugzilla.gnome.org/show_bug.cgi?id=622927
2015-08-10 09:45:04 -04:00
Dan Winship
753e81d21f build: make libnm-util/libnm-glib optional
Add --without-libnm-glib, for people who don't want to build the
legacy client libraries. When building with this option, dbus-glib and
libdbus are not required.
2015-08-10 09:41:26 -04:00
Dan Winship
1cf35cb26b core: final gdbus porting
Port remaining bits to gdbus and remove stray dbus-glib references

Drop the dbus-glib version check from configure, since nothing depends
on new dbus-glib any more.

Move nm-dbus-glib-types.h and nm-gvaluearray-compat.h from include/ to
libnm-util/ since they are now only used by libnm-util and libnm-glib.
2015-08-10 09:41:26 -04:00
Dan Winship
34ba4e14b8 core: port NMManager to gdbus 2015-08-10 09:41:26 -04:00
Dan Winship
6c8f860820 core: port IP/DHCP config to gdbus 2015-08-10 09:41:26 -04:00
Dan Winship
7f6e39ec6e dhcp-manager: port to gdbus
The existing code was somewhat confusing because it used
string->GValue hash tables in some places, and string->string hash
tables in other places. In the new version, the string->GValue hash
tables become GVariants, but the string->string hash tables stay as
hash tables, so you can tell them apart more easily.
2015-08-10 09:41:26 -04:00
Dan Winship
8f36727ac8 ppp-manager: port to gdbus 2015-08-10 09:41:26 -04:00
Dan Winship
c050fb7cd2 devices, active-connection: port to gdbus 2015-08-10 09:41:26 -04:00
Dan Winship
df6706813a settings: port to gdbus 2015-08-10 09:41:26 -04:00
Dan Winship
9f8de603e3 ifcfg-rh: port to gdbus 2015-08-10 09:41:26 -04:00
Dan Winship
4b823a86c9 core: port NMBusManager to gdbus
Also remove some now-unused NMBusManager API
2015-08-10 09:41:26 -04:00
Dan Winship
073991f5a8 core: port NMExportedObject to gdbus
Port NMExportedObject to gdbus, and make
nm_exported_object_class_add_interface() deal with generating D-Bus
skeleton objects and attaching signal handlers and property bindings
as needed to properly handle methods, signals, and properties.
2015-08-10 09:41:26 -04:00
Dan Winship
284e15a877 core: make NMManager singleton more like others
Rename nm_manager_new() to nm_manager_setup(), and change the local
@singleton variable to @singleton_instance. (Also, add a local @self
variable inside nm_manager_setup().)

Also, make NMManager own NMSettings rather than having them both owned
by main().
2015-08-10 09:41:26 -04:00
Dan Winship
b7911bae51 core: better order the code at startup
NM was calling nm_bus_manager_start_service() to claim its bus name
before it exported any of its objects, but this didn't matter under
dbus-glib, because no client connections would be accepted until the
main loop was started later on, by which point we would have exported
everything.

But with gdbus, method calls are initially received in the gdbus
worker thread, which means that clients would be able to connect right
away and then be told that the expected interfaces don't exist.

So move the nm_bus_manager_start_service() call to occur after
creating NMSettings and NMManager (and, indirectly, NMAgentManager).
This requires splitting out the slow parts of nm_settings_new() into a
new nm_settings_start(), so that we can create and export it first,
and then read the connections, etc afterward. (Likewise, there were
still a few potentially-slow bits in nm_manager_new() which are now
moved into nm_manager_start().)
2015-08-10 09:41:26 -04:00
Dan Winship
1c11c5cff1 core: fix NMManager in private-bus-only case
NMManager was failing to initialize if there was only a private bus,
despite the fact that this is exactly the use case that the private
bus was added for.

The only other potentially-failing code in nm_manager_new() was adding
prop_filter to the D-Bus connection, but this can't really fail, so
just assert that it doesn't. And now, nm_manager_new() always
succeeds, so update the caller for that.
2015-08-10 09:41:25 -04:00
Lubomir Rintel
c44069c10a device: avoid setting MTU to zero if undefined 2015-08-10 14:10:17 +02:00
Thomas Haller
b503b02cac libnm: add NM_AVAILABLE_IN_1_2 for API nm_access_point_get_last_seen()
Fixes: 1e85c35846
2015-08-09 14:37:10 +02:00
Thomas Haller
311b90080f libnm-glib: add NM_AVAILABLE_IN_1_2 for API nm_access_point_get_last_seen()
Fixes: f3b8285be5
2015-08-09 14:36:55 +02:00
Thomas Haller
8bce48d8bf libnm: backport symbol nm_access_point_get_last_seen@libnm_1_0_6
nm_access_point_get_last_seen() was backported for 1.0.6 in
commit fade4ded37e16e44ff75947dd22d054789c5a2a7.
2015-08-09 12:20:01 +02:00
Dan Winship
578e5e53c0 core: fix runtime warning when building without libaudit
If !HAVE_LIBAUDIT then sizeof(NMAuditManagerPrivate) was 0, which
upset g_type_class_add_private(). (It's also not valid C.)

Fix things up so that NMAuditManagerPrivate as a whole only exists if
HAVE_LIBAUDIT.
2015-08-07 16:46:33 -04:00
Eric Koegel
0db81e1014 sleep-monitor: add support for ConsoleKit2 inhibit
ConsoleKit2 has added the same suspend/resume DBUS API that Systemd
uses. This patch adds the code to use ConsoleKit2's inhibit API.
http://consolekit2.github.io/ConsoleKit2/#Manager.Inhibit

[thaller@redhat.com: modified original patch]

https://bugzilla.gnome.org/show_bug.cgi?id=752836
2015-08-07 11:45:57 +02:00
Thomas Haller
558117222f device: merge branch 'th/device-ignore-auto-bgo752546'
https://bugzilla.gnome.org/show_bug.cgi?id=752546
2015-08-06 17:55:22 +02:00
Thomas Haller
43e6f6a178 device: only 'ignore-auto-routes' and 'ignore-auto-dns' for certain settings
During merge_and_apply(), we merge several NMIPxConfig into a new
@composite. For 'ignore-auto-routes' and 'ignore-auto-dns', we want to
prevent certain routes/dns-settings to be merged.

But it is wrong to reject settings from all partial configs.
For example, especially ext_ipx_config and vpn_ipx_config contain
routes that we still must merge and preserve.

This was recently changed by 79630c11e5
and previously by ab6548c62134518ba2871306397e7fb9c84260ca. But it was
wrong for a long time already.

Also note, that nm_ip4_config_merge() now also ignores NIS, WINS, and
dns-options.

https://bugzilla.gnome.org/show_bug.cgi?id=752546

Fixes: 79630c11e5
2015-08-06 17:52:55 +02:00
Thomas Haller
f7a8962dd4 core: add @merge_flags argument to nm_ip4_config_merge() and nm_ip6_config_merge()
The new flags are not yet used, so there is no change in functionality.

The flags NM_IP_CONFIG_MERGE_NO_ROUTES and NM_IP_CONFIG_MERGE_NO_DNS go
together with the 'ignore-auto-routes' and 'ignore-auto-dns' setting.

Note that for IPv4, NM_IP_CONFIG_MERGE_NO_DNS also ignores NIS, WINS, and dns-options.
This is different from current other places that handle 'ignore-auto-dns'
and only care about nameservers, domains, and searches.
2015-08-06 17:52:55 +02:00
Beniamino Galvani
54d10f0ec1 device: fix memory leak in act_stage3_ip6_config_start()
If linklocal6_start() finds that the device already has an IPv6
link-local address and returns NM_ACT_STAGE_RETURN_FINISH, we don't
need to fill @out_config with an empty configuration. A non-NULL
@out_config is required only for ret = NM_ACT_STAGE_RETURN_SUCCESS.

Fixes: 396dc2b3b4
2015-08-05 18:04:51 +02:00
Thomas Haller
c0138fa7e7 contrib/rpm: compile audit support but disable by default
The default SELinux policy on current RHEL and Fedora distributions
does not allow for NetworkManager to use audit. Hence, unless the user
changes the SELinux policy it will not work.

Disable auditing by default, but have it compiled so that the user can
enable it via "NetworkManager.conf".
2015-08-05 17:05:01 +02:00
Thomas Haller
97ec44f593 libnm: fix gtkdoc for nm_utils_enum_to_str() and nm_utils_enum_from_str()
Fixes: 8be9814793
2015-08-05 16:35:26 +02:00
Thomas Haller
1766ab6e21 libnm: fix gtkdoc for _nm_utils_dns_option_*()
Fixes: 019943bb5d
2015-08-05 16:33:44 +02:00
Thomas Haller
d81e8b96d2 libnm: fix gtkdoc for nm_setting_ip_config_next_valid_dns_option()
Fixes: 019943bb5d
2015-08-05 16:32:00 +02:00