Commit graph

30310 commits

Author SHA1 Message Date
Lubomir Rintel
2dbbea3f10 nmcli/connections: export nmc_connection_check_deprecated()
It's going to be useful with "nmcli dev wifi connect" that also creates
a connection that should be checked.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1224
2022-05-12 14:37:18 +02:00
Thomas Haller
1a995325d5
build/meson: workaround meson bug related to ternary expression
On Debian 10, `apt-get install meson` gives meson-0.49.2-1.
That version doesn't like certain ternary expressions (while some
that we have are OK), which leads to a crash of meson.

Avoid that.

Fixes: bddffb1731 ('build/meson: honor prefix for udev_dir and don't use pkg-config')
2022-05-11 22:34:38 +02:00
Thomas Haller
f6f961f381
gitlab-ci: avoid pager for "run-test.sh"
In particular, `dpkg -l` likes to show a pager, when you are on the
terminal. Being on the terminal happens, if you try to reproduce
a test on your own container. So let's avoid that.
2022-05-11 22:12:56 +02:00
Thomas Haller
19a96f64ed
dhcp: merge branch 'th/dhcpv6-otherconf-ignore-addr'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1220
2022-05-11 19:07:18 +02:00
Thomas Haller
2875ad7e50
dhcp: fix ignoring addresses with DHCPv6 otherconf (O flag)
With O flag (otherconf mode), don't add the IPv6 addresses to the
collected lease.

An alternative would be to add it initially, but ignore it when
merging the configuration in NML3Cfg. The idea of that would be that if
the mode switches from otherconf to managed, that we already have the
address. However, depending on the mode we made a different DHCPv6
request. That means, if the mode changes we anyway cannot just use the
previous lease, because it might not contain all the information. So
it seems better to ignore the address early.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')

https://bugzilla.redhat.com/show_bug.cgi?id=2083968
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/953

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1220
2022-05-11 19:06:00 +02:00
Thomas Haller
41df480fdd
dhcp: fix setting "-S" flag for dhclient info-only requests
Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2022-05-11 19:03:46 +02:00
Thomas Haller
bacd3e1482
dhcp: always explicitly set request/information-request flags for internal DHCPv6 client
It seems clearer to explicitly set this always, and not rely on the
defaults.
2022-05-11 19:03:45 +02:00
Thomas Haller
265a4a07bd
platform,core: merge branch 'th/platform-struct-packing'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1217
2022-05-11 17:08:22 +02:00
Thomas Haller
6ebc622303
audit: handle error from audit_encode_nv_string()
audit_encode_nv_string() is documented that it might fail. Handle
the error.

Also, the returned string was allocated with malloc(). We must free
that with free()/nm_auto_free, not g_free()/gs_free.
2022-05-11 17:06:12 +02:00
Thomas Haller
fd4ddd8d40
platform: reorder fields in __NMPlatformIPRoute_COMMON for tight packing 2022-05-11 17:06:12 +02:00
Thomas Haller
a34bad8b52
platform: use flexible array members for "NMPlatformIPAddress.address_ptr"/"NMPlatformIPRoute.network_ptr"
Try to workaround a coverity warning:

 30. NetworkManager-1.39.3/src/core/vpn/nm-vpn-connection.c:2000:
     overrun-buffer-val: Overrunning array "address.ax.address_ptr" of 1
     bytes by passing it to a function which accesses it at byte offset 3.
2022-05-11 17:06:12 +02:00
Thomas Haller
d6e6443b86
build: merge branch 'th/meson-prefix-dir'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1221
2022-05-11 16:45:49 +02:00
Thomas Haller
c840e56e0a
meson/build: fix using correct prefix for "systemdsystemunitdir"
We do the same with autotools.

Well, almost the same. Of course, meson's define_variable only
accepts a list of two strings, to define one variable. So we cannot
also redefine "prefix", unlike configure.ac.
2022-05-11 15:29:45 +02:00
Thomas Haller
331a7c9943
build/autotools: cleanup udev-dir option in configure.ac
- also accept empty value to autodetect. This makes it similar
  to what is done with meson.
- log the chosen udev-dir.
- use ${prefix} instead of $(prefix). It's usually used at other
  places.
2022-05-11 15:20:38 +02:00
Thomas Haller
bddffb1731
build/meson: honor prefix for udev_dir and don't use pkg-config
When building with `mesond -Dprefix=/tmp/nm`, then we would expect
that udev files are installed there (wouldn't we?).

The user can already explicitly set "-Dudev_dir=", or even disable
installing the files with "-Dudev_dir=no".

Note that meson be default pre-populates `get_option("prefix")`, so there
is always something set. So we cannot just act on whether the user set a
prefix. It seems to default to /usr/local.

Note that package builds from Fedora spec file pass "-Dprefix=/usr".

I think we should honor the prefix. However, then it seems wrong to also
honor pkg-config at the same time.
In particular, because `pkg-config --variable=udevdir udev` gives /usr/lib/udev.
That means, if we would just prepend the default prefix "/usr" or "/usr/local"
to "/usr/lib/udev" we get the wrong result.

Note that we already to the same for autotools.
2022-05-11 10:38:32 +02:00
Lubomir Rintel
b0240418b3 bridge: assume wired settings are there
We can now assert instead of checking.

Also, let's move the whole get-the-mtu part down closer to where it is
actually used.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1208
2022-05-10 21:41:19 +02:00
Lubomir Rintel
41291ef773 core/connection: ensure wired settings are around for bridges
Bridges are wired ethernet bridges, it makes sense for them to have
wired ethernet settings.

Ensuring they always exist makes reapplying the MTU changes more
convenient. The MTU for bridges is taken from wired settings, making it
impossible to change and reapply it for connections that lack them
(as reapply doesn't really cope well with addition and removal of
settings).

https://bugzilla.redhat.com/show_bug.cgi?id=2076131
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1208
2022-05-10 21:41:19 +02:00
Fernando Fernandez Mancera
62f461ebeb bond: drop _get_option_or_default() and use _get_option_normalized()
Currently nm_setting_bond_get_option_normalized() and
nm_setting_bond_get_option_or_default() are identical functions. As the
first one is exposed as public API and has a better name, let's drop the
second one.
2022-05-10 12:42:11 +02:00
Thomas Haller
5d5e27528d
nmtui: merge branch 'gfm:nmtui-tun-tap'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1214
2022-05-09 21:15:08 +02:00
Olivier Gayot
928cd1cb15
nmtui: add support for activating tun/tap connections
tun/tap connections can be created using a command such as:

  $ nmcli connection add type tun ifname tun0 mode tap owner 1000

They appear in nmcli connection as TYPE "tun".

This patch adds the ability to activate and deactivate this type of
connection using nmtui.

Each connection of TYPE "tun" appears as:

  TUN/TAP (<ifname>)
  * <connection-name>

Example:

  TUN/TAP (tap0)
  * bridge-slave-tap0

  TUN/TAP (tap1)
    bridge-slave-tap1
2022-05-09 21:14:59 +02:00
Olivier Gayot
24d8980692
nm-connection.c: replace !strcmp() expressions by nm_streq() 2022-05-09 21:14:59 +02:00
Thomas Haller
452158a036
core: merge branch 'th/fix-clear-ip6-temp-addrs'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1209
2022-05-09 19:23:49 +02:00
Thomas Haller
9a69bc8d84
l3cfg: refresh platform cache before creating prune list during L3Cfg commit
It seems, we should make decisions based on the latest state.
Make sure to process all pending netlink events.
2022-05-09 19:21:59 +02:00
Thomas Haller
518f6124c6
l3cfg: fix clearing IPv6 temporary addresses to avoid stale addresses
IPv6 temporary addresses are configured by kernel, with the
"ipv6.ip6-privacy" setting ("use_tempaddr" sysctl) and the
IFA_F_MANAGETEMPADDR flag.

As such, the idea was that during reapply we would not remove them.
However, that is wrong.

The only case when we want to keep those addresses, is if during reapply
we are going to configure the same primary address (with mngtmpaddr
flag) again. Otherwise, theses addresses must always go away.

This is quite serious. This not only affects Reapply. Also during disconnect
we clear IP configuration via l3cfg.
Have an ethernet profile active with "ipv6.ip6-privacy". Unplug
the cable, the device disconnects but the temporary IPv6 address is not
cleared. As such, nm_device_generate_connection() will now generate
an external profile (with "ipv6.method=disabled" and no manual IP addresses).
The result is, that the device cannot properly autoconnect again,
once you replug the cable.

This is serious for disconnect. But I could not actually reproduce the
problem using reapply. That is, because during reapply we usually
toggle ipv6_disable sysctl, which drops all IPv6 addresses. I still
went through the effort of trying to preserve addresses that we still
want to have, because I am not sure whether there are cases where we
don't toggle ipv6_disable. Also, doing ipv6_disable during reapply is
bad anyway, and we might want to avoid that in the future.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2022-05-09 19:21:58 +02:00
Thomas Haller
5ff08fbbea
glib-aux: add nm_g_array_data() helper
It's annoying to do

  (arr ? arr->data : NULL)

Especially, because usually you'd need to cast the above
(which would have type (char *)).
2022-05-09 19:21:58 +02:00
Thomas Haller
8b9e52b9ce
all: merge branch 'th/clean-includes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1205
2022-05-09 19:20:28 +02:00
Thomas Haller
501a7a3d00
daemon-helper: include "libnm-std-aux/nm-default-std.h" as first in "nm-daemon-helper.c"
All our sources should include one of the "nm-default*.h" headers
first. That one drags in <config.h>, which must be included first
and a few other basics.

Which is the right "nm-default*.h" header depends on the component. In
case of "nm-daemon-helper.c", it's "libnm-std-aux/nm-default-std.h".
2022-05-09 19:20:19 +02:00
Thomas Haller
0b7dc4137d
std-aux: include default std-aux headers by "nm-default-std.h" 2022-05-09 19:20:19 +02:00
Thomas Haller
d75aae8b26
all: drop redundant includes 2022-05-09 19:20:18 +02:00
Thomas Haller
80a19958dc
code-style: fix wrong indentation for code comments 2022-05-09 19:20:18 +02:00
Thomas Haller
c6e41b2df3
glib-aux: merge branch 'th/str-buf-stack-allocated'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1203
2022-05-09 19:18:48 +02:00
Thomas Haller
560feecb4c
glib-aux: avoid #if in "nm-str-buf.h"
NM_MORE_ASSERT is a compile time constant. The compiler can optimize
it away just fine.
2022-05-09 19:18:30 +02:00
Thomas Haller
532f3e34a8
glib-aux: drop nm_str_buf_init() for NM_STR_BUF_INIT()
NM_STR_BUF_INIT() and nm_str_buf_init() were pretty much redundant. Drop one of
them.

Usually our pattern is that we don't have functions that return structs.
But NM_STR_BUF_INIT() returns a struct, because it's convenient to use
with

  nm_auto_str_buf NMStrBuf strbuf = NM_STR_BUF_INIT(...);

So use that variant instead.
2022-05-09 19:18:30 +02:00
Thomas Haller
13d25f9d0b
glib-aux: add support for starting with stack-allocated buffer in NMStrBuf
Allow to initialize NMStrBuf with an externally allocated array.
Usually a stack buffer. If the NMStrBuf grows beyond the size of
that initial buffer, then it would switch using malloc.

The idea is to support the common case where the result is small enough
to fit on the stack.

I always wanted to do such optimization because the main purpose of
NMStrBuf is to put it on the stack and ad-hoc construct a string.
I just figured, it would complicate the implementation and add
a runtime overhead. But turns out, it doesn't really.
The biggest question is how NMStrBuf should behave with a pre-allocated
buffer? Turns out, most choices can be made in a rather obvious way.
The only non-obvious thing is that nm_str_buf_finalize() would malloc()
a buffer, but that too seems consistent and what a user would probably
expect. As such, this doesn't seem to add unexpected semantics to the API.
2022-05-09 19:18:23 +02:00
Beniamino Galvani
77c8b2960a device: commit l3cfg on link change only when the device is activating
On link change, the configuration should be reapplied only when the
device is activating.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')

https://bugzilla.redhat.com/show_bug.cgi?id=2079054
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1216
2022-05-09 14:58:57 +02:00
Lubomir Rintel
6525e8a7d7 merge: branch 'lr/gtkdoc'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1211
2022-05-06 18:50:26 +02:00
Lubomir Rintel
99d92e2f10 libnm-client: fix some comments
Correct the mismatched arguments and descriptions, likely a copy &
paste error.
2022-05-06 18:33:27 +02:00
Lubomir Rintel
a3174af914 libnm: fix placement of some "Since:" tags
libnm-client-impl/nm-client.c:8398: warning: multi-line since docs found
  libnm-client-impl/nm-device-macvlan.c:115: warning: multi-line since docs found
  libnm-client-impl/nm-device-vxlan.c:540: warning: multi-line since docs found
  libnm-client-impl/nm-device-vxlan.c:92: warning: multi-line since docs found
  libnm-core-impl/nm-setting-ethtool.c:41: warning: multi-line since docs found
  libnm-core-impl/nm-setting-ip-config.c:2475: warning: multi-line since docs found
  libnm-core-impl/nm-setting-ip-config.c:2504: warning: multi-line since docs found
2022-05-06 18:33:27 +02:00
Lubomir Rintel
649314ddaa libnm: replace nm-types.h by defining the types in respective headers
The typedefs in nm-types.h confuse gtkdoc-scan. It generates a
libnm-sections.txt file like this:

  <SECTION>
  <FILE>nm-types</FILE>
  <TITLE>NMDeviceOvs</TITLE>
  NMAccessPoint
  NMActiveConnection
  NMCheckpoint
  NMClient
  NMDevice
  ...

Note the wrongly picked title and, more importantly, the object types in
a bogus section. This in turn makes gtkdoc-mkdb fail to include the
property and signal documentation in appropriate sections.

Without nm-types.h, we need to mind the header dependencies. This means
that we need to order the headers that define types before the ones that
use them. Also, we need to break the depencency loops in few palces.
2022-05-06 18:33:27 +02:00
Thomas Haller
53cfb30beb
n-dhcp4: re-import git-subtree for 'src/n-dhcp4'
git subtree pull --prefix src/n-dhcp4 git@github.com:nettools/n-dhcp4.git master --squash
2022-05-06 13:49:04 +02:00
Thomas Haller
3a49d158e0 Squashed 'src/n-dhcp4/' changes from 64513e31c01a..e4af93228e37
e4af93228e37 probe: forget lease after a NAK
c39e1fe74463 connection: discard NAKs from other servers in SELECTING

git-subtree-dir: src/n-dhcp4
git-subtree-split: e4af93228e3772bbb443ec1237252e6a2f3e3dd7
2022-05-06 13:48:25 +02:00
Beniamino Galvani
e141cd45d6
n-dhcp4/probe: forget lease after a NAK
If we have a lease and we get a NAK renewing/rebinding it, the lease
is lost.

Without this, probe->current_lease remains set and after the next
DISCOVER/OFFER round, any call to n_dhcp4_client_lease_select() will
fail at:

        if (lease->probe->current_lease)
                return -ENOTRECOVERABLE;

As in:

 [5325.1313] dhcp4 (veth0): send REQUEST of 172.25.1.200 to 255.255.255.255
 [5325.1434] dhcp4 (veth0): received NACK from 172.25.1.1
 [5325.1435] dhcp4 (veth0): client event 3 (RETRACTED)
 [5325.1436] dhcp4 (veth0): send DISCOVER to 255.255.255.255
 [5325.1641] dhcp4 (veth0): received OFFER of 172.25.1.200 from 172.25.1.1
 [5325.1641] dhcp4 (veth0): client event (OFFER)
 [5325.1641] dhcp4 (veth0): selecting lease failed: -131 (ENOTRECOVERABLE)

Upstream: https://github.com/nettools/n-dhcp4/pull/33
Upstream: e4af93228e

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/993

e43b1791a3 ('Merge commit 'e23b3c9c3ac86b065eef002fa5c4321cc4a87df2' as 'shared/n-dhcp4'')
2022-05-06 10:23:03 +02:00
Thomas Haller
192864ed3d
c-list: re-import git-subtree for 'src/c-list'
git subtree pull --prefix src/c-list git@github.com:c-util/c-list.git main --squash
2022-05-06 10:02:17 +02:00
Thomas Haller
106825f7c5 Squashed 'src/c-list/' changes from a0970f12f1f4..b86ba656ac22
b86ba656ac22 c-list: add c_list_split()
76900e4e3625 build: align with new c-util style

git-subtree-dir: src/c-list
git-subtree-split: b86ba656ac22b00fe785b2f058123e807f97c109
2022-05-06 10:02:08 +02:00
Thomas Haller
e69f011d60
c-rbtree: re-import git-subtree for 'src/c-rbtree'
git subtree pull --prefix src/c-rbtree git@github.com:c-util/c-rbtree.git main --squash
2022-05-06 09:58:08 +02:00
Thomas Haller
8d2d37446d Squashed 'src/c-rbtree/' changes from 8aa7bd1828ee..9b9713aeb9ec
9b9713aeb9ec build: update docs
7d38954dfd69 c-rbtree: document c_rbtree_entry() better
401241d4db02 build: always build test-parallel
337eb6c06d48 build: declare meson dependency
5741c13745cc ci: switch to new c-util CI workflow
39f870caf0aa build: drop redundant _GNU_SOURCE
cd315e186cf0 build: define 'ptrace' option
a1fb0a3296ae build: drop old submodules
739c1e982d74 build: re-order build definitions alphabetically
e98d4ed5a863 build: rework dependency handling
f9dd3852b8de build: use both_libraries()

git-subtree-dir: src/c-rbtree
git-subtree-split: 9b9713aeb9eca98566a85c8c90a02942ea430819
2022-05-06 09:57:51 +02:00
Thomas Haller
c3b8ef3539
c-siphash: re-import git-subtree for 'src/c-siphash'
git subtree pull --prefix src/c-siphash git@github.com:c-util/c-siphash.git main --squash
2022-05-06 09:52:00 +02:00
Thomas Haller
2750002547 Squashed 'src/c-siphash/' changes from eb87a9c4a5b0..1da8a0d46bfd
1da8a0d46bfd build: align with new c-util style

git-subtree-dir: src/c-siphash
git-subtree-split: 1da8a0d46bfdf07dc263a33ea9f22682db7dbea0
2022-05-06 09:51:44 +02:00
Thomas Haller
2e2bc2a4c0
c-stdaux: re-import git-subtree for 'src/c-stdaux'
git subtree pull --prefix src/c-stdaux git@github.com:c-util/c-stdaux.git main --squash
2022-05-06 09:46:30 +02:00
Thomas Haller
1c260f5a96 Squashed 'src/c-stdaux/' changes from f20e1cf2dfb1..99fe83cd5698
99fe83cd5698 build: update copyright
344b3ca8ce29 build: declare meson dependency
0e0982fd327e ci: use v1 of cabuild
9d2dafc4aaa4 ci: enable matrix-mode
822e358e60bb ci: switch to new C-Util CI
45b322aa6fb4 ci: try out new cabuild workflow

git-subtree-dir: src/c-stdaux
git-subtree-split: 99fe83cd5698b406f1cd991989551aac299f3d29
2022-05-06 09:46:16 +02:00