Commit Graph

18368 Commits

Author SHA1 Message Date
Thomas Haller
660fee1622 cli: allow dynamic results from values_fcn() and describe_fcn() property functions
Mostly these strings are static. In same cases they are generated
however. Instead of caching them in a static variable, return them
to the caller.

And belatedly fix invoking describe_fcn().
2017-03-30 13:09:57 +02:00
Thomas Haller
8e74837f14 cli: refactor indirection to legacy signatures (2) 2017-03-30 13:09:57 +02:00
Thomas Haller
24434be5a1 cli: fix intermediate regression of hiding blobs data
Restore previous behavior of hiding blobs for certain
certificate properties.
2017-03-30 13:09:57 +02:00
Thomas Haller
d92b50fc70 cli: use define for argument lists in settings.c
settings.c basically consists of property-type structures and *a lot* of
accessors. All these accessors share the same argument list.

It is very repetitive to specify it over and over again. Also, there
are so many arguments that one is compelled to wrap the lines. All
in all it results in a lot of noise that takes the eye from the important
code.

Also, the argument list is expected to change, so we possibly only
have to change one place.
2017-03-30 13:09:57 +02:00
Thomas Haller
4bfb3c8aa7 cli: refactor indirection to legacy signatures 2017-03-30 13:09:57 +02:00
Thomas Haller
e1d60712d9 cli: add property-info for the rest 2017-03-30 13:09:57 +02:00
Thomas Haller
10fca1ae3a cli: add property-info for NMSettingWireless 2017-03-30 13:09:57 +02:00
Thomas Haller
84aa6bad89 cli: add property-info for NMSettingWired 2017-03-30 13:09:57 +02:00
Thomas Haller
486dc1e596 cli: add property-info for NMSettingWimax 2017-03-30 13:09:57 +02:00
Thomas Haller
d07acc753c cli: let string property-type handle checking values 2017-03-30 13:09:56 +02:00
Thomas Haller
9c6f70f9e0 cli: add property-info for NMSettingAdsl 2017-03-30 13:09:56 +02:00
Thomas Haller
f34ef5d1fe cli: add property-info for NMSettingPpp 2017-03-30 13:09:56 +02:00
Thomas Haller
6bf1d6fc16 cli: add property-info for NMSetting8021x 2017-03-30 13:09:56 +02:00
Thomas Haller
d530bffb6c cli: add property-info for NMSettingWirelessSecurity 2017-03-30 13:09:56 +02:00
Thomas Haller
09d127b473 cli: add property-info for NMSettingPppoe 2017-03-30 13:09:56 +02:00
Thomas Haller
a89e9a0a6f cli: add property-info for NMSettingDcb 2017-03-30 13:09:56 +02:00
Thomas Haller
89b5685695 cli: add property-info for NMSettingProxy 2017-03-30 13:09:56 +02:00
Thomas Haller
b9029a798e cli: add NmcPropertyType structure
We shall not only have a PropertyInfo. Most properties share common
behavior, that is, they have a type. Move the function pointers to
a NmcPropertyType structure, so that it can be reused for multiple
properties.

This promotes the idea that properties have a (limited) set of types
with some type specific behaviors. Contrary, to having each property
re-implement fully it's type. E.g. instead of having various property
re-define their full behavior as an "bool", have one property type
"bool" which can be attached to a property.
2017-03-30 13:09:56 +02:00
Thomas Haller
40f47dbb06 cli: add property-info for NMSettingIP4Config and NMSettingIP6Config 2017-03-30 13:09:56 +02:00
Thomas Haller
c023edc3bb cli: remove GLUE macros that hide names
It's useful to see the entire name not having a macro construct it.
Otherwise, the usage is not grepable.
2017-03-30 13:09:55 +02:00
Thomas Haller
f7937c8f4a cli: generate all-properties list from NmcSettingInfo
It's redundant information that requires us to declare it
in the static meta data. Generate it instead as needed.
2017-03-30 13:09:55 +02:00
Thomas Haller
cb66cf96d7 cli: add values_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Thomas Haller
10119aa3a3 cli: add remove_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Thomas Haller
850d652cdb cli: add remove_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Thomas Haller
2de82f11c9 cli: add set_func() to NmcPropertyInfo and use for "connection" setting 2017-03-30 13:09:55 +02:00
Thomas Haller
8b96cee124 cli: implement property getter for "connection" setting via nmc_setting_info 2017-03-30 13:09:55 +02:00
Thomas Haller
4e91492b76 cli: rework property handling via NmcPropertyInfo for NMSettingConnection
Add an improved way of tracking meta data about settings.

