Commit graph

11140 commits

Author SHA1 Message Date
Beniamino Galvani
f744e29dd3 device: fix crash in nm_device_generate_connection()
Fixes: 89d1c9fb30

https://bugzilla.redhat.com/show_bug.cgi?id=1631741
2018-09-27 18:08:46 +02:00
Thomas Haller
7729555a59 acd: make NMAcdManager no GObject
NMAcdManager is a rather simple instance.

It does not need (thread-safe) ref-counting, in fact, having
it ref-counted makes it slighly ugly that we connect a signal,
but never bother to disconnect it (while the ref-counted instance
could outlife the signal subscriber).

We also don't need GObject signals. They have more overhead
and are less type-safe than a regular function pointers. Signals
would make sense, if there could be multiple independent listeners,
but that just doesn't make sense.

Implementing it as a plain struct is less lines of code, and less
runtime over head.

Also drop the possiblitiy to reset the NMAcdManager instance.
It wasn't needed and I think it was buggy because it wouldn't
reset the n-acd instance.

https://github.com/NetworkManager/NetworkManager/pull/213
2018-09-27 17:36:42 +02:00
Beniamino Galvani
6b5790a05e device: set token only after router discovery was started
Kernel complains with:

  platform-linux: link: change 10: token: set IPv6 address generation token to ::bbbb
  platform-linux: do-change-link[10]: failure changing link: failure 22 (Invalid argument)

if we try to set an IPv6 token in ip_config_merge_and_apply() and we
haven't set accept_ra=1 yet. Since the flag is set when starting
router discovery, ensure that we don't try to set a token before that.

https://github.com/NetworkManager/NetworkManager/pull/214
https://bugzilla.redhat.com/show_bug.cgi?id=1560652
2018-09-27 17:21:29 +02:00
Beniamino Galvani
1e43ae9e77 supplicant: fix memory leak
Fixes: 17da42704a
2018-09-27 15:24:28 +02:00
Beniamino Galvani
5d97e76c7d wifi: support hidden ssid in AP mode
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/48
2018-09-27 13:35:53 +02:00
Beniamino Galvani
0ba0f52cb7 dhcp: dhclient: fix memory leak
Fixes: c263f5355c
2018-09-27 09:23:54 +02:00
Thomas Haller
a4de56a3d1 dns: fix sort order of DNS configurations by type
Fixes: d7017005e1
2018-09-27 08:01:35 +02:00
Andrew Zaborowski
bfacd24f83 wifi/iwd: handle IWD Station interface disappearing
The net.connman.iwd.Station interface, unlike the Device interface, can
go away and come back when the device changes modes or goes DOWN and UP.
The GDbusProxy for the interface becomes invalid after the interface
disappeared and reappeared.  This would make the IWD backend stop
working after rfkill was used or after suspend/resume (provided the
suspend/resume events are detected, without them everything works and is
really fast too).

Redo the handling of the Powered property changes, corresponding to
device UP state, to get a new GDBusProxy when the Station interface
reappears.  Simplify some checks knowing that priv->can_scan implies for
example that the Station interface is present, and that priv->enabled
implies the NM device state is >= DISCONNECTED.

https://github.com/NetworkManager/NetworkManager/pull/211
2018-09-26 13:47:03 +02:00
Thomas Haller
365079c09e wifi: log warning when active scanning for hidden networks
When there are profiles with wifi.hidden=yes, NetworkManager
will actively scan for these SSIDs. This makes the scan request
(and thus the user) recognizable and trackable.

It seems generally a bad idea to use hidden networks, as they
compromise either the privacy or usablity for the clients.

Log a (rate-limited) warning about this.
2018-09-26 12:50:35 +02:00
Beniamino Galvani
f069c98cc9 device: don't remove routes when the interface is down
In update update_ext_ip_config() we remove from various internal
configurations those addresses and routes that were removed externally
by users.

When the interface is brought down, the kernel automatically removes
routes associated with it and so we should not consider them as
"removed by users".

