Commit graph

31604 commits

Author SHA1 Message Date
Thomas Haller
037fdcaf20
CONTRIBUTING: add hint for using cscope 2023-01-17 16:29:06 +01:00
Thomas Haller
8f13cb490b
build: fix make cscope step for removed directories 2023-01-17 16:29:05 +01:00
Thomas Haller
a45029b7b0
tests: merge branch 'th/leak-test-data'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1492
2023-01-17 16:27:41 +01:00
Thomas Haller
5d81b472dc
glib-aux: use struct initialization in nm_dedup_multi_index_new() 2023-01-17 16:26:51 +01:00
Thomas Haller
f1874e6790
glib-aux/tests: avoid valgrind leak with nmtst_add_test_func()
When only running a subset of the tests (with "-p"), then valgrind
indicates a leak. Avoid that.

  $ ./tools/run-nm-test.sh -m src/core/platform/tests/test-route-linux -v
  # no leak

  $ ./tools/run-nm-test.sh -m src/core/platform/tests/test-route-linux -v -p /route/ip4
  # many leaks:
  ==1662102== 107 (96 direct, 11 indirect) bytes in 1 blocks are definitely lost in loss record 388 of 448
  ==1662102==    at 0x4848464: calloc (vg_replace_malloc.c:1340)
  ==1662102==    by 0x4F615F0: g_malloc0 (gmem.c:163)
  ==1662102==    by 0x1621A6: _nmtst_add_test_func_full (nm-test-utils.h:918)
  ==1662102==    by 0x1623EB: _nmtstp_setup_tests (test-route.c:2179)
  ==1662102==    by 0x16E53D: main (test-common.c:2693)
  ==1662102==
  {
     <insert_a_suppression_name_here>
     Memcheck:Leak
     match-leak-kinds: definite
     fun:calloc
     fun:g_malloc0
     fun:_nmtst_add_test_func_full
     fun:_nmtstp_setup_tests
     fun:main
  }
2023-01-17 16:26:51 +01:00
Thomas Haller
43860e2b74
glib-aux/tests: add mechanims to track and free test data
This allows to free resources (a pointer) at the end of the test.
The purpose is to avoid valgrind warnings about leaks. While a leak
in the test is not a severe issue by itself, it does interfere with
checking for actual leaks. Thus every leak must be avoided.
2023-01-17 16:26:50 +01:00
Thomas Haller
d0dff07687
glib-aux/tests: embed testpath in NmtstTestData struct
Only allocate one chunk of memory to contain all data of
NmtstTestData.

This isn't about performance (which doesn't matter for test code).
It's about packing all in one struct and being able to free all at
once with a simple g_free(). We no longer need _nmtst_test_data_free()
with this.

Note that NmtstTestData is never mutated, it just holds some data.
As such, the single place where such a structure gets initialized,
can become a bit more complicated, in exchange for having a trivial
free operation (and anyway there no functions that modify the data
or that would care about the data layout).
2023-01-17 16:26:15 +01:00
Thomas Haller
e4104a9f12
glib-aux/tests: use struct initialization in _nmtst_add_test_func_full()
It's nicer, and doesn't require g_malloc0() to ensure all
fields are initialized.
2023-01-17 16:25:15 +01:00
Thomas Haller
eda7d08a02
glib-aux/tests: use C99 flexible array members for pointers in NmtstTestData
It's just nicer code. The previous code was correct, in particular, the
alignment of the data was most likely correct. Still, this is nicer.
2023-01-17 16:25:15 +01:00
Thomas Haller
6850766679
glib-aux/tests: expose current test name that is running under nmtst_add_test_func_full*() 2023-01-17 16:25:15 +01:00
Thomas Haller
3cd02b6ed6
libnm,platform: fix range for "weight" property of next hops for routes
In kernel, the valid range for the weight is 1-256 (on netlink this is
expressed as u8 in rtnh_hops, ranging 0-255).

We need an additional value, to represent

- unset weight, for non-ECMP routes in kernel.

- in libnm API, to express routes that should not be merged as ECMP
  routes (the default).

