Commit graph

30703 commits

Author SHA1 Message Date
Thomas Haller
3d4906a3da
platform: add genl socket support for events and genl family
For generic netlink, the family-id is important. It changes when
loading/unloading a module, so we should not cache it indefinitely.
To get this right, takes some effort. For "nl80211", "nl802154"
and "wireguard", we only cache the family ID in relation to an
interface. If the module gets unloaded, the family ID also becomes
irrelevant and we need to re-fetch it the next time.

For generic families like "mptcp_pm" or "ethtool", they are commonly not
kernel modules and cannot be unloaded. So caching them would be
(probably) fine.

Still. Some generic netlink families emit notifications, and it will
be interesting to be able to handle them. Since that will be useful later,
start by doing something simple: let the generic netlink family also be
cached this way. Generic netlink will send notifications when a family gets
added/deleted, and we can use that to reliably cache the family ID.

We only care about a well-known set of generic families. Unlike libnl
(which has "struct genl_family" object to handle any family), we can hard
code the few we care about (NMPGenlFamilyType).

This adds the necessary infrastructure of NMLinuxPlatform to listen to
events on the generic netlink socket.
2022-07-19 12:36:57 +02:00
Thomas Haller
355331b779
platform: make FOR_EACH_DELAYED_ACTION() robust against integer overflow
Currently there is no problem. However, DelayedActionType is a packed
enum, and if we add a few more enum values, it might happen that
DELAYED_ACTION_TYPE_MAX is 0x8000 and DelayedActionType effectively
uint16_t.

When that happens, the code would become an infinite loop, because
0x8000 is not larger than DELAYED_ACTION_TYPE_MAX, but `<<= 1`
shifts out the bit, making it zero.

Avoid that.
2022-07-19 12:36:57 +02:00
Thomas Haller
d83bd8c6a0
platform: rename DELAYED_ACTION_TYPE_REFRESH_ALL_* enums to "all-rtnl"
We'll also have generic netlink things. Rename.
2022-07-19 12:36:56 +02:00
Thomas Haller
8d42b5c52a
platform: add delayed_action_schedule_refresh_all() helper and avoid refreshing tc cache
If nm_platform_get_cache_tc() is disabled, there is no need to refresh
it. Filter those flags out.

Also, don't duplicate the code and add a helper function
delayed_action_schedule_refresh_all().
2022-07-19 12:36:56 +02:00
Thomas Haller
a27e9b21cf
platform: rename rtnetlink specific enum values to be clearly about rtnl
We will have similar names which are about generic netlink. Rename to be
clear.
2022-07-19 12:36:56 +02:00
Thomas Haller
6ff6c1dfc1
platform: tighter pack structs and enums
Reorder fields in DelayedActionWaitForNlResponseData, so that
the struct size is optimal due to the alignment constraints.

Also, when we remember enum values and embed them somewhere, it's nice
if they only take the space actually needed. _nm_packed solves that.
2022-07-19 12:36:56 +02:00
Thomas Haller
baecadbe98
platform: rename RefreshAllInfo.addr_family to "addr_family_for_dump"
The term "addr_family" is used very frequently, and it usually is an
auto variable or a function parameter.

It is interesting to search where this field is used. So rename to give
it a unique (and better fitting) name.

While at it, use gint8 to encode the addr_family. It's always
sufficient, and this reduces the size of RefreshAllInfo from 8 bytes
to two.
2022-07-19 12:36:56 +02:00
Thomas Haller
3b58404712
platform: add NMPGenlFamilyType enum for generic netlink types
The genl types that we care about are well known. Add an enum
for them, so we can do a lookup by index.

To kernel, the corresponding names (like "wireguard") are also well
known. However, the family-id, that we need when using genl are
allocated dynamically. So we need to lookup the family-id, and by having
an enum for the genl type, we can do so generically.
2022-07-19 12:33:50 +02:00
Thomas Haller
9ef02ef7d0
platform/netlink: ensure padding is zero in _nest_end()
nla_reserve() also ensures that the padding is zero, and only the
padding. Thus, when we call nla_reserve(), we need to zero the padding
ourselves.
2022-07-19 12:33:49 +02:00
Thomas Haller
78dfc56a74
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-07-19 09:02:42 +02:00
Thomas Haller
0a46856689 Squashed 'src/c-stdaux/' changes from 1407a1fb2754..da7209900ef0
da7209900ef0 api: add c_memcmp()
2369947a563b build: use v1 ci-sphinx
d46a3eeaf30d build: mention documentation in README.md

