Commit graph

5710 commits

Author SHA1 Message Date
Dan Williams
10aff12526 dns: kill plugin child synchronously to avoid restart race (rh #1161232) (bgo #728342)
NM was killing the dnsmasq local caching nameserver process and immediately
starting a new one, and new process couldn't bind to 127.0.0.1 because the
old one hadn't quit yet.  Thus the new process quit, and the user was
left with no split DNS at all.

While this does introduce more synchronous waiting into the connection
process, it's not that much time and NM will kill dnsmasq if it hasn't
quit after 1 second.  The longer-term fix is to use dnsmasq's D-Bus
interface to update DNS without respawning it.

https://bugzilla.gnome.org/show_bug.cgi?id=728342
https://bugzilla.redhat.com/show_bug.cgi?id=1161232
2015-03-27 16:20:55 -05:00
Dan Williams
c4b9f397c8 core: use dev_id when calculating the interface IPv6 IID (rh #1101809)
Some device types (s390 OSA and ipvlan) can use the same link-layer address
for multiple virtual interfaces, and the kernel used the dev_id property
to differentiate these devices when constructing the IID.  NM should do
this too to prevent IID clashes.

https://bugzilla.redhat.com/show_bug.cgi?id=1101809
2015-03-27 15:24:49 -05:00
Dan Williams
51fd5a9bd7 platform: add nm_platform_link_get_dev_id()
Some devices (s390 OSA and ipvlan) use the same link layer address
for different interfaces, and dev_id is what differentiates them.
2015-03-27 15:24:48 -05:00
Dan Williams
f3902ca423 platform: update code documentation for nm_platform_link_get_physical_port_id() 2015-03-27 15:18:03 -05:00
Thomas Haller
4cc06783ab libnm: accept unknown WEP key type in nm_utils_wep_key_valid()
libnm-core treated the UNKNOWN WEP key type as KEY. Relax that
and try to guess the correct type based on the key.

This is for example important if you have a valid connection with
  wep-key-type=0 (unknown)
If you request passwords for such a connection, the user cannot
enter them in password format -- but there is no UI indication
that the password must be KEY.

(cherry picked from commit 628f47285d)
2015-03-20 13:07:10 +01:00
Thomas Haller
e860c0e4ea 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

(cherry picked from commit 21562052ec)

Conflicts:
	src/main.c
2015-03-20 12:47:09 +01:00
Thomas Haller
b24d44cb2d 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.

(cherry picked from commit 7fe0f349ce)
2015-03-20 12:43:31 +01:00
Thomas Haller
06d038cd58 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.

(cherry picked from commit 49cfe64874)
2015-03-20 12:43:31 +01:00
Thomas Haller
ba054666f0 main: (order) log "is starting" message immediately after setting up logging
(cherry picked from commit f64c79afda)

Conflicts:
	src/main.c
2015-03-20 12:43:29 +01:00
Thomas Haller
22db307456 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.

(cherry picked from commit 7be9024c82)
2015-03-20 12:41:56 +01:00
Thomas Haller
bc2ea72a79 main: (order) check pidfile earlier for running NM
We should check for conflicting process (pidfile)
early on and error out.

(cherry picked from commit af2b44cb43)
2015-03-20 12:41:56 +01:00
Thomas Haller
f8430aaa9f 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.

(cherry picked from commit e36bfaadf7)
2015-03-20 12:41:56 +01:00
Thomas Haller
4a42792322 main: (order) move root user check after help/version option
With this change, `NetworkManager --help` and `NetworkManager --version`
work for non-root user.

(cherry picked from commit 95786a4e4e)

Conflicts:
	src/main-utils.c
	src/main-utils.h
2015-03-20 12:41:54 +01:00
Thomas Haller
3aad126ec1 main: (order) early call _init_nm_debug()
_init_nm_debug() only depends on DEBUG config setting.
Let's call it first after parsing configuration.

(cherry picked from commit 3696c675fe)
2015-03-20 12:40:01 +01:00
Thomas Haller
ed26762e13 main: (order) set g_log_set_always_fatal() early on
After parsing the cmd line options, we already can setup fatal glog
level.

(cherry picked from commit c50622c845)
2015-03-20 12:40:01 +01:00
Thomas Haller
4753027ddd 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.

(cherry picked from commit 0587dbe96c)

Conflicts:
	src/nm-iface-helper.c
2015-03-20 12:39:59 +01:00
Thomas Haller
4c396b6e2c 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.

(cherry picked from commit 12ad2c7fe7)
2015-03-20 12:39:20 +01:00
Thomas Haller
8782998056 main: split out nm_main_utils_ensure_rundir ()
Also, don't use nm_log_err() as nm-logging is not yet setup.

(cherry picked from commit 29718fcaa4)
2015-03-20 12:39:20 +01:00
Thomas Haller
c7fe834bdf 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.

(cherry picked from commit 5775df9a6d)
(cherry picked from commit 8e58fc7425)

Conflicts:
	src/main.c
	src/nm-iface-helper.c
2015-03-20 12:38:48 +01:00
Thomas Haller
8295b75742 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.

(cherry picked from commit 1fc5aba42a)

Conflicts:
	src/nm-iface-helper.c
2015-03-20 11:56:51 +01:00
Thomas Haller
9cc54f43bc main-utils: don't leak description for command line arguments in nm_main_utils_early_setup()
(cherry picked from commit b5ca5bd7b7)
2015-03-20 11:53:26 +01:00
Thomas Haller
126723f94d 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.

(cherry picked from commit ee4543bd6e)
2015-03-20 11:52:02 +01:00
Lubomir Rintel
6a147dff87 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.

(cherry picked from commit 396dc2b3b4)
2015-03-17 17:19:00 +01:00
Lubomir Rintel
409c0fb544 device: fix a couple of copy & paste errors
(cherry picked from commit a8a9955d75)
2015-03-17 17:18:59 +01:00
Lubomir Rintel
4c8cbc6534 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.

(cherry picked from commit f85513b8e4)
2015-03-17 17:18:58 +01:00
Dan Williams
46c836e5cd 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.

(cherry picked from commit 90692e3eff)
2015-03-16 10:49:36 -05:00
Thomas Haller
545fbd2b09 config/test: fix memleaks in test-config.c 2015-03-13 11:50:51 +01:00
Thomas Haller
d510f0a039 config: fix memleak in merge_no_auto_default_state() 2015-03-13 11:50:51 +01:00
Thomas Haller
537ce96fa2 config/tests: inject NMDBusManager for tests in NMDevice stub
We don't need the bus for the tests and the manager may warn when it
is not available.

  $ (cd src/tests/config/; env -i DBUS_SYSTEM_BUS_ADDRESS=meow ./test-config)

  /config/parse-error: OK
  /config/no-auto-default: NetworkManager-Message: <info>  Could not connect to the system bus; only the private D-Bus socket will be available.
  /bin/sh: line 5: 29997 Trace/breakpoint trap   ${dir}$tst
  FAIL: test-config

This reverts commit 6994454461 for the
most part. It's not sufficient to disable logging warnings. Creating
a DBus Manager might affect the system in undesired ways.

(cherry picked from commit 5040a8a851)
2015-03-13 11:50:51 +01:00
Thomas Haller
36a136fb58 config/test: move test over to nm-test-util
(partially cherry picked from commit 13c7f6a56d)

Conflicts:
	src/tests/config/test-config.c
2015-03-13 11:50:51 +01:00
Thomas Haller
91144ee070 dbus-manager: add nm_dbus_manager_setup() function for testing
(cherry picked from commit 9b16e85ece)
2015-03-13 11:50:50 +01:00
Thomas Haller
07786f6ee6 dbus-manager: refactor singleton getter dropping g_once_init_enter()
The class itself is not thread-safe, so no need for guarding
the creation with g_once_init_*().

Also, assert against multiple creation and log a line when
creating the singleton. The getter is now more similar to what
is created by NM_DEFINE_SINGLETON_GETTER().

(cherry picked from commit 99465a34ca)
2015-03-13 11:50:50 +01:00
Thomas Haller
04f22b9a44 dbus: destroy singleton instance of NMDBusManager on exit
Don't have the singleton instance of NMDBusManager owned by
the main function. Instead use NM_DEFINE_SINGLETON_DESTRUCTOR()
which also logs what's happening.

(cherry picked from commit 1208c0dd13)

Conflicts:
	src/main.c
2015-03-13 11:50:50 +01:00
Thomas Haller
62bff65e14 core/trivial: rename singleton variables according to default name
(cherry picked from commit 822cb293ef)
2015-03-13 11:50:50 +01:00
Thomas Haller
cea32bd0dc core: fix memleak in NMDBusManager:private_server_new()
(cherry picked from commit 96b8b99c7d)
2015-03-13 11:50:50 +01:00
Dan Williams
c505658815 ifcfg-rh: fix memleak in test-ifcfg-rh.c
(cherry picked from commit ad90f2f0ea)
2015-03-13 11:50:50 +01:00
Dan Williams
33264396c9 tests: fix memleaks in test-wifi-ap-utils.c
(cherry picked from commit 51b3540ae4)
2015-03-13 11:50:50 +01:00
Lubomir Rintel
411fa7d002 test: initialize auto-destructed pointers
Otherwise the compiler complains that they could be left uninitialized in case
the function returns too early.

Fixes: 76745817c3
(cherry picked from commit 2981839bde)
2015-03-13 11:50:50 +01:00
Thomas Haller
b9a8f3c059 tests: enable valgrind tests for tests
(cherry picked from commit c50f30e79c)
2015-03-13 11:50:04 +01:00
Thomas Haller
c2cd7e631f platform/tests: reenable valgrind tests
valgrind tests for platform were wrongly disabled.

Fixes: e3784fa618
(cherry picked from commit 6853d07f05)
2015-03-13 11:50:04 +01:00
Thomas Haller
692619ea89 supplicant/tests: fix memleaks in test code for valgrind
(cherry picked from commit 624aa51614)
2015-03-13 11:50:04 +01:00
Thomas Haller
12ee98f471 dhcp/tests: fix memleaks in test code for valgrind
(cherry picked from commit d74a3d0a02)
2015-03-13 11:50:04 +01:00
Thomas Haller
4f685b4310 config/tests: fix memleak in test code for valgrind
(cherry picked from commit 63f5a22ad7)
2015-03-13 11:50:04 +01:00
Thomas Haller
a369923d03 device: refactor dispose/cleanup of NMDevice to free members in finalize
NMTestDevice does not invoke dispose(), hence it leaks memory which causes
false warnings in testing.
Some minor refactring to let dispose() clear the fields, but free it
later in finalize(). This avoids memleaks in the NMTestDevice stub.

(cherry picked from commit a82d94a64e)
2015-03-13 11:50:04 +01:00
Thomas Haller
e25d06cf71 ifcfg-rh/tests: fix memleaks in test code for valgrind
(cherry picked from commit 0750d934bf)
2015-03-13 11:50:04 +01:00
Thomas Haller
72666156e3 ibft/tests: fix memleaks in test code for valgrind
(cherry picked from commit fbe8c0ed87)
2015-03-13 11:50:04 +01:00
Thomas Haller
f334c4a7f1 keyfile/tests: fix memleaks in test code for valgrind
(cherry picked from commit 9a2f2ed7fd)
2015-03-13 11:50:04 +01:00
Thomas Haller
b352d0a26b core/tests: fix memleak in tests to avoid valgrind warnings
(cherry picked from commit 1680bf3ad1)
2015-03-13 11:50:04 +01:00
Thomas Haller
84ff53ec76 dhcp: fix memleak in process_dhclient_rfc3442_route()
(cherry picked from commit 1935fca09a)
2015-03-13 11:50:04 +01:00
Thomas Haller
825eb5cb62 ifcfg-rh: fix memleak in write_ip4_aliases() and assert against overflow
(cherry picked from commit a9bfe9f4bb)
2015-03-13 11:50:04 +01:00