Instead, keep them so that they can be restored when the interface
comes up again.
2018-09-26 11:49:37 +02:00
Beniamino Galvani
8f07b3ac4f ip-config: add @intersect_routes argument to intersect functions
In some cases we want to intersect two IP configurations without
considering routes.
2018-09-26 11:49:37 +02:00
Beniamino Galvani
46ed756112 device: fix updating device information after link change
device_link_changed() can't use nm_device_update_from_platform_link()
to update the device private fields because the latter overwrites
priv->iface and priv->up, and so the checks below as:

  if (info.name[0] && strcmp (priv->iface, info.name) != 0) {

and:

  was_up = priv->up;
  priv->up = NM_FLAGS_HAS (info.n_ifi_flags, IFF_UP);
  ...
  if (priv->up && !was_up) {

never succeed.

Fixes: d7f7725ae8
2018-09-26 11:49:37 +02:00
Beniamino Galvani
3b49d1075d core: improve nm_ip_config_dump()
Previously we had nm_ip{4,6}_config_dump() for debugging purposes, but
they were inconveniently printing to stdout and so the output was not
ordered in the journal.

Implement a unified nm_ip_config_dump() that logs through the usual
logging mechanism.
2018-09-26 11:49:37 +02:00
Thomas Haller
d7017005e1 dns: use NM_CMP_*() macros sorting IP config in DNS manager 2018-09-26 11:24:09 +02:00
Thomas Haller
ad10e79ae4 dns: drop redundant call to clear_domain_lists() in update_dns()
It does nothing.
2018-09-26 09:55:50 +02:00
Lubomir Rintel
60007d7cbd connectivity: fix a wrong comparision
Thanks clang 7.

Fixes: cbfe6aa973
2018-09-24 15:57:43 +02:00
Lubomir Rintel
cbfe6aa973 connectivity: create a multi-handle for all requests
This is dead ugly and works around what probably is a libcurl (7.59) bug:
It shares the resolver cache among easy handles in a multi handle when
it shouldn't:

When we create two easy handles, one for IPv4 and one for IPv6 in a
single mhandle:

  curl_easy_setopt (ehandle6, CURLOPT_RESOLVE,
    "fedoraproject.org:2605:bc80:3010:600:dead:beef:cafe:feda"
    "fedoraproject.org:2604:1580:fe00:0:dead:beef:cafe:fed1")
  curl_easy_setopt (ehandle4, CURLOPT_RESOLVE,
    "fedoraproject.org:8.43.85.67"
    "fedoraproject.org:152.19.134.198")
  curl_multi_add_handle (mhandle, ehandle6);
  curl_multi_add_handle (mhandle, ehandle4);

Both end up connecting to the same (either v4 or v6) address. None of
CURLOPT_FORBID_REUSE(3), CURLOPT_FRESH_CONNECT(3),
CURLOPT_DNS_USE_GLOBAL_CACHE(3) and CURLOPT_DNS_CACHE_TIMEOUT(3) make
any difference. Nor does CURLOPT_DNS_LOCAL_IP[46].
2018-09-24 15:38:16 +02:00
Lubomir Rintel
d8971fcbcd device: expose connectivity check result on a device
Separate properties for IPv4 and IPv6.
2018-09-24 15:36:19 +02:00
Lubomir Rintel
9664f284a1 connectivity: allow limiting the connectivity check to a specified AF
Nothing changes practically, as the NMDevice still starts this with
AF_UNSPEC. That is going to change in the following commit.

The ugly part:

priv->concheck_x[0] in few places. I believe we shouldn't be using union
aliasing here, and instead of indexing the v4/v6 arrays by a boolean it
should be an enum. I'm not fixing it here, but I eventually plan to if
this gets an ACK.
2018-09-24 15:17:02 +02:00
Lubomir Rintel
2cec94bacc connectivity: use systemd-resolved for resolving the check endpoint
This allows us to use the correct DNS server for the particular interface
independent of what the system resolver is configured to use.

The ugly part:

Unfortunately, it is not all that easy. The libc's libresolv.so API does
not provide means for influencing neither interface nor name servers used
for DNS resolving.

Curl can also be compiled with c-ares resolver backend that does provide
the necessary functionality, but it requires and extra library and the
Linux distributions don't seem to enable it. (Fedora doesn't, which is a
good sign we don't have an option of relying on it.)

systemd-resolved does provide everything we need. If we take care to
keep its congfiguration up to date, we can use it to do the resolving on
a particular interface with that interface's DNS configuration. Great!

There's one more problem: Curl doesn't provide callbacks for resolving
host names.  It doesn't, however, allow us to pass in the pre-resolved
hostnames in form of an CURLOPT_RESOLVE(3) option. This means we have to
parse the host name out of the URL ourselves. Fair enough I guess...
2018-09-24 15:17:02 +02:00
Lubomir Rintel
753ffdbca8 connectivity: improve curl error messages 2018-09-24 15:17:02 +02:00
Lubomir Rintel
d4eb4cb45f dns: allow loading nm-dns-systemd-resolve alongside other DNS plugins
Even when the system resolver is configured to something else that
systemd-resolved, it still is a good idea to keep systemd-resolved up to
date. If not anything else, it does a good job at doing per-interface
resolving for connectivity checks.

If for whatever reasons don't want NetworkManager to push the DNS data
it discovers to systemd-resolved, the functionality can be disabled
with:

  [main]
  systemd-resolved=false
2018-09-24 15:17:02 +02:00
Lubomir Rintel
ecde3e9034 initrd/cmdline-reader: fix whitespace errors
Detected by checkpatch.pl
2018-09-24 13:21:12 +02:00
Thomas Haller
511709c54d dns: fix creating resolv.conf content
g_string_new_len() allocates the buffer with length
bytes. Maybe it should be obvious (wasn't to me), but
if a init argument is given, that is taken as containing
length bytes.

So,

    str = g_string_new_len (init, len);

is more like

    str = g_string_new_len (NULL, len);
    g_string_append_len (str, init, len);

and not (how I wrongly thought)

    str = g_string_new_len (NULL, len);
    g_string_append (str, init);

Fixes: 95b006c244
2018-09-21 13:12:05 +02:00
Thomas Haller
cddb91324c dns: always write "/var/run/NetworkManager/resolv.conf"
Previously, if "main.rc-manager" was set to "unmanaged"
and "/etc/resolv.conf" was symlink to our internal file
"/var/run/NetworkManager/resolv.conf", NM would not rewrite
the file, in an attempt to honor the requirement of NetworkManager
not changing resolv.conf.

No longer special case this. I think it was wrong and inconsistent.
If the user specifies rc-manager unmanaged, he also should manage
/etc/resolv.conf accordingly. And if the user decided to symlink
it to our internal file, that is fine. It should not stop NM from
updating that file.

Also, this was the only cases, where NM would not write our internal
resolv.conf (errors aside). It was inconsitent, and also not documented
behavior. Instead, it is documented that `man NetworkManager.conf`:

  Regardless of this setting, NetworkManager will always write
  resolv.conf to its runtime state directory
  /var/run/NetworkManager/resolv.conf.
2018-09-21 11:12:47 +02:00
Thomas Haller
0dc673f0a5 dns: write original DNS servers to /var/run/NetworkManager/no-stub-resolv.conf
When a DNS plugin is enabled (like "main.dns=dnsmasq" or "main.dns=systemd-resolved"),
the name servers announced to the rc-manager are coerced to be 127.0.0.1
or 127.0.0.53.

Depending on the "main.rc-manager" setting, also "/etc/resolv.conf"
contains only this coerced name server to the local caching service.
The same is true for "/var/run/NetworkManager/resolv.conf" file, which
contains what we would write to "/etc/resolv.conf" (depending on
the "main.rc-manager" configuration).

Write a new file "/var/run/NetworkManager/no-stub-resolv.conf", which contains
the original name servers, uncoerced. Like "/var/run/NetworkManager/resolv.conf",
this file is always written.

The effect is, when one enables "main.dns=systemd-resolved", then there
is still a file "no-stub-resolv.conf" with the same content as with
"main.dns=default".

The no-stub-resolv.conf may be a possible solution, when a user wants
NetworkManager to update systemd-resolved, but still have a regular
/etc/resolv.conf [1]. For that, the user could configure

    [main]
    dns=systemd-resolved
    rc-manager=unmanaged

and symlink "/etc/resolv.conf" to "/var/run/NetworkManager/no-stub-resolv.conf".
This is not necessarily the only solution for the problem and does not preclude
options for updating systemd-resolved in combination with other DNS plugins.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/20
2018-09-21 11:12:47 +02:00
Thomas Haller
95b006c244 dns: refactor create_resolv_conf() to use GString for constructing content 2018-09-21 10:39:30 +02:00
Frederic Danis
7d155757b1 core: fix route metric set to -1 on DHCP renewal
The first DHCP renew after setting back Ethernet metric to default (-1)
applies a metric of 4294967295 (uint16 -1) instead of the default metric.

The route becomes:
  Kernel IP routing table
  Destination     Gateway         Genmask         Flags Metric Ref Use Iface
  0.0.0.0         0.0.0.0         0.0.0.0         U     700    0     0 ppp0
  0.0.0.0         192.168.19.193  0.0.0.0         UG    -1     0     0 eth0
  10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0     0 ppp0
  10.64.64.64     0.0.0.0         255.255.255.255 UH    700    0     0 ppp0
  10.250.0.0      0.0.0.0         255.255.0.0     U     50     0     0 tun0
  192.168.19.0    0.0.0.0         255.255.255.0   U     100    0     0 eth0
  192.168.19.193  0.0.0.0         255.255.255.255 UH    100    0     0 eth0
  217.114.201.194 192.168.19.193  255.255.255.255 UGH   100    0     0 eth0

Route update traces:
  Sep 20 09:53:11.869027 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): REQUEST (renewing)
  Sep 20 09:53:11.873766 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): ACK
  Sep 20 09:53:11.873792 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): lease expires in 1min 58s
  Sep 20 09:53:11.873800 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): T2 expires in 1min 35s
  Sep 20 09:53:11.873808 tap-0FB1 NetworkManager[762]: <debug> libsystemd: DHCP CLIENT (0xfd5eaeb9): T1 expires in 50s
  Sep 20 09:53:11.873845 tap-0FB1 NetworkManager[762]: <debug> dhcp4 (eth0): client event 4
  Sep 20 09:53:11.873853 tap-0FB1 NetworkManager[762]: <debug> dhcp4 (eth0): lease available
  Sep 20 09:53:11.873881 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   address 192.168.19.100
  Sep 20 09:53:11.873890 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   plen 24
  Sep 20 09:53:11.873899 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   expires in 120 seconds
  Sep 20 09:53:11.873916 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   nameserver '192.168.19.193'
  Sep 20 09:53:11.873925 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   hostname 'TAPOFB1'
  Sep 20 09:53:11.873932 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0):   gateway 192.168.19.193
  Sep 20 09:53:11.874064 tap-0FB1 NetworkManager[762]: <info>  dhcp4 (eth0): state changed bound -> bound
  Sep 20 09:53:11.874082 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): new DHCPv4 client state 1
  Sep 20 09:53:11.874535 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): ip4-config: update (commit=1, new-config=0x558dc6110be0)
  Sep 20 09:53:11.874569 tap-0FB1 NetworkManager[762]: <debug> platform: address: adding or updating IPv4 address: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-0[120,120] dev 2 flags noprefixroute src unkn
  Sep 20 09:53:11.874626 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_NEWADDR, flags 0, seq 141: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-237[120,120] dev 2 flags noprl
  Sep 20 09:53:11.874653 tap-0FB1 NetworkManager[762]: <debug> platform: signal: address 4 changed: 192.168.19.100/24 lft 120sec pref 120sec lifetime 237-237[120,120] dev 2 flags noprefixroute src kernel
  Sep 20 09:53:11.874671 tap-0FB1 NetworkManager[762]: <debug> device[0x558dc60b3140] (eth0): queued IP4 config change
  Sep 20 09:53:11.874699 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-add-ip4-address[2: 192.168.19.100/24]: success
  Sep 20 09:53:11.874723 tap-0FB1 NetworkManager[762]: <debug> platform: route: append     IPv4 route: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src dhcp
  Sep 20 09:53:11.874778 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_NEWROUTE, flags excl,create, seq 142: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcl
  Sep 20 09:53:11.874809 tap-0FB1 NetworkManager[762]: <debug> platform: signal: route   4   added: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874846 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-add-ip4-route[0.0.0.0/0 via 192.168.19.193 dev 2 metric 4294967295 mss 0 rt-src rt-dhcp scope global]: success
  Sep 20 09:53:11.874867 tap-0FB1 NetworkManager[762]: <debug> platform: ip4-route: delete 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874904 tap-0FB1 NetworkManager[762]: <trace> platform-linux: event-notification: RTM_DELROUTE, flags 0, seq 143: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874930 tap-0FB1 NetworkManager[762]: <debug> platform: signal: route   4 removed: 0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global
  Sep 20 09:53:11.874961 tap-0FB1 NetworkManager[762]: <debug> platform-linux: do-delete-ip4-route[0.0.0.0/0 via 192.168.19.193 dev 2 metric 100 mss 0 rt-src rt-dhcp scope global]: success
  Sep 20 09:53:11.874983 tap-0FB1 NetworkManager[762]: <trace> platform: ip4-dev-route: register 192.168.19.0/24 via 0.0.0.0 dev 2 metric 0 mss 0 rt-src rt-kernel scope link pref-src 192.168.19.100 (update)