Extend the type in NMPlatformIP4Route.weight to u16, and fix the code
for the special handling of the numeric range.

Also the libnm API needs to change. Modify the type of the attribute on
D-Bus from "b" to "u", to use a 32 bit integer. We use 32 bit, because
we already have common code to handle 32 bit unsigned integers, despite
only requiring 257 values. It seems better to stick to a few data types
(u32) instead of introducing more, only because the range is limited.

Co-Authored-By: Fernando Fernandez Mancera <ffmancera@riseup.net>

Fixes: 1bbdecf5e1 ('platform: manage ECMP routes')
2023-01-17 14:05:13 +01:00
Lubomir Rintel
ff472d8e59 rpm: don't BR dhcp-client
We don't need the builder to install dhcp-client to build with support for
it. Requiring it to be installed it not great because it has runtime
implications -- it installs a dispatcher script.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1503
2023-01-17 13:56:57 +01:00
Thomas Haller
7af9562f28
device: fix available-connections for a device for user-request
There are two callers of available_connections_add(). One from
cp_connection_added_or_updated() (which is when a connection
gets added/modified) and one from nm_device_recheck_available_connections().

They both call first nm_device_check_connection_available() to see
whether the profile is available on the device. They certainly
need to pass the same check flags, otherwise a profile might
be available in some cases, and not in others.

I didn't actually test this, but I think this could result
in a profile wrongly not being listed as an available-connection.
Moreover, that might mean, that `nmcli connection up $PROFILE`
might work to find the device/profile, but `nmcli device up $DEVICE`
couldn't find the suitable profile (because the latter calls
nm_device_get_best_connection(), which iterates the
available-connections). I didn't test this, because regardless of
that, it seems obvious that the conditions for when we call
available_connections_add() must be the same from both places.
So the only question is what is the right condition, and it would
seem that _NM_DEVICE_CHECK_CON_AVAILABLE_FOR_USER_REQUEST is the right
flag.

Fixes: 02dbe670ca ('device: for available connections check whether they are available for user-request')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1496
2023-01-17 09:34:28 +01:00
Beniamino Galvani
f930d55fea all: add support for ovs-dpdk n-rxq-desc and n-txq-desc
https://bugzilla.redhat.com/show_bug.cgi?id=2156385

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1500
2023-01-17 08:45:04 +01:00
Thomas Haller
4721f83003
nmcli: avoid message about guessed wep-key-type when setting WEP password
$ nmcli --offline connection add type wifi con-name hotspot ssid hotspot-ssid wifi.mode ap wifi-sec.key-mgmt none wifi-sec.wep-key-type 1 wifi-sec.wep-key0 1234567890

would previously always print a message

  Info: WEP key is guessed to be of '1 (key)'

At least, when we explicitly set the key-type, this message is bogus.
Suppress it.

It's anyway questionable whether printing such warnings does anything good.
We would still get the warning with the arguments swapped, which seems wrong:

  $ nmcli --offline connection add type wifi con-name hotspot ssid hotspot-ssid wifi.mode ap wifi-sec.key-mgmt none wifi-sec.wep-key0 1234567890 wifi-sec.wep-key-type 1
  Info: WEP key is guessed to be of '1 (key)'

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1497
2023-01-16 10:28:29 +01:00
Thomas Haller
3b7e0ae083
firewall: merge branch 'th/iptables-wait'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1182

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1495
2023-01-16 10:20:09 +01:00
Thomas Haller
84a71771d9
firewall: pass "--wait 2" to iptables to wait for concurrent invocations
iptables takes a file lock at /run/xtables.lock. By default, if
the file is locked, iptables will fail with error. When that happens,
the iptables rules won't be configured, and the shared mode
(for which we use iptables) will not be setup properly.

