Commit Graph

9633 Commits

Author SHA1 Message Date
Thomas Haller
7087956870 supplicant/tests: work-around coverify false-positive in test
NetworkManager-1.8.0/src/supplicant/tests/test-supplicant-config.c:528: check_return: Calling "nm_setting_802_1x_set_ca_cert" without checking return value (as is done elsewhere 13 out of 16 times).
2017-06-02 19:51:11 +02:00
Thomas Haller
f1eb1619f1 connectivity: fix scheduling periodic connectivity checks
commit a955639 (connectivity: don't do periodic checks on interval=0)
broke scheduling connectivity checks.

That is because the timer is on only scheduled if
nm_connectivity_check_enabled(), which in turn only returns TRUE
if curl_mhandle is set. However, nm_connectivity_init() would only
initialize curl_mhandle after update_config(), missing to schedule
the periodic task.

https://mail.gnome.org/archives/networkmanager-list/2017-May/msg00076.html

Fixes: a95563996f
2017-06-02 19:15:30 +02:00
Thomas Haller
ea6648cea1 all: replace uses of inet_aton() and friends
rpmdiff complains about uses of inet_aton, inet_makeaddr, inet_netof,
inet_ntoa under the IPv6 section:

   usr/sbin/NetworkManager on aarch64 i686 x86_64 ppc ppc64 ppc64le s390 s390x uses function inet_aton, which may impact IPv6 support

I think the warning is bogus, but refactor our code to avoid it.

Note that systemd code still uses them, so it don't avoid the rpmdiff
warning. But let's not diverge our systemd import from upstream for this.

- for NMSettingBond:validate_ip() also avoid g_strsplit_set() which
  allocates a full strv. Instead, we can do with one g_strdup().

- for test-resolvconf-capture.c, replace the functions with macros.
  Macros should be avoided usually, but for test asserts they are
  more convenient as they preserved the __FILE__:__LINE__ of where
  the assertion fails.
2017-06-02 14:07:10 +02:00
Lubomir Rintel
c0419257e7 all: reject duplicate keys in JSON
Teamd is not happy about them and would fail anyway. Worse even, if we
json_loads() such a JSON, which is precisely what happens when we inject the
"hwaddr" key, we turn bad JSON into a good one in a lossy matter. Not good.

https://bugzilla.redhat.com/show_bug.cgi?id=1455130
2017-06-01 13:30:21 +02:00
Lubomir Rintel
bf7e86128c bridge: move the Bluetooth NAP logic to bridge device
The Bluetooth NAP functionality seems only useful for the bridges. Move
it away from NMDevice.
2017-06-01 11:57:42 +02:00
Thomas Haller
b0f9571d3d libnm: add _nm_connection_get_setting_bluetooth_for_nap()
If there is value in such a helper function (there is), then
it should go alongside the other nm_connection_get_setting*()
helpers. NMDevice is already large enough.
2017-06-01 11:28:57 +02:00
Thomas Haller
1be01bd51f device: don't include header of bluetooth plugin in nm-device.h
The plugins may use stuff from core, but not the other way around.
Including "bluetooth/nm-bluez-common.h" is wrong.

The UUID argument is always "nap" in the NAP case. We don't need
the flexibility that it might be anything else. Just drop it.

As far as NMDevice is concerned, it anyway wouldn't (or shouldn't
know what the uuid is. It says register, and NMBluez5Manager should
figure out the details.
2017-06-01 11:28:57 +02:00
Lubomir Rintel
29a0876db6 bluetooth: emit component-added when a network server is added 2017-06-01 11:28:57 +02:00
Lubomir Rintel
d6f2a2e73c bluetooth: expose known HCI adapters to devices
They may register the Bluetooth NAP enabled bridges for Bluez to enslave their
BNEP links to.
2017-06-01 11:28:57 +02:00
Lubomir Rintel
53482c38e2 device: register a bridge for Bluetooth NAP with Bluez
Bluez needs to know about then so that it can eventually enslave the BNEP links
for PANU client connections to it.
2017-05-31 20:18:24 +02:00
Lubomir Rintel
b866a12667 device: retry autoactivation upon a component addition
It might have changed circumstances that were blocking the autoactivation.
2017-05-31 20:18:12 +02:00
Lubomir Rintel
805d3240f9 devices/factory: allow announcing a NULL component
We'll use this to let the devices know they can retry autoactivation
because some component became available without actually having any
data that would be useful for that device.

Adjust the comment.
2017-05-31 20:17:54 +02:00
Lubomir Rintel
15daf29220 bluez5: avoid leaking the interface dictionary 2017-05-31 20:11:46 +02:00
Lubomir Rintel
1bb751b9d1 bluez5: use _NMLOG 2017-05-31 20:11:15 +02:00
Lubomir Rintel
1a20611f66 bluetooth/trivial: rename the defines 2017-05-31 20:10:30 +02:00
Lubomir Rintel
43c43d5e3a bluetooth: streamline NMBluez5Manager teardown a bit 2017-05-31 20:05:53 +02:00
Lubomir Rintel
0d71c0569f ifcfg: drop an unused variable 2017-05-31 19:50:58 +02:00
Thomas Haller
b8707cba3c platform/tests: minor fix in _wait_for_ipv6_addr_non_tentative()
For better or worse, there is a platform argument. Use it instead
of the singleton.
2017-05-31 11:01:52 +02:00
Thomas Haller
d6aae6af72 platform/tests: reorder wait-loop in test_ip6_route_options()
- no need to call nm_platform_process_events() after
  nmtstp_wait_for_signal(). The latter processes all events
  that are pending.
- with addr_n number of addresses, we still only want to wait
  a maximum time, not for each addresss individually. Basically,
  the for-loop must be inside NMTST_WAIT(), not the other way around.
2017-05-31 10:46:43 +02:00
Thomas Haller
07751b444b platform/tests: make timeout_ms argument for nmtstp_wait_for_signal() signed
Having an unsigned "guint timeout_ms" argument is very inconvenient, because

    nmtstp_wait_for_signal (NM_PLATFORM_GET (), end_time - now_time);

might easily be negative. In such a case, the correct behavior
is to wait not at all.
2017-05-31 10:46:43 +02:00
Thomas Haller
af9c474844 platform/tests: change nmtstp_wait_for_signal() to wait with zero timeout
The previous behavior, of treating timeout_ms as *no timeout*, makes
no sense. At least not for unit tests. If you have a really long timeout,
then set it. "0" should really mean to schedule a zero timeout.
2017-05-31 10:46:43 +02:00
Francesco Giudici
21a941d40b platform/tests: fix test_ip6_route_options
when adding a route with RTA_PREFSRC some kernel versions will reject
the request if the specified source address is still tentative: be sure
that the just added addresses are no more tentative before adding the
routes.
2017-05-30 19:00:54 +02:00
Thomas Haller
84f2d226b5 ifcfg-rh: fix build failure in write_wired_setting()
Fixes: f80d0eb29e
2017-05-30 18:27:37 +02:00
Thomas Haller
f80d0eb29e ifcfg-rh: use svSetValueInt64_cond() to write MTU value 2017-05-30 16:37:28 +02:00
Thomas Haller
80c0a37b47 ifcfg-rh: add svSetValueInt64_cond()
There are a lot of places where we want to either write a number,
or conditionally clear it. Like:

    mtu = nm_setting_wireless_get_mtu (s_wireless);
    if (mtu)
        svSetValueInt64 (ifcfg, "MTU", mtu);
    else
        svUnsetValue (ifcfg, "MTU");
2017-05-30 16:35:13 +02:00
Thomas Haller
263c5b9207 ifcfg-rh: cleanup writer by using numbered_tag() helper 2017-05-30 13:40:34 +02:00
Thomas Haller
afc76d78ed ifcfg-rh: move numbered_tag() util to "nms-ifcfg-rh-utils.h" header 2017-05-30 13:40:34 +02:00
Thomas Haller
844bf3d1a2 ifcfg-rh: fix preserving NETMASK key in write_ip4_setting()
To support legacy scripts, we want to write out the NETMASK
key whenever the ifcfg file has a NETMASK key previously.
Note, that we anyway always write the relevant PREFIX key.
The NETMASK is redundant, only there to help legacy scripts.

That was broken, because we would svUnsetValue("NETMASK") before
checking whether the NETMASK key is present.

Also, when saving a connection to ifcfg-rh file that was created
by other tools, we might mix up the numbering. E.g. we never
write out IPADDR0. Hence, turn on legacy mode whenever the ifcfg-rh
file has any key starting with "NETMASK".
2017-05-30 13:39:15 +02:00
Thomas Haller
ba05819c89 ifcfg-rh/tests: add test for reading NETMASK property 2017-05-30 11:10:19 +02:00
Thomas Haller
e9d960740a ifcfg-rh: add svFindFirstKeyWithPrefix() function 2017-05-30 11:10:19 +02:00
Thomas Haller
bdd7d858f3 ifcfg-rh: return from svSetValue*() functions whether anything changed 2017-05-30 11:10:19 +02:00
Thomas Haller
efd462d946 ifcfg-rh: fix writing NETMASK in write_ip4_setting() 2017-05-30 11:10:19 +02:00
Thomas Haller
d512ed9f1f dnsmasq: fix generating shared IPv4 address range
Change behavior for the network-address and broadcast-address.
Users should not specify such addresses, but if they do, generate
something more sensible.

Also, if the address was in network larger then /24, the
generated address range was rather unexpected. Change behavior
here.

There are no particularly strong reasons for the chosen range.
It just seems suitable. The decision to hand out at most a /24
is because it is likely to be plenty, and because that is what
the previous code did -- at least, if the address was in the
first /24 of the subnet. See how the result for 192.168.0.1/20
is unchanged, but 192.168.1.1/20 changes.
2017-05-29 11:10:36 +02:00
Thomas Haller
e4ae34584b dnsmasq/tests: add more tests for test_address_ranges() 2017-05-29 11:10:36 +02:00
Thomas Haller
76492632b9 device: cleanup generating shared-IP in shared4_new_config()
Changes:

- merge reserve_shared_ip() into shared4_new_config().
  shared4_new_config() needs to register release_shared_ip(). However, it
  wrongly would always register release_shared_ip(), even for user-supplied
  addresses. To fix that, we would need yet another argument to
  reserve_shared_ip() and coupling it even more with shared4_new_config().
  At that point, it's cleaner to just merge the two functions.

- only create the shared_ips hash when needed, and delete it when
  it's empty. The idea is, that NetworkManager possibly runs for a long
  time, and most of the time no shared connection is active. Just clean
  up the empty hash while we don't need it.
2017-05-29 11:10:36 +02:00
Yuri Chornoivan
0050e8bd34 all: fix typos in documentation, translated strings and comments
https://bugzilla.gnome.org/show_bug.cgi?id=783173
2017-05-28 17:33:37 +02:00
Thomas Haller
d3c71ce4da platform/tests: use nm_platform_link_veth_add() to create veth pair in test 2017-05-27 23:16:56 +02:00
Thomas Haller
6ab2288c28 platform: add nm_platform_link_veth_add() to create VETH links 2017-05-27 23:16:56 +02:00
Thomas Haller
b14c07f70e device: remove unused private data for NMDeviceVeth 2017-05-27 23:16:56 +02:00
Thomas Haller
2c4d9f66ae platform/tests: recreate test environment for each route test
Use nmtstp_env1_add_test_func*() to setup and teardown a new
interface for each test.
2017-05-27 23:16:56 +02:00
Thomas Haller
a367361bc8 platform/tests: refactor test_ip6_route_options() to make it extendable
Have it suitable for multiple scenarios.
2017-05-27 23:16:56 +02:00
Thomas Haller
0f905a0b88 platform/tests: move test fixture "env1" from test-address.c to test-common.h
nmtstp_env1_add_test_func() allows to register test functions in a
particular test environment ("env1", for lack of a better name).

It will be reused for "test-route.c"
2017-05-27 23:16:56 +02:00
Thomas Haller
1b046039d1 device: minor cleanup replacing g_slist_for_each() by iteration
Iterating a list is so easy, it's easier to just do it by
hand, then splitting the functionality accross multiple lines.
2017-05-27 11:38:38 +02:00
Thomas Haller
d1b951a7e5 platform: remove plen argument for IPv6 address ID
The prefix length is not part of the ID for IPv6 address. Remove
it from nmp_object_stackinit_id_ip6_address().
2017-05-27 11:38:38 +02:00
Francesco Giudici
adbf383628 device: when setting back a device to managed, update internal sys state
Otherwise a device which was set as unmanaged (updated to the REMOVED
internal sys-state) will never update its own sys-state if later set
back as managed.
Manage either when setting explictly the device to managed either when
just upping a connection on an unmanaged device.
2017-05-26 15:47:25 +02:00
Francesco Giudici
55b8ba4ddc device: add the internal interface state to the state change log message 2017-05-26 15:47:18 +02:00
Beniamino Galvani
31656a066b core: add configuration flag to choose slaves activation order
Commits 39d0559d9a ("platform: sort links by name instead of
ifindex") and 529a0a1a7f ("manager: sort slaves to be autoconnected
by device name") changed the order of activation of slaves. Introduce
a system-wide configuration property to preserve the old behavior.

https://bugzilla.redhat.com/show_bug.cgi?id=1452585
2017-05-24 15:56:15 +02:00
Thomas Haller
44df6d7938 core: don't enable setrlimit(RLIMIT_CORE) when running with address sanitizer
With address sanitizer, the call to setrlimit() fails by default,
because the core dump would be huge. That could be overwritten via

  ASAN_OPTIONS=disable_core=0

But just don't try to enable core-dumps with asan.
2017-05-24 13:56:12 +02:00
Beniamino Galvani
3355a2823b device: release removed devices from master on cleanup
On cleanup, unconditionally release a device from its master if the
link is missing or it doesn't have a master, otherwise the master
would later try to release the slave, hitting the following assertion:

 "nm_platform_link_release: assertion 'slave > 0' failed"
  #0  g_logv
  #1  g_log
  #2  g_return_if_fail_warning
  #3  nm_platform_link_release
  #4  release_slave
  #5  nm_device_master_release_one_slave
  #6  slave_state_changed
  #7  ffi_call_unix64
  #8  ffi_call
  #9  g_cclosure_marshal_generic
  #10 g_closure_invoke
  #11 signal_emit_unlocked_R
  #12 g_signal_emit_valist
  #14 _set_state_full
  #15 nm_device_state_changed
  #16 nm_device_unrealize
  #17 _platform_link_cb_idle
  #18 g_main_context_dispatch
  #19 g_main_context_dispatch
  #20 g_main_context_iterate
  #21 g_main_loop_run
  #22 main

Fixes: 9e8218f99a

https://bugzilla.redhat.com/show_bug.cgi?id=1448907
2017-05-24 13:39:27 +02:00
Lubomir Rintel
0aa2e0bad3 bluetooth: unhook adapter properties callback when the adapter vanishes
https://bugzilla.redhat.com/show_bug.cgi?id=1454654
2017-05-23 11:33:15 +02:00