Commit graph

19137 commits

Author SHA1 Message Date
Lubomir Rintel
5fe4e83020 man/openvswitch: fix type in examples
"conn.type" doesn't allow type aliases. Use "type" instead.

https://bugzilla.redhat.com/show_bug.cgi?id=1519173
(cherry picked from commit 6713ab4d6c)
2017-12-19 10:04:46 +01:00
Lubomir Rintel
c96ab5277e ifcfg-rh: remove the watch on finalize
(cherry picked from commit 0ae44fe7e2)
2017-12-19 10:04:46 +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
643d80ec91 manager: fix connectivity-check-enabled property
(cherry picked from commit 99fea5f380)
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
1cfbfde38d core: merge branch 'th/device-route-metric-rh1505893'
https://bugzilla.redhat.com/show_bug.cgi?id=1505893

(cherry picked from commit b2273ce3dd)
2017-12-15 11:45:18 +01:00
Thomas Haller
bd2d71754b device: generate unique default route-metrics per interface
In the past we had NMDefaultRouteManager which would coordinate adding
the default-route with identical metrics. That especially happened, when
activating two devices of the same type, without explicitly specifying
ipv4.route-metric. For example, with ethernet devices, the routes on
both interfaces would get a metric of 100.

Coordinating routes was especially necessary, because we added
routes with NLM_F_EXCL flag, akin to `ip route replace`. We not
only had to avoid that activating two devices in NetworkManager would
result in a fight over the default-route, but more importently
to preserve externally added default-routes on unmanaged interfaces.

NMDefaultRouteManager would ensure that in case of duplicate
metrics, that the device that activated first would keep the
best default-route. It would do so by bumping the metric
of the second device to find a unused metric. The bumping itself
was not very important -- MDefaultRouteManager could also just not
configure any default-routes that show up as second, the result
would be quite similar. More important was to keep the best
default-route on the first activating device until the device
deactivates or a device activates that really has a better
default-route..

Likewise, NMRouteManager would globally manage non-default-routes.
It would not do any bumping of metrics, but it would also ensure that the routes
of the device that activates first are not overwritten by a device activating
later.

However, the `ip route replace` approach has downsides, especially
that it messes with routes on other interfaces, interfaces that are
possibly not managed by NetworkManager. Another downside is, that
binding a socket to an interface might not result in correct
routes, because the route might just not be there (in case of
NMRouteManager, which wouldn't configure duplicate routes by bumping
their metric).

Since commit 77ec302714 we would no longer
use NLM_F_EXCL, but add routes akin to `ip route append`. When
activating for example two ethernet devices with no explict route
metric configuration, there are two routes like

   default via 10.16.122.254 dev eth0 proto dhcp metric 100
   default via 192.168.100.1 dev eth1 proto dhcp metric 100

This does not only affect default routes. In case of a multi-homing
setup you'd get

  192.168.100.0/24 dev eth0 proto kernel scope link src 192.168.100.1 metric 100
  192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.1 metric 100

but it's visible the most for default-routes.

Note that we would append the routes that are activated later, as the order
of `ip route show` confirms. One might hence expect, that kernel selects
a route based on the order in the routing tables. However, that isn't
the case, and activating the second interface will non-deterministically
re-route traffic via the new interface. That will interfere badly with
with NAT, stateful firewalls, and existing connections (like TCP).

The solution is to have NMManager keep a global index of the default route-metrics
currently in use. So, instead of determining the default-route metric based solely
on the device-type, we now in addition generate default metrics that do not
overlap. For example, if you activate eth0 first, it gets route-metric 100,
and if you then activate eth1, it gets 101. Note that if you deactivate
and re-activate eth0, then it will get route-metric 102, because the
best route should stick on eth1 (which reserves the range 100 to 101).

Note that when a connection explititly selects a particular metric, then that
choice is honored (contrary to NMDefaultRouteManager which was more concerned
with avoiding conflicts, then keeping the exact metric).

https://bugzilla.redhat.com/show_bug.cgi?id=1505893
(cherry picked from commit 6a32c64d8f)
2017-12-15 11:44:52 +01:00
Thomas Haller
282ed0d175 core: add read/write support for route-metric to NMConfig's device state
(cherry picked from commit a90b523a3e)
2017-12-15 11:44:52 +01:00
Thomas Haller
7b89933406 core: cache device state in NMConfig and load all at once
NMManager will need to know the state of all device at once.
Hence, load it once and cache it in NMConfig.

Note that this wastes a bit of memory in the order of
O(number-of-interfaces). But each device state entry is
rather small, and we always consume memory in the order
of O(number-of-interfaces).

