Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
21562052ec main: (order) early start D-Bus service
systemd considers the startup time of NetworkManager until the D-Bus
service is claimed. By doing that earlier, this time is significantly
reduced.
This has the advantage, that services that are ordered to start
after NetworkManager can start earlier. Most notably, 'network.target'
orders itself After=NetworkManager.service and many services are ordered
After=network.target.

  $ systemd-analyze blame | grep NetworkManager.service
2015-03-20 11:43:30 +01:00
Thomas Haller
7fe0f349ce main: (order) move run_from_build_dir check before setting up logging
Or: move setup of nm-logging immediately after it is really needed:
before setup of config.
2015-03-20 11:43:30 +01:00
Thomas Haller
49cfe64874 main: (order) earlier create rundir
Create the rundir earlier and before setting up nm-logging.
nm_main_utils_ensure_rundir() errors out with fprintf(stderr)
and does not need nm-logging.
2015-03-20 11:43:30 +01:00
Thomas Haller
f64c79afda main: (order) log "is starting" message immediately after setting up logging 2015-03-20 11:43:30 +01:00
Thomas Haller
7be9024c82 main: (order) parse state file later and use nm-logging
Parse the state file a bit later after daemonizing and setting up
logging. That way, we can use nm-logging.
2015-03-20 11:43:30 +01:00
Thomas Haller
af2b44cb43 main: (order) check pidfile earlier for running NM
We should check for conflicting process (pidfile)
early on and error out.
2015-03-20 11:43:30 +01:00
Thomas Haller
e36bfaadf7 nm-iface-helper: fix pidfile name and obtain the ifindex earlier
The @ifindex is needed for the @pidfile. Obtain the @ifindex earlier
without resorting to platform.
2015-03-20 11:43:30 +01:00
Thomas Haller
95786a4e4e main: (order) move root user check after help/version option
With this change, `NetworkManager --help` and `NetworkManager --version`
work for non-root user.
2015-03-20 11:43:30 +01:00
Thomas Haller
3696c675fe main: (order) early call _init_nm_debug()
_init_nm_debug() only depends on DEBUG config setting.
Let's call it first after parsing configuration.
2015-03-20 11:43:30 +01:00
Thomas Haller
c50622c845 main: (order) set g_log_set_always_fatal() early on
After parsing the cmd line options, we already can setup fatal glog
level.
2015-03-20 11:43:30 +01:00
Thomas Haller
0587dbe96c main: (order) call g_type_init() very early in main()
g_type_init() is independent of all NetworkManager
functionality. Just get it done early on.
2015-03-20 11:43:30 +01:00
Thomas Haller
12ad2c7fe7 main: refactor nm_main_utils_check_pidfile() to exit directly on failure
And rename the function to nm_main_utils_ensure_not_running_pidfile()
to match the other _ensure_ functions that exit(1).

Also no longer pass @name to nm_main_utils_ensure_not_running_pidfile()
and use g_get_prgname() instead.
nm_main_utils_ensure_not_running_pidfile() checks that the running
process has the same program name, so this changes behavior if the
user renamed the binary. Before, we would check whether the running
process is named 'NetworkManager' ('nm-iface-helper'). Now we check
whether the process has the same name as the current process.
This means, that if you rename the binary to 'NetworkManager2' we
would now only detect a conflicting 'NetworkManager2'. Before we would
only detect conflicting 'NetworkManager' binaries.
2015-03-20 11:43:30 +01:00
Thomas Haller
29718fcaa4 main: split out nm_main_utils_ensure_rundir ()
Also, don't use nm_log_err() as nm-logging is not yet setup.
2015-03-20 11:43:30 +01:00
Thomas Haller
5775df9a6d main: refactor early setup in main()
Move call to nm_main_utils_early_setup() to a separate function.
Also move the @options array away from the main function, saving
a few bytes on the stack.
Now only do_early_setup() modifies the @global_opt structure.
2015-03-20 11:43:29 +01:00
Thomas Haller
1fc5aba42a main: move option variables to static variable
Move the variables to a static struct so that we can factor
out some of the initialization code.

