Commit graph

31450 commits

Author SHA1 Message Date
Lubomir Rintel
f2595067ef core/team: read teamd configuration asynchronously
This gets rid of some blocking calls in NMDeviceTeam.

What's left is the readout of port configurations.
2022-11-28 08:15:27 +01:00
Lubomir Rintel
75642f087a core/team: do D-Bus comms ourselves
The teamdtcl interface doesn't help us too much. It's just simple
synchronous wrappers around a straightforward API. Moreover it's libdbus
based, so it drags in another D-Bus client library (and makes it
impossible to trace the traffic with G_DBUS_DEBUG=message).

Let's do g_dbus_connection_call*() instead. Synchronously, for now, in
hopes of replacing with asynchronous calls eventually.
2022-11-28 08:15:27 +01:00
Lubomir Rintel
b1c8deeafe core/team: don't try to be too smart about timeouts
If we didn't get a bus name in time, there's likely not much to do. This
was probably in place before in hopes we'd fall back to the usock
backend.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
2b1490962c core/team: don't respawn teamd after kill
This unnecessarily complicated things.
We really only need to respawn once the bus name drops off.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
316fdb3026 core/team: do not care about who owns the bus name
We don't need to care about the processes, just the bus name.

We also don't need to kill out process, it's just going to die by itself
if it fails to grab the bus name. On top of that, the process that grabbed
the name might not even be the same as we spawned, there could have been
a fork in between. Don't assume too much.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
e377ce39d2 core/team: do not compare the configuration we got from teamd
It is never going to match! At the very least, teamd always adds
{ "device": "team0", "runner": { "name": "roundrobin" } }
2022-11-28 08:03:35 +01:00
Lubomir Rintel
9e21946568 core/team: save busname for later
We're going to use it once we do comms D-Bus ourselves.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
b1162f444a core/team: fold teamd_gone() into teamd_dbus_appeared()
No need for it to be separate now that the "usock" interface is gone.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
4c08edaab6 core/team: fold teamd_ready() into teamd_dbus_appeared()
No need for it to be separate now that the "usock" interface is gone.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
ed8b00c618 core/team: remove "usock" transport support
This can't be done asynchronously via libteam.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
72acb59971 core/team: don't wait for teamd -k (kill) to finish
This removes a synchronous operation.

Perhaps it might have been nice to watch the process finish and warn on
failure or something, but currently we don't do anything with the result
either.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
b792a74785 core/team: drop bad use of g_return_val_if_reached()
It's perfectly legal for teamdctl_alloc() to return NULL (on
out-of-memory conditions I guess) and we already handle it just fine.
No need to trip an assertion.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
7442a8296c core/team: avoid g_return_val_if_reached() when if_fail() is appropriate
This is nicer.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
6484318fe9 core/team: drop teamd_binary argument for teamd_kill()
It's just going to figure the real value for itself anyway.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
5cc0219cb7 core/team: turn a cannot-happen construct into asserts
This is just confusing and serves no purpose. Let's just bail out if we
know things are not right.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
eb6142d7c7 core/team: rename teamd_timeout to teamd_dbus_timeout
Make its purpose clearer.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
9ec3cab8bb core/team: kill _get_config()
Access priv->config directly instead.
2022-11-28 08:03:35 +01:00
Lubomir Rintel
8298a320c3 core/team: improve logging a little
I found the logging not too useful by default. Let's increase severity of
some logs, add some more.
2022-11-28 08:03:35 +01:00
Beniamino Galvani
953628a765 ovs: merge branch 'bg/ovs-port-trunks'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1467
https://bugzilla.redhat.com/show_bug.cgi?id=2111959
2022-11-25 14:25:47 +01:00
Beniamino Galvani
9ae0605055 libnm: accept "dot1q-tunnel" as vlan mode for ovs-ports
openvswitch accepts "dot1q-tunnel" as vlan mode:

    A dot1q-tunnel port is somewhat like an access port. Like an
    access port, it carries packets on the single VLAN specified
    in  the  tag  column and this VLAN, called the service VLAN,
    does not appear in an 802.1Q header for packets that ingress
    or  egress  on the port. The main difference lies in the be‐
    havior when packets that include a 802.1Q header ingress  on
    the  port.  Whereas  an  access  port  drops such packets, a
    dot1q-tunnel port treats these  as  double-tagged  with  the
    outer  service  VLAN  tag  and the inner customer VLAN taken
    from the 802.1Q header. Correspondingly, to  egress  on  the
    port,  a packet outer VLAN (or only VLAN) must be tag, which
    is removed before egress, which exposes the inner (customer)
    VLAN if one is present.