Instead, pass "--wait 2", to block. Yes, it's ugly that we use
blocking program invocations, but that's how it is. Also, iptables
should be fast to not be a problem in practice.
2023-01-16 10:19:39 +01:00
Thomas Haller
53422c8693
firewall: automatically add iptables path to _share_iptables_call() call
No need to redundantly specify the path. Also, next we will specify the
"--wait" option, so this will work better.
2023-01-16 10:19:34 +01:00
Beniamino Galvani
58b7019b05 release: bump version to 1.41.8 (development) 2023-01-11 23:39:47 +01:00
Thomas Haller
b6122540fa
ovs: merge branch 'th/ovs-other-config'
https://bugzilla.redhat.com/show_bug.cgi?id=2151455

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1498
2023-01-11 21:49:53 +01:00
Thomas Haller
a259303e1d
ovs: add support for "other_config" settings
See `man ovs-vswitchd.conf.db` for documentation of "other_config" keys.

https://bugzilla.redhat.com/show_bug.cgi?id=2151455
2023-01-11 21:49:36 +01:00
Thomas Haller
8445b96b04
ovs: extend "external-ids" handle for supporting "other_config"
Next, support for "other_config" will be added. That is very similar
to "external_ids". Extend the existing code, to make that next update
simpler. The only purpose of this patch, is to reduce the diff of
when actually adding "other_config". Only in light of that, do some
of the changes here make sense.
2023-01-11 20:46:03 +01:00
Thomas Haller
79ca9b6412
ovs: rename internal code to make independent of "external-ids"
We will add support for "other_config". This is in many aspects similar
to "external-ids". So first do a renaming, so that the code can be
sensibly reused. This is a separate patch, so that the followup commit
has less noise in the diff.

This function *only* renames (and reformats). No other changes.
2023-01-11 20:41:45 +01:00
Thomas Haller
d219527dba
ovs: ensure existing "external-ids" get updated during reapply
"mutate" with operation "insert" does not update existing entries.
Delete them first.

Otherwise, a reapply that only change the value of an external-ids
entry does not work.

Note that https://www.rfc-editor.org/rfc/rfc7047 says about
"<mutations>":

  If <mutator> is "insert", then each of the key-value pairs in
  the map in <value> is added to <column> only if its key is not
  already present.  The required type of <value> is slightly
  relaxed, in that it may have fewer than the minimum number of
  elements specified by the column's type.

Fixes: 7055539c9f ('core/ovs: support setting OVS external-ids')
2023-01-11 20:33:57 +01:00
Thomas Haller
2641af2cc9
ovs: don't replace all "other_config" in _set_bridge_mac()
Doing an "update" is wrong, because that will replace all "other_config"
entries. We only want to reset the "hwaddr".

Note that https://www.rfc-editor.org/rfc/rfc7047 says about
"<mutations>":

  If <mutator> is "insert", then each of the key-value pairs in
  the map in <value> is added to <column> only if its key is not
  already present.  The required type of <value> is slightly
  relaxed, in that it may have fewer than the minimum number of
  elements specified by the column's type.

That means, we need to first delete, and then insert the key.

Fixes: 5d4c8521a3 ('ovs: set MAC address on the bridge for local interfaces')
2023-01-11 20:33:56 +01:00
Thomas Haller
17e16c8fa6
ovs: fix _external_ids_to_string() to print strdict in logging
Fixes: a4b13d5069 ('core/ovs: log external-ids of Interfaces/Ports/Bridges')
2023-01-11 20:33:51 +01:00
Thomas Haller
f79ecbd34a
libnm: move verify() for OVS connection type to separate function
Will be used next.
2023-01-11 12:45:35 +01:00
Thomas Haller
064fd6e6b0
libnm: fix message in GError in NMSettingOvsExternalIDs.verify() and documentation 2023-01-11 12:45:35 +01:00
Thomas Haller
96d01a5f8b
libnm: make NMSettingOvsExternalIDs.verify() deterministic
Iterating over a hash table is not deterministic. When we have
two invalid keys in ovs-external-ids, we should deterministically
get the same error message.

