Commit graph

968 commits

Author SHA1 Message Date
Thomas Haller
97db8306d9 libnm: rename MDns flag UNKNOWN to DEFAULT
"UNKNOWN" is not a good name. If you don't set the property
in the connection explicitly, it should be "DEFAULT".

Also, make "DEFAULT" -1. For one, that ensures that the enum's
underlying integer type is signed. Otherwise, it's cumbersome
to test "if (mdns >= DEFAULT)" because in case of unsigned types,
the compiler will warn about the check always being true.
Also, it allows for "NO" to be zero. These are no strong reasons,
but I tend to think this is better.

Also, don't make the property of NMSettingConnection a CONSTRUCT property.
Initialize the default manually in the init function.

Also, order the numeric values so that DEFAULT < NO < RESOLVE < YES with
YES being largest because it enables *the most*.

(cherry picked from commit 9d92848ada)
2018-10-19 18:39:32 +02:00
Thomas Haller
230eb62821 libnm: verify value for connection.mdns
Also, keep the internal variable of type int. The only way to set the
field is via the GObject property setter. At that point, don't yet
cast the integer type to enum.

(cherry picked from commit eec907b35a)
2018-10-19 18:39:32 +02:00
Ismo Puustinen
19d7e66099 mdns: add new connection property.
Add support for mDNS as a connection-level property. Update ifcfg-rh and
keyfile plugins to support it.

(cherry picked from commit 2e2ff6f27a)
2018-10-19 18:39:31 +02:00
Beniamino Galvani
12e2d62673 wifi: support hidden ssid in AP mode
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/48
(cherry picked from commit 5d97e76c7d)
(cherry picked from commit f235d57a3a)
(cherry picked from commit 6f6a810189)
2018-09-27 14:21:14 +02:00
Thomas Haller
b02000a2f3 libnm/doc: explicitly point out privacy issue of setting wifi.hidden
(cherry picked from commit bca28c8c0c)
2018-09-27 14:21:10 +02:00
Thomas Haller
71e2a25a0d libnm/keyfile: fix double free in keyfile's get_bytes()
Fixes: 5e7b14af03
(cherry picked from commit fcf254c03a)
(cherry picked from commit 1c56be4090)
2018-09-04 07:49:23 +02:00
Beniamino Galvani
9b46af1a62 libnm-core: support private keys encrypted with AES-{192,256}-CBC
https://github.com/NetworkManager/NetworkManager/pull/189
(cherry picked from commit 93f85edcce)
(cherry picked from commit 74fc6f30b2)
2018-08-30 10:09:17 +02:00
Lubomir Rintel
19c22a13b2 core/connection: don't emit Updated on Connection.GetSecrets
The secrets are transient -- when they are loaded into the connections and
subsequently cleared the connection itself doesn't change. The Update
signal is to be emmited only on explicit Update()/Update2() or
ClearSecrets() which is already the case.

Apart from Update being wrong, it has the ill effect of causing libnm to
drop secrets from the cached connection.

(cherry picked from commit 66ae0cc306)
2018-02-20 17:04:13 +01:00
Francesco Giudici
10760b100c libnm-core: team: add support to runner "random"
https://bugzilla.redhat.com/show_bug.cgi?id=1538699
(cherry picked from commit 31d9a9de14)
2018-02-06 12:45:18 +01:00
Thomas Haller
ec630dc256 libnm: cleanup include in "libnm-core/nm-json.c"
We already define _GNU_SOURCE in "config.h", depending
on configure checks.

Also, we always should first include "config.h" (which means
to first include "nm-default.h").

Also, we don't need the entire <link.h>, <dlfcn.h> suffices.

(cherry picked from commit 84576ce861)
2018-01-25 18:26:34 +01:00
Thomas Haller
5269978e37 libnm: add include guard to nm-json.h
(cherry picked from commit ee56c9250f)
2018-01-25 18:23:34 +01:00
Thomas Haller
0aa9273d33 libnm: fix spelling for NM_JAONSSON_C define
(cherry picked from commit 2888778480)
2018-01-25 18:23:07 +01:00
Thomas Haller
bbcb9ebefc libnm: rename "libnm-core/nm-jansson.h" to "libnm-core/nm-json.h"
We already have "shared/nm-utils/nm-jansson.h". Avoid reusing the same file name.

(cherry picked from commit b6b6baa773)
2018-01-25 18:23:01 +01:00
Thomas Haller
75dfbfcef4 libnm/trivial: don't use non-leading tabs
(cherry picked from commit 950a14128b)
2018-01-25 18:22:26 +01:00
Lubomir Rintel
66ae13f012 core: load jansson on demand
Avoid using it if the symbols clash is detected.

(cherry picked from commit cd476e4dc9)
2018-01-25 18:19:59 +01:00
Francesco Giudici
fa3efd3ed6 libnm-core: ensure alignment of team.config and other team properties
https://bugzilla.redhat.com/show_bug.cgi?id=1533830
(cherry picked from commit 381c1a19b6)
2018-01-22 19:18:32 +01:00
Francesco Giudici
c34cd5e09a libnm-core: team: fix runner sys_prio default value
(cherry picked from commit 2c99eba42f)
2018-01-18 18:49:42 +01:00
Francesco Giudici
f219090fdd cli: get team defaults from setting header files
this allows centralizing default values definition and allows quicker
and safer update of default values.

(cherry picked from commit c6448f724b)
2018-01-18 18:49:28 +01:00
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