Commit graph

950 commits

Author SHA1 Message Date
Francesco Giudici
c6e1b3abc0 libnm-core: update team.runner description
https://bugzilla.redhat.com/show_bug.cgi?id=1533799
(cherry picked from commit 112f8bd5af)
2018-01-12 14:25:29 +01:00
Thomas Haller
41a89aeeba dhcp: cleanup handling of ipv4.dhcp-client-id and avoid assertion failure
The internal client asserts that the length of the client ID is not more
than MAX_CLIENT_ID_LEN. Avoid that assert by truncating the string.

Also add new nm_dhcp_client_set_client_id_*() setters, that either
set the ID based on a string (in our common dhclient specific
format), or based on the binary data (as obtained from systemd client).

Also, add checks and assertions that the client ID which is
set via nm_dhcp_client_set_client_id() is always of length
of at least 2 (as required by rfc2132, section-9.14).

(cherry picked from commit 686afe531a)
2018-01-04 18:53:34 +01:00
Beniamino Galvani
207eb3266f all: add more meaningful error code for unsupported IP method
Add a new device state reason code for unsupported IP method. It is
returned, for example, when users select manual IP configuration for
WWAN connections:

 # nmcli connection mod Gsm ipv4.method manual ipv4.address 1.2.3.4/32
 # nmcli connection up Gsm
 Error: Connection activation failed: The selected IP method is not
 supported

compared to the old:

 Error: Connection activation failed: IP configuration could not be
 reserved (no available address, timeout, etc.)

Note that we could instead fail the connection validation if the
method is not supported by the connection type, but adding such
limitation now could make existing connections invalid.

https://bugzilla.redhat.com/show_bug.cgi?id=1459529
(cherry picked from commit aa820e9386)
2017-12-21 10:07:12 +01:00
Beniamino Galvani
8a570a41cf device: add a new state-reason for DAD failures
(cherry picked from commit 12a49cbdc7)
2017-12-21 10:07:07 +01:00
Lubomir Rintel
8ac6b1b5d5 libnm/vpn: fix secret comparison
One setting may contain a superset or subset of the another. Be sure not
to ignore the presence of extra secret properties.

(cherry picked from commit 16f8651908)
2017-12-19 10:04:46 +01:00
Lubomir Rintel
8d120a6fda libnm-core/tc-config: remove deprecation guards from typedefs
They're triggered by the prototypes in header file inclusion, even
though no routines or variables that use the type are actually used.

(cherry picked from commit 685cb5c88b)
2017-12-19 10:04:46 +01:00
Thomas Haller
dabf366838 utils: extend binary-search to return the first/last index
binary-search can find an index of a matching entry in a sorted
list. However, if the list contains multiple entries that compare
equal, it can be interesting to find the first/last entry. For example,
if you want to append new items after the last.

Extend binary search to optionally continue the binary search
to determine the range that compares equal.

(cherry picked from commit d83eee5d57)
2017-12-15 11:44:51 +01:00
Thomas Haller
7673a3badc core: avoid leaks parsing team link-watcher
Found by coverity.

(cherry picked from commit f44f21c87e)
2017-12-12 11:21:05 +01:00
Thomas Haller
ccdfe9d3e5 libnm: fix checking argument in nm_team_link_watcher_new_arp_ping()
Found by coverity.

Fixes: 6c93e32212
(cherry picked from commit fb2da4b26c)
2017-12-12 11:21:05 +01:00
Lubomir Rintel
775893fc00 ifcfg-rh: add tc support
Format:

  QDISC1=ingress
  QDISC2="root handle 1234: fq_codel"
  FILTER1="parent ffff: matchall action simple sdata Input"
  FILTER2="parent 1234: matchall action simple sdata Output"

(cherry picked from commit 902bbfdb18)
2017-12-11 19:53:09 +01:00
Lubomir Rintel
6237650803 keyfile: add ability to read/write tc filters
The idea is

  tfilter.<parent>=[handle <handle>] <tfilter> [<options>] [action [<action options>...]]