(cherry picked from commit ea08df925f)
2017-12-15 11:44:52 +01:00
Thomas Haller
42fbc9410b core: add nm_config_keyfile_get_int64() util
(cherry picked from commit 3f38b76515)
2017-12-15 11:44:52 +01:00
Thomas Haller
ea78f156f2 device: expose nm_device_get_route_metric_default()
(cherry picked from commit 989b5fabaa)
2017-12-15 11:44:52 +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
Francesco Giudici
2638d53ca8 devices/test: give more time to dad checking in test-arping
# random seed: R02Sc708af827453d4ace33cd27ffd3d7f0b
  1..2
  # Start of arping tests
  **
  NetworkManager:ERROR:src/devices/tests/test-arping.c:95:test_arping_common: assertion failed (nm_arping_manager_check_address (manager, info->addresses[i]) == info->expected_result[i]): (1 == 0)
  ok 1 /arping/1
  PASS: src/devices/tests/test-arping 1 /arping/1
  ./tools/run-nm-test.sh: line 193:  2836 Aborted                 "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  # NetworkManager:ERROR:src/devices/tests/test-arping.c:95:test_arping_common: assertion failed (nm_arping_manager_check_address (manager, info->addresses[i]) == info->expected_result[i]): (1 == 0)
  ERROR: src/devices/tests/test-arping - too few tests run (expected 2, got 1)
  ERROR: src/devices/tests/test-arping - exited with status 134 (terminated by signal 6?)

(cherry picked from commit 5c6a382d4d)
2017-12-13 10:27:43 +01:00
Thomas Haller
4205f71c4f merge: bug fixes found via coverity
(cherry picked from commit cc5ff98456)
2017-12-12 11:21:24 +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
7fb865947c cli: avoid out-of-bounds-read for show_device_info()
Probably not critical, because it will still include
the terminating NULL, and just continue to fill the
temporary buffer with static addresses.

Found by coverity.

Fixes: bfb9fd0d2f
(cherry picked from commit c274b565a6)
2017-12-12 11:21:05 +01:00
Thomas Haller
490911c6fa platform: assert() for valid item in nm_platform_link_get_all()
Coverity thinks that item might be NULL, but actually it
cannot. Unclear how to avoid the false positive.

(cherry picked from commit 62d4dba74b)
2017-12-12 11:21:05 +01:00
Thomas Haller
99eef7a2ea platform: fix crash hashing NMPlatformTfilter and NMPlatformQdisc
@kind might be NULL. There are 3 forms of the hash-update functions for
string: str(), str0(), and strarr().

- str0() is when the string might be NULL.
- str() does not allow the string to be NULL
- strarr() is like str(), except it adds a G_STATIC_ASSERT()
  that the argument is a C array.

The reason why a difference between str() and str0() exists, is
because str0() hashes NULL different from a "" or any other string.
This has an overhead, because it effectively must hash another bit
of information that tells whether a string was passed or not.

The reason is, that hashing a tupple of two strings should always
yield a different hash value, even for "aa",""; "a","a"; "","aa",
where naive concatentation would yield identical hash values in all
three cases.

Fixes: e75fc8279b
(cherry picked from commit 27e8fffdb8)
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
Thomas Haller
1bb6b3a79f core: avoid dereferencing NULL in nm_utils_resolve_conf_parse()
Found by coverity.

Fixes: 8f1ef161f4
(cherry picked from commit a7087b1f05)
2017-12-12 11:21:05 +01:00
Thomas Haller
387377d8fc core: fix uninialized boolean variable in reset_autoconnect_all()
It's not critical, because at worst we get a false-positive that
something changed.

Found by coverity.

Fixes: 4e7b05de79
(cherry picked from commit fbc6008260)
2017-12-12 11:21:05 +01:00
Lubomir Rintel
6f37ae7df4 po: translations from the Red Hat translators
(cherry picked from commit f4419783b7)
2017-12-12 11:01:34 +01:00
Lubomir Rintel
f66e5a06d2 po: update-po for the translations that are going to be updated
Just so that we get a nicer diff when pulling from the Red Hat Zanata.
(cherry picked from commit 4103c72c15)
2017-12-12 11:01:11 +01:00
Beniamino Galvani
1bcbf88a62 release: bump version to 1.10.3 (development) 2017-12-12 02:45:52 +01:00
Beniamino Galvani
7ebc925845 release: bump version to 1.10.2 2017-12-12 02:35:30 +01:00
Beniamino Galvani
a5ee6f62bc release: update NEWS 2017-12-12 01:03:17 +01:00
Thomas Haller
d6e7857389 platform/tests: fix memleaks in tests
Fixes: 0b0fb045bc
(cherry picked from commit 5201121a1b)
2017-12-11 21:04:58 +01:00
Lubomir Rintel
35e86a0cef device: ensure simple action sdata is a NUL-terminated bytestring
(cherry picked from commit 9639a176ff)
2017-12-11 19:53:09 +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
626bf76972 device: set traffic filters when device comes up
(cherry picked from commit 8bffb2c750)
2017-12-11 19:53:09 +01:00
Thomas Haller
014b50fcbe 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.

(cherry picked from commit fe3d7209e7)
2017-12-11 19:53:09 +01:00
Lubomir Rintel
97eeadb990 platform: add support for traffic filters
(cherry picked from commit b0fd3ecbaf)
2017-12-11 19:53:09 +01:00
Lubomir Rintel
81967af3fc 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'

(cherry picked from commit 3261820004)
2017-12-11 19:43:40 +01:00
Lubomir Rintel
e881d0ab33 keyfile/tests: test tc traffic filter reading and writing
(cherry picked from commit bc471c8e7a)
2017-12-11 19:43:37 +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
f8da7febbc device: set qdiscs when device comes up
(cherry picked from commit e4bdb21909)
2017-12-11 19:34:31 +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
bb50e73626 keyfile/tests: test tc qdisc reading and writing
(cherry picked from commit 8547387942)
2017-12-11 19:06:28 +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