https://mail.gnome.org/archives/networkmanager-list/2018-September/msg00020.html

Fixes: b9e6433a02
2018-09-21 08:34:42 +02:00
Thomas Haller
29c95cd98a acd: fix crash in acd-event loop
Don't emit signals while popping acd events. Otherwise, we can get
a crash:

    #0  0x000055c2bb094e3b in n_acd_pop_event (acd=0x0, eventp=eventp@entry=0x7ffd47de65b0) at shared/n-acd/src/n-acd.c:846
            node = <optimized out>
            t_node = <optimized out>
    #1  0x000055c2baff53be in acd_event (source=<optimized out>, condition=<optimized out>, data=0x55c2bc4a6cf0) at src/devices/nm-acd-manager.c:180
            self = 0x55c2bc4a6cf0
            priv = 0x55c2bc4a6d08
            __func__ = "acd_event"
            event = 0x55c2bc593af0
            info = 0x55c2bc4b76c0
            address_str = "\000\000\000\000\000\000\000\000\bd\373\272\302U\000"
            hwaddr_str = 0x0
            r = <optimized out>
    #2  0x00007eff336238f9 in g_main_context_dispatch (context=0x55c2bc41f480) at gmain.c:3146
            dispatch = 0x7eff336688a0 <g_io_unix_dispatch>
            prev_source = 0x0
            was_in_call = 0
            user_data = 0x55c2bc4a6cf0
            callback = 0x55c2baff5310 <acd_event>
            cb_funcs = 0x7eff338eb920 <g_source_callback_funcs>
            cb_data = 0x55c2bc558680
            need_destroy = <optimized out>
            source = 0x55c2bc58c160
            current = 0x55c2bc43dd10
            i = 0
    ...

