Commit graph

12098 commits

Author SHA1 Message Date
Thomas Haller
15b1304477 policy-routing: take ownership of externally configured rules
IP addresses, routes, TC and QDiscs are all tied to a certain interface.
So when NetworkManager manages an interface, it can be confident that
all related entires should be managed, deleted and modified by NetworkManager.

Routing policy rules are global. For that we have NMPRulesManager which
keeps track of whether NetworkManager owns a rule. This allows multiple
connection profiles to specify the same rule, and NMPRulesManager can
consolidate this information to know whether to add or remove the rule.

NMPRulesManager would also support to explicitly block a rule by
tracking it with negative priority. However that is still unused at
the moment. All that devices do is to add rules (track with positive
priority) and remove them (untrack) once the profile gets deactivated.

As rules are not exclusively owned by NetworkManager, NetworkManager
tries not to interfere with rules that it knows nothing about. That
means in particular, when NetworkManager starts it will "weakly track"
all rules that are present. "weakly track" is mostly interesting for two
cases:

  - when NMPRulesManager had the same rule explicitly tracked (added) by a
    device, then deactivating the device will leave the rule in place.

  - when NMPRulesManager had the same rule explicitly blocked (tracked
    with negative priority), then it would restore the rule when that
    block gets removed (as said, currently nobody actually does this).

Note that when restarting NetworkManager, then the device may stay and
the rules kept. However after restart, NetworkManager no longer knows
that it previously added this route, so it would weakly track it and
never remove them again.

That is a problem. Avoid that, by whenever explicitly tracking a rule we
also make sure to no longer weakly track it. Most likely this rule was
indeed previously managed by NetworkManager. If this was really a rule
added by externally, then the user really should choose distinct
rule priorities to avoid such conflicts altogether.
2019-07-16 10:16:07 +02:00
Thomas Haller
6ea56bc04c libnm,core: add support for "suppress_prefixlength" rule attribute
WireGuard's wq-quick configures such rules to avoid routing loops.
While we currently don't have an automatic solution for this, at least
we should support it via explicit user configuration.

One problem is that suppress_prefixlength is relatively new and kernel
might not support this attribute. That can lead to odd results, because
the NetworkManager is valid but it cannot be configured on the current
kernel. But this is a general problem, and we would require a general
solution. The solution cannot be to only support rule attributes that
are supported by the oldest possible kernel. It's not clear how much of
a problem there really is, or which general solution is required (if
any).
2019-07-16 10:03:17 +02:00
Thomas Haller
9ae8a79457 dhcp-listener: keep reference to NMDBusManager singleton
When subscribing a signal to a singleton, we should ensure that the
source object stays alive. Take a reference.

