Commit Graph

14110 Commits

Author SHA1 Message Date
Dan Williams
15d305c07f utils: add @filter_func argument to nm_utils_g_value_set_object_path_array() 2015-12-04 12:15:12 +01:00
Thomas Haller
9e36ccbe28 device: split new_device_added() out of component_added()
Commit cd3df12c8f reused the
virtual function component_added() to notify the vlan device
about a possibly new parent.

This reuse of the virtual function for another purpose is confusing.
Clean that up by splitting the implementation and add a new
virtual function nm_device_notify_new_device_added() which gets
(only implemented by NMDeviceVlan).
2015-12-04 12:15:12 +01:00
Lubomir Rintel
d681cbfd3d libnm-glib: queue added/removed signals and suppress uninitialized notifications
This is a straightforward copy of the changes done in libnm. It is done to cope
with test failures due to redundant or misordered signals. See
commit 52ae28f6e5 for a detailed explanation.
2015-12-04 12:15:12 +01:00
Thomas Haller
2e1e7ff0e6 device: fix disconnecting slave-device when master gets deleted
When deleting a master-device either via `nmcli device delete`
or `ip link delete`, the slave-device would hang.

This seems to be broken for a very long time already.

This is due to the following:

  #0  0x00005555555f548c in nm_device_slave_notify_release (self=0x555555dc1300, reason=NM_DEVICE_STATE_REASON_NONE) at devices/nm-device.c:2175
  #1  0x00005555555d6de2 in nm_device_release_one_slave (self=0x555555de3dd0, slave=0x555555dc1300, configure=0, reason=NM_DEVICE_STATE_REASON_NONE) at devices/nm-device.c:1117
  #2  0x00005555555f02b7 in device_link_changed (self=0x555555dc1300) at devices/nm-device.c:1460

Previously, nm_device_slave_notify_release() being called with reason
"NONE" did not actually transition the device-state, thus keeping the
device wrongly in activated state.

There were two callers that passed configure=FALSE to nm_device_release_one_slave(),
(and thus reason=NONE to nm_device_slave_notify_release()):

  - (1) device_link_changed():
      nm_device_release_one_slave (priv->master, self, FALSE, /*wrong reason NONE*/);
  - (2) nm_device_removed():
      nm_device_release_one_slave (priv->master, self, FALSE, NM_DEVICE_STATE_REASON_REMOVED);

We should always change the device-state during nm_device_slave_notify_release()
regardless of the reason.