What works now:

  [tc]
  qdisc.root=handle 1234: fq_codel
  qdisc.ffff:fff1=ingress
  tfilter.1234:=matchall action drop
  tfilter.ffff:=matchall action simple sdata Hello

(cherry picked from commit 2e8fc6947d)
2017-12-11 19:43:08 +01:00
Thomas Haller
7257c5ec83 libnm: disable g_warning() from library
Printing a g_warning() from the library is not helpful.

Client-side, libnm should support newer server versions and changing
formats. To support forward-compatibility, it should parse the received
GVariant best-effort like, without complaining.

Server-side, libnm-core should return errors when receiving invalid
configuration. It must not maintain forward-compatibility, only
backward-compatibility -- which is implemented by handling old
and newer formats. But never should server allow a configuration
that is invalid.

Currently, the libnm API cannot yet fail at this point. Hence,
it cannot return an error. It would need a strict and relaxed
parsing mode. Until that exists, just comment out the warnings.

(cherry picked from commit 7cd2b6178d)
2017-12-11 19:42:39 +01:00
Lubomir Rintel
0e7a179910 libnm-core/tests: test NMSettingTCConfig traffic filter support
(cherry picked from commit dbef7e684f)
2017-12-11 19:42:11 +01:00
Lubomir Rintel
69d86d91b3 libnm-core: add functionality for dealing with tc-style traffic filter specifiers
Tailored to fit both nmcli and keyfile needs.

(cherry picked from commit de41c45e61)
2017-12-11 19:40:22 +01:00
Lubomir Rintel
457a17ae83 libnm-core: add traffic filter support to NMSettingTCConfig
(cherry picked from commit e035cb7be0)
2017-12-11 19:38:37 +01:00
Lubomir Rintel
4a35c71354 libnm-core/tests: test NMSettingTCConfig action support
(cherry picked from commit 883e565b7d)
2017-12-11 19:38:35 +01:00
Lubomir Rintel
946bbcc69d libnm-core: add functionality for dealing with tc-style action specifiers
Tailored to fit both nmcli and keyfile needs.

(cherry picked from commit 733464ada3)
2017-12-11 19:36:53 +01:00
Thomas Haller
ddd3fa8ee2 libnm-core: consider attributes in nm_tc_action_equal()
(cherry picked from commit b0ba17e903)
2017-12-11 19:36:26 +01:00
Lubomir Rintel
fa8e896f94 libnm-core: add action support to NMSettingTCConfig
The actions are not too useful my themselves, but it will be possible to
embed them into traffic filters in subsequent commits.

(cherry picked from commit 7c8ce778fb)
2017-12-11 19:34:44 +01:00
Lubomir Rintel
47e5e3ba7d clients: add tc qdisc support
What works:

  nmcli c add con-name dum0 ifname dum0 type dummy \
      tc.qdiscs 'ingress, root pfifo_fast'
  nmcli c modify dum0 -tc.qdiscs 'root pfifo_fast'
  nmcli c modify dum0 +tc.qdiscs 'root handle 666: fq_codel'

(cherry picked from commit 92f8f30d47)
2017-12-11 19:06:31 +01:00
Lubomir Rintel
f3d127c502 keyfile: add ability to read/write qdiscs from tc setting
The format for qdiscs is

  qdisc.<parent>=[handle <handle>] <qdisc> [<options>...]

E.g.:

  [tc]
  qdisc.root=fq_codel handle de4d:
  qdisc.ffff:fff1=ingress

That is pretty much what is supported at this point.

(cherry picked from commit 9d0eeb30b6)
2017-12-11 19:06:23 +01:00
Lubomir Rintel
650fcffb9a libnm-core/tests: test NMSettingTCConfig qdisc support
...so that we have an excuse when it breaks.