E.g. it is wrong to generate for each property a nmc_property_*_get_*()
function. Instead, there should be a meta data about the property
itself, and a mechanism to retrieve the property.

For now, only do this for NMSettingConnection and keep all the existing
infrastructure in place. Later on all settings shall be moved.

Especially to accomodate NmcOutputField mangles the concept of
setting-meta data, formatting options, and collecting output results.
It's a total hack, that will be need fixing later.
2017-03-30 13:09:55 +02:00
Thomas Haller
d3ad7920de cli: add setting-info structure to settings.c
Will get more use soon.
2017-03-30 13:09:55 +02:00
Thomas Haller
3690311b02 meta: add table @nm_meta_setting_infos of all settings types 2017-03-30 13:09:55 +02:00
Thomas Haller
2b0c00a3e3 Revert "nmcli: output property values in "parsable" mode when the "--terse" option is specified"
This will be solved differently by th/setting-user-data-bgo776276
branch. Revert the change for now, the same functionality will be
restored later.

This reverts commit 623d888801.
2017-03-30 13:09:55 +02:00
Thomas Haller
e26a81cf35 libnm: handler numeric values more gracefully in nm_utils_enum_from_str()
nm_utils_enum_to_str() may also output numeric values if there is no
corresponding "nick" for the enum/flag value.

For enums the value is in decimal and for flags the value is hexadecimal
(with a "0x" prefix).

The same was already supported by nm_utils_enum_from_str() when reading
the value. However, previously, reading a flag would only support hex
numbers and reading a enum would only support decimal numbers.

Extend that, to allow passing numbers in any base. For nm_utils_enum_to_str()
also make sure to never output nicks that may be misinterpreted as
numbers.
2017-03-30 13:09:55 +02:00
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
02d7084fc4 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
(cherry picked from commit 166988264f)
2017-03-30 10:17:32 +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
7dc010606b 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
(cherry picked from commit e73c15eec9)
2017-03-29 14:32:19 +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
f7c72045b7 nmcli: fix nmcli parsing
Fixes the parsing for correct and incorrect commands.
e.g.:
nmcli connection down id <conn>
nmcli -t
...

Fixes: 16902a2be6
(cherry picked from commit ef0d0d08eb)
2017-03-29 14:25:48 +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
9a38eb4c66 nmcli: fix nmcli connection edit
fix extra parameters check in nmc_parse_args()
e.g.: nmcli connection edit type ethernet

Fixes: 16902a2be6
(cherry picked from commit 0e73a06646)
2017-03-29 11:37:15 +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
6198c2a5a4 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)

(cherry picked from commit 68ab166f38)
2017-03-29 11:26:27 +02:00
Thomas Haller
7db4dd738d build: declare build dependency for ifcfg-rh tests
(cherry picked from commit 18663c0960)
2017-03-29 11:26:25 +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
12cc8d729d 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
(cherry picked from commit e044071825)
2017-03-29 09:48:47 +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
c26229f91b libnm: fix showing UDEV properties for device
https://mail.gnome.org/archives/networkmanager-list/2017-March/msg00065.html

Fixes: c7ccdf5fc8
(cherry picked from commit c06308a10c)
2017-03-29 09:43:32 +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