Commit graph

12599 commits

Author SHA1 Message Date
Thomas Haller
feaa4e5b9a platform: EAGAIN is equal to EWOULDBLOCK
The macro EWOULDBLOCK is another name for EAGAIN; they are always the
  same in the GNU C Library.

  https://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/Error-Codes.html

Otherwise, we would need a workaround for EWOULDBLOCK too, because
libnl maps that to NLE_FAILURE. So we would have to detect EAGAIN
as (nle == -NLE_FAILURE && errno == EWOULDBLOCK).

(cherry picked from commit d2fab2df54)
2015-12-10 17:57:22 +01:00
Thomas Haller
df4e535752 platform: fix event_handler_read_netlink_one() wrongly returning with nothing to read
When the errno was accidentally set to EAGAIN or EWOULDBLOCK,
we would only read one single message and return that there is
nothing to read.

This means, if there were more then one messages ready to read,
we would only read the first one and return to the main-loop
(which then again calls back to platform as more data is ready
to be read).

(cherry picked from commit 10b684b827)
2015-12-10 17:20:12 +01:00
Thomas Haller
a89feb474b tests/valgrind: rename name of logfile for valgrind run
Change the name of the file where to store the results
of the valgrind run.

Previously the file had a prefix "valgrind-", which is inconvinient.
Instead, have the file using the same name as the test executable,
with a ".valgrind-log" suffix.

(cherry picked from commit ce238a7074)
2015-12-05 20:36:24 +01:00
Beniamino Galvani
83f4c1c9bf core: strip trailing dot from domain search list
dhclient adds a trailing dot to domain search list entries received
from the server, while the same domains received by other means
(dhcpcd on RA) don't have the final dot. The result is that
resolv.conf can be populated with duplicated entries.

Fix this by stripping the trailing dot when a new search domain is
added to a IP configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=758777
(cherry picked from commit 6e990cf97b)
2015-12-05 10:08:15 +01:00
Thomas Haller
dd088ed595 ppp-manager: fix crash in create_pppd_cmd_line() for ADSL with PPPOE protocol
Failed to lookup pppoe_binary, which results in a failed assertion

    NetworkManager:ERROR:ppp-manager/nm-ppp-manager.c:949:create_pppd_cmd_line: assertion failed: (pppoe_binary != NULL)

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

Fixes: 7955806a02
2015-12-04 14:25:57 +01:00
Jiří Klimeš
77c7292fc6 cli: remove duplicated checks for running Networkmanager
It is already performed in do_connections().