(cherry picked from commit 0ab77ebd1d)
2017-12-11 19:06:17 +01:00
Lubomir Rintel
0bae63d701 libnm-core: add functionality for dealing with tc-style qdisc specifiers
Tailored to fit both nmcli and keyfile needs.

(cherry picked from commit 7c1de05f41)
2017-12-11 19:05:10 +01:00
Lubomir Rintel
93b3fc8c57 libnm-core: add NMSettingTCConfig with qdisc support
Currently is only able to hold the queueing disciplines.

(cherry picked from commit da13c7a1a4)
2017-12-11 19:04:02 +01:00
Lubomir Rintel
595a06b689 libnm-core/utils: allow use of bytestring with attributes
(cherry picked from commit 18dd937b81)
2017-12-11 18:56:38 +01:00
Lubomir Rintel
1a41724998 libnm-core/utils: add some special properties for the attributes
"no_value" indicates that the the attribute is a single word, not a
key=value pair. If the type is BOOLEAN then the attribute is considered
true, if it's a STRING then the key is used instead of a value.

"consumes_rest" indicates that the particular key takes the unparseable
tail of the string for a value.

This allows parsing tc-style strings. Consider this filter:

              ,------ regular key/value pair
       ,-----'----.
  root handle 1234: matchall action simple foo bar baz
    |                  |     `-----------.-----------'
    |                  |                 `- "", STRING, consumes_rest
    |                  `------------------- "kind", STRING, no_value
    `-------------------------------------- "root', BOOLEAN, no_value

(cherry picked from commit 47b1dc3828)
2017-12-11 18:56:32 +01:00
Lubomir Rintel
51d5b97bd7 libnm-core/utils: allow using the same character for key/value and attribute separators
Allows doing a nm_utils_parse_variant_attributes(..., ' ', ' ').

(cherry picked from commit 48a619e62b)
2017-12-11 18:56:27 +01:00
Lubomir Rintel
faa6ddc272 libnm-core/utils: (trivial) use g_set_error_literal() where appropriate
(cherry picked from commit 9a00750c06)
2017-12-11 18:56:24 +01:00
Thomas Haller
3b68867123 libnm: don't use g_strsplit_set() to search string for invalid characters
(cherry picked from commit 6c93e32212)
2017-12-08 11:33:34 +01:00
Thomas Haller
1268038b4a libnm/tests: fix memleak in test
(cherry picked from commit af6f62be8d)
2017-12-08 11:33:15 +01:00
Thomas Haller
f13b97a9e4 keyfile: reject team properties in parser
We don't properly coordinate reading the team properties from keyfile.
They must be ignored, at least for now.

(cherry picked from commit 1b8ae83967)
2017-12-08 11:32:41 +01:00
Francesco Giudici
78d10c9d18 libnm-core: add test cases for NMSettingTeamPort
(cherry picked from commit b5f0d61d03)
2017-12-08 04:00:09 +01:00
Francesco Giudici
7abcede5bb libnm-core: add test cases for NMSettingTeam
(cherry picked from commit 1248969342)
2017-12-08 04:00:09 +01:00
Lubomir Rintel
bb3fc9769b libnm-core: merge the settings tests into a single one
Thomas likes this more and who am I to argue.

(cherry picked from commit 9bb30f86ec)
2017-12-08 04:00:09 +01:00
Francesco Giudici
bc92380a76 libnm-core: team: skip writing in the keyfile all the exposed properties
Their values are already saved in the team.config and team-port.config
properties, from which they are synced.

(cherry picked from commit bb4c95e168)
2017-12-08 04:00:09 +01:00
Francesco Giudici
4525b7e208 libnm-core: team: change tx-hash APIs idx type from int to guint
(cherry picked from commit 4c7a841823)
2017-12-08 04:00:09 +01:00
Francesco Giudici
5d79b6cc42 libnm-core: team: rework defaults management on runner properties
till now when no explicit value was set on a property, the default value
for that property was returned, also if the property was not applicable
to the selected runner.
Fix this, showing default values for properties only when relevant and
showing instead -1 or null when the property is not relevant for the
selected runner.
Moreover, reset all the properties but the link-watchers when the team.runner
is changed: this is required to clean up the properties unrelated to the
new runner and start with the runner-specific defaults.