Support this mode.
2022-11-25 14:15:41 +01:00
Beniamino Galvani
1af7dc9c37 ovsdb: set port "trunks" property 2022-11-25 14:15:41 +01:00
Beniamino Galvani
b64e690db8 libnm: add ovs-port.trunks property
Add a new "ovs-port.trunks" property that indicates which VLANs are
trunked by the port.

At ovsdb level the property is just an array of integers; on the
command line, ovs-vsctl accepts ranges and expands them.

In NetworkManager the ovs-port setting stores the trunks directly as a
list of ranges.
2022-11-25 14:15:41 +01:00
Beniamino Galvani
041e38b151 libnm: add NMRange
The next commit is going to introduce a new object in libnm to
represent a range of ovs-port VLANs. A "range of integers" object
seems something that can be used for other purposes in the future, so
instead of adding an object specific for this case
(e.g. NMOvsPortVlanRange), introduce a generic NMRange object that
generically represents a range of non-negative integers.
2022-11-25 14:15:39 +01:00
Thomas Haller
29bec94ee8
loopback: merge branch 'wl/tmp'
https://bugzilla.redhat.com/show_bug.cgi?id=2060905
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1287

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1332
2022-11-25 08:52:54 +01:00
Wen Liang
121ba23c16
device: allow autoconnect on external
In some scenarios, autoconnect should not be blocked if the device is
activated on the external connection (e.g. autoconnect on the loopback
device).

Adding the `allow_autoconnect_on_external` flag to support such
behavior.
2022-11-24 18:04:56 +01:00
Wen Liang
e8618f03d7
support loopback interface
Support managing the loopback interface through NM as the users want to
set the proper mtu for loopback interface when forwarding the packets.
Additionally, the IP addresses, DNS, route and routing rules are also
allowed to configure for the loopback connection profiles.

https://bugzilla.redhat.com/show_bug.cgi?id=2060905
2022-11-23 20:51:22 +01:00
Thomas Haller
72e92e0a2b
policy: skip external devices in build_device_hostname_infos()
We soon will handle loopback, so -- if no loopback profile is activated
in NetworkManager -- we will have an externally managed profile on
loopback. This messes up the result.

