Commit graph

16850 commits

Author SHA1 Message Date
Jason Reeder
eb8fd9cdfd libsystemd-network: ipv4ll probe conflict counter (#5361)
A bug exists where the conflict counter is cleared
regardless of whether or not the next probe attempt leads to
a successful address acquisition. This causes 'bursts' of
MAX_CONFLICTS probes followed by a delay of
RATE_LIMIT_INTERVAL instead of a single probe each
RATE_LIMIT_INTERVAL when beyond MAX_CONFLICTS.

The conflict counter should only be cleared after an
address is successfully acquired. This commit achieves that
goal.

From RFC3927:
A host should maintain a counter of the number of address
conflicts it has experienced in the process of trying to
acquire an address, and if the number of conflicts exceeds
MAX_CONFLICTS then the host MUST limit the rate at which it
probes for new addresses to no more than one new address per
RATE_LIMIT_INTERVAL.  This is to prevent catastrophic ARP
storms in pathological failure cases, such as a rogue host
that answers all ARP probes, causing legitimate hosts to go
into an infinite loop attempting to select a usable address.

Signed-off-by: Jason Reeder <jasonreeder@gmail.com>

(cherry picked from commit 0cbc024d591e1b1095d90494e0337dabd9ef2e19)
2018-10-29 20:53:02 +01:00
Thomas Haller
26b4122825 wwan: don't assume DNS info is always available for IPv6
See also "5df024f57a wwan: don't assume DNS info is always available"
which does the same for IPv4.

(cherry picked from commit cec7ade86c)
(cherry picked from commit 00f14736e6)
(cherry picked from commit 7c09527d5e)
(cherry picked from commit e3e86af74e)
(cherry picked from commit 0e812da25e)
2018-10-12 00:22:09 +02:00
Thomas Haller
0a95b1a593 wifi: fix leaking fake AP in NMDeviceWifi's act_stage1_prepare()
Fixes: 96f40dcdcd
(cherry picked from commit ef61d7909f)
(cherry picked from commit d08530ac4b)
(cherry picked from commit 6c4c12c796)
(cherry picked from commit 4a345b2e78)
(cherry picked from commit ae112d0070)
2018-09-13 16:30:58 +02:00
Thomas Haller
d95e1304e7 dhcp: fix leak in dhclient's dhclient_start()
Fixes: 5d6d5cd136
(cherry picked from commit c87faf07a1)
(cherry picked from commit 8f9240de96)
(cherry picked from commit c740726b57)
(cherry picked from commit 0a69572cae)
(cherry picked from commit 13aaad7c5b)
2018-09-10 14:40:04 +02:00
Thomas Haller
11ad2a0e9e libnm/keyfile: fix double free in keyfile's get_bytes()
Fixes: 5e7b14af03
(cherry picked from commit fcf254c03a)
(cherry picked from commit 1c56be4090)
(cherry picked from commit 71e2a25a0d)
(cherry picked from commit fd6acf6183)
2018-09-04 07:50:25 +02:00
Thomas Haller
9e82199d57 wifi: don't use :1 bitfield for gboolean type
gboolean is a typedef for "int".

While older compilers might treat such bitfields as unsigned ([1]),
commonly such a bitfield is signed and can only contain the values 0
and -1.

We only want to use numeric 1 for TRUE, hence, creating such bitfields
is wrong, or at least error prone.

In fact, in this case it's a bug, because later we compare
it with a regular gboolean

  if (priv->scanning != new_scanning)

[1] https://lgtm.com/rules/1506024027114/

Fixes: e0f9677018
(cherry picked from commit 610ca87016)
(cherry picked from commit f326feaba3)
(cherry picked from commit 7689b9b73b)
(cherry picked from commit 9f41fae864)
2018-08-26 18:35:17 +02:00
Beniamino Galvani
4c53d31d64 libnm: add (allow-none) annotations to nm_device_reapply()
The @connection argument can be NULL; add the (allow-none) annotation
otherwise calling the API with a NULL argument through GObject
introspection fails with:

 Argument 1 does not allow None as a value

Fixes: 278fd4fb0f
(cherry picked from commit f396826466)
(cherry picked from commit a03b867ba4)
(cherry picked from commit cd6c17cb21)
(cherry picked from commit 8d4fce4daf)
2018-07-04 14:20:12 +02:00
Thomas Haller
f4ff9540eb device: fix crash during reapply
Fixes: bf3b3d444c
(cherry picked from commit fe1f5871c8)
(cherry picked from commit 28cf2ecd0d)
(cherry picked from commit a8411d11f8)
2018-06-15 09:14:44 +02:00
Benjamin Berg
4bcb4c4ef2 Add calls to g_simple_async_result_set_check_cancellable
If an operation is cancelled through the GCancellable, then the idiom is
that the operation is always cancelled, even if it has finished
successfully. To ensure this is the case, add calls to
g_simple_async_result_set_check_cancellable everywhere.

Without this, e.g. gnome-control-center will crash when switching away
from the power panel quickly, as the NMClient creation finishes
asynchronously and g-c-c assume that G_IO_ERROR_CANCELLED is returned to
ensure it doesn't access the now invalid user_data parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=794088
(cherry picked from commit 26c215e22d)
(cherry picked from commit e1b99d9201)
(cherry picked from commit 2e62853509)
2018-03-08 15:36:42 +01:00
Pavel Šimerda
58c8a70808 libnm: fix empty statements that were supposed to return NULL
Discovered thanks to `-Wunused-value` when building on openSUSE Leap 42.3.

(cherry picked from commit c4f655579c)
(cherry picked from commit a30b2fcd84)
(cherry picked from commit b2b28cb644)
2018-01-17 19:21:56 +01:00
Lubomir Rintel
17bb14f433 secret-agent: construct the dbus proxy for async agent with the correct bus name
The asynchronous secret agent initialization doesn't work at all due to a
rather silly typo. Oops.

While at it, fix a whitespace error too.

(cherry picked from commit 603daa5b25)
2018-01-11 13:43:50 +01:00
Francesco Giudici
895de040e2 platform/tests: relax checking for signals in test-address-linux
# Start of ipv6 tests
  ../tools/run-nm-test.sh: line 193: 32194 Trace/breakpoint trap   (core dumped) "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  # NetworkManager-FATAL-ERROR: NMPlatformSignalAssert: ../src/platform/tests/test-address.c:153, test_ip6_address_general(): failure to accept signal [0,1] times: 'ip6-address-changed-changed' ifindex 11 (2 times received)

(cherry picked from commit f9b9c5979e)
(cherry picked from commit 029f78983c)
2018-01-08 16:52:04 +01:00
Francesco Giudici
c513762721 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)
(cherry picked from commit 2638d53ca8)
(cherry picked from commit 116214ecf0)
2017-12-13 10:32:08 +01:00
Thomas Haller
5806ee1397 tests: increase timeout for arping test
I hit an assertion failure running with valgrind on a busy machine.
Maybe the timeout is just not long enough for every case.

