Commit graph

19207 commits

Author SHA1 Message Date
Lubomir Rintel
8bffb2c750 device: set traffic filters when device comes up 2017-12-11 11:20:13 +01:00
Thomas Haller
fe3d7209e7 platform: fix TC to-string/hash/cmp functions to include the action
Also add a define NM_PLATFORM_ACTION_KIND_SIMPLE. It makes the
uses of "simple" grepable.
2017-12-11 11:08:41 +01:00
Lubomir Rintel
b0fd3ecbaf platform: add support for traffic filters 2017-12-11 11:08:41 +01:00
Lubomir Rintel
3261820004 clients: add tc tfilter support
What works:

  nmcli c add con-name dum0 ifname dum0 type dummy \
      tc.tfilters 'parent 1234: matchall action drop, parent ffff: matchall action drop'
  nmcli c modify dum0 -tc.tfilters 'parent ffff: matchall action drop'
  nmcli c modify dum0 +tc.tfilters 'parent ffff: matchall action simple sdata Hello'
2017-12-11 11:02:04 +01:00
Lubomir Rintel
bc471c8e7a keyfile/tests: test tc traffic filter reading and writing 2017-12-11 11:02:04 +01:00
Lubomir Rintel
2e8fc6947d 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
2017-12-11 11:02:04 +01:00
Thomas Haller
7cd2b6178d 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.
2017-12-11 11:02:04 +01:00
Lubomir Rintel
dbef7e684f libnm-core/tests: test NMSettingTCConfig traffic filter support 2017-12-11 11:02:04 +01:00
Lubomir Rintel
de41c45e61 libnm-core: add functionality for dealing with tc-style traffic filter specifiers
Tailored to fit both nmcli and keyfile needs.
2017-12-11 11:02:04 +01:00
Lubomir Rintel
e035cb7be0 libnm-core: add traffic filter support to NMSettingTCConfig 2017-12-11 11:02:04 +01:00
Lubomir Rintel
883e565b7d libnm-core/tests: test NMSettingTCConfig action support 2017-12-11 11:02:04 +01:00
Lubomir Rintel
733464ada3 libnm-core: add functionality for dealing with tc-style action specifiers
Tailored to fit both nmcli and keyfile needs.
2017-12-11 11:02:04 +01:00
Thomas Haller
b0ba17e903 libnm-core: consider attributes in nm_tc_action_equal() 2017-12-11 11:01:59 +01:00
Lubomir Rintel
7c8ce778fb 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.
2017-12-11 10:52:23 +01:00
Lubomir Rintel
e4bdb21909 device: set qdiscs when device comes up 2017-12-11 10:52:23 +01:00
Lubomir Rintel
92f8f30d47 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'
2017-12-11 10:52:23 +01:00
Lubomir Rintel
8547387942 keyfile/tests: test tc qdisc reading and writing 2017-12-11 10:52:23 +01:00
Lubomir Rintel
9d0eeb30b6 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.
2017-12-11 10:52:23 +01:00
Lubomir Rintel
0ab77ebd1d libnm-core/tests: test NMSettingTCConfig qdisc support
...so that we have an excuse when it breaks.
2017-12-11 10:52:22 +01:00
Lubomir Rintel
7c1de05f41 libnm-core: add functionality for dealing with tc-style qdisc specifiers
Tailored to fit both nmcli and keyfile needs.
2017-12-11 10:52:22 +01:00
Lubomir Rintel
da13c7a1a4 libnm-core: add NMSettingTCConfig with qdisc support
Currently is only able to hold the queueing disciplines.
2017-12-11 10:52:22 +01:00
Lubomir Rintel
0b0fb045bc platform/tests: tests qdisc caching behavior
Just the most rudimentary tests.
2017-12-11 10:52:22 +01:00
Lubomir Rintel
ff9f27eb12 platform: add support for queueing disciplines 2017-12-11 10:52:22 +01:00
Thomas Haller
82befe3c40 platform: add <linux/tc_act/tc_defact.h> header
We're going to need that one for TC filter & action support.

<linux/tc_act/tc_defact.h> was moved to user-space API only in 2013
by commit 5bc3db5c9ca8407f52918b6504d3b27230defedc. Our travis CI currently
fails to build due to that.

Re-implement the header.
2017-12-11 10:50:43 +01:00
Thomas Haller
7573594a21 platform: merge nm_platform_*_delete() delete functions
It only makes sense to call delete() with NMPObjects that
we obtained from the platform cache. Otherwise, if we didn't
get it from the cache in the first place, we wouldn't know
what to delete.