Also it's nice to have all options placed together in one struct so
that is is obvious which static variables are part of the command line
options, and which have other use.
2015-03-20 11:43:29 +01:00
Thomas Haller
b5ca5bd7b7 main-utils: don't leak description for command line arguments in nm_main_utils_early_setup() 2015-03-20 11:43:29 +01:00
Thomas Haller
5e962bef87 main: don't unref config instance at end of main()
config is a singleton implemented using NM_DEFINE_SINGLETON_DESTRUCTOR().
No need to unref it manually.
2015-03-20 11:43:29 +01:00
Thomas Haller
ee4543bd6e main/trivial: change order of arguments for nm_main_utils_early_setup()
Change the order of the argv and argc argument to match
the main() function.
2015-03-20 11:43:29 +01:00
Jiří Klimeš
b8a2f42a38 cli: allow multiple devices for 'nmcli device disconnect/delete' (bgo #746097)
Allow disconnecting and deleting multiple interfaces at a time. It is much
more user friendly. TAB and bash completions are supported as well.

https://bugzilla.gnome.org/show_bug.cgi?id=746097
2015-03-20 11:03:44 +01:00
Thomas Haller
ae0d563906 trivial: use macro instead of plain C string for gobject property name 2015-03-19 17:01:57 +01:00
Lubomir Rintel
5206a9b28d build: fix clang + glib 2.43 build
Known glib issue. Fixes Fedora 22 build.
2015-03-19 16:29:33 +01:00
Lubomir Rintel
f0740aff88 build: disable warnings that trigger known clang problems
Fixes build with clang 3.5 on Fedora 21.
2015-03-19 11:48:49 +01:00
Lubomir Rintel
3ccc6f290d build: disable warnings where macros expand to tautological comparisons 2015-03-19 11:48:49 +01:00
Lubomir Rintel
a43f95b0ac trivial: remove a tautological compare
Unsigned enum is always >= 0.
2015-03-19 11:48:49 +01:00
Lubomir Rintel
fd41aa451b libnm,core: don't mix up enum types
Touches a weak spot on clang's soul.
2015-03-19 11:48:49 +01:00
Petr Vorel
1e646f30f2 examples: bash: print errors int stderr
+ whitespace

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
2015-03-18 15:07:59 -05:00
Lubomir Rintel
396dc2b3b4 device: if there's a ll address already don't re-commit it
Configuration commit is an unsafe thing to do for assumed connections,
it can remove an externally added address we don't know about yet.

The device already has a link-local address; for an assumed connection
it's the reason we assumed the method=link-local in the first place.
2015-03-17 17:16:03 +01:00
Lubomir Rintel
a8a9955d75 device: fix a couple of copy & paste errors 2015-03-17 15:36:12 +01:00
Lubomir Rintel
f85513b8e4 device: do not touch sysctls after the device was removed
Paths to sysctls don't use ifindex and device names can be reused. If someone
removes a device and quickly creates a device with the same name, chances are
we're cleaning up the device that was just added.

Sadly, it seems there's no better API than sysctl-- neither netlink nor procfs
symlinks with ifindex or anything like that.
2015-03-17 15:36:12 +01:00
Thomas Haller
d05bedbc0d libnm/keyfile: fix format string for unsigned integer
Fixes: 04df4edf48
2015-03-17 13:00:16 +01:00
Thomas Haller
d198618aa7 libnm: fix error prefix in NMSettingGsm:verify() 2015-03-17 11:49:55 +01:00
Jiří Klimeš
f52e6bbdda cli: do not stall in 'nmcli connection delete/down' (rh #1168657)
NetworkManager only responds to the last D-Bus call when called delete/down
for the same connection in quick succession. (It should be fixed later).
So do not issue the call multiple times to prevent that. Otherwise nmcli would
stall waiting for the response.

https://bugzilla.redhat.com/show_bug.cgi?id=1168657
2015-03-16 16:58:05 +01:00
Dan Williams
90692e3eff connectivity: disable HTTP keepalive for connectivity checks
There won't be any further requests, so there's no point in keeping
the connection alive.  Even if the HTTP server doesn't care, proxy
servers in-between might keep the connection open for a couple seconds
for keepalive, and we might as well be nice to them and tell them we
don't need to keep it alive.
2015-03-16 10:45:25 -05:00
Thomas Haller
2e86c37dd3 trivial: do an assignment before the conditional instead of in both branches
[lkundrak@v3.sk: An improvement suggested in bugzilla, but I failed to apply
it to the commit.]

https://bugzilla.redhat.com/show_bug.cgi?id=1079353
2015-03-16 15:44:14 +01:00
Thomas Haller
641a57994c valgrind: fix suppressions for Fedora 20
Fixes: 3cde821344
2015-03-16 11:34:20 +01:00
Lubomir Rintel
dba4e8ece8 libnm,nm-object: fix tracing of object removal
When a new connection is activated and presently active connection goes away,
the active-connection-removed signal is not emitted for the old connection.
This is what happens:

1.) Initially, nm-manager::active-connections = [ActiveConnection/old]

2.) First PropertyChange is signalled for the new connection addition:
nm-manager::active-connections = [ActiveConnection/old,ActiveConnection/new]

This triggers load of ActiveConnection/new object.

3.) Another PropertyChange is signalled for the old connection removal:
nm-manager::active-connections = [ActiveConnection/new]

This removes the ActiveConnection/old object from
nm-manager::active-connections and enqueues active-connection-removed
signal. The signal is not emmitted as there's a reload from 2.) in progress.

4.) ActiveConnection/new reload finished