Increase it.

(cherry picked from commit 88c24ffc6a)
(cherry picked from commit 54706e6557)
2017-12-13 10:32:00 +01:00
Thomas Haller
39623f7ffb platform/tests: relax checking for signals in test-link-linux
# random seed: R02S4ca8cfc3dace399c0f15b42411e45d2e
  1..48
  # Start of link tests
  ok 1 /link/bogus
  PASS: src/platform/tests/test-link-linux 1 /link/bogus
  ok 2 /link/loopback
  PASS: src/platform/tests/test-link-linux 2 /link/loopback

  nmtst: initialize nmtst_get_rand() with NMTST_SEED_RAND=2697682474
  ok 3 /link/internal
  PASS: src/platform/tests/test-link-linux 3 /link/internal
  ok 4 /link/external
  PASS: src/platform/tests/test-link-linux 4 /link/external
  # Start of software tests
  ./tools/run-nm-test.sh: line 193:  7589 Trace/breakpoint trap   (core dumped) "${NMTST_DBUS_RUN_SESSION[@]}" "$TEST" "$@"
  NMPlatformSignalAssert: src/platform/tests/test-link.c:298, test_slave(): failure to accept signal 0 times: 'link-changed-changed' ifindex 9 (1 times received)
  ERROR: src/platform/tests/test-link-linux - too few tests run (expected 48, got 4)
  ERROR: src/platform/tests/test-link-linux - exited with status 133 (terminated by signal 5?)