While at it, don't return from the events N_ACD_EVENT_DEFENDED,
N_ACD_EVENT_CONFLICT, and <default>, but continue popping events.

Fixes: d9a4b59c18
2018-09-20 09:48:26 +02:00
Thomas Haller
793afb7d95 core: improve logging why startup-complete is blocked
Before:

    "manager: check_if_startup_complete returns FALSE because of eth0"

Now:

    "manager: startup complete is waiting for device 'eth0' (autoactivate)"

Also, the logging line is now more a human readable sentence, but still
follows the same pattern as later

    "manager: startup complete"

Meaning: grepping for "startup complete" becomes more helpful because
one first finds the reasons why startup-complete is not yet reached,
followed by the moment when it is reached.
2018-09-19 17:51:01 +02:00
Beniamino Galvani
470c5c0a82 initrd: enable meson builds 2018-09-19 16:03:32 +02:00
Beniamino Galvani
19a718bc13 build: meson: fix computing NM exported symbols
The script didn't include all the symbols needed by plugins because
libNetworkManager.a, as built by meson, doesn't include symbols from
other static libraries that are linked in. Since we used
libNetworkManager.a to know which symbols are potentiall available
from NM, the result was an incomplete list.

Unfortunately, the only way to include the whole static library is to
create a dependency object and use 'link_whole', but this is only
available in meson >= 0.46. Since 'link_whole' is available for
executables in meson >= 0.40, create a fake executable and use that to
enumerate symbols.