git-subtree-dir: src/c-stdaux
git-subtree-split: da7209900ef065024db92b180dd8bc70440af9b4
2022-07-19 09:02:42 +02:00
Thomas Haller
7fc2bc7a29
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-07-19 09:02:38 +02:00
Thomas Haller
9358a0e184 Squashed 'src/c-rbtree/' changes from e56535a5daa5..edec411b3c1c
edec411b3c1c build: add RTD link to README.md
431a47467052 build: add RTD integration
e406cca122d7 build: import documentation builder
5f41b5d8ff75 ci: convert to new ci-c-util workflow

git-subtree-dir: src/c-rbtree
git-subtree-split: edec411b3c1c03985adb73e3f5b4c9a402206f5b
2022-07-19 09:02:38 +02:00
Thomas Haller
e2bedbf8a5
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-07-19 09:02:36 +02:00
Thomas Haller
d7fc80b9c7 Squashed 'src/c-list/' changes from fa024740fc6f..9aa81d84cadc
9aa81d84cadc ci: convert to new ci-c-util

git-subtree-dir: src/c-list
git-subtree-split: 9aa81d84cadc67e92b441c89f84c57e72dd1e8a9
2022-07-19 09:02:36 +02:00
Thomas Haller
8b20d2a856
contrib: add "git-subtree-reimport.sh" script 2022-07-19 08:53:47 +02:00
NorwayFun
2d891741aa
po: update Georgian (ka) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1301
2022-07-18 16:14:32 +02:00
Thomas Haller
4ef40700c4
core: merge branch 'th/cmdline-log-debug'
https://bugzilla.redhat.com/show_bug.cgi?id=2102313

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1297
2022-07-18 15:02:48 +02:00
Thomas Haller
5c84fe0db5
core: support "nm.debug" kernel command line to enable verbose logging
When NetworkManager runs in initrd, it can be cumbersome to enable debug logging.
Granted, when using dracut, the NetworkManager dracut module will honor "rd.debug".
However, a user may use NetworkManager in initrd without dracut. Then,
the only way to enable debug logging would be by changing
"NetworkManager.conf" and rebuild the initrd (or having some script in
place, that allows to more conveniently enable debug logging for
NetworkManager).

To make it easier for debugging, honor "nm.debug" on the kernel command
line.

Note that if "nm.debug" is set on the kernel command line, it always overrides
both the command line arguments and the configuration from NetworkManager.conf.
That is intentional. The only way to override that is by overriding the
kernel command line with a file "/run/NetworkManager/proc-cmdline".

https://bugzilla.redhat.com/show_bug.cgi?id=2102313
2022-07-18 15:00:04 +02:00
Thomas Haller
d4b7934997
core: support "/run/NetworkManager/proc-cmdline" to overwrite /proc/cmdline
We read /proc/cmdline for "match.kernel-command-line". But next we will
also honor "nm.debug" on the kernel command line, to enable debug
logging. For "nm.debug" it makes sense that it overwrites the debug
options from the command line and from "NetworkManager.conf". That
means, if you set "nm.debug", then verbose logging will be enabled. It
can only be turned off again at runtime (via D-Bus), otherwise, it's
hard to avoid.

It still can make sense to overrule this setting once again. Support
that, by honoring a file "/run/NetworkManager/proc-cmdline" to be used
instead of "/proc/cmdline".

This option is mainly for debugging and testing, but it might be useful
in production too, if you had "nm.debug" enabled during boot, but later
want to disable it until next reboot. Then you could do:

  sed 's/ *\<nm\.debug\> */ /g' /proc/cmdline > /run/NetworkManager/proc-cmdline
  nmcli general logging level DEFAULT domains DEFAULT
2022-07-18 14:58:00 +02:00
Thomas Haller
4dd4d5b759
glib-aux: don't use GPtrArray in nm_utils_strsplit_quoted()
GPtrArray requires an additional heap allocation for the GPtrArray.
Utterly useless in the majority of cases.

Anyway. Allocating (and exponentially grown) a buffer is not too hard,
just slightly more cumbersome. Since nm_utils_strsplit_quoted() is
heavily unit tested and entirely self-contained, let's opt for the
more complicated implementation and avoid the extra allocation.
2022-07-18 14:58:00 +02:00
Beniamino Galvani
e122df6005 core: merge branch 'bg/l3cd-dns-priority'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1045
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1298
2022-07-18 07:50:03 +02:00
Beniamino Galvani
8c17760f62 ppp,wwan: remove explicit initialization of DNS priority
It's no longer necessary, as modem devices get the priority from the
ipmanual configuration created from the profile.
2022-07-18 07:48:13 +02:00
Beniamino Galvani
0717589972 wwan: enable manual IP configuration
Before 1.36, manual addresses from the profile were assigned to the
interface; restore that behavior.