This is also right in this case, because NMDBusManager (and its dependencies)
should never use NMDhcpListener. So, there is a clear direction of who references
who.
2019-07-15 12:45:38 +02:00
Lubomir Rintel
eb7c47b3fc ovs/interface: actually allow dpdk type interfaces
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/203
2019-07-15 11:30:20 +02:00
Lubomir Rintel
12d9c3eb18 ovs/ovsdb: correctly set the dpdk-devargs option
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/203
2019-07-15 11:30:12 +02:00
Thomas Haller
b1297b8b8a libnm,cli,ifcfg-rh: add connection:wait-device-timeout property
Initscripts already honor the DEVTIMEOUT variable (rh #1171917).

Don't make this a property only supported by initscripts. Every
useful property should also be supported by keyfile and it should
be accessible via D-Bus.

Also, I will soon drop NMSIfcfgConnection, so handling this would
require extra code. It's easier when DEVTIMEOUT is a regular property of
the connection profile.

The property is not yet implemented. ifcfg-rh still uses the old
implementation, and keyfile is not yet adjusted. Since both keyfile
and ifcfg-rh will both be rewritten soon, this property will be
implemented then.
2019-07-10 12:43:06 +02:00
Thomas Haller
dd5acc0370 core: use nm_c_list_elem_free_steal() in _delete_volatile_connection_all () 2019-07-10 12:43:06 +02:00
Thomas Haller
a8fa015a4e core: fix mangling static IPv6 routes in nm_ip6_config_merge_setting()
https://bugzilla.redhat.com/show_bug.cgi?id=1727193

Fixes: 433d2f8659 ('core: merge IPv4 and IPv6 version of _nm_ip_config_merge_route_attributes()')
2019-07-09 14:33:57 +02:00
Thomas Haller
6a62314968 platform/tests: relax check for accepting platform signals
nmtst: initialize nmtst_get_rand() with NMTST_SEED_RAND=0
    /link/bogus: OK
    /link/loopback: OK
    /link/internal: OK
    /link/external: OK
    /link/software/bridge: OK
    /link/software/bond: OK
    /link/software/team: NMPlatformSignalAssert: ../src/platform/tests/test-link.c:331, test_slave(): failure to accept signal [0,2] times: 'link-changed-changed' ifindex 15 (3 times received)
    --- stderr ---
    /builds/NetworkManager/NetworkManager/tools/run-nm-test.sh: line 264: 106682 Trace/breakpoint trap      --quiet --error-exitcode= --leak-check=full --gen-suppressions=all  --num-callers=100 --log-file=
    The test failed. Also check the valgrind log at '/builds/NetworkManager/NetworkManager/build/src/platform/tests/test-link-linux.valgrind-log'
2019-07-09 10:59:57 +02:00
Lubomir Rintel
c610667286 settings: fix a reversed conditional in have_connection_for_device()
https://bugzilla.redhat.com/show_bug.cgi?id=1727411

Fixes: be0018382d ('settings: in have_connection_for_device() first skip over irrelevant connection types')
2019-07-08 18:07:01 +02:00
Beniamino Galvani
ba7b427aec manager: propagate the for-user-request flag for slaves autoconnection
If the master is activated by user, propagate the for-user-request to
slaves activations when autoconnecting slaves, so that they can manage
slaves device as needed.

Reproducer:

 ip l add eth1 type veth peer name eth2
 ip l set eth1 up
 ip l set eth2 up
 sleep 2

 echo " * Initial state"
 echo " - eth1: $(nmcli -g general.state device show eth1)"

 nmcli con add type ethernet ifname eth1 con-name slave-test+ master br-test slave-type bridge
 nmcli con add type bridge ifname br-test con-name br-test+ connection.autoconnect-slaves yes ip4 172.25.1.1/24

 nmcli con up br-test+

 echo " * After user activation"
 echo " - br-test: $(nmcli -g general.state device show br-test)"
 echo " - eth1: $(nmcli -g general.state device show eth1)"

should give:

 * Initial state
 - eth1: 10 (unmanaged)
 * After user activation
 - br-test: 100 (connected)
 - eth1: 100 (connected)
2019-07-08 13:51:30 +02:00
Beniamino Galvani
c7fd4aeecf device: properly honor flags when checking connection availability
The previous code returned that the device was available when it had
only unmanaged-flags that can be overridden by user, without actually
considering the @flags argument.

Fixes: 920346a5b9 ('device: add and use overrule-unmanaged flag for nm_device_check_connection_available()')
2019-07-08 13:51:30 +02:00
Francesco Giudici
f9314526d0 dhcp/dhclient: expose the private_xyz labels for dhcp private options
alias the default "unknown_xyz" labels when found.
2019-07-05 15:15:11 +02:00
Francesco Giudici
eed205bff3 dhcp/internal: move dhcp options management to shared dhcp codebase 2019-07-05 15:13:09 +02:00
Francesco Giudici
f42754c8d7 dhcp/internal: expose on D-Bus all the private dhcp options
when dhclient is used as the dhcp client in NetworkManager we expose on
D-Bus all the variables that are passed to our script file. In
particular, we use the variable names there as labels (stripping the
heading "new") taking whatever dhclient passes us.
There are few exception to this. Dhclient allows to redefine option
variable names and we use this functionality for a few dhcp options:
dhcp option code 121 --> "rfc3442_classless_static_routes"
dhcp option code 249 --> "ms_classless_static_routes"
dhcp option code 252 --> "wpad"

Note that for private dhcp options (224-254) default dhclient labels are
in the form "unknown_$OPTNUM".
2019-07-05 15:08:31 +02:00
Francesco Giudici
a6036b2352 dhcp: access internal systemd structure to retrieve dhcp private options 2019-07-05 14:12:21 +02:00
Francesco Giudici
5008a25f62 dhcp/internal: expose on D-Bus some more dhcp options
When using the internal dhcp client we skip exporting on D-Bus many of
the dhcp options received from the dhcp server. We instead export almost
all of them when using the dhclient dhcp client, using the variable
names passed by dhclient itself.
Map more DHCP options to dhclient variable names in order to allow the
internal client to retrieve them easily, namely: the server identifier,
the broadcast address, the renewal time, the rebinding time and the timezone.
Note that not all the DHCP options can be exported at this time because
systemd-networkd code drops many it won't process, so we have no way to
retrieve them without changing core systemd-networkd code.
2019-07-05 14:12:21 +02:00
Francesco Giudici
3775f31cb9 dhcp/internal: expose on D-Bus the lease time dhcp option
It was already exposed implicity as the expiration time: add also the
explicit option using same format of dhclient dhcp plugin.
In the meanwhile, drop the SD_DHCP_OPTION_CLIENT_IDENTIFIER as not used.
2019-07-05 14:12:21 +02:00
Francesco Giudici
97ce488f5f dhcp/internal: decrease logging level when retrieving dhcp options
Use DEBUG logging level for the parsing result of lease file.
Moreover, use consistent labels for the dhcp options: same labels of
what is exposed on D-Bus.
2019-07-05 14:12:21 +02:00
Beniamino Galvani
40babe1c44 dhcp: pass broadcast address to clients
Read the broadcast address from platform and pass it to
clients. Currently only the nettool backends uses it.
2019-07-05 11:06:01 +02:00
Beniamino Galvani
1609f50866 core: drop nm_platform_link_get_address_as_bytes()
Drop nm_platform_link_get_address_as_bytes() and introduce
nmp_link_address_get_as_bytes() so that it becomes possible to obtain
also the broadcast address without an additional lookup of the link.
2019-07-05 11:06:01 +02:00
Beniamino Galvani
36348c7dc5 dhcp: nettools: improve error messages
Add the reason to error messages to make debugging easier.

Note that n_dhcp4_client_new() also returns positive internal error
values, so we can't use nm_utils_error_set_errno().
2019-07-05 11:04:32 +02:00
Beniamino Galvani
7332c7343d dhcp: nettools: decrease initial delay
I think that artificially slowing down DHCP is not going to make users
happier, so let's decrease it to the minimum allowed value (1 ms).
Note that also dhclient and the internal client have it disabled. From
the dhclient.conf man page:

 *initial-delay* parameter sets the maximum time client can wait after
 start before commencing first transmission.  According to RFC2131
 Section 4.4.1, client should wait a random time between startup and
 the actual first trans‐ mission. Previous versions of ISC DHCP client
 used to wait random time up to 5 seconds, but that was unwanted due
 to impact on startup time. As such, new versions have the default
 initial delay set to 0. To restore old behavior, please set
 initial-delay to 5.
2019-07-05 11:04:32 +02:00
Beniamino Galvani
584298b7da dhcp: nettools: support the FQDN option
Add option 81 (FQDN) when the ipv4.dhcp-fqdn property is set. We don't
support changing the FQDN flags yet.
2019-07-05 11:04:32 +02:00
Beniamino Galvani
7d3098ff90 systemd: add dns-domain utils to systemd static library
dns-domain.c contains useful functions for manipulating DNS names.
Add it to the systemd static library we build in shared/, similarly to
what we already do for other utility files that were originally in
src/systemd/src/basic/.
2019-07-05 11:04:32 +02:00
Beniamino Galvani
92a717e7c2 dhcp: nettools: relicense as LGPL
Acked-by: Tom Gundersen <teg@jklm.no>
2019-07-05 11:04:32 +02:00
Tom Gundersen
6adade6f21 dhcp: add nettools dhcp4 client
This is inspired by the existing systemd integration, with a few differences:

* This parses the WPAD option, which systemd requested, but did not use.
* We hook into the DAD handling, only making use of the configured address
  once DAD has completed successfully, and declining the lease if it fails.

There are still many areas of possible improvement. In particular, we need
to ensure the parsing of all options are compliant, as n-dhcp4 treats all
options as opaque, unlike sd-dhcp4. We probably also need to look at how
to handle failures and retries (in particular if we decline a lease).

We need to query the current MTU at client startu, as well as the hardware
broadcast address. Both these are provided by the kernel over netlink, so
it should simply be a matter of hooking that up with NM's netlink layer.

Contribution under LGPL2.0+, in addition to stated licenses.
2019-07-05 11:04:32 +02:00
Tom Gundersen
401fee7c20 dhcp: support notifying the client of the result of DAD
The DHCP client is not meant to use the assigned address before DAD
has completed successfully, if enabled. And if DAD fails, the server
should be notified with a DECLINE, in order to potentially blacklist
the address.

Currently, none of the clients support this, but add the required
callbacks, and allow clients to opt in if they want.
2019-07-05 11:04:32 +02:00
Beniamino Galvani
be8f7b5a5d systemd: merge branch systemd into master 2019-07-05 09:13:53 +02:00
Beniamino Galvani
55c47d4efa systemd: update code from upstream (2019-07-04)
This is a direct dump from systemd git.

======

SYSTEMD_DIR=../systemd
COMMIT=52d8bcd131e7f3c9b7629412302e1ea46ddb70ca

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files -z :/src/systemd/src/ \
                :/shared/systemd/src/ \
                :/shared/nm-utils/unaligned.h | \
  xargs -0 rm -f

nm_copy_sd_shared() {
    mkdir -p "./shared/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./shared/systemd/$1"
}

nm_copy_sd_core() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd_nmutils() {
    mkdir -p "./shared/nm-utils/"
    cp "$SYSTEMD_DIR/$1" "./shared/nm-utils/${1##*/}"
}

nm_copy_sd_core "src/libsystemd-network/arp-util.c"
nm_copy_sd_core "src/libsystemd-network/arp-util.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd_core "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd_core "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd_core "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd_core "src/libsystemd-network/lldp-internal.h"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd_core "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd_core "src/libsystemd-network/lldp-network.c"
nm_copy_sd_core "src/libsystemd-network/lldp-network.h"
nm_copy_sd_core "src/libsystemd-network/network-internal.c"
nm_copy_sd_core "src/libsystemd-network/network-internal.h"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd_core "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd_core "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd_core "src/libsystemd-network/sd-lldp.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-source.h"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.c"
nm_copy_sd_core "src/libsystemd/sd-event/event-util.h"
nm_copy_sd_core "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd_core "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd_core "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd_core "src/shared/dns-domain.c"
nm_copy_sd_core "src/shared/dns-domain.h"
nm_copy_sd_core "src/systemd/_sd-common.h"
nm_copy_sd_core "src/systemd/sd-dhcp-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp-lease.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-client.h"
nm_copy_sd_core "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd_core "src/systemd/sd-event.h"
nm_copy_sd_core "src/systemd/sd-id128.h"
nm_copy_sd_core "src/systemd/sd-ipv4acd.h"
nm_copy_sd_core "src/systemd/sd-ipv4ll.h"
nm_copy_sd_core "src/systemd/sd-lldp.h"
nm_copy_sd_core "src/systemd/sd-ndisc.h"
nm_copy_sd_nmutils "src/basic/unaligned.h"
nm_copy_sd_shared "src/basic/alloc-util.c"
nm_copy_sd_shared "src/basic/alloc-util.h"
nm_copy_sd_shared "src/basic/async.h"
nm_copy_sd_shared "src/basic/env-file.c"
nm_copy_sd_shared "src/basic/env-file.h"
nm_copy_sd_shared "src/basic/env-util.c"
nm_copy_sd_shared "src/basic/env-util.h"
nm_copy_sd_shared "src/basic/errno-util.h"
nm_copy_sd_shared "src/basic/escape.c"
nm_copy_sd_shared "src/basic/escape.h"
nm_copy_sd_shared "src/basic/ether-addr-util.c"
nm_copy_sd_shared "src/basic/ether-addr-util.h"
nm_copy_sd_shared "src/basic/extract-word.c"
nm_copy_sd_shared "src/basic/extract-word.h"
nm_copy_sd_shared "src/basic/fd-util.c"
nm_copy_sd_shared "src/basic/fd-util.h"
nm_copy_sd_shared "src/basic/fileio.c"
nm_copy_sd_shared "src/basic/fileio.h"
nm_copy_sd_shared "src/basic/format-util.c"
nm_copy_sd_shared "src/basic/format-util.h"
nm_copy_sd_shared "src/basic/fs-util.c"
nm_copy_sd_shared "src/basic/fs-util.h"
nm_copy_sd_shared "src/basic/hash-funcs.c"
nm_copy_sd_shared "src/basic/hash-funcs.h"
nm_copy_sd_shared "src/basic/hashmap.c"
nm_copy_sd_shared "src/basic/hashmap.h"
nm_copy_sd_shared "src/basic/hexdecoct.c"
nm_copy_sd_shared "src/basic/hexdecoct.h"
nm_copy_sd_shared "src/basic/hostname-util.c"
nm_copy_sd_shared "src/basic/hostname-util.h"
nm_copy_sd_shared "src/basic/in-addr-util.c"
nm_copy_sd_shared "src/basic/in-addr-util.h"
nm_copy_sd_shared "src/basic/io-util.c"
nm_copy_sd_shared "src/basic/io-util.h"
nm_copy_sd_shared "src/basic/list.h"
nm_copy_sd_shared "src/basic/log.h"
nm_copy_sd_shared "src/basic/macro.h"
nm_copy_sd_shared "src/basic/memory-util.c"
nm_copy_sd_shared "src/basic/memory-util.h"
nm_copy_sd_shared "src/basic/mempool.c"
nm_copy_sd_shared "src/basic/mempool.h"
nm_copy_sd_shared "src/basic/missing_fcntl.h"
nm_copy_sd_shared "src/basic/missing_socket.h"
nm_copy_sd_shared "src/basic/missing_stat.h"
nm_copy_sd_shared "src/basic/missing_type.h"
nm_copy_sd_shared "src/basic/parse-util.c"
nm_copy_sd_shared "src/basic/parse-util.h"
nm_copy_sd_shared "src/basic/path-util.c"
nm_copy_sd_shared "src/basic/path-util.h"
nm_copy_sd_shared "src/basic/prioq.c"
nm_copy_sd_shared "src/basic/prioq.h"
nm_copy_sd_shared "src/basic/process-util.c"
nm_copy_sd_shared "src/basic/process-util.h"
nm_copy_sd_shared "src/basic/random-util.c"
nm_copy_sd_shared "src/basic/random-util.h"
nm_copy_sd_shared "src/basic/set.h"
nm_copy_sd_shared "src/basic/signal-util.h"
nm_copy_sd_shared "src/basic/siphash24.h"
nm_copy_sd_shared "src/basic/socket-util.c"
nm_copy_sd_shared "src/basic/socket-util.h"
nm_copy_sd_shared "src/basic/sort-util.h"
nm_copy_sd_shared "src/basic/sparse-endian.h"
nm_copy_sd_shared "src/basic/stat-util.c"
nm_copy_sd_shared "src/basic/stat-util.h"
nm_copy_sd_shared "src/basic/stdio-util.h"
nm_copy_sd_shared "src/basic/string-table.c"
nm_copy_sd_shared "src/basic/string-table.h"
nm_copy_sd_shared "src/basic/string-util.c"
nm_copy_sd_shared "src/basic/string-util.h"
nm_copy_sd_shared "src/basic/strv.c"
nm_copy_sd_shared "src/basic/strv.h"
nm_copy_sd_shared "src/basic/time-util.c"
nm_copy_sd_shared "src/basic/time-util.h"
nm_copy_sd_shared "src/basic/tmpfile-util.c"
nm_copy_sd_shared "src/basic/tmpfile-util.h"
nm_copy_sd_shared "src/basic/umask-util.h"
nm_copy_sd_shared "src/basic/utf8.c"
nm_copy_sd_shared "src/basic/utf8.h"
nm_copy_sd_shared "src/basic/util.c"
nm_copy_sd_shared "src/basic/util.h"
2019-07-04 18:13:17 +02:00
Beniamino Galvani
c045267837 ifcfg-rh: fix memory leak reading infiniband setting 2019-07-04 11:53:25 +02:00
Beniamino Galvani
17f4a1e794 device: ppp: check that connection has a PPPoE parent
NMDevicePPP only handles connections with the pppoe.parent property
set. match_connection() already checks this when we creating a new
device. We should also perform the same check in
check_connection_compatible().

Fixes: 6c3195931e ('core: implement activation of PPP devices')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/203
2019-07-03 17:56:37 +02:00
Lubomir Rintel
ce89e8b9b0 merge: branch 'lr/bootif'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/195
2019-07-03 09:27:43 +02:00
Lubomir Rintel
93859d8ffd initrd/tests: add some more variations of possible BOOTIF= variables
Test the form with a hwtype and color-separated as well as
hyphen-separated.
2019-07-03 09:16:52 +02:00
Lubomir Rintel
2952953a48 initrd: skip ethernet hwtype in BOOTIF
Dracut documents the BOOTIF argument to be a MAC address and so we
accept one in any of the conventions we recognize. However, the PXE boot
loaders like to prepend a "01-" to denote an ethernet hardware type.
Accept that too.

https://bugzilla.redhat.com/show_bug.cgi?id=1726240
2019-07-03 09:16:52 +02:00
Thomas Haller
c163207b07 core: create virtual device on settings changes in idle handler
The callback from NMSettings about adding/updating a settings comes
from a deep call-stack already. We don't know the context of it, and
we shouldn't just right away create the profile. Instead, schedule an
action to create it in an idle handler.
2019-07-02 17:52:53 +02:00
Thomas Haller
42a034812a ifcfg-rh: refactor code re-reading profile from disk after write
The function only has one caller and it should be simple enough
to perform the necessary steps right in nms_ifcfg_rh_writer_write_connection().

More functions don't (always) simplify the code.
2019-07-02 17:52:53 +02:00
Thomas Haller
5b98f2fb01 device: fix crash releasing destroyed slave
I encountered this on a WIP branch, but I think it can happen
under regular conditions. I think there is no error condition here,
and we should do nothing if we have no ifindex.

  <debug> [1561653068.2192] platform: signal: link removed: 1699: test1p <DOWN;broadcast,multicast> mtu 1500 master 1698 arp 1 veth* init addrgenmode none addr D6:14:45:97:06:75 brd FF:FF:FF:FF:FF:FF driver veth rx:0,0 tx:38,5606
  ...
  <info>  [1561653068.2617] device (test1): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
  ...
  <trace> [1561653068.2635] device[0x564058c73750] (test1p): sys-iface-state: external -> removed
  <debug> [1561653068.2635] device[0x564058c73750] (test1p): unrealize (ifindex 1699)
  <debug> [1561653068.2636] device[0x564058c73750] (test1p): parent: clear
  <trace> [1561653068.2636] device[0x564058b98eb0] (vethbr): mtu: commit-mtu...
  <debug> [1561653068.2639] device[0x564058c73750] (test1p): unmanaged: flags set to [platform-init,!sleeping,!by-type,!user-explicit,!user-settings,!user-udev,!is-slave=0x10/0x1479/unmanaged/unrealized], set-unmanaged [platform-init=0x10])
  <debug> [1561653068.2639] device[0x564058c73750] (test1p): unmanaged: flags set to [platform-init,!sleeping,!user-settings=0x10/0x51/unmanaged/unrealized], forget [parent,by-type,user-explicit,user-udev,external-down,is-slave=0x1c2c])
  <info>  [1561653068.2639] device (test1p): state change: activated -> unmanaged (reason 'unmanaged', sys-iface-state: 'removed')
  <debug> [1561653068.2640] device[0x564058c73750] (test1p): deactivating device (reason 'unmanaged') [3]
  <trace> [1561653068.2640] device[0x564058c73750] (test1p): ip4-state: set to 0 (none)
  <trace> [1561653068.2640] device[0x564058c73750] (test1p): ip6-state: set to 0 (none)
  <trace> [1561653068.2640] device[0x564058c73750] (test1p): remove_pending_action (0): 'dhcp6' not pending (expected)
  <trace> [1561653068.2640] device[0x564058c73750] (test1p): remove_pending_action (0): 'autoconf6' not pending (expected)
  <debug> [1561653068.2640] rules-manager: sync
  <debug> [1561653068.2640] device[0x564058c73750] (test1p): set metered value 0
  <debug> [1561653068.2641] device[0x564058c73750] (test1p): ip4-config: update (commit=1, new-config=(nil))
  <debug> [1561653068.2641] device[0x564058c73750] (test1p): ip6-config: update (commit=1, new-config=(nil))
  <debug> [1561653068.2644] device[0x564058b98eb0] (vethbr): slave test1p state change 100 (activated) -> 10 (unmanaged)
  <trace> [1561653068.2644] device[0x564058b98eb0] (vethbr): master: release one slave 0x564058c73750/test1p
  ((src/platform/nm-platform.c:2002)): assertion '<dropped>' failed

