Commit graph

9326 commits

Author SHA1 Message Date
Francesco Giudici
029f78983c 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)
2018-01-08 16:50:09 +01:00
Francesco Giudici
116214ecf0 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)
2017-12-13 10:30:46 +01:00
Thomas Haller
54706e6557 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)
2017-12-13 10:30:35 +01:00
Thomas Haller
903ed7bc59 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)
2017-12-12 18:45:35 +01:00
Thomas Haller
9f3d152f47 all: use cast macros instead of C cast
When building with assertions, they nm_assert() for the
type. Otherwise, they are identical to a C cast.

Also, where possible, don't cast at all, but adjust
the type instead.

Also, there were a few missing casts.

(cherry picked from commit 7661ad64ba)
(cherry picked from commit ceeeb51e1d)
2017-12-06 10:51:47 +01:00
Colin Walters
2c30198d91 tree-wide: cast after g_object_ref() for proposed GLib patch
This fixes the build with related bug https://bugzilla.gnome.org/show_bug.cgi?id=790697

https://mail.gnome.org/archives/networkmanager-list/2017-December/msg00005.html
(cherry picked from commit 3f6bef47f3)
(cherry picked from commit 4bd3069b68)
2017-12-06 10:51:47 +01:00
Beniamino Galvani
e2c6a0dd6a settings: preserve agent-owned secrets on connection add
Settings plugins now return the connection that was reread from file
when adding a connection, which means that any agent-owned secret is
lost. Ensure that we don't forget agent-owned secrets by caching them
and readding them to the new connection returned by plugins.

Fixes: 8a1d483ca8
Fixes: b4594af55e

https://bugzilla.gnome.org/show_bug.cgi?id=789383
(cherry picked from commit 62141d59cb)
(cherry picked from commit 0bd8b34725)
2017-11-21 13:40:51 +01:00
Beniamino Galvani
9fea242f72 manager: fix evaluation of manager state
The state should be set to CONNECTED_GLOBAL only when there is full
connectivity.

Fixes: 9d43869e47

https://bugzilla.gnome.org/show_bug.cgi?id=785281
(cherry picked from commit ebb30c53cd)
2017-10-20 11:15:16 +02:00
Beniamino Galvani
01b10fe24d 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)
2017-10-19 09:06:09 +02:00
Beniamino Galvani
bb4b6be912 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)
2017-10-12 09:19:06 +02:00
Lubomir Rintel
51c7520752 platform: treat dsa devices as regular wired ethernet
https://bugzilla.redhat.com/show_bug.cgi?id=1371289
(cherry picked from commit 5c2ee8b26e)
2017-10-09 19:40:52 +02:00
Beniamino Galvani
5bd8269315 device: fix frozen notify signals on unrealize error path
If unrealize() failed we returned without thawing notify signals. Fix
this by moving g_object_freeze_notify() after the
unrealization/deletion but before the properties are reset in
unrealize_notify().

Fixes: a93807c288
(cherry picked from commit 24a7f88bc5)
2017-10-04 15:52:35 +02:00
Thomas Haller
482fcb507e keyfile: fix reading/writing route metric zero
Zero is a valid route metric and distinct from -1, which means unspecified.
Fix reader and writer.