(cherry picked from commit 4c437863fa)
2015-12-03 16:15:29 +01:00
Jiří Klimeš
c66a021b7e dhcp: lifetimes are unsigned integers, use %u printf specifier (rh #1268911)
https://bugzilla.redhat.com/show_bug.cgi?id=1268911

(cherry picked from commit d944a0f134)
2015-12-03 15:29:51 +01:00
Thomas Haller
25c4497173 platform: cope differently with spurious RTM_DELLINK message when unslaving bridge-slave
Unslaving from a bridge causes a wrong RTM_DELLINK event for
the former slave.

    # ip link add dummy0 type dummy
    # ip link add bridge0 type bridge
    # ip link set bridge0 up
    # ip link set dummy0 master bridge0
    # ip monitor link &
    # ip link set dummy0 nomaster
    18: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop master bridge0 state DOWN group default
        link/ether 76:44:5f:b9:38:02 brd ff:ff:ff:ff:ff:ff
    18: dummy0: <BROADCAST,NOARP> mtu 1500 master bridge0 state DOWN
        link/ether 76:44:5f:b9:38:02
    Deleted 18: dummy0: <BROADCAST,NOARP> mtu 1500 master bridge0 state DOWN
        link/ether 76:44:5f:b9:38:02
    18: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
        link/ether 76:44:5f:b9:38:02 brd ff:ff:ff:ff:ff:ff
    19: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    19: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff

Previously, during do_request_link() we would remember the link that is
about to be requested (delayed_deletion) and delay processing a new
RTM_DELLINK message until the end of do_request_link() -- and possibly
forget about about the deletion, if RTM_DELLINK was followed by a
RTM_NEWLINK.

However, this hack does not catch the case where an external command
unslaves the link.

Instead just accept the wrong event and raise a "removed" signal right
away. This brings the cache in an externally visible, wrong state that
will be fixed by a following "added" signal.

Still do that because working around the kernel bug is complicated. Also,
we already might emit wrong "added" signals for devices that are already
removed. As a consequence, a user should not consider the platform signals
until all events are processed.
Listeners to that signal should accept that added/removed link changes
can be wrong and should preferably handle them idly, when the events
have settled.

It can even be worse, that a RTM_DELLINK is not fixed by a following
RTM_NEWLINK:

    ...
    # ip link set dummy0 nomaster
    36: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop master bridge0 state DOWN
        link/ether e2:f2:20:98:3a:be brd ff:ff:ff:ff:ff:ff
    36: dummy0: <BROADCAST,NOARP> mtu 1500 master bridge0 state DOWN
        link/ether e2:f2:20:98:3a:be
    Deleted 36: dummy0: <BROADCAST,NOARP> mtu 1500 master bridge0 state DOWN
        link/ether e2:f2:20:98:3a:be
    37: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
    37: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
        link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff

So, when a slave is deleted, we have to refetch it too.

https://bugzilla.redhat.com/show_bug.cgi?id=1285719
(cherry picked from commit 8a87a91813)

Conflicts:
    src/platform/nm-linux-platform.c
    src/platform/tests/test-link.c
2015-12-01 17:26:02 +01:00
Thomas Haller
ba9a278c7c Revert "platform: cancel delayed action REFRESH_LINK when receiving an update"
On some kernels (at least RHEL-7.2) we receive a spurious RTM_NEWLINK
message after the RTM_DELLINK message for deleting a bond master.

On RHEL-7, the following commands give:

    # ip link add dummy0 type dummy
    # ip link add bond0 type bond
    # ip link set bond0 up
    # ip link set dummy0 master bond0
    # ip monitor link &
    # ip link del bond0
    21: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noqueue state DOWN
        link/ether 1e:a6:6c:81:c1:8d brd ff:ff:ff:ff:ff:ff
    Deleted 21: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
        link/ether 1e:a6:6c:81:c1:8d brd ff:ff:ff:ff:ff:ff
    20: dummy0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
        link/ether 1e:a6:6c:81:c1:8d brd ff:ff:ff:ff:ff:ff
    21: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
        link/ether da:ee:58:70:6f:e5 brd ff:ff:ff:ff:ff:ff

    ^^^^^^^^^^^^^^^ RTM_NEWLINK after RTM_DELLINK (and there follows no
    RTM_DELLINK afterwards)

    21: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN
        link/ether da:ee:58:70:6f:e5 brd ff:ff:ff:ff:ff:ff
    20: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noqueue state DOWN
        link/ether 1e:a6:6c:81:c1:8d brd ff:ff:ff:ff:ff:ff
    20: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noqueue state DOWN
        link/ether 1e:a6:6c:81:c1:8d brd ff:ff:ff:ff:ff:ff

Fix that by reverting clear_REFRESH_LINK(). This fix has two downsides:

- on kernels where this hack is not necessary, we unnecessarily refetch
  a link
- the platform cache first removes the link, adds it again and removes
  it. This is ugly, but should have no real consequences because all
  listeners to the platform signals delay processing the signals to an
  idle handler.

https://bugzilla.redhat.com/show_bug.cgi?id=1285719

This reverts commit f4f4e1cf09 (on master).
This reverts commit 91c00072f2 (on nm-1-0).

(cherry picked from commit 83240f24ae)
2015-12-01 17:21:14 +01:00
Thomas Haller
f5149a1f5a platform: workaround kernel bug about missing IFLA_LINK/parent when creating veth
The related bug rh#1285827 in kernel causes a missing IFLA_LINK/parent
attribute when creating a veth pair:

    # ip monitor link &
    [1] 6745

    # ip link add dev vm1 type veth peer name vm2
    30: vm2@NONE: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
        link/ether be:e3:b7:0e:14:52 brd ff:ff:ff:ff:ff:ff
    31: vm1@vm2: <BROADCAST,MULTICAST,M-DOWN> mtu 1500 qdisc noop state DOWN
        link/ether da:e6:a6:c5:42:54 brd ff:ff:ff:ff:ff:ff

Add a workaround and test.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1285827
(cherry picked from commit 5650c82a8e)

Conflicts:
    src/platform/nm-linux-platform.c
    src/platform/tests/test-link.c
2015-12-01 17:15:01 +01:00
Jiří Klimeš
015f99121f merge: merge changes for getting singleton objects (rh #1286576)
This fixes a problem of invoking wpa_supplicant in main() even if it is
not required later.
2015-12-01 15:32:31 +01:00
Thomas Haller
b8cb56eda7 core: declare nm_agent_manager_get() using NM_DEFINE_SINGLETON_GETTER()
Also move the initilization of the instance into the constructed()
method.

NMAgentManager now owns a reference to the DBUS manager and Auth
manager and the dispose() function properly unregisters itself from
both.

(cherry picked from commit 3af40acf31)
2015-12-01 13:17:23 +01:00
Thomas Haller
9c280a9a73 core: declare nm_supplicant_manager_get() using NM_DEFINE_SINGLETON_GETTER()
(cherry picked from commit d45c1b84f4)
2015-12-01 13:16:58 +01:00
Thomas Haller
cbe410e560 core: declare nm_firewall_manager_get() using NM_DEFINE_SINGLETON_GETTER()
(cherry picked from commit 22409e0481)
2015-12-01 13:14:01 +01:00
Thomas Haller
53737e87e2 core: declare nm_inotify_helper_get() using NM_DEFINE_SINGLETON_GETTER()
Refactor NMInotifyHelper to implement the singleton getter using
NM_DEFINE_SINGLETON_GETTER().

For one this means that the getter no longer increments the reference
count. This was anyway wrong, because no caller of nm_inotify_helper_get()
unrefered the returned reference, hence leaking the singleton.

Also, the getter can no longer fail to create the singleton instance.
Note that none of the callers actually coped with a failure to get
the singleton.
Instead return an instance that does nothing.
One downside (upside?) of this is that we only try once to initialize
the inotify handle.

(cherry picked from commit f4bf50bf4a)
2015-12-01 13:11:06 +01:00
Thomas Haller
6cb1cea4c1 core: declare nm_vpn_manager_get() using NM_DEFINE_SINGLETON_GETTER()
(cherry picked from commit e2739cfc1b)
2015-12-01 13:10:28 +01:00
Thomas Haller
4ab08c3e45 core: declare nm_dhcp_manager_get() using NM_DEFINE_SINGLETON_GETTER()
(cherry picked from commit fc575d6783)
2015-12-01 13:07:05 +01:00
Thomas Haller
7fcb56eaba core: declare nm_dns_manager_get() using NM_DEFINE_SINGLETON_GETTER()
(cherry picked from commit e439637ada)
2015-12-01 13:01:37 +01:00
Thomas Haller
0b654d984c core: declare nm_sleep_monitor_get() using NM_DEFINE_SINGLETON_GETTER()
Also no longer increment the reference count in the getter and
properly disconnect the signals in NMManager:dispose().

Also use the defines for the signal names instead of plain strings.

(cherry picked from commit a8ebd1aa1a)
2015-12-01 12:57:42 +01:00
Jiří Klimeš
816762515b wifi: only try adding supplicant interface 5 times on errors (bgo #753971)
When wpa_supplicant keeps returning an error, NetworkManager was trying over
and over again. Which resulted in endless messages:
<error> [1448462154.584916] [supplicant-manager/nm-supplicant-interface.c:879] interface_add_cb(): (AAA): error adding interface: wpa_supplicant couldn't grab this interface.
NetworkManager[17073]: <info>  (AAA): supplicant interface state: starting -> down

Testcase:
$ iw list | grep -A 3 "interface combinations"
	interface combinations are not supported
	HT Capability overrides:
		 * MCS: ff ff ff ff ff ff ff ff ff ff
		 * maximum A-MSDU length
$ sudo iw wlan0 interface add AAA type managed
...
$ sudo iw dev AAA del

Fixes: 3a2e6de0d3

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

(cherry picked from commit 7e93ceb640)
2015-11-30 15:00:44 +01:00
Jiří Klimeš
717b494a00 cli: fix an error in setting s390-options in nmcli editor
nmcli> set eth.s390-options portno=
(process:4711): libnm-CRITICAL **: nm_setting_wired_add_s390_option: assertion 'value_len > 0 && value_len < 200' failed

(cherry picked from commit 6ffe4b61f7)
2015-11-28 19:56:27 +01:00
Jiří Klimeš
00bfaa4ed7 cli: fix an error in nmcli editor when setting vpn.data/vpn.secrets
nmcli> set vpn.data haha=
(process:3951): libnm-CRITICAL **: nm_setting_vpn_add_data_item: assertion 'strlen (item) > 0' failed
nmcli> set vpn.secrets haha=
(process:3951): libnm-CRITICAL **: nm_setting_vpn_add_secret: assertion 'strlen (secret) > 0' failed

(cherry picked from commit 5f9b8b887d)
2015-11-28 19:56:20 +01:00
Thomas Haller
9012e61bfb platform/tests: drop "platform" test binary
"platform" implements a iproute2 like command-line
tool based on NMPlatform.

It is badly maintained and mostly unused. If we want
to test something, we should write tests that are run
automatically during `make check`. Manual tests just
don't fly.

(cherry picked from commit f122879c83)
2015-11-27 15:55:01 +01:00
Thomas Haller
84c01376ea platform/tests: remove "dump" test-program
The program ran over the platform links and printed them.
Our to-string methods of platform objects are already supposed
to print all fields. So this only duplicates code to print a link.

If you want to see what links were picked up by platfrom run:

  NMTST_DEBUG=log-level=TRACE ./src/platform/tests/monitor

or just

  ./src/platform/tests/monitor

Yes, this has less the iproute2 feeling, but it gives you a more
native access to the platform objects -- which is what you want
for debugging platform.

(cherry picked from commit d13d17f84a)
2015-11-27 15:54:22 +01:00
Thomas Haller
55403cd032 nmtst: refactor NMTST_BUSY_WAIT() and rename to NMTST_WAIT*()
(cherry picked from commit 998772805c)
2015-11-27 15:53:12 +01:00
Thomas Haller
a950a54516 test: add NMTST_BUSY_WAIT() util
(cherry picked from commit 4eb48d8c87)
2015-11-27 15:52:12 +01:00
Thomas Haller
61fd1ecf5c nmtst: support shorthand "NMTST_DEBUG=TRACE" to set logging level
(cherry picked from commit c97f7b54fe)
2015-11-27 15:49:34 +01:00
Jiří Klimeš
2149db231d clients: (trivial) remove unused commented code in nm-vpn-helpers
(cherry picked from commit 191f213c49)
2015-11-26 15:01:16 +01:00
Jiří Klimeš
50867ad4e4 clients: move clients/tui/vpn-helpers.c to clients/common/nm-vpn-helpers.c
The file has not been used up to now. But it is going to be used by both
nmtui and nmcli later.

(cherry picked from commit b8d6bd1a98)
2015-11-26 15:01:08 +01:00
Beniamino Galvani
d1be467d38 ip4-config: properly handle gateway in nm_ip4_config_replace()
When @src didn't have a gateway and @dst did, the function left @dst's
gateway set to 0.0.0.0; fix this and unset the gateway in such case.

Fixes: 063677101a
(cherry picked from commit d1a776bff9)
2015-11-26 10:13:10 +01:00
Thomas Haller
b776301662 platform/tests: use "nm-test-utils.h" in "monitor.c"
This gives us a way to externally configure the logging level like:

  NMTST_DEBUG=log-level=TRACE ./src/platform/tests/monitor

(cherry picked from commit ca8e40e1dc)
2015-11-25 15:16:04 +01:00
Jiří Klimeš
c7cb2e8c1c clients: check errors of polkit_unix_session_new_for_process_sync()
polkit_unix_session_new_for_process_sync() can fail. And calling
polkit_agent_listener_register() with NULL PolkitSubject results in errors.

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

(cherry picked from commit 542200f539)
2015-11-25 12:14:02 +01:00
Thomas Haller
be8619261d core: don't handle SIGUSR1 and SIGUSR2 signals for pre 2.36.0 glib
https://bugzilla.gnome.org/show_bug.cgi?id=758614

Reported-by: Glenn Washburn <development@efficientek.com>
(cherry picked from commit 8aab22fe45)
2015-11-25 10:58:22 +01:00
Thomas Haller
5196e53071 nm-glib: add nm_glib_check_version() util
(cherry picked from commit 4c4b67e515)
2015-11-25 10:58:18 +01:00
Glenn Washburn
061b7bbde8 dhcp-helper: call g_type_init() to support pre 2.36.0 glib
https://bugzilla.gnome.org/show_bug.cgi?id=758614

(cherry picked from commit 7a97d16944)
2015-11-25 10:57:12 +01:00
Fran Diéguez
ad572bedbe po: updated Galician (gl) translation (bgo #758631)
Some errors fixed by Jiri Klimes

https://bugzilla.gnome.org/show_bug.cgi?id=758631
2015-11-25 09:51:35 +01:00
Jiří Klimeš
a261e9c3e5 device: use nm_utils_find_helper() to find out ping/ping6 binary (bgo #758566)
https://bugzilla.gnome.org/show_bug.cgi?id=758566

(cherry picked from commit 795a3943ea)
2015-11-24 14:35:46 +01:00
Thomas Haller
1e7d952731 tests: merge branch 'th/test-run-valgrind'
(cherry picked from commit 5276f6896b)
2015-11-24 11:15:27 +01:00
Thomas Haller
f29aee87ec nmtst/valgrind: allow calling 'run-test-valgrind.sh' script directly
When you want to run valgrind for a test, you either had to
invoke valgrind manually, or doing it via `make check` (provided
you configured --with-valgrind).

Make it more convenient to run valgrind by passing the test
to run to the "run-test-valgrind.sh" wrapper.

This also allows to pass -p/-s to the test, which is not possible
during `make check` because selecting tests conflicts with "--tap".
The following invocations are largely equivalent and work as
expected:

  $ ./tools/run-test-valgrind.sh ./src/platform/tests/test-link-linux -p /link/software/detect/vlan

  $ NMTST_DEBUG=no-debug,p=/link/software/detect/vlan ./tools/run-test-valgrind.sh ./src/platform/tests/test-link-linux

(cherry picked from commit 4dacf0b1ad)
2015-11-24 11:14:50 +01:00
Thomas Haller
243d0facb8 nmtst: support -p and -s arguments from gtestutils via $NMTST_DEBUG
For tests based on glib's test framework, you can select which tests to
run by passing -p/-s on the command line.

Usually, we want to invoke our tests via `make check` which conveniently
calls valgrind (run-test-valgrind.sh) or spawns a private D-Bus server
(libnm-test-launch.sh, libnm-glib-test-launch.sh). At that point, it is
not directly possible to specify command line arguments for the tests,
which is why it is convenient to specify arguments via $NMTST_DEBUG
environment variable.

Parse "p" and "s" arguments from $NMTST_DEBUG and pass them to g_test_init()
to select which tests to run.

  NMTST_DEBUG=p=/core/general/test_setting_ip4_changed_signal ./libnm-core/tests/test-general

However, there is a problem here: in gtestutils, -p/-s conflicts with --tap,
which is how our Makefile invokes the tests. Thus the new options explicitly
don't work when being called during `make check`. Which makes this much
less useful. I only noticed that afterwards, so still keep the patch
because it might still be convenient during developing tests to set the
environment variable once, and then repeatedly spawn the tests, without
specifying -p/-s.

(cherry picked from commit 73cb579108)
2015-11-24 11:14:48 +01:00
Thomas Haller
7eed71d860 nmtst: pass -m=quick when specifying quick test in $NMTST_DEBUG
When the environment variable indicates that we want to run quick
tests, pass "-m=quick" to g_test_init().

(cherry picked from commit a6a2fd7eef)
2015-11-24 11:14:47 +01:00
Thomas Haller
8bdb2aaeea nmtst: detect whether the test runs as tap test
Same as gtestutils does, look for --tap command line argument.

(cherry picked from commit c8174f0f9f)
2015-11-24 11:14:46 +01:00
Thomas Haller
c3aafd9dab nmtst: initialize g_test_init() after parsing NMTST_DEBUG
(cherry picked from commit 5031fc3c71)
2015-11-24 11:14:42 +01:00
Lubomir Rintel
dd32d973b0 release: bump version to 1.0.9 (development) 2015-11-23 18:03:04 +01:00
Lubomir Rintel
faea1ff074 release: bump version to 1.0.8 2015-11-23 17:54:42 +01:00
Thomas Haller
0414e61e9a main: add argument --print-config to NetworkManager
(cherry picked from commit e1ea4b725e)
2015-11-22 13:46:21 +01:00
Lubomir Rintel
2c7ea3d7c3 release: update NEWS 2015-11-20 19:56:34 +01:00
Thomas Haller
0178baea2c default-route: fix deleting default-route when disconnecting device (bgo #757587)
When deconfiguring a device, we must also explicitly clear the
default-route -- unless the device was assumed.

This can easily reproduced by disconnecting the cable from the
wired connection that has the default rout. Prevously, the
default-route was not cleared and lingered around.

https://bugzilla.gnome.org/show_bug.cgi?id=757587
(cherry picked from commit c2831875e3)
2015-11-20 15:26:12 +01:00
Thomas Haller
c8d688874f default-route: introduce _LOG2*() logging macros to log entry-messages
(cherry picked from commit 661ce49973)
2015-11-20 15:24:25 +01:00
Thomas Haller
1bfd5b098d logging: introduce an alternative set of logging macros
We already have the macros _LOGD(), _LOGI(), etc. to provide context sensitive
logging (such as printing the object pointer as prefix).

In some implementations, we would like to have a second set of logging
macros, that shall be used differently. For example, use the default
_LOGD() for messages that are explicitly issued by one objects, and use
_LOG2D() in a static context when no object is around.

The "_LOG2" prefix is not great from a naming point of view. However, it is
meant to be a second (alternative) set of logging macros with the same
usage pattern as the _LOGD() macros.

(cherry picked from commit ed5ebf7e74)
2015-11-20 15:24:25 +01:00