backtrace:
  ...
  #3  0x0000564057fb713e _nm_g_return_if_fail_warning (NetworkManager)
  #4  0x000056405808b37c release_slave (NetworkManager)
  #5  0x0000564058079aef nm_device_master_release_one_slave (NetworkManager)
  #6  0x00005640580844d7 slave_state_changed (NetworkManager)
  #7  0x00007efc24833fae ffi_call_unix64 (libffi.so.6)
  #8  0x00007efc2483396f ffi_call (libffi.so.6)
  #9  0x00007efc29b836e5 g_cclosure_marshal_generic (libgobject-2.0.so.0)
  #10 0x00007efc29b82c1d g_closure_invoke (libgobject-2.0.so.0)
  #11 0x00007efc29b96173 signal_emit_unlocked_R (libgobject-2.0.so.0)
  #12 0x00007efc29b9f29a g_signal_emit_valist (libgobject-2.0.so.0)
  #13 0x00007efc29b9f893 g_signal_emit (libgobject-2.0.so.0)
  #14 0x000056405807ab20 _set_state_full (NetworkManager)
  #15 0x000056405807d803 nm_device_unrealize (NetworkManager)
  #16 0x0000564057f6072c _platform_link_cb_idle (NetworkManager)
  #17 0x00007efc296a01db g_idle_dispatch (libglib-2.0.so.0)
  ...