Also add tests to check that plugins can be loaded correctly.

Fixes: dfa2a2b40c
2018-09-19 16:03:32 +02:00
Lubomir Rintel
b64ae759ad settings/ifupdown/tests: avoid asserting on an array
char[] is not a char *; it can not go NULL.

  test-ifupdown.c:147:27: error: address of array 'n->name' will always evaluate
                                 to 'true' [-Werror,-Wpointer-bool-conversion]
                g_assert (b->name && n->name);
  test-ifupdown.c:156:27: error: address of array 'm->key' will always evaluate
                                 to 'true' [-Werror,-Wpointer-bool-conversion]
                        g_assert (k->key && m->key);
2018-09-19 14:28:08 +02:00
Lubomir Rintel
36f0825626 devices/acd-manager: avoid uninitialzied variable use
src/devices/nm-acd-manager.c:419:31: error: variable 'info' is uninitialized
                                       when used here [-Werror,-Wuninitialized]
                       nm_utils_inet4_ntop (info->address, NULL),
2018-09-19 14:28:08 +02:00
Andrew Zaborowski
061913c588 wifi/iwd: don't change state in secrets callback
Also make sure the secrets request callback only send a reply to IWD and
the Connect method return callback executes the device state change to
"disconnected".
2018-09-19 08:37:52 +02:00
Andrew Zaborowski
44af62eb1f wifi/iwd: actually wait for Connect() call return
state_changed (called when IWD signalled device state change) was
supposed to not change NM device state on connect success or failure and
instead wait for the DBus Connect() method callback but it would
actually still call nm_device_emit_recheck_auto_activate on failure so
refactor state_changed and network_connect_cb to make sure
the state change and nm_device_emit_recheck_auto_activate are only
called from network_connect_cb.