(cherry picked from commit 1ee6dea02f)
(cherry picked from commit 903ed7bc59)
2017-12-12 18:49:25 +01:00
Lubomir Rintel
a5d7cf5c4b systemd: drop xlocale.h include
It is not needed and doesn't exist in glibc 2.26 or other libcs.
systemd removed it in commit 284d1cd0a1 too.
2017-11-03 10:47:40 +01:00
Lubomir Rintel
b2af5f7ab6 libnm/client: proxy *_enabled and metered properties to the right object
They're provided by the Manager, not by the RemoteSettings.

(cherry picked from commit c81005b846)
(cherry picked from commit 34035ceee8)
2017-11-02 09:05:22 +01:00
Beniamino Galvani
6c6fd5d60d core: don't close input fd in nm_utils_fd_get_contents()
The function should not close the input file descriptor; however
fdopen() associates the fd to the new stream so that when the stream
is closed, the fd is too. The result is a double close() and the
second call can in certain cases affect a wrong fd.

Use a duplicate fd for the stream.

Fixes: 1d9bdad1df

https://bugzilla.redhat.com/show_bug.cgi?id=1451236
(cherry picked from commit 597072296a)
(cherry picked from commit 01b10fe24d)
2017-10-19 09:08:20 +02:00
Beniamino Galvani
44cbd3b036 bus-manager: don't leak connections
The bus manager takes extra references to the GDBusConnection every
time g_dbus_object_manager_server_get_connection() its called,
preventing its disposal once the connection is closed. This causes a
leak for each DHCP event.

https://bugzilla.redhat.com/show_bug.cgi?id=1461643
(cherry picked from commit 5b81d40338)
(cherry picked from commit bb4b6be912)
2017-10-15 10:24:51 +02:00
Beniamino Galvani
f8bc8d0a3e release: bump version to 1.6.5 (development) 2017-07-17 16:38:30 +02:00
Beniamino Galvani
6ef7e37553 release: bump version to 1.6.4 2017-07-17 16:36:16 +02:00
Beniamino Galvani
93aea204f7 release: update NEWS 2017-07-17 16:27:26 +02:00
Thomas Haller
357fc9b2d0 build: don't depend on libnm-core directory for make target
(cherry picked from commit d440958de1)
2017-07-17 16:27:26 +02:00
Lubomir Rintel
a8695f2e11 build: avoid passing enums-to-docbook.pl to itself on its command line
(cherry picked from commit e947739dd6)
2017-07-17 16:19:48 +02:00
Beniamino Galvani
af4c406cea core,cli: replace wrong pattern for clearing GError
Use gs_free_error instead of gs_free.

(cherry picked from commit 65a0208ba0)
(cherry picked from commit 10ccdf4b81)
2017-06-27 09:49:15 +02:00
Thomas Haller
14b65ec28d clients: fix appending integer to result in nmc_property_set_bytes()
(cherry picked from commit d76c190dc7)
(cherry picked from commit 06d3c95e4f)
2017-05-23 16:12:31 +02:00
Beniamino Galvani
9a07ef5be5 clients: fix setter for 802-1x.password-raw
The property is a GBytes, not a GByteArray.

https://bugzilla.gnome.org/show_bug.cgi?id=782836
(cherry picked from commit 30393ee236)
(cherry picked from commit cc6c9468fc)
2017-05-23 16:12:29 +02:00
Thomas Haller
5aa250e888 release: belatedly add NEWS entry for 1.6.0 release 2017-05-10 13:25:50 +02:00
Thomas Haller
ca342ed61d policy: fix memleak in lookup_callback() and cancelling
When the operation is cancelled, we must not touch user_data. Note that
NM_POLICY_GET_PRIVATE() theoretically doesn't dereference the pointer
(does it?) but doing pointer arithmetic on a dangling pointer is a very
ugly thing to do.