The manual IP configuration also contains the DNS priority from the
profile; so this change ensures that the merged l3cd has a DNS
priority and that dynamically discovered DNS servers are not ignored
by the DNS manager.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2022-07-18 07:48:12 +02:00
Beniamino Galvani
2ae8433520 device: add "is_manual" argument to ready_for_ip_config() device method
Some device types might want to run manual ip configuration while
skipping other methods.
2022-07-18 07:48:12 +02:00
Vojtech Bubela
5e4632f021
doc: preserve paraghraphs in nmcli man pages
Improve documentation by preserving paragraphs in the
nm-settings-nmcli man pages.

To do that structure of src/libnm-client-impl/nm-settings-docs-gir.xml
was changed to have "description" as subnode to property node instead
of attribute of property node. Another subnode "description-docbook"
was added - this node is then used when generating man pages.

tools/generate-docs-nm-settings-docs-gir.py and man/nm-settings-dbus.xsl
were also changed to accomodate for changes mentioned above.

Replace xsltproc tool with python script when generating
./src/libnmc-setting/settings-docs.h.

Deleted settings-docs.xsl since it was replaced by python script.

Change src/libnmc-setting/settings-docs.h.in accodring to newly
generated src/libnmc-setting/settings-docs.h

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1260
2022-07-15 17:25:15 +02:00
Thomas Haller
ff5541d875
libnm: add comment to libnm.ver about preserving existing version nodes 2022-07-15 09:31:55 +02:00
Thomas Haller
a9818692b8
policy: downgrade verbosity of hostname change logging message
This message seems not useful at <info> level. Downgrade logging level.
2022-07-15 09:22:56 +02:00
Antonio Alvarez Feijoo
218c8759fb man/nm-initrd-generator: add missing command line options
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1300
2022-07-14 21:32:48 +02:00
Lubomir Rintel
34c1497ee4 release: bump version to 1.39.10 (development) 2022-07-13 15:39:16 +02:00
Thomas Haller
9511ac7d20
examples: fix tracking destruction in destroy_nmc()
While iterating the context (once), multiple sources can be dispatched.
So if we get a timeout and shortly after the weak-ref callback, then
we still need to honor the weak-ref.

In particular, because weak_ref.unref() is not safe to do after
the object was already destroyed. So we need to be correct about
tracking destruction.
2022-07-13 10:05:12 +02:00
Fernando Fernandez Mancera
4655b7c308 veth: fix veth activation on booting
When creating one profile for each veth during activation the creation
of the veth could fail. When the link for the first profile is created
the link for the peer is generated in kernel. Therefore when trying to
activate the second profile it will fail because the link already
exists. NetworkManager must check if the link already exists and
corresponds to the same veth, if so, it should skip the link creation.

https://bugzilla.redhat.com/show_bug.cgi?id=2036023
https://bugzilla.redhat.com/show_bug.cgi?id=2105956
2022-07-12 13:34:18 +02:00
Beniamino Galvani
1784fc9fa1 core: update DNS when the device enters IP_CONFIG state
Update DNS information when the device enters the IP_CONFIG state. In
this way, when dispatcher events "dhcp4-change,dhcp6-change" are
emitted resolv.conf already contains the information received from
the DHCP lease.

https://bugzilla.redhat.com/show_bug.cgi?id=2100456
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1283
2022-07-11 15:51:37 +02:00
Beniamino Galvani
2504a72ec0 initrd: set a default carrier timeout of 10 seconds in initrd
In initrd, a too short carrier timeout means that the machine will
possibly fail to boot. On the other hand, increasing the value doesn't
have side effects, except for a bit longer delay on some machines.

Increase the value to 10 seconds. Note that the default value is not
propagated to the real root.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1239
2022-07-11 15:47:40 +02:00
Lubomir Rintel
8d12cc8152 contrib/rpm: untangle setting of bcond_{test,debug} defaults
Resolve the defaults in build.sh instead of RPM macros. This looks less
terrible maintaining the same defaults as well as options to override it
upstream.

Moving it to the block that downstreams (Fedora, Red Hat) keep
customized makes it possible for them to also maintain customized
defaults here.