In general, external connections don't make much sense for
build_device_hostname_infos(). Ignore them.
2022-11-23 20:51:21 +01:00
Thomas Haller
da29726b07
policy: skip external devices in any_devices_active()
any_devices_active() exists to avoid hostname update when no devices are
active. See [1] and commit b07f6712e9 ('policy: check for active
devices before triggering dns update on hostname change').

Soon, we will add support for loopback device, so "lo" will
almost always be activated (either externally or actively managed by
NetworkManager).

In any case, external devices should not count here, even if they appear
activating/activated.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1344303
2022-11-23 20:51:21 +01:00
Thomas Haller
18e107e098
std-aux: implement static-asserts via bitfields
The implementation for static asserts with (sizeof(char[(cond) ? 1 : -1]))
silently fails if the condition is not a compile time constant, because
it results in a VLA which is evaluated at runtime. Well, for that reason
we build with "-Wvla" to catch accidentally using a non-const expression
in a static assert. But still, we can do better. Use instead bitfields
to trigger the compiler error. This works only with static expressions
and also without "-Wvla".

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1468
2022-11-23 18:02:38 +01:00
Thomas Haller
e292c80da4
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-11-23 18:01:57 +01:00
Thomas Haller
634547635b Squashed 'src/c-stdaux/' changes from 4e78ffaea49d..2d3877aabd7d
2d3877aabd7d docs: avoid duplicate headers
ba751b517888 c-stdaux: be more consistent with #ifdef
9796f4a63a4b c-stdaux: move _c_always_inline_ to *-generic
34067b3a5f4f c-stdaux: avoid declspec-fallback for _c_public_
82b82245cf36 c-stdaux: expose _c_public_ in *-generic
37fa624afcd6 docs: set C_COMPILER_DOCS
7197bc75f829 docs: add ./src to include path
34ed5b2c4b52 test-basic: avoid _c_unused_
00cc51c99c64 test-basic: fix *_gnuc() fallback to have an argument
6a9262c168f7 test-basic: use strtol() over close() to set errno
807d4a704757 test-basic: guard cleanup-tests by GNUC
13f65ad8c27c test-basic: separate tests by module
fdf399ef7f5b test-api: only test for available APIs
1f9cfe8e3b2f c-stdaux: export C_MODULE_*
65bf768151e3 c-stdaux: move GNUC-macros into separate module
6549fa0eb8f3 c-stdaux: extract unix'ish code into separate module
d69c3c0fe7ee c-stdaux: split off portable code
132d82a37607 c-stdaux: add C_COMPILER_DOCS documentation
053b2d9f1c11 c-stdaux: avoid ctx-expr in c_assert()
e75f32c2e046 c-stdaux: fix typo in c_assert() docs
d75a2350ae22 c-stdaux: stub likely/unlikely as fallback
eb90a0d0fced c-stdaux: fix documentation of likely/unlikely
57f332c53184 c-stdaux: fix typo in c_closedir() docs
f3d6b60400d3 c-stdaux: add _c_always_inline_
8d017b02cf12 c-stdaux: provide target identification
3d8f78f964ff ci: enable windows builds

git-subtree-dir: src/c-stdaux
git-subtree-split: 2d3877aabd7d0e813f4a153ac262ee83b3c04793
2022-11-23 18:00:35 +01:00
Thomas Haller
bdeaf0ebb0
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-11-23 18:00:33 +01:00
Thomas Haller
571ba5a824 Squashed 'src/c-siphash/' changes from 04187aa367ee..4a8b5f42f0be
4a8b5f42f0be c-siphash: support SipHash variants other than SipHash24
60dd3c423a13 build: update AUTHORS
be0cd29ad7c9 c-siphash: fix typo
ad372ccd75f1 build: use module-definition files with MSVC
8ae0b4ca1a0c c-siphash: avoid empty initializers
fd2ae696dab3 ci: enable macos+windows builds

git-subtree-dir: src/c-siphash
git-subtree-split: 4a8b5f42f0be0248d2f1ebc19c5d053c9862f823
2022-11-23 18:00:33 +01:00
Thomas Haller
3ab5642d24
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-11-23 18:00:31 +01:00
Thomas Haller
25a5bb49a6 Squashed 'src/c-rbtree/' changes from edec411b3c1c..a4144785ab77
a4144785ab77 docs: include ./src in include path
efd6619234cd docs: use c-apidocs glob

git-subtree-dir: src/c-rbtree
git-subtree-split: a4144785ab77ecc0627898c7c60523b2368c6ecb
2022-11-23 18:00:31 +01:00
Thomas Haller
89cfd34ae0
gitlab-ci: extend run-test.sh script to manually select certain build steps to run
When the test in gitlab-ci fails, you might want to rerun the test
on your machine. You fire up podman, run "./.gitlab-ci/*-install.sh"
and "./.gitlab-ci/run-test.sh".

Make it possible to manually select parts that are tested by
"run-test.sh" by setting NM_TEST_SELECT_RUN. Otherwise, if you want to
test a particular configuration, you either have to run all earlier
steps (which takes a long time and can even be broken) or you have
to manually patch the file.

For example,

  NM_TEST_SELECT_RUN=6 ./.gitlab-ci/run-test.sh
2022-11-23 16:51:54 +01:00
Thomas Haller
2afadee27f
platform: workaround build error in nm_platform_ip4_route_hash_update() with old clang
clang-3.4.2-9.el7 does not like nesting NM_MAX() macro inside nm_hash_update_vals() macro.
Workaround by using MAX() instead. NM_MAX() uses an expression statement and NM_UNIQ()
to evaluate the arguments only once. We don't need that here and glib's MAX() suffices.

    CC       src/libnm-platform/src_libnm_platform_libnm_platform_la-nm-platform.lo
  ../src/libnm-platform/nm-platform.c:8247:53: error: in-class initializer for static data member is not a constant expression
                                      (guint8) NM_MAX(obj->weight, 1u));
                                                      ^
  ../src/libnm-std-aux/nm-std-aux.h:399:40: note: expanded from macro 'NM_MAX'
  #define NM_MAX(a, b) __NM_MAX(NM_UNIQ, a, NM_UNIQ, b)
                                         ^
  ../src/libnm-std-aux/nm-std-aux.h:402:39: note: expanded from macro '__NM_MAX'
          typeof(a) NM_UNIQ_T(A, aq) = (a);                                              \
                                        ^
  ../src/libnm-glib-aux/nm-hash-utils.h:124:36: note: expanded from macro 'nm_hash_update_vals'
          NM_HASH_COMBINE_VALS(_val, __VA_ARGS__);      \
                                     ^