This fixes a race where during a switch from one network to another NM
would immediately start a new activation after state_changed and
network_connect_cb would then handle the Connect failure and mark the
new activation as failed.
2018-09-19 08:37:52 +02:00
Andrew Zaborowski
e3aba12d14 wifi/iwd: don't save secrets in mirror NM connections
When creating the mirror 802.1x connections for IWD 802.1x profiles
set the NM_SETTING_SECRET_FLAG_NOT_SAVED flag on the secrets that
may at some point be requested from our agent.  The saved secrets could
not be used anyway because of our use of
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW in
nm_device_iwd_agent_query.  But also try to respect whatever secret
caching policy has been configured in the IWD profile for those secrets,
IWD would be responsible for storing them if it was allowed in the
profile.
2018-09-19 08:37:52 +02:00
Andrew Zaborowski
fd1cfa6db4 wifi/iwd: access Network objects through ObjectManager
In two places stop using g_dbus_proxy_new_* to create whole new
interface proxy objects for net.connman.iwd.Network as this will
normally have a huge overhead compared to asking the ObjectManager
client that we already have in NMIwdManager for those proxies.
dbus-monitor shows that for each network path returned by
GetOrderedNetworks () -- and we call it every 10 or 20 seconds and may
get many dozens of networks back -- gdbus would do the following each
time:
org.freedesktop.DBus.AddMatch("member=PropertiesChanged")
org.freedesktop.DBus.StartServiceByName("net.connman.iwd")
org.freedesktop.DBus.GetNameOwner("net.connman.iwd")
org.freedesktop.DBus.Properties.GetAll("net.connman.iwd.Network")
org.freedesktop.DBus.RemoveMatch("member=PropertiesChanged")
2018-09-19 08:37:52 +02:00
Lubomir Rintel
a82e9083c1 manager: initialize a potentially uninitialized variable 2018-09-18 18:14:27 +02:00
Lubomir Rintel
e4a5f0b900 initrd: adjust to the newer nm_utils_parse_inaddr_*bin() API 2018-09-18 18:14:09 +02:00
Lubomir Rintel
7c270f0860 initrd-generator: add a missing include 2018-09-18 18:12:34 +02:00
Lubomir Rintel
9f9609555d initrd: add configuration generator
nm-initrd-generator scans the command line for options relevant to network
configuration and creates configuration files for an early instance of
NetworkManager run from the initial ramdisk during early boot.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
ecc074b2f8 initrd: add command line parser 2018-09-18 17:40:47 +02:00
Lubomir Rintel
b544f7243d initrd: add iBFT reader
This is loosely based on nms-ibft-reader, but with some significant
changes. Notably, it parses /sys/firmware/ibft directly instead of
iscsiadm output.