In particular, the downstreams should be able to enable bcond_test
at least for their production release (otherwise there's little point in
actually running tests at package build time).

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1286
2022-07-10 20:49:05 +02:00
Lubomir Rintel
880bec0f4f release: bump version to 1.39.9 (development) 2022-07-07 14:53:15 +02:00
Thomas Haller
556bff1767
systemd: merge branch systemd into main
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1291
2022-07-07 00:50:46 +02:00
Thomas Haller
b12281089c
gitlab-ci: fix unit tests on centos7 for python-pexpect dependency
Fixes: 9570224e86 ('tests/client: add a pexpect-based test runner')
2022-07-06 18:36:52 +02:00
Thomas Haller
8dff528195
clang-format: merge branch 'th/gitlab-ci-update'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1242
2022-07-06 11:09:28 +02:00
Thomas Haller
b428de6916
add reformatting commit to ".git-blame-ignore-revs" 2022-07-06 11:08:23 +02:00
Thomas Haller
d8a4b3bec2
all: reformat with clang-format (clang-tools-extra-14.0.0-1.fc36) and update gitlab-ci to f36 2022-07-06 11:06:53 +02:00
Thomas Haller
30d89a121d
contrib: fix "nm-python-black-format.sh" script to ignore systemd,c-util,nettools files
Otherwise, the path "src/c-stdaux/src/docs/conf.py" matches for
formatting. But this file is imported via git-subtree, we don't
want to format it.

Filter out such paths.
2022-07-06 10:44:18 +02:00
Thomas Haller
42a70ce1d9
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-07-06 10:16:01 +02:00
Thomas Haller
9d1772bd73 Squashed 'src/c-stdaux/' changes from 99fe83cd5698..1407a1fb2754
1407a1fb2754 ci: add clang to RTD scripts
8404c4ca6d06 ci: build documentation
044c65c2e134 docs: add sphinx-based API documentation
ad8449068d96 ci: use ci-c-util for macos runs
179987035687 build: adjust for v1.1.0 release
55d787178c84 build: prepare v1.1.0 release
29ca943e636a c-stdaux: avoid NULL arithmetic even in dead-code
c6358e956c29 c-stdaux: avoid NULL-dereference in constant expressions
7fab258bdf6a c-stdaux: improve kerneldoc comments
434b75a796c0 build: export 'version-scripts' configuration
33d56a6aecb9 c-stdaux: encapsulate C_EXPR_ASSERT()
aca7ee0ece60 ci: add macos run
0aa338b1f0de test: prefer pipe() over eventfd() for portability
adda5ff3e9d9 build: export cflags via pkg-config
7a8493bebc59 api: add c_memcpy()
a01615aefe48 build: prepare v1.0.0
1685fc39db3d api: provide c_memzero()
1257244f886a api: add c_memset()

git-subtree-dir: src/c-stdaux
git-subtree-split: 1407a1fb275494f9efc1abbef2fd19856fb1f43d
2022-07-06 10:15:51 +02:00
Thomas Haller
18f14d044d
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-07-06 10:14:28 +02:00
Thomas Haller
f852f532b0 Squashed 'src/c-siphash/' changes from 1da8a0d46bfd..04187aa367ee
04187aa367ee build: prepare v1.0.0 release
0e41909e19e1 build: use libcstdaux.version-scripts
203347c4d3e4 build: drop --no-undefined

git-subtree-dir: src/c-siphash
git-subtree-split: 04187aa367ee24dcbfb23678558b6efa31fd6511
2022-07-06 10:13:02 +02:00
Thomas Haller
8fdcd7030c
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-07-06 10:07:14 +02:00
Thomas Haller
49f854886e Squashed 'src/c-rbtree/' changes from eb778d39694a..e56535a5daa5
e56535a5daa5 c-rbtree: add overview comments
e1187dd4f56c c-rbtree: improve doc-strings
5c58005f4352 build: bump version
becd70d97145 build: prepare v3.1.0 release
1d865e41b95f build: use libcstdaux.version-scripts
2d4fccbc0095 build: synchronize AUTHORS
b6af0681629a meson: no longer pass -Wl,--no-undefined explicitly
7995758e8540 ci: run on macos

git-subtree-dir: src/c-rbtree
git-subtree-split: e56535a5daa598f329ad05ffb9a9f38585496f34
2022-07-06 10:06:23 +02:00
Thomas Haller
7d2bf498ca
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-07-06 10:04:09 +02:00
Thomas Haller
130ac3e3a9 Squashed 'src/c-list/' changes from b86ba656ac22..fa024740fc6f
fa024740fc6f build: prepare v3.1.0 release

git-subtree-dir: src/c-list
git-subtree-split: fa024740fc6f0e244afb3eed888f95bffdf36323
2022-07-06 09:45:34 +02:00