And of course, the memleak.

Fixes: 5c716c8af8
Fixes: a2cdf63204
(cherry picked from commit 3215508293)
(cherry picked from commit f1469558c0)
2017-05-02 18:27:16 +02:00
Thomas Haller
bd72919b47 device: fix restricting Generic connection by interface-name
NMDeviceGeneric:check_connection_compatible() doesn't check for a
matching interface name. It relies on the parent implementation to
do that.

The parent implementation calls nm_manager_get_connection_iface().
That fails for NM_SETTING_GENERIC_SETTING_NAME, because that one has
no factory. Maybe this imbalance of having no factory for the Generic device
is wrong, but usually factories only match a distinct set of device
types, while the generic factory would handle them all (as last resort).

Without this, activating a generic connection might activate the
wrong interface.

(cherry picked from commit 3876b10a47)
(cherry picked from commit 753a2cc4d9)
2017-04-26 21:10:15 +02:00
Thomas Haller
2ebc390734 build: fix type on Makefile.am
Fixes: 3cc00dd550
(cherry picked from commit e824dd34f0)
2017-04-20 15:50:44 +02:00
Thomas Haller
4c595997f2 ifcfg: also read DEFROUTE and GATEWAY from alias files
Also accept DEFROUTE and GATEWAY when they are defined in
alias files -- provided, that they are not yet defined
in the main ifcfg file.

(cherry picked from commit 3cc00dd550)
2017-04-20 15:36:30 +02:00
Thomas Haller
be1daa4580 ifcfg: ensure ipv4.method is not "disabled" when reading IP addresses from alias files
When the main ifcfg file contains no IP addresses, the method
will be "disabled". Later, when reading IP addresses for the
aliases, we must ensure that the method is manual.

Otherwise, validation fails with

  ip.addresses: this property is not allowed for method=disabled