Fixes: e374923bbe
(cherry picked from commit 099be8e4db)
2017-10-04 12:09:15 +02:00
Thomas Haller
0ba498b17d device: fix delay startup complete for unrealized devices
Since commit 6845b9b80a ("device: delay
startup complete until device is initialized in platform", we also wait
for devices that are still initializing platform/UDEV.

Obviously, that only applies to realized devices.

Otherwise, an unrealized device is going to block startup complete.

Fixes: 6845b9b80a
(cherry picked from commit 9ad8010fe0)
2017-09-29 17:37:30 +02:00
Francesco Giudici
5499dda250 dhcp: dhclient: remove the --timeout argument from the command line
the --timeout command line option is a custom feature added in some
linux distributions (fedora). Passing that command line argument will
make dhclient fail if the binary does not support it, preventing
activation of dhcp based connections.
Worse, the option has just been recently changed from "-timeout", so
that we are currently incompatibile with Centos, RedHat and older
versions of Fedora too.

Leverage the "timeout" option in dhclient config file: it will produce
the expected behavior and will be universally supported.

Fixes test: dhcp-timeout
Fixes: fa46736013

https://bugzilla.redhat.com/show_bug.cgi?id=1491243
(cherry picked from commit 1cb4832f09)
2017-09-15 12:51:22 +02:00
Francesco Giudici
b946aefe24 dhcp: dhclient: fix daemon start when dhcp-timeout is specified
A typo in the new dhcp-timeout option caused the dhclient daemon to exit
with error when the dhcp-timeout option was specified.
This prevents dhcp connection to be upped.

Fixes: 82ef497cc9
(cherry picked from commit fa46736013)
2017-09-11 15:14:37 +02:00
Beniamino Galvani
b4e9cea4b0 route-manager: fix route comparison
When comparing a platform route with a route from configuration, we
must translate the value of rt_source.

This fixes CI test @ipv6_preserve_cached_routes
2017-09-05 09:49:47 +02:00
Beniamino Galvani
ac7d908d36 device: don't release external slaves on state change
If the slave is 'external' we should never touch it, in particular we
should not release the link from its master; we only have to remove it
from master's list.

https://bugzilla.redhat.com/show_bug.cgi?id=1442361
(cherry picked from commit 981f90e324)
2017-09-02 10:46:16 +02:00
Beniamino Galvani
52b4df5127 device: don't promote slave devices to managed
Previously, if a master device had internal state 'managed', we would
promote the slave to 'managed' as well. However,

 - if the slave is 'external', it should stay as is because we don't
   want to start managing it

 - if the slave is 'assumed', it will become managed when the
   activation succeeds, so it's not necessary to do it here

Fixes: 850c977953
(cherry picked from commit 9e99590508)
2017-09-02 10:46:14 +02:00
Beniamino Galvani
bc9269ffcb default-route: skip addition when the route already exists
Re-adding the default route has side-effects, as it also prunes the
cloned routes from the kernel FIB.

https://bugzilla.redhat.com/show_bug.cgi?id=1470930
(cherry picked from commit bea6d05c1d)
2017-08-29 10:46:49 +02:00
Beniamino Galvani
fb5834c3c1 checkpoint: better restore device managed state on rollback
Manage a device again if it was managed before the checkpoint.

https://bugzilla.redhat.com/show_bug.cgi?id=1464904
(cherry picked from commit 67bfdbfc91)
2017-08-28 10:33:04 +02:00
Beniamino Galvani
c8d0a0fcf7 device: don't set a fake permanent hardware address
Software devices don't have a permanent hardware address and thus it
doesn't make sense to enforce the 'fake' (generated) permanent one
when cloned-mac-address=permanent.  Also, setting the fake permanent
address on bond devices, prevents them from inheriting the first slave
hardware address, so let's just skip the setting of MAC when
cloned-mac-address=permanent and there is no real permanent address.

https://bugzilla.redhat.com/show_bug.cgi?id=1472965
(cherry picked from commit 2f4dfd0f2e)
2017-07-26 14:08:23 +02:00
Thomas Haller
39b947fc7f platform: fix return value for do_delete_object()
The return value for the delete methods checks whether the object
is actually deleted. That is questionable behavior, because if the netlink
request succeeds, there is little point in checking with the platform cache.
As it is, it is racy.

Anyway, the previous value was totally wrong.

But it also uncovers another platform bug, which currently breaks
route tests. Will be fixed next.

(cherry picked from commit 5b09f7151b)
2017-07-25 06:57:26 +02:00
Beniamino Galvani
b72b8ef34c connectivity: fix memory leak
Fixes: 9d43869e47
(cherry picked from commit 7204472de5)
2017-07-19 22:16:46 +02:00
Beniamino Galvani
e80163c713 dns: perform the public-suffix check only for the hostname-derived domain
The DNS manager drops from the search list domains that are public
suffixes to prevent a possible domain hijack when using two-labels
hostnames [1].

This is a problem now that every single-label domain can be a TLD
since this means that such domains can't be used in the search list.

While it's useful to apply such restriction to the domain
automatically derived from the system hostname, it seems wrong to drop
domains specified by users in the configuration or provided by DHCP.

This commit keeps the public-suffix check only for the
hostname-derived domain

[1] https://bugzilla.redhat.com/show_bug.cgi?id=812394

https://bugzilla.redhat.com/show_bug.cgi?id=1404350
(cherry picked from commit 5aa22ed8c9)
2017-07-17 17:04:28 +02:00
Thomas Haller
beeb8df9ac dhcp/tests: add test parsing dhclient config
(cherry picked from commit 0c23191b01)
2017-07-10 11:55:54 +02:00
Jonathan Kang
7200906a62 dhcp/dhclient: improve "interface" statement parsing
In commit d405cfd908, parsing "interface"
statement is introduced. But it leads to uncommplete parsing of the
"request" entry, if one of the lines in "request" entry is prefixed with
word "interface". For example, the default configuration of openSUSE
distribution:

request subnet-mask, broadcast-address, routers,
	rfc3442-classless-static-routes,
	interface-mtu, host-name, domain-name, domain-search,
	domain-name-servers, nis-domain, nis-servers,
	nds-context, nds-servers, nds-tree-name,
	netbios-name-servers, netbios-dd-server,
	netbios-node-type, netbios-scope, ntp-servers;

Fixes: d405cfd908

https://bugzilla.opensuse.org/show_bug.cgi?id=1047004
https://mail.gnome.org/archives/networkmanager-list/2017-July/msg00015.html
(cherry picked from commit 3646ed083d)
2017-07-10 11:55:52 +02:00
Lubomir Rintel
61b1ab2fcd ifcfg: drop an unused variable
(cherry picked from commit 0d71c0569f)
2017-07-07 13:44:30 +02:00
Beniamino Galvani
75fb2897d7 checkpoint: disconnect device before reactivation during rollback
Since commit 0922a17738 ("manager: avoid that auto-activations
preempt user activations") the manager doesn't allow a internal
activation to disconnect the same connection already active on the
device.  Thus, during a rollback we must ensure that the device is
deactivated before.

Fixes: 0922a17738
(cherry picked from commit 348959cfa2)
2017-07-05 11:19:55 +02:00
Beniamino Galvani
10ccdf4b81 core,cli: replace wrong pattern for clearing GError
Use gs_free_error instead of gs_free.

(cherry picked from commit 65a0208ba0)
2017-06-27 09:46:09 +02:00
Beniamino Galvani
4b21a00ae2 bond: ignore miimon option only when it is zero
The default value for miimon, when missing in the setting, is 0 if
arp_interval is != 0, and 100 otherwise. So, when generating a
connection, let's ignore miimon=0 (which means that miimon is
disabled) and accept any other value. Adding miimon=100 does not cause
any harm to the connection assumption.

While at it, slightly improve the code: ignore_if_zero() is not useful
for 'updelay','downdelay','arp_interval' because zero is their default
value, so introduce a new function that checks if the value is the
default (and specially handles 'miimon').

Reported-by: Taketo Kabe <rkabe@vega.pgw.jp>

https://bugzilla.redhat.com/show_bug.cgi?id=1463077
(cherry picked from commit 92fc109183)
2017-06-23 11:28:15 +02:00
Francesco Giudici
cf726a51b9 manager: when a connection is upped on a device, do an early update of its internal state
When a user forces up a connection on a device, mark earlier the
device as managed: this would allow proper clean-up on the device also
when it was previously unmanaged or assumed.
This would avoid skipping IPv6LL address generation when instead it was
needed.

Fixes: adbf383628

https://bugzilla.redhat.com/show_bug.cgi?id=1452046
(cherry picked from commit d4a033c4ad)
2017-06-21 16:15:59 +02:00
Beniamino Galvani
2236c3c728 manager: avoid that auto-activations preempt user activations
In _internal_activate_device(), we try to find an existing master AC
for the slave AC, and we create a new one in case of failure. The
master AC may already exist, but it may not be detected by
find_master() because it is undergoing authorization.

The result is that we auto-activate the master when there is already a
user activation in place, and the auto-activation will cancel the user
one. This is bad, as user-activation should always have precedence.

To fix this, introduce a last-minute check before activating internal
connections.

https://bugzilla.redhat.com/show_bug.cgi?id=1450219
(cherry picked from commit 0922a17738)
2017-06-19 16:00:57 +02:00
Thomas Haller
24f4caebec dns: don't clone DNS configs list for nm_dns_plugin_update()
No need to clone the list anymore. Unfortunately, GPtrArray is not NULL
terminated (without extra effort), so we have to pass on the GPtrArray
instance for the length.

(cherry picked from commit 19a98c6f61)
2017-06-19 15:15:49 +02:00
Thomas Haller
4c81a447cc dns: fix negative ipv4.dns-priority for systemd-resolved
A negative ipv4.dns-priority and ipv6.dns-priority has the meaning to configure
the DNS information of the connection exclusively. With systemd-resolved, that means
we must explicitly unset the configuration from other interfaces.

https://bugzilla.gnome.org/show_bug.cgi?id=783569
(cherry picked from commit 70792e51d9)
2017-06-19 15:15:49 +02:00
Thomas Haller
6ac67655be dns: make configs argument to update a const pointer
(cherry picked from commit d582176939)
2017-06-19 15:15:49 +02:00
Thomas Haller
08d8b38a81 dns/systemd: remove unused device lookup in add_interface_configuration()
(cherry picked from commit 1c9285b06e)
2017-06-19 15:15:49 +02:00
Thomas Haller
8887970713 dns: add helper method to get DNS priority from NMDnsIPConfigData
(cherry picked from commit c818e46d48)
2017-06-19 15:15:49 +02:00
Thomas Haller
c464e111a4 dns: minor refactoring in _collect_resolv_conf_data()
The code was correct previously, but it was confusing to me,
because

  - once @skip gets set to TRUE, it stays TRUE for the rest
    of the loop.
  - in each additional skipped iteration, it would still set
    plugin_confs[i] to NULL. Which is not wrong, but confusing.
  - it would set "prev_prio = prio;" in each iteration.
    After @skip is set to TRUE, that doesn't matter anymore,
    but is confusing. Before @skip is set to TRUE it also
    doesn't really matter to set it more then once, because
    we only care about the very first priority.
  - @skip sounded to me like the current iteration would
    be skipped. But really all remaining will be skipped too.

(cherry picked from commit aa347182bb)
2017-06-19 15:15:49 +02:00
Thomas Haller
368c7329f8 device: fix taking over device after modifying external connection
For externally managed interfaces, we create an in-memory connection
and keep the device with sys-iface-state=external.

When the user actively modifies the connection, we persist it to
storage. But we also must take over managing the device.

One problem is that nm_device_reapply() errors out if the device
is still activating. It's unclear how to reapply the connection
while the device is in the process of activation. So, if the user
modifies the created connection very quickly, reapplying the settings
will fail.

https://bugzilla.redhat.com/show_bug.cgi?id=1462223
(cherry picked from commit 10c0632df0)
2017-06-19 15:02:11 +02:00
Thomas Haller
08c58c759a core: fix registering notify-flags hook in NMActiveConnection
We react on changes to NMSettingsConnection.flags, so that we can update
from an external activation to a managed one.

However, previously we would only register the _settings_connection_notify_flags
callback during _set_settings_connection(). So, if via constructor properties
we first set PROP_SETTINGS_CONNECTION and later PROP_ACTIVATION_TYPE, we wouldn't
register the callback.

(cherry picked from commit b84da25713)
2017-06-19 15:02:11 +02:00
Thomas Haller
653ba8b759 core: log changes to NMSettingsConnection's flags
(cherry picked from commit 2656ba8d1d)
2017-06-19 15:02:11 +02:00
Beniamino Galvani
9819ffe7d4 core: sort addresses in captured IPv4 configuration
When IPv4 addresses are synchronized to platform, the order of IPv4
addresses matters because the first address is considered the primary
one. Thus, nm_ip4_config_capture() should put the primary address as
first, otherwise during synchronization addresses will be removed and
added back with a different primary/secondary role.

https://bugzilla.redhat.com/show_bug.cgi?id=1459813
(cherry picked from commit b6fa87a4c0)
2017-06-13 23:36:07 +02:00
Thomas Haller
588841f2e0 device: don't set MTU of device unless explicitly configured
Since commit 2b51d3967 "device: merge branch 'th/device-mtu-bgo777251'",
we always set the MTU for certain device types during activation. Even
if the MTU is neither specified via the connection nor other means, like
DHCP.

Revert that change. On activation, if nothing explicitly configures the
MTU, leave it unchanged. This is like what we do with ethernet's
cloned-mac-address, which has a default value "preserve".
So, as last resort the default value for MTU is now 0 (don't change),
instead of depending on the device type.

Note that you also can override the default value in global
configuration via NetworkManager.conf.

This behavior makes sense, because whenever NM actively resets the MTU,
it remembers the previous value and restores it when deactivating
the connection. That wasn't implemented before 2b51d3967, and the
MTU would depend on which connection was previously active. That
is no longer an issue as the MTU gets reset when deactivating.

https://bugzilla.redhat.com/show_bug.cgi?id=1460760
(cherry picked from commit 4ca3002b86)
2017-06-13 15:27:21 +02:00
Thomas Haller
1b954fe09b ppp: fix cancelling timeout when pppd process exits
Otherwise, we get pppd_timed_out() later, which will
emit a DEAD state change at unexpected times.

(cherry picked from commit b9af32b056)
2017-06-09 16:16:42 +02:00
Thomas Haller
b87327a5fe ppp: cleanup logging pppd exit reason in ppp_watch_cb
- don't use assert but be more graceful with g_return_if_fail().
- in case of failure, don't log a debug message after the warning.
  One message is sufficient, drop "pppd pid %d cleaned up".
- print GPid type as long long.
- increase log level to warning. pppd dying unexpectedly warrants a
  warning.

(cherry picked from commit 250e723951)
2017-06-09 16:16:42 +02:00
Thomas Haller
38b5d356de ppp: don't log newlines
(cherry picked from commit a814b96ebf)
2017-06-09 16:16:42 +02:00
Thomas Haller
ccda61b6fc ppp: refactor ppp_exit_code() to split out error to string conversion
ppp_exit_code() does too much or too little. Either it should log
about all reasons why pppd exited, including signals, or it should
just do the status to string conversion. Split it.

(cherry picked from commit 3f64910b52)
2017-06-09 16:16:42 +02:00
Thomas Haller
105ef99cbf ppp/trivial: fix whitespace
(cherry picked from commit 5c5fbe0a9f)
2017-06-09 16:16:42 +02:00
Thomas Haller
620adbcc7b ppp: inline and drop trivial function remove_timeout_handler()
(cherry picked from commit 0f16649ba2)
2017-06-09 16:16:42 +02:00