Commit graph

17279 commits

Author SHA1 Message Date
Thomas Haller
112f09cf4b libnm: return zero flags value from nm_utils_enum_to_str()
It is not uncommon that a flags type has also the value 0 mapped,
for example to "unknown" or "none".

In that case, we should not return an empty string, but instead
that zero value.

Also, flags actually have an unsigned type. That isn't a real
problem to cast it to a signed int. But be more careful about
it and use unsigned while handling unsigned values and only
cast to int once.
2017-03-30 13:09:54 +02:00
Thomas Haller
255bc928d7 libnm: fix error message for invalid ipv6.addr-gen-mode 2017-03-30 10:19:13 +02:00
Beniamino Galvani
166988264f device: update the address type in nm_device_hw_addr_set_cloned()
Commit 029a0a21ea ("device: split out cloned MAC decision from
nm_device_hw_addr_set_cloned()") accidentally removed the assignment
of the new device @hw_addr_type, which then was left to
HW_ADDR_TYPE_UNSET. As a consequence, we never restored the initial
MAC address when the connection was deactivated. Fix this.

Fixes: 029a0a21ea
2017-03-30 09:54:20 +02:00
Beniamino Galvani
e73c15eec9 device: don't update disconnected devices routes after connectivity check
When the device is not activated it does not make sense to try to
update its default route metric based on connectivity status.

Fixes the following:

 nm_ip4_config_commit: assertion 'ifindex > 0' failed

 #0  raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/pt-raise.c:37
 #1  g_logv (breakpoint=1) at gmessages.c:324
 #2  g_logv (log_domain=<> "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=<optimized out>) at gmessages.c:1081
 #3  g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1119
 #4  g_return_if_fail_warning (log_domain=<optimized out>, pretty_function=<optimized out>, expression=<optimized out>) at gmessages.c:1128
 #5  nm_ip4_config_commit (config=<> [NMIP4Config], ifindex=<optimized out>, routes_full_sync=<optimized out>, default_route_metric=-1) at src/nm-ip4-config.c:339
 #6  nm_device_set_ip4_config (self=<> [NMDeviceTun], new_config=<> [NMIP4Config], default_route_metric=450, commit=1, routes_full_sync=<optimized out>) at src/devices/nm-device.c:9635
 #7  ip4_config_merge_and_apply (self=<> [NMDeviceTun], config=0x0, commit=1) at src/devices/nm-device.c:5541
 #8  update_connectivity_state (self=<> [NMDeviceTun], state=NM_CONNECTIVITY_NONE) at src/devices/nm-device.c:1743
 #9  concheck_periodic_update (self=<> [NMDeviceTun]) at src/devices/nm-device.c:1872
 #10 nm_device_set_ip4_config (self=<> [NMDeviceTun], new_config=0x0, default_route_metric=0, commit=1, routes_full_sync=1) at src/devices/nm-device.c:9669
 #11 _cleanup_generic_post (self=<> [NMDeviceTun], cleanup_type=CLEANUP_TYPE_KEEP) at src/devices/nm-device.c:11863
 #12 nm_device_cleanup (self=<> [NMDeviceTun], reason=NM_DEVICE_STATE_REASON_NOW_UNMANAGED, cleanup_type=<optimized out>) at src/devices/nm-device.c:12006
 #13 _set_state_full (self=<> [NMDeviceTun], state=<optimized out>, reason=<optimized out>, quitting=<optimized out>) at src/devices/nm-device.c:12376
 #14 nm_device_unrealize (self=<> [NMDeviceTun], remove_resources=<optimized out>, error=<>) at src/devices/nm-device.c:3183
 #15 _platform_link_cb_idle (data=<>) at src/nm-manager.c:2359
 #16 g_idle_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at gmain.c:5439
 #17 g_main_context_dispatch (context=<>) at gmain.c:3152
 #18 g_main_context_dispatch (context=<>) at gmain.c:3767
 #19 g_main_context_iterate (context=<>, block=1, dispatch=1, self=<optimized out>) a

Fixes: 6b7e9f9b22

https://bugzilla.redhat.com/show_bug.cgi?id=1436978
2017-03-29 14:27:57 +02:00
Francesco Giudici
ef0d0d08eb nmcli: fix nmcli parsing
Fixes the parsing for correct and incorrect commands.
e.g.:
nmcli connection down id <conn>
nmcli -t
...

Fixes: 16902a2be6
2017-03-29 13:02:39 +02:00
Francesco Giudici
0e73a06646 nmcli: fix nmcli connection edit
fix extra parameters check in nmc_parse_args()
e.g.: nmcli connection edit type ethernet

Fixes: 16902a2be6
2017-03-29 11:34:13 +02:00
Thomas Haller
68ab166f38 build: declare build dependencies requiring "nm-core-enum-types.h"
cat <<-EOF > /tmp/glib-mkenums
	#!/bin/bash
	sleep 15 && /usr/bin/glib-mkenums "\$@"
	EOF

	chmod +x /tmp/glib-mkenums

	(export PATH="/tmp:$PATH" &&
	 git clean -fdx &&
	 ./autogen.sh &&
	 make -j20 all-am)
2017-03-29 11:26:04 +02:00
Beniamino Galvani
e044071825 ifcfg-rh: also check BONDING_OPTS to determine the connection type
Connections with "TYPE=Ethernet" and "BONDING_OPTS=..." are regarded
by initscripts as bond masters. To maintain the best compatibility, do
the same.

https://bugzilla.redhat.com/show_bug.cgi?id=1434555
2017-03-29 09:47:37 +02:00
Thomas Haller
c06308a10c libnm: fix showing UDEV properties for device
https://mail.gnome.org/archives/networkmanager-list/2017-March/msg00065.html

Fixes: c7ccdf5fc8
2017-03-29 09:42:43 +02:00
Thomas Haller
18663c0960 build: declare build dependency for ifcfg-rh tests 2017-03-28 22:37:19 +02:00
Lubomir Rintel
1fcb3b40c2 release: bump version to 1.9.0 (development) 2017-03-28 16:34:22 +02:00
Lubomir Rintel
aac581d4ec release: bump version to 1.7.90 (1.8-rc1) 2017-03-28 15:39:21 +02:00
Lubomir Rintel
092cf11226 NEWS: update for a release candidate 2017-03-28 15:39:21 +02:00
Lubomir Rintel
fa292a60aa merge: branch 'lr/cli-ask-rh1351263'
https://bugzilla.redhat.com/show_bug.cgi?id=1351263
2017-03-28 15:32:28 +02:00
Lubomir Rintel
cd2a5c5800 cli/connections: drop the redundant parsing of --show-secrets
This is no longer needed now that --show-secrets is a global option.
2017-03-28 15:32:06 +02:00
Lubomir Rintel
f909ef421b cli: check for global options before each agument
Turn --ask and --show-secrets into global options. This is for user
comfort, see: rh #1351263.
2017-03-28 15:32:05 +02:00
Lubomir Rintel
5a71bc8022 cli: add NmCli argument to next_arg()
Will be useful in next commit.
2017-03-28 15:32:05 +02:00
Lubomir Rintel
16902a2be6 cli: use next_arg() on argument boundary
Shift argc and argc manually between argument ant its value and use
next_arg() between arguments everywhere. Whill be useful to parse global
arguments.
2017-03-28 15:32:05 +02:00
Lubomir Rintel
29af644f9a merge: branch 'lr/device-conn'
https://bugzilla.gnome.org/show_bug.cgi?id=780448
2017-03-28 15:27:05 +02:00
Lubomir Rintel
6b7e9f9b22 device: penalize default route metrics for connectivity failures
This makes it possible to retain Internet connectivity when multiple devices
have a default route, but one with the link type of a higher priority can not
reach the Internet.
2017-03-28 15:26:47 +02:00
Lubomir Rintel
9d43869e47 core: make connectivity checking per-device
This moves tracking of connectivity to NMDevice and makes the NMManager
negotiate the best of known connectivity states of devices. The NMConnectivity
singleton handles its own configuration and scheduling of the permission
checks, but otherwise greatly simplifies it.

This will be useful to determine correct metrics for multiple default routes
depending on actual internet connectivity.

The per-device connection checks is not yet exposed on the D-Bus, since they
probably should be per-address-family as well.
2017-03-28 15:26:47 +02:00
Thomas Haller
4ec7dd987e libnm: add NMSettingUser
This only adds new API for a NMSettingUser. The setting class
is still entirely unused.

The point is getting the new API into 1.8.0 release of libnm.
It's easier to backport the use of the API to a stable branch
then backporting public API.

https://bugzilla.gnome.org/show_bug.cgi?id=776276
https://bugzilla.redhat.com/show_bug.cgi?id=1421429
2017-03-28 14:58:21 +02:00
Thomas Haller
1601d2caf6 libnm: document to allow omitting argument to get-options functions
These functions return static information, and don't require
a @setting argument. The list of options is interesting even
when having now setting instance at hand.

Document this to promise the user that passing %NULL is allowed.

It was allowed since when those functions were added.
2017-03-28 14:58:21 +02:00
Lubomir Rintel
a482fbe1b6 tests/general: allow error margin on comparing floats
Fixes test on Fedora/i686.
2017-03-28 13:52:27 +02:00
Lubomir Rintel
1f623bacbf tests/lldp: skip test if there's no Tun device 2017-03-28 13:52:26 +02:00
Thomas Haller
618dd28950 cli: fix completion of setting names for --fields (2) 2017-03-28 13:42:40 +02:00
Francesco Giudici
5526769950 merge: branch 'fg/nmcli_parsing_rh1391170'
https://bugzilla.redhat.com/show_bug.cgi?id=1391170
2017-03-28 10:55:48 +02:00
Francesco Giudici
8bfb9989cd nmcli: fix colorize_string() signature in order to return static char *
moved from: char *colorize_string (..., gboolean &dealloc)
to: const char *colorize_string (..., char **out_to_free)

No more needed to cast (char *) on a (const char *).

Fixed also get_value_to_print() which relies on colorize_string()
2017-03-28 10:55:00 +02:00
Francesco Giudici
f4d0417c8d nmcli: add -g[et-values] option as a '-m tab -t -f <arg>' shortcut
Quick and easy way to get clean and parsable field values.
2017-03-28 10:55:00 +02:00
Francesco Giudici
a62b72272f nmcli: fix missing CONNECTIONS section name from nmcli -f all -m tab dev show <dev>
When a full section is specified as the field parameter in terse tabular
mode, the section name should be printed followed by all the field values
belonging to that section separated by ':'. The NAME of section CONNECTIONS
was missing.

sample command:
$ nmcli -m tab -t -f CONNECTIONS device show ens3
previous output was:
/org/freedesktop/NetworkManager/Settings/{1}:5059XXX-XXXX.. | ens3-dhcp
now:
CONNECTIONS:/org/freedesktop/NetworkManager/Settings/{1}:5059XXX-XXXX.. | ens3-dhcp
2017-03-28 10:55:00 +02:00
Francesco Giudici
7d96f1f17d nmcli: don't enforce anymore the -f(ields) option in -t(erse) mode 2017-03-28 10:55:00 +02:00
Francesco Giudici
4fa2e1422d nmcli: (trivial) add comment 2017-03-28 10:55:00 +02:00
Francesco Giudici
7b589a0aef nmcli: refactor print_required_fields
When only the main header should be printed and output mode
is 'pretty' skip the construction of the string containing
field values as it will not be used.
2017-03-28 10:55:00 +02:00
Francesco Giudici
cf39ef52da nmcli: remove redundant check 2017-03-28 10:55:00 +02:00
Francesco Giudici
6520cf1171 nmcli: always print "--" for empty or unset values in normal/pretty output
This was already true for tabular ouput mode.
Align to this behavior when printing in multiline mode.
2017-03-28 10:55:00 +02:00
Francesco Giudici
39f1d44ec8 nmcli: output just the raw value of vlan.flags when in terse mode 2017-03-28 10:55:00 +02:00
Francesco Giudici
3e3d36450c nmcli: don't substitute empty strings with "--" in terse mode 2017-03-28 10:55:00 +02:00
Francesco Giudici
623d888801 nmcli: output property values in "parsable" mode when the "--terse" option is specified
Don't print value output in the "PRETTY" format when the --terse option
has been specified.
This should allow to feed back the output from "nmcli show" to "nmcli
modify" without changes.
2017-03-28 10:55:00 +02:00
Alfonso Sánchez-Beato
76cf0e590f Remove assertion for empty DHCP options
It turns out that some routers return responses to DHCP6
Information-request messages that do not contain any of the options
that we insert in the "options" table. When that happened and the
info-only flag for DHCP6 was set, the assertion was triggered and
NetworkManager crashed. We remove the assertion as having empty options
is a possibility and is harmless anyway. This happened while using the
internal dhclient.
2017-03-28 06:50:54 +02:00
Beniamino Galvani
1db6c80cee merge: branch 'bg/slaves-order-rh1420708'
https://bugzilla.redhat.com/show_bug.cgi?id=1420708
2017-03-27 21:52:39 +02:00
Beniamino Galvani
529a0a1a7f manager: sort slaves to be autoconnected by device name
Autoconnect slaves based on device name order instead of activation
timestamp.
2017-03-27 21:51:55 +02:00
Beniamino Galvani
826f510303 manager: rework find_slaves() to return the matching device
Perform the lookup for a matching device earlier, so that in
autoconnect_slaves() we already know which device a connection is
being activated on. This will be needed to sort the returned
connections by interface name.
2017-03-27 21:51:55 +02:00
Beniamino Galvani
7fd987f7be manager: change nm_manager_get_best_device_for_connection() signature
Add a @unavailable_devices argument that specifies an hash table of
devices to be excluded from the search.
2017-03-27 21:51:55 +02:00
Beniamino Galvani
39d0559d9a platform: sort links by name instead of ifindex
We should try to guarantee a stable activation order of connections
across reboots; this is required, for example, for bonds because they
get assigned the MAC address of the first device enslaved, and thus
changing the activation order of slaves means also changing the MAC
address of the bond. Since we activate connections in the order links
are discovered, having a stable sorting of links returned by platform
is enough.

The ifindex of interfaces can change between reboots as it depends on
the order in which kernel discover interfaces. Provided that the
system uses a mechanism to enforce persistent interface naming (as
udev rules or systemd-udevd predictable names), and that NM starts
after all interfaces have been announced by udev, using the interface
name instead of ifindex will guarantee a consistent order.
2017-03-27 21:51:55 +02:00
Beniamino Galvani
52b1f0415d manager: check that slaves connection have a compatible device
When slave connections are autoactivated as dependency to master we
don't check if a compatible device is available before trying to
activate them, leading to the following failed assertion:

 nm_act_request_new: assertion 'NM_IS_DEVICE (device)' failed
2017-03-27 21:51:55 +02:00
Thomas Haller
6e1616ba69 cli: fix completion of setting names for --fields 2017-03-26 19:48:29 +02:00
Thomas Haller
163e193286 libnm: fix type annotation for nm_utils_enum_from_str() 2017-03-25 17:12:27 +01:00
Francesco Giudici
017b7c2bb6 merge: branch 'fg/keep_externally_set_hostname-rh1422610'
https://bugzilla.redhat.com/show_bug.cgi?id=1422610
https://bugzilla.redhat.com/show_bug.cgi?id=1405275
2017-03-24 17:00:48 +01:00
Francesco Giudici
70c768901b man: add description for the 'hostname' config option in the main section 2017-03-24 15:18:09 +01:00
Francesco Giudici
76b2e9542f policy: add some verbose logging for tracking hostname management 2017-03-24 15:18:09 +01:00