Commit Graph

28062 Commits

Author SHA1 Message Date
Thomas Haller
f938ec6977 contrib: update nm-git-bundle to use "main" branch 2021-04-01 22:24:49 +02:00
Thomas Haller
371b64bd70 gilab-ci: update .gitlab-ci.yml to use "main" branch name 2021-04-01 21:43:01 +02:00
Thomas Haller
f0612bd67b contrib/scripts: update find-backports script to use "main" branch name 2021-04-01 21:40:25 +02:00
Thomas Haller
1db34e4fb1 contrib/release: update release.sh script to use "main" branch name 2021-04-01 21:38:17 +02:00
Thomas Haller
ca607d2eff example: rework "vpn-import-libnm" example
- add more error handling and free/unref data.

- split code in 3 functions: vpn_connection_import(),
  connection_add() and main(). These steps are mostly
  independent, and having them in separate functions
  makes their separation clearer.

- handle error from nm_client_add_connection_async() to
  exit program with non zero exit code.
2021-04-01 21:16:01 +02:00
Thomas Haller
24bcb8e3e4 systemd: fix borked merge
Fixes: 5f7f81a6a0 ('systemd: merge branch systemd into master')
2021-04-01 21:05:53 +02:00
Thomas Haller
5f7f81a6a0 systemd: merge branch systemd into master
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/799
2021-04-01 18:19:46 +02:00
Thomas Haller
d378240385 all: merge branch 'balrog-kun:serialize-flags'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/795
2021-04-01 17:56:27 +02:00
Thomas Haller
15fe784180 libnm-core: use _nm_connection_serialize_non_secret() in _nm_utils_hwaddr_cloned_data_synth() 2021-04-01 17:44:57 +02:00
Andrew Zaborowski
f0fe7384e1 all: Replace deprecated NM_CONNECTION_SERIALIZE_* flags
Review and replace usages of the two nm_connection_to_dbus() flags
marked deprecated in commit 84648e562c98 ('libnm: Refactor
NM_CONNECTION_SERIALIZE_* flags'):

NM_CONNECTION_SERIALIZE_NO_SECRETS and
NM_CONNECTION_SERIALIZE_ONLY_SECRETS.
2021-04-01 17:19:15 +02:00
Andrew Zaborowski
2a1b65ce12 settings: Don't clone connections to serialize secrets
Use the new nm_connection_to_dbus() flags to filter secrets instead of
cloning connections and using
_nm_connection_clear_secrets_by_secret_flags() and then serializing all
secrets in NMSettingsConnection.  Fix a related comment.
2021-04-01 17:19:15 +02:00
Andrew Zaborowski
34285fec76 libnm: Refactor NM_CONNECTION_SERIALIZE_* flags
nm-settings-connection.c has code similar to this in two places:

    /* FIXME: improve NMConnection API so we can avoid the overhead of cloning the connection,
     *   in particular if there are no secrets to begin with. */

    connection_cloned = nm_simple_connection_new_clone(new);

    /* Clear out unwanted secrets */
    _nm_connection_clear_secrets_by_secret_flags(connection_cloned,
                                                 NM_SETTING_SECRET_FLAG_NOT_SAVED
                                                     | NM_SETTING_SECRET_FLAG_AGENT_OWNED);

    secrets = nm_g_variant_ref_sink(
        nm_connection_to_dbus(connection_cloned, NM_CONNECTION_SERIALIZE_ONLY_SECRETS));

It seems the secrets filtering can be done by nm_connection_to_dbus() if
the NM_CONNECTION_SERIALIZE_* flags are extended.  The current set of
flags contains flags that start with NO, ONLY and WITH prefixes, which
makes it useless for combining the flags because most combinations of
more than one flag don't have a clear interpretation.  So they're mostly
useful when used alone, i.e. you'd need to add a new enum value for
each new subset of settings to be serialized.

To get the most flexibility from a small set of flags they should
either all be of the WITH_* type or NO_* type.  In the former case they
could be combined to extend the subset of properties serialized, in the
latter case each flag would reduce the subset.  After trying both
options I found it's easier to adapt the current set of flags to the
WITH_* schema while keeping binary and source compatibility.  This
commit changes the set of flags in the following way:

NM_CONNECTION_SERIALIZE_ALL is kept for compatibility but is equivalent
to a combination of other flags.

NM_CONNECTION_SERIALIZE_WITH_NON_SECRET is added with the same value as
NM_CONNECTION_SERIALIZE_NO_SECRETS, it implies that non-secret
properties are included but doesn't prevent including other properties.
Since it couldn't be meaningfully combined with any other flag this
change shouldn't break compatibility.

Similarly NM_CONNECTION_SERIALIZE_WITH_SECRETS is added with the same
value as existing NM_CONNECTION_SERIALIZE_ONLY_SECRETS with the same
consideration about compatibility.

NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED and the new
NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED and
NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_SAVED add only subsets of
secrets and can be combined.  For backwards compatibility
NM_CONNECTION_SERIALIZE_ONLY_SECRETS is basically ignored when either of
these three is present, so that the value:
..ONLY_SECRETS | ..AGENT_OWNED works as previously.
2021-04-01 17:19:15 +02:00
Julia Dronova
af75b2b206 po: update Russian (ru) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/697
2021-04-01 14:44:26 +02:00
Yuri Chornoivan
ce88429009 po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/801
2021-04-01 11:31:28 +02:00
Yuri Chornoivan
5ff6cf575a libnm: don't use defined strings in translated strings in "nm-setting-ip-config.c"
[thaller@redhat.com: reworked patch by Yuri]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/800
2021-03-30 17:54:26 +02:00
Thomas Haller
7935c11044 systemd: update code from upstream (2021-03-30)
This is a direct dump from systemd git.

======

SYSTEMD_DIR=../systemd
COMMIT=119063d2b149667a91e0e08e4bdf82a0eb6a7efd

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

git ls-files -z :/src/core/systemd/src/ \
                :/src/libnm-systemd-shared/src/ \
                :/src/libnm-std-aux/unaligned.h | \
  xargs -0 rm -f

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

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

nm_copy_sd_stdaux() {
    mkdir -p "./src/libnm-std-aux/"
    cp "$SYSTEMD_DIR/$1" "./src/libnm-std-aux/${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/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-dhcp-option.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-dhcp6-option.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_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/cgroup-util.h"
nm_copy_sd_shared "src/basic/dns-def.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_random.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_syscall.h"
nm_copy_sd_shared "src/basic/missing_type.h"
nm_copy_sd_shared "src/basic/ordered-set.c"
nm_copy_sd_shared "src/basic/ordered-set.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/ratelimit.c"
nm_copy_sd_shared "src/basic/ratelimit.h"
nm_copy_sd_shared "src/basic/set.h"
nm_copy_sd_shared "src/basic/signal-util.c"
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/strxcpyx.c"
nm_copy_sd_shared "src/basic/strxcpyx.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/user-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"
nm_copy_sd_shared "src/fundamental/macro-fundamental.h"
nm_copy_sd_shared "src/fundamental/string-util-fundamental.c"
nm_copy_sd_shared "src/fundamental/string-util-fundamental.h"
nm_copy_sd_shared "src/fundamental/type.h"
nm_copy_sd_shared "src/shared/dns-domain.c"
nm_copy_sd_shared "src/shared/dns-domain.h"
nm_copy_sd_shared "src/shared/log-link.h"
nm_copy_sd_shared "src/shared/web-util.c"
nm_copy_sd_shared "src/shared/web-util.h"
nm_copy_sd_stdaux "src/basic/unaligned.h"
2021-03-30 14:20:06 +02:00
Thomas Haller
094687b1cb systemd: merge branch 'systemd'
This introduces no change. On systemd branch files were moved
around to follow what also happened on master. The merge commit
just makes git aware of this part of history.
2021-03-30 08:34:05 +02:00
Thomas Haller
bd7a21e099 all: move "shared/nm-std-aux/unaligned.h" to "src/libnm-std-aux/"
Like commit a8c34b9dcf ('build: move "shared/nm-std-aux" to "src/libnm-std-aux"')
2021-03-30 08:32:51 +02:00
Thomas Haller
6103b0fe23 all: move "shared/systemd/" directory to "src/libnm-systemd-shared/"
Like commit 39225258d6 ('build: move "shared/systemd" to "src/libnm-systemd-shared"')
2021-03-30 08:21:23 +02:00
Thomas Haller
5d6532f2d7 ifcfg-rh: always honor "$VLAN_ID" in ifcfg files
initscripts don't support "$VLAN_ID". They actually support "$VID",
which NetworkManager doesn't.

"$VLAN_ID" was introduced by commit 10b32be37b ('ifcfg-rh: various VLAN
cleanups'). It has a comment about "backward compatibility" for the case
where the reader would ignore "$VLAN_ID" if "$DEVICE"'s name contains
a suffix that is parsable as VLAN ID.

That is wrong. If a new feature gets introduce (like NetworkManager
supporting "$VLAN_ID"), then there is no way that an older version of the
tool -- which doesn't know the new feature yet (initscripts) -- supports it.
This is not what backward compatibility means. Backward compatibility
means that if a user has an old ifcfg-file without "$VLAN_ID", then we
continue parsing it as before.

Consider, when a user (or NetworkManager) writes a configuration

  DEVICE=vlan9
  PHYSDEV=eth0
  VLAN_ID=10

then it makes no sense to ignore VLAN_ID=10 and use "9" instead.
Otherwise the user (or NetworkManager) should not have written the
file this way.

Also, NetworkManager profiles support "connection.interface-name=vlan9"
together with "vlan.id=10". Such a configuration is valid and must be
expressible in ifcfg-rh format. The ifcfg-rh writer code did not somehow
restrict the setting of "$VLAN_ID" to account for this odd behavior. Whenever
NetworkManager in the past wrote VLAN_ID variable to file, it really meant
it.

https://bugzilla.redhat.com/show_bug.cgi?id=1907960

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/794
2021-03-29 21:12:47 +02:00
Thomas Haller
ba6552c472 libnm: merge branch 'th/libnm-client-context'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/798
2021-03-29 21:06:51 +02:00
Thomas Haller
49d69bc1b0 libnm: add comment about context-busy-watcher and g_dbus_connection_signal_unsubscribe() 2021-03-29 21:05:38 +02:00
Thomas Haller
193a6ac3e5 libnm: better explain nm_client_new()/nm_client_new_async() 2021-03-29 18:33:35 +02:00
Thomas Haller
89a6671e5f libnm: cleanup handling of cancellation for initializing NMClient 2021-03-29 18:33:31 +02:00
Paul Menzel
1f890f5831 man: fix typo in *commanded* in wifi.iwd.autoconnect description
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/797
2021-03-29 16:12:21 +02:00
Beniamino Galvani
c21d4ce125 Revert "initrd: set the bootif MAC in existing connection with ifname"
This reverts commit 389575a6b1.

When the command line contains BOOTIF and there is another ip=
argument specifying an interface name, we can follow 2 approaches:

 a) BOOTIF creates a new distinct connection with DHCP
    (the behaviour before the commit)

 b) the connection generated for ip= will be also be bound to the
    BOOTIF MAC (the behavior introduced by the commit)

Restore a) because we can't be sure that the MAC address refers to the
same interface. In that case it's preferable to generate a different
connection.