Instead, iterate over the (sorted) keys. This does have an overhead,
because we need to fetch the keys, and we need to lookup each value
by key. Still, correctness and determinism is more important.
2023-01-11 12:45:35 +01:00
Thomas Haller
4c2db6a3fd
glib-aux,libnm: add nm_ascii_is_regular_char() to validate keys for "ovs-external-ids"
The same will also be used by "ovs-other-config". Also, there should be
a general concept, meaning, we should have a function whether a character
is from some benign set, and not whether we have a character usable for
keys of "ovs-external-ids".
2023-01-11 12:45:35 +01:00
Beniamino Galvani
2c056cf9a3 dhcp: fix test for out-of-tree build
New files must be written to the build directory, not to the source
one.

Fixes: 5ee2f3d1dc ('dhcp/tests: refactor tests for nm_dhcp_dhclient_save_duid()')
2023-01-11 10:54:01 +01:00
Frederic Martinsons
4509c303fa
all: add new "ipv[46].auto-route-ext-gw" setting
For external gateway route management. This setting allows an user
to deactivate the automatic route addition to the external gateway.
It can be especially useful when a VPN inside another VPN is used.

Signed-off-by: Frederic Martinsons <frederic.martinsons@unabiz.com>

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1491
2023-01-09 09:35:52 +01:00
Wen Liang
2b23c2cab4 device: merge branch 'wl/improve_reapply'
https://bugzilla.redhat.com/show_bug.cgi?id=2117352

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1443
2023-01-05 12:27:15 -05:00
Thomas Haller
e17fe6335e dhcp: make _emit_notify() a macro to more conveniently construct notify data 2023-01-05 12:25:47 -05:00
Wen Liang
61e1027cc7 device: preserve the DHCP lease during reapply
When the connection setting changes at the first place, then calling
the device reapply, the ip address got temporarily removed when DHCP
restarted. To avoid the ip address got temporarily removed, we should
preserve the previous lease and keep using it until the new lease comes
along.
2023-01-05 12:25:47 -05:00
Wen Liang
5a816650bc device: merge arg for '_cleanup_ip_pre()' 2023-01-05 12:25:47 -05:00
Thomas Haller
da371f8108
ndisc/tests: fix reference counting in nm_fake_ndisc_new()
This adjusts the change from commit ffbcf01589 ('test-ndisc-fake:
free l3cfg after creating fake-ndisc').

ndisc_new() already correctly handles the reference count of l3cfg via
"gs_unref_object". The party that took the wrong reference was
nm_fake_ndisc_new().

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2023-01-05 12:13:39 +01:00
Thomas Haller
6c81f281eb
core: fix crash in nm_netns_ip_route_ecmp_commit()
#0  0x00000000004c53e0 in nm_netns_ip_route_ecmp_commit (self=0x27bde30, l3cfg=l3cfg@entry=0x2890810, out_singlehop_routes=out_singlehop_routes@entry=0x7ffd0cac3ce8)
      at src/core/nm-netns.c:686
  #1  0x00000000004b4335 in _commit_collect_routes
      (self=self@entry=0x2890810, addr_family=addr_family@entry=2, commit_type=commit_type@entry=NM_L3_CFG_COMMIT_TYPE_UPDATE, routes=routes@entry=0x7ffd0cac3de8, routes_nodev=routes_nodev@entry=0x7ffd0cac3de0) at src/core/nm-l3cfg.c:1183
  #2  0x00000000004b8982 in _l3_commit_one
      (self=self@entry=0x2890810, addr_family=addr_family@entry=2, commit_type=commit_type@entry=NM_L3_CFG_COMMIT_TYPE_UPDATE, changed_combined_l3cd=<optimized out>, l3cd_old=<optimized out>) at src/core/nm-l3cfg.c:4605
  #3  0x00000000004c0f52 in _l3_commit (self=self@entry=0x2890810, commit_type=NM_L3_CFG_COMMIT_TYPE_UPDATE, commit_type@entry=NM_L3_CFG_COMMIT_TYPE_AUTO, is_idle=is_idle@entry=1)
      at src/core/nm-l3cfg.c:4786
  #4  0x00000000004c11cb in _l3_commit_on_idle_cb (user_data=user_data@entry=0x2890810) at src/core/nm-l3cfg.c:3164
  #5  0x00007f532d02dcb2 in g_idle_dispatch (source=0x28f70c0, callback=0x4c116e <_l3_commit_on_idle_cb>, user_data=0x2890810) at ../glib/gmain.c:6124
  #6  0x00007f532d02ecbf in g_main_dispatch (context=0x27c2d60) at ../glib/gmain.c:3444

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

Fixes: 5b5ce42682 ('nm-netns: track ECMP routes')
2023-01-05 10:40:32 +01:00
Thomas Haller
ae7e7bf3d3
contrib: add "reexec" step to "nm-in-container.sh"
Just a shortcut for reset and exec.
2023-01-05 08:59:10 +01:00
Thomas Haller
897a96da7b
contrib: default to run same fedora version in nm-in-container.sh as host
If the out host runs Fedora, it's most useful that the container is the
same Fedora version. Detect it.
2023-01-05 08:17:24 +01:00
Thomas Haller
81527052d7
contrib: install more package in "nm-in-container.sh"
NM-ci wants to install a lot of packages when running the first test.
In particular, NM-ci has no nice script that lists all the dependencies,
so it's not immediately clear which packages are required.

Still, install some of those packages so that they are already present
when running the first NM-ci test.
2023-01-04 21:40:00 +01:00
yan12125
a92a0725b9
po: fix verb consistency in zh_TW
嚐試 and 嘗試 have the same meaning, and the latter is recommended [1].
Other translated texts in this file use 嘗試 as well.

[1] 鄒濬智。〈因古今字關係而形成之異形詞辨析〉。《國防大學通識教育學報》10 (2020): 123-133。 https://www.airitilibrary.com/Publication/alDetailedMesh?docid=P20160919001-202010-202011090010-202011090010-123-133

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1488
2023-01-02 10:04:13 +01:00
Yuri Chornoivan
bcd37e2df8
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1490
2023-01-02 09:42:19 +01:00
Frederic Martinsons
c62d6fa84e
Correct meson command examples
The change directory option must be after subcommand.
Moreover use directly build directory (which is default showing
in 'Building from Source' section)
The install command must specify the build directory

Signed-off-by: Frederic Martinsons <frederic.martinsons@unabiz.com>
2023-01-02 09:29:16 +01:00
Fernando Fernandez Mancera
bf34212345 merge: branch 'ff/ipv4_ecmp'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1365
2022-12-23 16:58:21 +01:00
Fernando Fernandez Mancera
b71e695c9b nm-netns: fix crash due to use of EcmpTrackObj after freeing it
When committing ECMP routes we are cleaning up dirty routes and freeing
the EcmpTrackObj. We need to free EcmpTrackObj only when it is not
needed anymore so it is the last thing we do when cleaning up the
routes.
2022-12-23 16:47:29 +01:00
Fernando Fernandez Mancera
ffbcf01589 test-ndisc-fake: free l3cfg after creating fake-ndisc
Considering nm_netns_l3cfg_acquire returns a l3cfg reference and only
keeps a weak reference we need to free l3cfg in fake-ndisc after
creating the object.
2022-12-23 16:47:29 +01:00
Fernando Fernandez Mancera
8b27a2b09a nm-netns: mark the ECMP route as needs_update when registering
If an L3Cfg try to register an ECMP route that we are tracking we must
mark it as needs_update because it means it could be dropped from
kernel. When merging them if the merged route didn't change we should
commit the route anyway because we know it needed update.
2022-12-23 16:47:29 +01:00
Fernando Fernandez Mancera
737cb5d424 nm-netns: add onlink routes for ECMP routes
When adding a static route, kernel enforce that the gateway is
reachable. To solve this, NetworkManager generates onlink routes for
each static route. As ECMP routes does not follow the same logic than
singlehop routes, we need to add the onlink route for each hop of ECMP
routes once merged.

NML3Cfg will take ownership of the onlink route added and will purge it
when it is not needed anymore.
2022-12-23 16:47:29 +01:00
Thomas Haller
5b5ce42682 nm-netns: track ECMP routes
Co-authored-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2022-12-23 16:47:29 +01:00