2019-07-02 17:52:53 +02:00
Lubomir Rintel
39d5c8c12f initrd/tests: ensure that nameserver= setting affects the correct connection 2019-07-02 13:43:06 +02:00
Lubomir Rintel
6da2058237 initrd: don't create a default connection if there's already one
Certain arguments (such as "nameserver") don't specify a connection they
apply to and using them would generate a default ethernet connection.
This is probably not the right thing to do.
2019-07-02 13:43:06 +02:00
Lubomir Rintel
77540b2a7c initrd/tests: ensure we accept a prefix in place of an IPv4 mask 2019-07-02 13:42:19 +02:00
Lubomir Rintel
390d79079e initrd: allow specifying the net mask in form of a prefix
This is not documented in dracut.cmdline(7), however it seems to have
worked and has users and Red Hat even seems to recommend this (thanks to
Dan Horak for the pointers):

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/chap-installer-booting-ipl-s390
https://bugzilla.redhat.com/show_bug.cgi?id=1725872
2019-07-02 13:42:19 +02:00
Lubomir Rintel
920e59016f initrd: remove an accidental backspace 2019-07-02 13:42:09 +02:00
Lubomir Rintel
4b097e314e initrd: fix error reporting on bad netmask
It says the address is bad, but what is wrong is the mask.
2019-07-02 10:29:23 +02:00
Thomas Haller
0d58cab4a0 settings: use nm_connection_to_dbus_full() to avoid cloning the connection during GetSettings() 2019-06-28 16:48:17 +02:00
Thomas Haller
31c4c111d3 settings: cleanup handling of seen-bssids list in NMSettingsConnection
- most connections are not Wi-Fi connections and thus don't have a seen-bssids
  list. Only create the seen_bssids hash when required. This avoids allocating the
  hash in common cases and avoids checking the hash for the content (which is often
  empty).