https://bugzilla.redhat.com/show_bug.cgi?id=1915493#c35
2021-03-26 07:26:55 +01:00
Beniamino Galvani
7adac95fc8 build: dist other missing meson.build files
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/690

Fixes: 54976f23cd ('build: move "clients/common/" to "src/libnmc-{base,setting}/"')
2021-03-25 11:41:37 +01:00
Thomas Haller
ddc922bbdf build: dist "src/libnm-systemd-shared/meson.build"
Fixes: 39225258d6 ('build: move "shared/systemd" to "src/libnm-systemd-shared"')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/690
2021-03-25 11:19:14 +01:00
Thomas Haller
420784e342 core: fix crash in nm_wildcard_match_check()
It's not entirely clear how to treat %NULL.
Clearly "match.interface-name=eth0" should not
match with an interface %NULL. But what about
"match.interface-name=!eth0"? It's now implemented
that negative matches still succeed against %NULL.
What about "match.interface-name=*"? That probably
should also match with %NULL. So we treat %NULL really
like "".

Against commit 11cd443448bc ('iwd: Don't call IWD methods when device
unmanaged'), we got this backtrace:

    #0  0x00007f1c164069f1 in __strnlen_avx2 () at ../sysdeps/x86_64/multiarch/strlen-avx2.S:62
    #1  0x00007f1c1637ac9e in __fnmatch (pattern=<optimized out>, string=<optimized out>, string@entry=0x0, flags=flags@entry=0) at fnmatch.c:379
            p = 0x0
            res = <optimized out>
            orig_pattern = <optimized out>
            n = <optimized out>
            wpattern = 0x7fff8d860730 L"pci-0000:03:00.0"
            ps = {__count = 0, __value = {__wch = 0, __wchb = "\000\000\000"}}
            wpattern_malloc = 0x0
            wstring_malloc = 0x0
            wstring = <optimized out>
            alloca_used = 80
            __PRETTY_FUNCTION__ = "__fnmatch"
    #2  0x0000564484a978bf in nm_wildcard_match_check (str=0x0, patterns=<optimized out>, num_patterns=<optimized out>) at src/core/nm-core-utils.c:1959
            is_inverted = 0
            is_mandatory = 0
            match = <optimized out>
            p = 0x564486c43fa0 "pci-0000:03:00.0"
            has_optional = 0
            has_any_optional = 0
            i = <optimized out>
    #3  0x0000564484bf4797 in check_connection_compatible (self=<optimized out>, connection=<optimized out>, error=0x0) at src/core/devices/nm-device.c:7499
            patterns = <optimized out>
            device_driver = 0x564486c76bd0 "veth"
            num_patterns = 1
            priv = 0x564486cbe0b0
            __func__ = "check_connection_compatible"
            device_iface = <optimized out>
            local = 0x564486c99a60
            conn_iface = 0x0
            klass = <optimized out>
            s_match = 0x564486c63df0 [NMSettingMatch]
    #4  0x0000564484c38491 in check_connection_compatible (device=0x564486cbe590 [NMDeviceVeth], connection=0x564486c6b160, error=0x0) at src/core/devices/nm-device-ethernet.c:348
            self = 0x564486cbe590 [NMDeviceVeth]
            s_wired = <optimized out>

Fixes: 3ced486f41 ('libnm/match: extend syntax for match patterns with '|', '&', '!' and '\\'')

https://bugzilla.redhat.com/show_bug.cgi?id=1942741
2021-03-24 21:18:54 +01:00
Beniamino Galvani
80f63ae01a release: bump version to 1.31.2 (development) 2021-03-24 18:12:04 +01:00
Thomas Haller
ccc884d471 core: micro optimization in check_connection_compatible() to check for patterns
Let's shortcut the test by consistently checking whether num_patterns
is positive before matching.

It's more about having a consistent form of the "if" checks, than
anything else.
2021-03-24 16:50:26 +01:00
Thomas Haller
8f138e6bc1 libnm/docs: improve wording for documentation of [match] setting options 2021-03-24 16:50:26 +01:00
Wen Liang
2e96cdfe5e CONTRIBUTIING: add chapter describing Cscope and code structure
Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/792
2021-03-24 16:42:40 +01:00
Thomas Haller
fbabfa5e36 core: merge branch 'th/local-route-sync'
https://bugzilla.redhat.com/show_bug.cgi?id=1907661

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/790
2021-03-24 14:21:02 +01:00
Thomas Haller
557644f5e0 core: don't add dependent local route for addresses
When adding an IPv4 address, kernel automatically adds a local route.
This is done by fib_add_ifaddr(). Note that if the address is
IFA_F_SECONDARY, then the "src" is the primary address. That means, with

  nmcli connection add con-name t type ethernet ifname t autoconnect no \
     ipv4.method manual ipv6.method disabled \
     ipv4.addresses '192.168.77.10/24, 192.168.77.11/24'

we get two routes:

  "local 192.168.77.10 dev t table local proto kernel scope host src 192.168.77.10"
  "local 192.168.77.11 dev t table local proto kernel scope host src 192.168.77.10"

Our code would only generate instead:

  "local 192.168.77.10 dev t table local proto kernel scope host src 192.168.77.10"
  "local 192.168.77.11 dev t table local proto kernel scope host src 192.168.77.11"

Afterwards, this artificial route will be leaked:

    #!/bin/bash

    set -vx

    nmcli connection delete t || :
    ip link delete t || :

    ip link add name t type veth peer t-veth

    nmcli connection add con-name t type ethernet ifname t autoconnect no ipv4.method manual ipv4.addresses '192.168.77.10/24, 192.168.77.11/24' ipv6.method disabled

    nmcli connection up t

    ip route show table all dev t | grep --color '^\|192.168.77.11'

    sleep 1

    nmcli device modify t -ipv4.addresses 192.168.77.11/24

    ip route show table all dev t | grep --color '^\|192.168.77.11'

    ip route show table all dev t | grep -q 192.168.77.11 && echo "the local route 192.168.77.11 is still there, because NM adds a local route with wrong pref-src"

It will also be leaked because in the example above ipv4.route-table is
unset, so we are not in full route sync mode and the local table is not
synced.

This was introduced by commit 3e5fc04df3 ('core: add dependent local
routes configured by kernel'), but it's unclear to me why we really need
this. Drop it again and effectively revert commit 3e5fc04df3 ('core:
add dependent local routes configured by kernel').

I think this "solution" is still bad. We need to improve our route sync
approach with L3Cfg rework. For now, it's probably good enough.

https://bugzilla.redhat.com/show_bug.cgi?id=1907661
2021-03-23 22:30:32 +01:00
Thomas Haller
fe1bf4c907 core: minor cleanup in nm_platform_ip_route_get_prune_list() 2021-03-23 17:56:47 +01:00
Thomas Haller
c29d995000 core: don't add ff00::/8 unicast route to nm_ip6_config_add_dependent_routes()
This effectively reverts commit cd89026c5f ('core: add dependent
multicast route configured by kernel for IPv6').

It's not clear to me why this was done or why it would be correct.

True, kernel automatically adds multicast route like

  multicast ff00::/8 dev $IFACE table local proto kernel metric 256 pref medium

But NetworkManager ignores all multicast routes for now. So the dependent
routes cannot contain multicast routes as they are not handled. Also,
the code added a unicast route, so I don't understand why the comment
is talking about multicast.

This seems just wrong. Drop it.
2021-03-23 17:56:47 +01:00
Thomas Haller
e226b5eb82 core: add NM_IP_ROUTE_TABLE_SYNC_MODE_ALL_PRUNE mode
When we deactivate a device, we flush all IP addresses and
routes. Thus, have yet another sync mode for that. It will sync more
than "ALL".
2021-03-23 17:56:46 +01:00
Thomas Haller
f6db2c6261 core: log route-table-sync-mode in nm_device_set_ip_config() 2021-03-23 17:56:46 +01:00
Thomas Haller
5da8c073ef core: avoid logging pointer value in nm_device_set_ip_config() 2021-03-23 17:56:46 +01:00
Thomas Haller
87f2c7bc6c config: use nm_streq() instead of strcmp() 2021-03-23 14:26:56 +01:00
Thomas Haller
3f07bda2a7 wifi: minor cleanup in "nm-wifi-utils.c" 2021-03-23 14:26:38 +01:00
Thomas Haller
bf564937bb wifi/iwd: merge branch 'balrog-kun:write-iwd-configs'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/695
2021-03-23 14:25:31 +01:00
Andrew Zaborowski
4229c97012 iwd: Mirror NM connections to IWD network config files
Watch for NMSettingConnection changes and creation signals and convert
them to IWD format and write them to the configured IWD profile storage
directory.  The logic is off by default and gets enabled when the new
iwd-config-path setting in nm.conf's [main] group is set to a path to
an existing directory.

The idea here is that when a user edits an NM connection profile, the
change is immediately mirrored in IWD since IWD watches its
configuration directory using inotify.  This way NM clients can be used
to edit 802.1x settings, the PSK passphrase or the SSID -- changes that
would previously not take effect with the IWD backend.

Some precautions are taken to not make connections owned by a user
available to other users, such connections are not converted at all.
In all other cases where a connection cannot be converted sufficiently
well to the IWD format, for various reasons, we also give up and not
mirror these connections.

Due to IWD limitations and design differences with NM this logic has
many problems where it may not do its task properly.  It's meant to work
on a best-effort and "better than nothing" basis, but it should be safe
in that it shouldn't delete users data or reveal secrets, etc.  The most
obvious limitation is that there can be multiple NM connections
referring to the same SSID+Security tuple and only one IWD profile can
exist because the filename is based on only the SSID+Security type.  We
already had one NM connection selected for each IWD KnownNetwork and
referenced by a pointer, so we ignore changes in NM connections other
than that selected one.
2021-03-23 14:24:42 +01:00
Andrew Zaborowski
9d22ae7981 wifi: Add utilities for writing IWD connection profiles
Add code that can take an NMConnection and convert it to the IWD
network config file format so as to be able to mirror NM connection
profiles to IWD connection profiles and make basic editing IWD
profile possible from nm-connection-editor.  The focus here is on 802.1x
settings.
2021-03-23 14:24:42 +01:00
Thomas Haller
62cd7682d9 core: merge branch 'th/routing-rule-attr-uidrange-and-type'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/788
2021-03-23 14:21:16 +01:00
Thomas Haller
e922404990 libnm,core: support "prohibit"/"blackhole"/"unreachable" type routing rules 2021-03-23 14:19:39 +01:00
Thomas Haller
972d1ba046 libnm,core: support "uidrange" parameter for routing rules 2021-03-23 14:19:38 +01:00
Thomas Haller
ba72d5a7e7 libnm: use binary search to lookup D-Bus info for routing-rules 2021-03-23 14:19:38 +01:00
Thomas Haller
945612cc5d all: use nm_net_aux_rtnl_rtntype_{n2a,a2n}() helpers 2021-03-23 14:19:38 +01:00