(2) was added by commit c83b40aca7, later
refined by commit 5dd48f7527. In a way
change the second fix to perform some of the configuration (but still
not unenslaving the device).
2015-12-04 12:10:26 +01:00
Jiří Klimeš
4c437863fa cli: remove duplicated checks for running Networkmanager
It is already performed in do_connections().
2015-12-03 16:12:26 +01:00
Jiří Klimeš
d944a0f134 dhcp: lifetimes are unsigned integers, use %u printf specifier (rh #1268911)
https://bugzilla.redhat.com/show_bug.cgi?id=1268911
2015-12-03 15:25:54 +01:00
Beniamino Galvani
bde713b8e2 platform/tests: adding missing checks for loaded modules
Check if 'ipip' and 'ip6_tunnel' modules are loaded when trying to
perform link tests that require them and skip the tests if the modules
are not available.

Fixes: 133724d958
Fixes: 1a3448b43b
2015-12-02 10:18:38 +01:00
Beniamino Galvani
193bf92918 merge: branch 'bg/device-creation-ip-tunnel-bgo758047'
Add support for creating IP tunnel interfaces.

https://bugzilla.gnome.org/show_bug.cgi?id=758047
2015-12-01 17:45:27 +01:00
Beniamino Galvani
818f7f5724 libnm-glib: add support for IP tunnel devices as generic ones 2015-12-01 17:39:41 +01:00
Beniamino Galvani
e2da055f90 libnm: add NMDeviceIPTunnel 2015-12-01 17:39:41 +01:00
Beniamino Galvani
8361fbf010 device/ip-tunnel: add support for IP6TNL tunnels 2015-12-01 17:39:41 +01:00
Beniamino Galvani
8d2aa13534 device/ip-tunnel: add support for IPIP tunnels 2015-12-01 17:39:41 +01:00
Beniamino Galvani
d1b389bfa8 device/ip-tunnel: add support for SIT tunnels 2015-12-01 17:39:41 +01:00
Beniamino Galvani
3dfeec75e5 device: remove NMDeviceGre
As per previous commit, GRE tunnels are now represented as generic IP
tunnel devices.
2015-12-01 17:39:41 +01:00
Beniamino Galvani
570fdce93f device: add NMDeviceIPTunnel
The new object type represents tunnels over IPv4 and IPv6.

We have a single setting type (NMSettingIPTunnel) for tunnels and it
can't be shared among different device factories. So we define also a
single device type for all tunnels.

This new object will also represent GRE tunnels, which before were
instantiated as NMDeviceGre and had a ".Device.Gre" D-Bus
interface. This commit introduces a change in behavior.
2015-12-01 17:39:41 +01:00
Beniamino Galvani
1a3448b43b platform/tests: test IP6TNL links 2015-12-01 17:39:41 +01:00
Beniamino Galvani
133724d958 platform/tests: test IPIP links 2015-12-01 17:39:41 +01:00
Beniamino Galvani
3063f40e9a platform/tests: test SIT links 2015-12-01 17:39:41 +01:00
Beniamino Galvani
0d606a187b platform/tests: test GRE links also using platform code 2015-12-01 17:39:41 +01:00
Beniamino Galvani
32f6e1ef2e platform: add IP6TNL links support 2015-12-01 17:39:41 +01:00
Beniamino Galvani
30e648f981 platform: add IPIP links support 2015-12-01 17:39:41 +01:00
Beniamino Galvani
0754280b9f platform: add SIT links support 2015-12-01 17:39:41 +01:00
Beniamino Galvani
91bf0efaa7 platform: add GRE links creation support 2015-12-01 17:39:41 +01:00
Beniamino Galvani
b614a5ec61 cli: add support for IP tunnel settings 2015-12-01 17:39:41 +01:00
Beniamino Galvani
ae8c7a8967 libnm-core: add NMSettingIPTunnel
Add a generic NMSettingTunnel which describes properties of tunnels
over IPv4 and IPv6 (GRE, SIT, IPIP, IPIP6, IP6GRE, etc.). Since those
tunnel types all have similar properties it makes sense to have a
single setting type for them.
2015-12-01 17:39:40 +01:00
Beniamino Galvani
13a981fc38 libnm-core: add nm_utils_enum_get_values()
Add function nm_utils_enum_get_values() which returns a string array
containing the enum values. It can be used, for example, to build a
list of allowed values for user.
2015-12-01 17:39:40 +01:00
Lubomir Rintel
604711488d libnm: avoid loosing signals
D-Bus has an upper limit on number of Match rules and it's rather easy
to hit as the proxy likes to add one for each object. Let's remove the Match
rule the proxy added and ensure a less granular rule is present instead.

Ideally, we should be able to tell glib not to hook its rules.
Related: https://bugzilla.gnome.org/show_bug.cgi?id=758749

https://bugzilla.gnome.org/show_bug.cgi?id=758751
2015-12-01 14:51:13 +01:00
Jiří Klimeš
7e93ceb640 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
2015-11-30 14:50:30 +01:00
Thomas Haller
27835ba73c Revert "systemd: fix potential memory leaks"
@random_data is declared as _cleanup_free_.

Freeing it is unnecessary and freeing without clearing the
pointer leads do a double free.

This reverts commit 3d1557eaad.
2015-11-28 22:53:31 +01:00
Jiří Klimeš
4eab8191eb man: add missing description of tun parameters in nmcli manual page
Fixes: 64c6b124d2
2015-11-28 19:48:02 +01:00
Jiří Klimeš
cb049d2500 cli: allow TAB-completion for tun.mode in nmcli editor
Fixes: 64c6b124d2
2015-11-28 19:48:02 +01:00
Jiří Klimeš
d374352b99 cli: allow TAB-completion of "Mode:" in 'nmcli -a con add type tun'
Fixes: 64c6b124d2
2015-11-28 19:48:02 +01:00
Jiří Klimeš
18b7a9a42f cli: ask user before requiring optional parameters for 'nmcli -a con add type tun'
Fixes: 64c6b124d2
2015-11-28 19:48:02 +01:00
Jiří Klimeš
6ffe4b61f7 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
2015-11-28 19:48:02 +01:00
Jiří Klimeš
5f9b8b887d 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
2015-11-28 19:48:02 +01:00
Jiří Klimeš
1b0be2bab0 cli: fix a crash in 'nmcli -a con clone'
when providing empty arguments.

Fixes: 0c65b28960
2015-11-28 19:48:02 +01:00
Jiří Klimeš
3d1557eaad systemd: fix potential memory leaks
Found by clang scan-build
2015-11-28 19:48:02 +01:00
Lubomir Rintel
b1076a698c build: re-add NetworkManager.conf.xml.in to dist
Fixes: 90683fcb3a
2015-11-28 17:26:33 +01:00
Thomas Haller
7300e59c14 platform: merge branch 'th/platform-netlink-events'
Add test cases for certain netlink peculiarities
and fix our NMLinxPlatform implementation to handle
them better.
2015-11-27 15:27:19 +01:00
Thomas Haller
832539a511 platform: emit signals by signal-id instead of string
We potentially emit a lot of signals. Don't look up the
signal by name because that adds quite some additional
overhead, like peeking for a GQuark.

Instead pass the numeric signal-id directly.
2015-11-27 15:17:44 +01:00
Thomas Haller
510e53ca16 platform: remove NMPlatformReason enum
This enum was unused and meaningless because the platform signals
are emitted as a consequence of netlink messages. It is not clear
whether a netlink message was received due to an external event
or an internal action.
2015-11-27 15:17:44 +01:00
Thomas Haller
8a87a91813 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
2015-11-27 15:14:55 +01:00
Thomas Haller
83240f24ae 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.
2015-11-27 14:38:12 +01:00
Thomas Haller
29c293728d platform/tests: add test for missing netlink notification for IFA_LINK_NETNSID
The related bug rh#1262908 in kernel causes missing netlink notifications
when moving a IFA_LINK interface to another netns.

Add a test for our workaround.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1262908
2015-11-27 14:38:12 +01:00
Thomas Haller
5650c82a8e 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
2015-11-27 14:22:06 +01:00
Thomas Haller
4488cf6903 platform: add workaround for incomplete netlink link messages
Due to kernel bugs [1], the first netlink event about a new link
sometimes lacks the IFLA_LINKINFO with the link-type lnk data.

In the case the data is missing, schedule a re-fetch the link
hoping that it gets send.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1284001
2015-11-27 14:22:06 +01:00
Thomas Haller
557c495326 platform/tests: add namespace helper functions to nmtstp 2015-11-27 14:22:06 +01:00
Thomas Haller
d72fe89899 platform/tests: add @expected_link_type to nmtstp_wait_for_link() 2015-11-27 14:22:06 +01:00
Thomas Haller
f122879c83 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.
2015-11-27 14:22:06 +01:00
Thomas Haller
998772805c nmtst: refactor NMTST_BUSY_WAIT() and rename to NMTST_WAIT*() 2015-11-27 14:22:06 +01:00