- nm_settings_connection_get_seen_bssids() should return a sorted list.
  Leaving the sort order undefined is ugly.

- in try_fill_ssid_for_hidden_ap(), we need to check all
  NMSettingsConnection instances whether they know this bssid.
  Reorder the checks, to first call nm_settings_connection_has_seen_bssid(), which
  is faster and in most cases returns a negative result (shortcutting
  the rest).
2019-06-28 16:48:17 +02:00
Beniamino Galvani
2c97ae435e dhcp: systemd: relicense as LGPL
Soon a new DHCP backend will be added that will take code from the
internal one. Change its license to LGPL so that the whole new backend
code can also be LGPL, which is the preferred license for new
NetworkManager code.

Acked-by: Dan Williams <dcbw@redhat.com>
Acked-by: Dan Winship <danw@redhat.com>
Acked-by: Lubomir Rintel <lkundrak@v3.sk>
Acked-by: Thomas Haller <thaller@redhat.com>
2019-06-27 17:08:37 +02:00
Thomas Haller
8a8e894f80 core: add and use nm_keep_alive_destroy()
When we are done with a NMKeepAlive instance, we always should do
three things:

  - unset the owner
  - disarm (freeze) the keep-alive
  - give up our reference.

Add and use nm_keep_alive_destroy() that does this.
2019-06-27 13:25:40 +02:00
Thomas Haller
e36cf1e890 ifcfg-rh: add allow_filename_cb() argument to write-ifcfg-rh function
The function determines the filename automatically, but we
need to blacklist certain names.

That is, because NetworkManager keeps a list of loaded files
in memory. When writing a new file, we really want to choose
a filename that is not yet taken. For that we must not only
consider files on disk, but also files that existed on the last
time of loading.
2019-06-26 12:26:11 +02:00
Thomas Haller
e5b21344c5 ifcfg-rh: cleanup utils_detect_ifcfg_path()
- avoid cloing the basename. Determining the basename can be done conveniently
  with strrchr().
- use cleanup macro for temporary variable.
- while in practice it should not happen, check that the colon in the name
  of alias file names is not followed by another '/'.
2019-06-26 12:26:11 +02:00