Hence, the input argument is (almost) always an NMPObject
in the first place. That is different from add(), where
we might create a new specific NMPlatform* instance on the
stack. For add() it makes slightly more sense to have different
functions depending on the type. For delete(), it doesn't.
2017-12-11 10:30:26 +01:00
Lubomir Rintel
44be0dfca7 platform/nmp-object: (trivial) keep enum ordered by a numeric value 2017-12-11 10:30:26 +01:00
Lubomir Rintel
ffe89f86e0 platform/linux: stringify also NLMSG_* in logs 2017-12-11 10:30:26 +01:00
Lubomir Rintel
273fb58e35 generate-setting-docs: document aa{sv} type
Will be useful for tc qdiscs.
2017-12-11 10:30:26 +01:00
Lubomir Rintel
93ac0e455b platform/trivial: s/ADDRROUTE/OBJECT/ for the cache lookup
It's going to be useful for other objects that have a type (of course)
and an ifindex.
2017-12-11 10:30:26 +01:00
Lubomir Rintel
18dd937b81 libnm-core/utils: allow use of bytestring with attributes 2017-12-11 10:30:26 +01:00
Lubomir Rintel
47b1dc3828 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
2017-12-11 10:30:26 +01:00
Lubomir Rintel
48a619e62b libnm-core/utils: allow using the same character for key/value and attribute separators
Allows doing a nm_utils_parse_variant_attributes(..., ' ', ' ').
2017-12-11 10:30:26 +01:00
Lubomir Rintel
9a00750c06 libnm-core/utils: (trivial) use g_set_error_literal() where appropriate 2017-12-11 10:30:25 +01:00
Lubomir Rintel
b49c7e026f ifcfg-rh: drop unused functions
Perhaps a cargo cult leftover.
2017-12-11 10:30:25 +01:00
Lubomir Rintel
17462a5a5f ifcfg-rh: drop unused and confusing error arguments 2017-12-11 10:30:25 +01:00
Lubomir Rintel
0583f8bb3c platform/tests: add a missing copyright notice 2017-12-11 10:30:25 +01:00
Lubomir Rintel
23b7f24d9e platform/tests: drop bad comment 2017-12-11 10:30:25 +01:00
Thomas Haller
45ad3ec886 core: fix typo for logging of NMSettingsConnectionFlags "nm-generated"
Fixes: c3dd5d8df2
2017-12-11 09:56:57 +01:00
Thomas Haller
b11eac1a0d libnm: use nm_utils_named_values_from_str_dict()
Make use of NMUtilsNamedValue in nm_utils_format_variant_attributes().
This avoids creating a GList and sorting it.

Also, reuse nm_utils_named_values_from_str_dict() in
nm_setting_bond_get_option().
2017-12-08 18:48:36 +01:00
Thomas Haller
097bd72e2e shared: add nm_utils_named_values_from_str_dict()
NMUtilsNamedValue's purpose is precisely to create
a list and sort by entires.

Add nm_utils_named_values_from_str_dict() as helper
function to do that.
2017-12-08 18:47:37 +01:00
Thomas Haller
e7d18548b9 cli: fix integer types in get-functions to match libnm origin
The num/i variables are initialized from libnm API and used
back at them. The integer types should match.
2017-12-08 16:31:28 +01:00
Thomas Haller
ae5af6b368 libnm: adjust symbol versioning after backporting team API to 1.10.2
The team API was backported to nm-1-10 branch.
It will be released both as 1.12.0 and 1.10.2.

To ensure the upgrade path from 1.10.2+ to 1.12+ works, the symbols
in libnm must be present on both versions.

Usually, we would duplicate the symbols on master via
NM_BACKPORT_SYMBOL() macro.

However, as we are sure that we will release 1.10.2 before 1.12.0,
we can just update the linker version of these symbols. So, although
the symbols will be first released on major release 1.12.0, their linker
version tag is libnm_1_10_2, to ease upgrade and to avoid duplicating the
symbols.
2017-12-08 13:48:58 +01:00
Thomas Haller
41803aac2d libnm: fix libnm.ver file to export libnm_1_10_2 ABI
Fixes: cb9facdfef
2017-12-08 13:43:49 +01:00
Thomas Haller
6c93e32212 libnm: don't use g_strsplit_set() to search string for invalid characters 2017-12-08 11:09:34 +01:00
Thomas Haller
79d5a06c8b build: don't link libnm against libjansson when building --without-json-validation
Also, don't add the CFLAGS for libjansson to dflt_cppflags_libnm_core.
dflt_cppflags_libnm_core is used also by core and libnm. But those
components do not (directly) link against libjansson. The cannot use
these flags.
2017-12-08 11:09:34 +01:00
Thomas Haller
b1c65d32fe Revert "Makefile: rework team compilation flags"
I don't think we should do this.

- renamining/dropping configure options is still an annoyance,
  because it requires to different ./configure options depending
  on the version. The rename from --enable-teamctl to --enable-team
  might be theoretically nice, but more annoying then helpful.

- There is no strict dependency between --enable-team and
  --enable-json-validation. At most, one could argue that
  when enabling the team plugin (--enable-teamctl), then
  libnm must also be build with --enable-json-validation.
  But in fact, the team plugin will happily work with a
  libnm that doesn't link against libjansson.
  That is --enable-teamctl --disable-json-validation will work
  in practice just fine.
  On the other hand, libnm is a client library to create connection
  profiles, fully supporting team profiles also makes sense if the
  actual plugin is not installed (or build). Thus, --disable-teamctl
  --enable-json-validation certainly makes sense.

At this point, one might ask whether libnm is even still complete without
libjansson. Maybe libnm should *require* --enable-json-validation.
But that is not what the patch was doing, and it would also need
some careful consideration before doing so.

This reverts commit 9d5cd7eae8.
2017-12-08 09:07:30 +01:00
Thomas Haller
af6f62be8d libnm/tests: fix memleak in test 2017-12-08 08:51:21 +01:00
Thomas Haller
d5d4911b58 gitignore: readd removed libnm-core/tests/test-setting* programs
Although removed, they show up whenever switching to an
old branch. Keep ignoring them.
2017-12-08 08:45:51 +01:00
Thomas Haller
1b8ae83967 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.
2017-12-08 08:39:02 +01:00
Francesco Giudici
4d1796b2c7 merge: branch 'fg/team_abstraction_tests_and_fixes_rh1398925'
https://bugzilla.redhat.com/show_bug.cgi?id=1398925
2017-12-08 00:53:46 +01:00