iscsiadm is not available on early boot (perhaps it's too large) and
turns out that parsing sysfs directly is easier and more
straightforwared anyways. A win-win situation.

It is not useful alone, it's in a separate commit just for the sake of
easier review.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
c263f5355c config: add --configure-and-quit=initrd mode
We need a mode that:

* doesn't leave processes behind
* doesn't force an internal dhclient
* doesn't auto-generate default connections
* doesn't write out files into libdir, only /run

The original configure-and-quit mode doesn't really fit the initrd use. But
it's proobably not a good idea to just change its behavior.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
e03d9ad1e0 dbus: don't even bother connecting in configure-and-quit mode
It makes no sense, results in unnecessary complexity both in code and in
code comments.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
ce4dbd7daf keyfile: write in-memory connections to /run
This is useful for in-memory connections to persist NetworkManager
restarts (as opposed to machine restarts).

Perhaps most improtantly, this allows generating in-memory connections outside
NetworkManager, e.g. passing configuration from early boot firmware in initrd.

Note that this does *not* aspire to do more than it says on the tin:
Notably, it doesn't touch the problem of provisioning connections in multiple
persistent connection directories and thus doesn't have to deal with the
problem of deleting or overlaying the connections tha (rh #772414) deals
with.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
e98ebc7e3b manager: don't save deactivating connections in the state file
Especially with configure-and-quit, it's easy to encounter a condition,
where the device reached a failed state, policy decides to quit, but the
active connection is not yet torn down from the device.

Upon the next start NetworkManager would think the connection succeeded
activating.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
e1fc005239 dns: don't let the plugins assert the bus manager has a connection
Make them just ask for connections from GDBus, as other D-Bus clients
do. GDBus anyway reuses the connection if it has one, but allows us to
deal with errors in a more civilized manner.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
89d1c9fb30 devices: make sure the generated connections are normalized
Using these unormalized was wrong all along, but by chance didn't hit
paths that needed normalized connections. This may change if we
actually write in memory connections to /run with the keyfile plugin,
because that one wants them normalized.

This also saves some work, because normalization does boring things for
us, such as adding default ipv4/ipv6/proxy settings everywhere.
2018-09-18 17:40:47 +02:00