(cherry picked from commit a5642fd93a)
2017-12-08 04:00:08 +01:00
Francesco Giudici
07a49b30af libnm-core: team: use the correct name for teamd property 'balancing_interval'
the teamd 'runner.tx_balancer.balancing_interval' property was wrongly
set and searched as 'runner.tx_balancer.interval'. Fixed.

Fixes: fc3b7d61e2
(cherry picked from commit ed2a1a153b)
2017-12-08 04:00:08 +01:00
Francesco Giudici
dd18259c63 libnm-core: json: share code to load defaults in team(-port).config
Move code from _nm_utils_team_config_get to the brand new
_json_team_add_defaults function without any change.
Then remove the duplicated code from _nm_utils_team_config_equal and
leverage the new function. Here the only functional change is that
the defaults for "notify_peers" and "mcast_rejoin" for the
"activebackup" runner are added (the only case in which their default
values are different than 0).

(cherry picked from commit fdd41852ee)
2017-12-08 04:00:08 +01:00
Francesco Giudici
a2357fea43 libnm-core: trivial: just move static json functions
(cherry picked from commit f0ae71e7d6)
2017-12-08 04:00:08 +01:00
Francesco Giudici
ad1be3a472 libnm-core: trivial: move json key deletion code to a separate function
(cherry picked from commit 8648aa576e)
2017-12-08 04:00:08 +01:00
Francesco Giudici
e8eb416675 libnm-core: use proper writer for team-port link-watchers
(cherry picked from commit 16c9435c5b)
2017-12-08 04:00:08 +01:00
Francesco Giudici
704f0acb77 libnm-core: team-port: expose the new link-watchers property
It will allow explicit configuration of link-watchers in the team port
configuration.

(cherry picked from commit f094837d73)
2017-12-08 04:00:08 +01:00
Francesco Giudici
10745107f2 libnm-core: add keyfile writer for team link watcher
Allow tests to dump the content of the property when getting a failure.

(cherry picked from commit 0d8fcc39ab)
2017-12-08 04:00:08 +01:00
Francesco Giudici
62876cee9a libnm-core: synchronize team.link_watchers when team.config is set.
(cherry picked from commit 363a2cfe95)
2017-12-08 04:00:07 +01:00
Francesco Giudici
a1c25edfe8 libnm-core: synchronize team.config when team.link_watchers is set.
(cherry picked from commit e59878ce19)
2017-12-08 04:00:07 +01:00
Francesco Giudici
466f8e0dd5 libnm-core: team: expose the new link-watchers property
It will allow explicit configuration of link-watchers in the team
configuration.

(cherry picked from commit ca816ae10e)
2017-12-08 04:00:07 +01:00
Francesco Giudici
574d70b2eb libnm-core: add backend for GVariant de/serialization of link_watchers.
(cherry picked from commit ba4ce843fa)
2017-12-08 04:00:07 +01:00
Francesco Giudici
e9d5836937 libnm-core: team: add NMTeamLinkWatcher boxed type
Team allows to specify multiple link watchers for each link.
Define a link watcher object in order to allow to specify multiple ones
for each Team configuration.

(cherry picked from commit 72f6d08714)
2017-12-08 03:59:59 +01:00
Francesco Giudici
5cbe512fd3 libnm-core: preserve keys order in team.config with old jansson libs
When jansson lib version is < 2.8 the order of the keys of json objects
is not preserved automatically. In particular, when loading the json
string, parsing it and dumping it back to a string the key order will be
lost if the now deprecated JSON_PRESERVE_ORDER flag is not set.
Add the flag: will do nothing on recent jansson versions but will fix
behavior for legacy ones.

(cherry picked from commit 5e6f7de4be)
2017-12-08 02:16:52 +01:00