(cherry picked from commit a8f0d88596)
2017-04-20 15:36:25 +02:00
Piotr Drąg
a710e127b4 po: update Polish (pl) translation (bgo #780277)
https://bugzilla.gnome.org/show_bug.cgi?id=780277

[thaller@redhat.com: with `make -C po NetworkManager.pot update-po`]
2017-04-19 17:54:12 +02:00
Thomas Haller
764796af76 po: import Zanata translations 2017-04-19 17:51:07 +02:00
Thomas Haller
f7b2e9888b po: make update-po 2017-04-19 17:51:06 +02:00
Thomas Haller
6c6d94f23f gitignore: ignore .zanata-cache directory 2017-04-19 17:51:06 +02:00
Dan Williams
53626395fe auth-utils: fix possibly uninitialized variables
src/nm-auth-utils.c:343:6: error: 'is_authorized' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   if (is_authorized) {
      ^
src/nm-auth-utils.c:320:11: note: 'is_authorized' was declared here
  gboolean is_authorized, is_challenge;
           ^
src/nm-auth-utils.c:346:13: error: 'is_challenge' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   } else if (is_challenge) {
             ^
src/nm-auth-utils.c:320:26: note: 'is_challenge' was declared here
  gboolean is_authorized, is_challenge;
                          ^

(cherry picked from commit 24ab2a4945)
2017-04-07 11:53:16 -05:00
Dan Williams
39d42c1774 default-route-manager: fix possibly uninitialized variable
src/nm-default-route-manager.c: In function '_ipx_update_default_route':
src/nm-default-route-manager.c:769:23: error: 'is_assumed' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    if (!default_route && !is_assumed) {
                       ^
src/nm-default-route-manager.c:763:13: note: 'is_assumed' was declared here
    gboolean is_assumed;
             ^

(cherry picked from commit 857f26dd19)
2017-04-07 11:34:07 -05:00
Thomas Haller
e9f23553bd build: add slash to directory name for mkdir
Just for consistency with other locations that call
$(MKDIR_P).

(cherry picked from commit c2f0764c1e)
2017-04-07 11:22:24 -05:00
Lubomir Rintel
eca56d3cab build: create missing directories for out-of-tree builds
They could be created by dumb luck with dependency tracking, but
apparently some distributions disable that.

(cherry picked from commit 258382be12)
2017-04-07 11:22:18 -05:00
Beniamino Galvani
bb3b8627a0 device,default-route-manager: merge branch 'th/default-route-resync'
(cherry picked from commit 6197c27f24)
2017-04-03 13:24:57 +02:00
Thomas Haller
172f5bb2e9 default-route-manager: decryptify logging line for default-route-manager
The default route manager logs for each entry relevant information,
in a compact but cryptic way:

  default-route: entry[0/dev:0x5633d5528560:enp0s25:1:+sync]: record:add    0.0.0.0/0 via 192.168.0.1 dev 2 metric 100 mss 0 rt-src user (100)

The flag whether a route is configured or not, was only expressed
via 0|1. Change that to log instead:

  default-route: entry[0/dev:0x5633d5528560:enp0s25:+has:+sync]: record:add    0.0.0.0/0 via 192.168.0.1 dev 2 metric 100 mss 0 rt-src user (100)

(cherry picked from commit 82bfb6c46d)
2017-04-03 13:23:49 +02:00
Thomas Haller
6c7ef310b1 default-route-manager: alyways force a sync of the default route
Whenever we call update for a non-assumed, synced route, we must
force a resync with the platform. Even if according to our internal
book-keeping the route is already configured, the route may have
been removed externally. So we cannot assume that everything is
still up-to-date.

https://bugzilla.redhat.com/show_bug.cgi?id=1431268
(cherry picked from commit c3c251ea12)
2017-04-03 13:23:47 +02:00
Thomas Haller
ac515194a5 default-route-manager: use nm_cmp_uint32_p_with_data() instead of reimplementation
(cherry picked from commit 0057dc332e)
2017-04-03 13:23:45 +02:00
Thomas Haller
5e12056c9e default-route-manager: add nm_default_route_manager_resync() function
(cherry picked from commit e181956fdd)
2017-04-03 13:23:43 +02:00
Thomas Haller
27c7b786d9 default-route-manager: simplify _platform_changed_cb() handling
There is only one caller of _platform_ipx_route_changed_cb(). Inline it,
it is simpler.

(cherry picked from commit 70ab174e0e)
2017-04-03 13:23:39 +02:00
Thomas Haller
9a322b4e19 default-route-manager: simplify determining synced flag in _ipx_update_default_route()
No change in behavior at all. The same logic applies, but this should
be simpler to understand.

(cherry picked from commit 0b3ba99409)
2017-04-03 13:23:37 +02:00
Lubomir Rintel
58c9a41959 settings-connection: fix Save()
Avoid using new_settings when they are none. Also, don't shortcut when
the connection hasn't been changed -- let the settings plugin decide if
it needs to rewrite the connection.

(cherry picked from commit b47340fd3f)
2017-03-24 10:28:19 +01:00
Iain Lane
1715ec53c1 nm-manager: Use g_dbus_message_new_method_error_literal()
GLib 2.52 added a G_GNUC_PRINTF attribute to
g_dbus_message_new_method_error(). This triggered warning in
NetworkManager when built with -Wformat, which is an error when built
with -Werror=format-security. It seems that gcc isn't smart enough to
see that (foo = "bar") should be treated as a literal.

Fortunately there is a g_dbus_message_new_method_error_literal()
function which does not take printf-style arguments, and we don't need
them, so we can use that.

This patch was originally by Rico Tzschichholz <ricotz@ubuntu.com>, and
was submitted to Launchpad at

https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1650972
https://bugzilla.gnome.org/show_bug.cgi?id=780444
(cherry picked from commit 6a77258f4e)
2017-03-23 13:13:16 +01:00