Fixes: 8cc41d41fe ('platform: add NM_PLATFORM_IP_ROUTE_CMP_TYPE_ECMP_ID for comparing ECMP base route')
2022-11-23 16:28:34 +01:00
Thomas Haller
0be1b4d95d
clang-format,gitlab-ci: merge branch 'th/update-to-fedora37'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1463
2022-11-23 09:19:31 +01:00
Thomas Haller
941f998792
gitlab-ci: update default Fedora image for building pages and check steps
We want to follow current Fedora, so update to f37.

Also, we now use clang-format from Fedora 37 release, so the default
image in gitlab-ci must match, because that image is used for the
"check-tree" test.
2022-11-23 09:18:43 +01:00
Thomas Haller
1106146bfd
gitlab-ci: update to latest ci-templates version 2022-11-23 09:17:55 +01:00
Thomas Haller
853959b10d
clang-format: add reformatting commit to ".git-blame-ignore-revs" 2022-11-23 09:17:55 +01:00
Thomas Haller
3fb8c0f614
clang-format: reformat code with clang-format 15.0.4-1.fc37
This is the version shipped in Fedora 37. As Fedora 37 is now out, the
core developers switch to it. Our gitlab-ci will also use that as base
image for the check-{patch.tree} tests and to generate the pages. There
is a need that everybody agrees on which clang-format version to use,
and that version should be the one of the currently used Fedora release.

Also update the used Fedora image in "contrib/scripts/nm-code-format-container.sh"
script.

The gitlab-ci still needs update in the following commit. The change
in isolation will break the "check-tree" test.
2022-11-23 09:17:21 +01:00
Fernando Fernandez Mancera
fe7bea9685 merge: brnach 'ff/platform_ecmp'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1466
2022-11-22 09:37:31 +01:00
Thomas Haller
48d7d1d78e
platform: drop inline cmp() wrappers around "full" versions
We sometimes have functions foo() and foo_full(), in which case
foo() has fewer arguments and just calls foo_full(). The "full"
function here is the more powerful one, and foo() is implemented
in terms of the former.

nm_platform_ip4_route_cmp_full() and m_platform_ip4_route_cmp() inverted
that pattern. The "_full" there stands for the full comparison, to not
allowing to select the comparison type.

That inconsistency is ugly. Also, these wrappers were used at only few
places. Let's drop them.

While at it, also drop nm_platform_qdisc_cmp() and rename
nm_platform_qdisc_cmp_full(). Here cmp()/cmp_full() followed the common
pattern foo()/foo_full(), but it's still hardly used and unnecessary.
2022-11-21 17:56:48 +01:00
Thomas Haller
8cc41d41fe platform: add NM_PLATFORM_IP_ROUTE_CMP_TYPE_ECMP_ID for comparing ECMP base route 2022-11-21 17:46:34 +01:00
Thomas Haller
9270bf611f platform: add nm_platform_ip4_route_hash() helper 2022-11-21 11:19:39 +01:00
Fernando Fernandez Mancera
151b2bed36 platform: pass extra_hops to ip_route_add function
When adding a new route we need to consider it contains extra nexthops
i.e it is a ECMP route. As we cannot modify the NMPObject once created,
we need to pass the extra nexthops as an argument.

We cannot use the original NMPObject because normalization is happening
during when adding the route.
2022-11-21 11:19:19 +01:00
Fernando Fernandez Mancera
1bbdecf5e1 platform: manage ECMP routes
When reading from netlink an ECMP IPv4 route, we need to parse the
multiple nexthops. In order to do that, we are introducing
NMPlatformIP4RtNextHop struct.

The first nexthop information will be kept at the original
NMPlatformIP4Route and the new property n_nexthops will indicate how
many nexthops we need to consider.
2022-11-21 11:18:03 +01:00
NorwayFun
e2b343c41c
po: Georgian translation (ka) fixes
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1464
2022-11-21 08:59:45 +01:00
Thomas Haller
b2931c9621
build: fix dist-ing "src/libnm-lldp/meson.build" in release tarball
Fixes: 630de288d2 ('lldp: add libnm-lldp as fork of systemd's sd_lldp_rx')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1142
2022-11-18 16:16:40 +01:00