object_property_complete() compares
[ActiveConnection/old,ActiveConnection/new] from its odata to current
nm-manager::active-connections and incorrectly concludes that
ActiveConnection/old was just added and removes the enqueued
active-connection-removed signal.

This patch fixes the issue by remembering the original
nm-manager::active-connections property value at 2.).

[thaller@redhat.com: fixed an integer overflow and odata->array unreffing]

https://bugzilla.redhat.com/show_bug.cgi?id=1079353
2015-03-16 10:54:57 +01:00
Jiří Klimeš
27bd0b7317 cli: only offer active connections in TAB completion for 'nmcli con down' 2015-03-13 10:14:50 +01:00
Lubomir Rintel
2e99ddb7a7 device: unschedule ip update if we just scheduled ip configuration
It would subtract the configuration from device confguration that's not yet
applied. This a the race where the loose the address while activating a
connection that has both IPv6 and IPv4 configuration.

Fixes: 557667df12

https://bugzilla.gnome.org/show_bug.cgi?id=746066
2015-03-13 08:21:57 +01:00
Lubomir Rintel
a772fde00d trivial: move nm_device_queued_ip_config_change_clear()
Just move it upwards, we'll need it in
nm_device_activate_schedule_ip4_config_result().
2015-03-13 08:21:45 +01:00
Dan Williams
d2de83e0f7 device: don't assume valid ip4/ip6 config in nm_device_get_ipX_route_metric()
These functions will sometimes get called on updates to the device's IP
config due to external changes, or when addresses get flushed from the
device when activating it.  If the device is a slave device, then at
this point its NMConnection won't have an IP settings.  Suppress the
warning that gets printed when s_ip == NULL, because it's expected.
2015-03-12 15:04:16 -05:00
Dan Williams
1dae47e9cc device: fix handling if DHCP hostname for configure-and-quit
Fixes: 5149fd120d
2015-03-12 14:38:01 -05:00
Dan Williams
28983b705c valgrind: fix suppression for newer glib 2015-03-12 13:46:28 -05:00
Dan Williams
acd6226e8a dispatcher: fix memleak in construct_device_dhcp4_items()
When iterating over a container variant, the children values
must be unrefed when no longer used.
2015-03-12 13:24:32 -05:00
Dan Williams
3cde821344 valgrind: update suppressions for newer glib and toolchain changes
It appears that the .isra and .part pieces can change depending on
how glib was built, so ignore those parts.  Add some new suppressions
for newer glib too.
2015-03-12 13:12:21 -05:00
Thomas Haller
59eb5312a5 keyfile: merge branch 'th/libnm-keyfile-bgo744699'
Move basic keyfile functionality from settings plugin to libnm-core.
This is a first step to have a semi-standard way to stringify
connections back and forth, which is also available to libnm users.

Still the new functions are internal API (nm-keyfile-internal.h).
Let's decide later how the public API should really look like.

https://bugzilla.gnome.org/show_bug.cgi?id=744699
2015-03-12 18:22:12 +01:00
Thomas Haller
997fc07ca5 test: add nmtst_create_connection_from_keyfile() 2015-03-12 18:16:58 +01:00
Thomas Haller
c9a8764ad2 keyfile: support writing certificates as blob inside the keyfile
keyfile should become our main import/export format. It is desirable,
that a keyfile can contain every aspect of a connection.

For blob certificates, the writer in core daemon would always write
them to a file and convert the scheme to path.
This behavior is not great for a (hyptetical) `nmcli connection export`
command because it would have to export them somehow outside of keyfile,
e.g. by writing them to temporary files.

Instead, if the write handler does not handle a certificate, use a
default implementation in nm_keyfile_write() which adds the blob inside
the keyfile.

Interestingly, keyfile reader already supported reading certificate
blobs. But this legacy format accepts the blob as arbitrary
binary without marking the format and without scheme prefix.
Instead of writing the binary data directly, write it with a new
uri scheme "data:;base64," and encode it in base64.

Also go through some lengths to make sure that whatever path
keyfile plugin writes, can be read back again. That is, because
keyfile writer preferably writes relative paths without prefix.
Add nm_keyfile_detect_unqualified_path_scheme() to encapsulate
the detection of pathnames without file:// prefix and use it to
check whether the path name must be fully qualified.
2015-03-12 18:16:58 +01:00
Thomas Haller
a49680dacd libnm: add define for cert scheme prefix file:// for NMSetting8021x 2015-03-12 18:12:27 +01:00
Thomas Haller
57a432fa8a keyfile: refactor to use reading and writing of keyfile from libnm-core 2015-03-12 18:12:26 +01:00
Thomas Haller
5e5afcffce libnm: merge nm-keyfile-reader.h and nm-keyfile-writer.h to internal header
These headers are not entirely private to libnm-core as they are also
used by keyfile plugin. Merge them to a new header file
nm-keyfile-internal.h so that the name makes the internal nature of the
header more apparent.
2015-03-12 18:12:26 +01:00