Commit graph

5891 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
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
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
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
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
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
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
57a432fa8a keyfile: refactor to use reading and writing of keyfile from libnm-core 2015-03-12 18:12:26 +01:00
Thomas Haller
e82293ebf6 libnm: move _nm_utils_uuid_generate_from_strings() from src/ to libnm-core/ 2015-03-12 18:12:26 +01:00
Thomas Haller
67510e323a trivial: rename nm_utils_uuid_generate_from_strings() to _nm_utils_uuid_generate_from_strings() 2015-03-12 18:12:26 +01:00
Thomas Haller
c5d23737fd libnm: move _nm_utils_ascii_str_to_int64() from src/ to libnm-core/ 2015-03-12 18:12:26 +01:00
Thomas Haller
093f6d477b trivial: rename nm_utils_ascii_str_to_int64() to _nm_utils_ascii_str_to_int64() 2015-03-12 18:12:26 +01:00
Thomas Haller
b66deb67fa keyfile: remove unused struct member ObjectType.privkey_pw_prop in writer.c 2015-03-12 18:12:26 +01:00
Thomas Haller
f430774ca0 keyfile: handle invalid integer list in keyfile reader get_bytes()
nm_keyfile_plugin_kf_get_integer_list() should always set
@length to zero when returning no integer list. So, this
is probably correct. Still, just to be explicit, anticipate
and handle a missing @tmp_list.
2015-03-12 18:12:26 +01:00
Thomas Haller
7b6759b764 keyfile: make reader more strict in handle_as_path()
When interpreting a blob as filename, ensure that it contains
no NUL character (except the last char).
2015-03-12 18:12:26 +01:00
Thomas Haller
1e4612e476 keyfile: add code comment to cert_writer() and downgrade assertion to g_critical() 2015-03-12 18:12:25 +01:00
Thomas Haller
65729cb740 route-manager: fix memleaks in nm_route_manager_ip4_route_sync()
Fixes: 4c3ba29b40
2015-03-12 13:51:06 +01:00
Dan Williams
a5891299b9 core: quit if manager startup completed before starting the mainloop 2015-03-11 09:17:01 -05:00
Dan Williams
fce2fa57a5 wifi: fix recognition of AP RSN capabilities
Stupid C&P error made everything look like WPA1.

Fixes: 59c8192b22
2015-03-10 13:47:36 -05:00
Dan Williams
e5e0fa566b supplicant: disconnect properties handler on dispose
The supplicant interface's proxy may outlive the interface object
itself, so we must ensure that all signal handlers are disconnected.
Fixes a crash on suspend/resume.

Fixes: 59c8192b22
2015-03-10 08:37:40 -05:00
Lubomir Rintel
7ba2a058f2 nm-device: avoid improper IPv6 MTU configuration
Ensure it's always (before address configuration starts and on updates) >= 1280
and not higher than the device MTU.
2015-03-09 18:21:01 +01:00
Lubomir Rintel
1bc202af02 nm-device: move device MTU setting from IP4Config to NMDevice
Just a refactoring, no functional change. This will make it easier to
coordinate the device MTU with IPv6 MTU.
2015-03-09 18:21:01 +01:00
Lubomir Rintel
4d6bf4eef3 nm-device: set ipv6 mtu at config commit time
Just a refactoring, doesn't make any actual difference. It is consistent with
IPv4 and will make it easier to implement a policy to recover from incorrect
MTUs settings.
2015-03-09 18:21:01 +01:00
Lubomir Rintel
6c5d93b847 route-manager: refactor: a readability improvement 2015-03-09 14:13:02 +01:00
Thomas Haller
02130cc157 supplicant: remove unused variable 2015-03-04 16:42:45 +01:00
Thomas Haller
2e788fac45 dhcp: sd-dhcp6-client: delay setting the DUID and don't fail constructor
reimport systemd dhcp code to bring patch cc22955cfefb4bd6e7a135f1ec95fb5a07ba9ce3.

    sd-dhcp6-client: delay setting the DUID and don't fail constructor

    sd_dhcp6_client_new() tried to set the DUID based on the machine id.
    If the host has no /etc/machine-id, the constructor would fail
    making it impossible to create an sd_dhcp6_client instance.

    Relax this and create a DUID only later as needed. This way a caller
    caller can workaround a missing machine-id file and set a DUID of his
    choosing via sd_dhcp6_client_set_duid().

Conflicts:
	src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp6-client.c
2015-03-04 11:52:26 +01:00