Commit graph

27120 commits

Author SHA1 Message Date
Thomas Haller
45cb0ef403
contrib/checkpatch: use random name for git remote and clean up afterwards 2020-11-10 17:14:07 +01:00
Thomas Haller
9ebf5f938c
gitlab-ci: bump default-tag 2020-11-10 13:51:29 +01:00
Thomas Haller
7fa122394c
gitlab-ci: merge "check-ci-script" test with static checks
Certain parts of the code are entirely generated or must follow
a certain format that can be enforced by a tool. These invariants
must never fail:

  - ci-fairy generate-template (check-ci-script)
  - black python formatting
  - clang-format C formatting
  - msgfmt -vs

On the other hand, we also have a checkpatch script that checks
the current patch for common errors. These are heuristics and
only depend on the current patch (contrary to the previous type
that depend on the entire source tree).

Refactor the gitlab-ci tests:

- split "checkpatch" into "check-patch" and "check-tree".

- merge the "check-ci-script" test into "check-tree".
2020-11-10 13:51:29 +01:00
Thomas Haller
a5d92d78c6
gitlab-ci: cleanup ".gitlab-ci/{build,fedora-install,debian-install}.sh"
Now that the individual steps are no longer in .gitlab.yml but we
run a full shell script, clean it up to be better readable.

Also, we need to fail the script when any command fails.
2020-11-10 13:51:29 +01:00
Thomas Haller
d6cbbbcad3
contrib: install "udev" package with "debian/REQUIRED_PACKAGES"
"debian/REQUIRED_PACKAGES" is used by gitlab-ci to prepare the image. We require
"udev" package, if only to install "/usr/share/pkgconfig/udev.pc" to get the
udev directory.

Otherwise build fails with:

    Run-time dependency udev found: NO (tried pkgconfig)
    meson.build:371:2: ERROR: Dependency "udev" not found, tried pkgconfig
2020-11-10 13:51:29 +01:00
Thomas Haller
a51d17cffa
contrib: install "python{3,}-setuptools" package with "debian/REQUIRED_PACKAGES"
Odd, sometimes gitlab CI fails to use pip3 install, because setuptools
module is not installed. But only sometimes...

Explicitly install it.
2020-11-10 13:51:29 +01:00
Thomas Haller
b55f13406f
ovs: merge branch 'th/ovs-external-ids' (first part of feature)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/673
2020-11-10 13:50:00 +01:00
Thomas Haller
bac5dc99d7
core/ovs: refactor duplicate code in ovsdb_next_command() 2020-11-09 17:53:19 +01:00
Thomas Haller
9b5bb3e45c
core/ovs: split payload out of OvsdbMethodCall struct
Before, ovsdb_call_method() has a long list of arguments
to account for all possible commands. That does not scale.

Instead, introduce a separate OvsdbMethodPayload type and
only add a macro to allow passing the right parameters.
2020-11-09 17:53:18 +01:00
Thomas Haller
81863c959b
core/ovs: rename logging output for _LOGT_call()
The text should match the OvsdbCommand enum. If the enum
value is named OVSDB_ADD_INTERFACE, then we should print
"add-interface". Or alternatively, if you think spelling
out interface is too long, then the enum should be renamed.
I don't care, but name should correspond.
2020-11-09 17:53:18 +01:00
Thomas Haller
487c78733e
core/ovs: name union fields in OvsdbMethodCall
As we add more command types, the union gets more members.
Name each union field explicitly to match the OvsdbCommand
type.
2020-11-09 17:53:18 +01:00
Thomas Haller
2d8c5e9efa
core/ovs: cleanup debug logging for OVS command
- always print the JSON string as last (if present). Previously
  that didn't happen with OVSDB_SET_INTERFACE_MTU.

- introduce _QUOTE_MSG() macro.
2020-11-09 17:53:18 +01:00
Thomas Haller
1eeca3c606
core/ovs: track external-ids for cached ovsdb objects
We will need them later.
2020-11-09 17:53:18 +01:00
Thomas Haller
7cf1f7fe02
core/ovs: cleanup logic in update handling of ovsdb_got_update()
ovsdb sends monitor updates, with "new" and "old" values that indicate
whether this is an addition, and update, or a removal.

Since we also cache the entries, we might not agree with what ovsdb
says. E.g. if ovsdb says this is an update, but we didn't have the
interface in our cache, we should rather pretend that the interface
was added. Even if this possibly indicates some inconsistency between
what OVS says and what we have cached, we should make the best of it.

Rework the code. On update, we compare the result with our cache
and care less about the "new" / "old" values.
2020-11-09 17:53:18 +01:00
Thomas Haller
f6d3b5f5f4
core/ovs: change function signature of _free_{bridge,port,interface}
We will call the function directly as well. Lets aim to
get the types right.

Also the compiler would warn if the cast to (GDestroyNotify)
would be to a fundamtally different function signature.
2020-11-09 17:53:18 +01:00
Thomas Haller
7dc4d0c666
core/ovs: use helper functions to emit NM_OVSDB_* signals 2020-11-09 17:53:18 +01:00
Thomas Haller
cb3b6a2417
core/ovs: move code in "nm-ovsdb.c" around to have simple helpers at the top 2020-11-09 17:53:17 +01:00
Thomas Haller
e403f76544
core/ovs: track key for OpenvswitchInterface in same struct 2020-11-09 17:53:17 +01:00
Thomas Haller
51495e4e9a
core/ovs: track key for OpenvswitchPort in same struct 2020-11-09 17:53:17 +01:00
Thomas Haller
2094cbb5d1
core/ovs: track key for OpenvswitchBridge in same struct
GHashTable is optimized for data that has no separate value
pointer. We can use the OpenvswitchBridge structs as key themselves,
by having the id as first field of the structure and only use
g_hash_table_add().
2020-11-09 17:53:17 +01:00
Thomas Haller
263e92bf49
core/ovs: minor cleanup of logic in _add_interface() 2020-11-09 17:53:17 +01:00
Thomas Haller
8d78f8effb
core/ovs: avoid possible crash in _add_interface() 2020-11-09 17:53:17 +01:00
Thomas Haller
5d5b35285e
core/ovs: use streq() instead of strcmp() 2020-11-09 17:53:16 +01:00
Thomas Haller
7738955c2f
core/ovs: cleanup uses of g_slice_*() in "nm-ovsdb.c" 2020-11-09 17:53:16 +01:00
Thomas Haller
4cad3cfe88
core/ovs: fix using unsigned "mtu" value to json_pack()
Of course, in practice "mtu" is much smaller than 2^31, and
also is sizeof(int) >= sizeof(uint32_t) (on our systems). Hence,
this was correct. Still, it feels ugly to pass a unsigned integer
where not the entire range is covered.
2020-11-09 17:53:16 +01:00
Thomas Haller
e05edcfd7e
core/ovs: cleanup handling of call id for OVS commands
- rename "id" to something more distinct: "call_id".

- consistently use guint64 type. We don't want nor need
  to handle negative values. For CALL_ID_UNSPEC we can use
  G_MAXUINT64.

- don't use "i" format string for the call id. That expects
  an "int", so it's not clear how this was working correctly
  previously. Also, "int" has a smaller range than our 64bits.
  Use instead "json_int_t" and cast properly in the variadic
  arguments of json_pack().
2020-11-09 17:53:16 +01:00
Thomas Haller
609b08e2eb
core/ovs: fix leak of "NMOvsdbPrivate.db_uuid
Also, never update the value to %NULL. If the current
message does not contain a UUID, keep the previous one.

Fixes: 830a5a14cb ('device: add support for OpenVSwitch devices')
2020-11-09 17:53:16 +01:00
Thomas Haller
46e0a3374b
core/trivial: add FIXME comment about immutable applied-connection 2020-11-09 17:53:16 +01:00
Thomas Haller
d75c31afd0
device: refactor NMDevice's can_reapply_change() to return early
Don't have if-else-if structure, if we can always return from an
"if" block, once we matched the setting-name.
2020-11-09 17:53:16 +01:00
Thomas Haller
cc35dc3bdf
device: improve "nm-device-logging.h" to support a self pointer of NMDevice type
"nm-device-logging.h" defines logging macros for a NMDevice instance.
It also expects a "self" variable in the call environment, and that
variable had to be in the type of NMDevice or the NMDevice subclass.

Extend the macro foo, so that @self can be either a NMDevice* pointer
or a NMDevice$SUBTYPE.

Of course, that would have always been possible, if we would simply cast
to "(NMDevice *)" where we need it. The trick is that the macro only
works if @self is one of the two expected types, and not some arbitrary
unrelated type.
2020-11-09 17:53:16 +01:00
Thomas Haller
7d5ec103df
format: mark json_{object,array}_foreach() macors as ForEachMacros for clang-format 2020-11-09 17:53:15 +01:00
Thomas Haller
7e39e23f64
examples: add "ovs-external-ids.py" example script
And example script for getting and setting OVS external-ids.

Since currently there is no nmcli support for these properties yet,
the script becomes more interesting.

This "example" is rather long, and it showcases less the usage of
libnm (which is rather trivial, with respect to configuring
NMSettingOvsExternalIDs). Instead, it aims to provide a useful
command line tool for debugging. Hence, it's mostly concerned with
an elaborate command line syntax and useful print output.
2020-11-09 17:53:15 +01:00
Thomas Haller
6100b52e5c
libnm: add NMSettingOvsExternalIDs 2020-11-09 17:53:15 +01:00
Thomas Haller
0d083f5dab
libnm: add nm_utils_print() function
libnm supports verbose debug logging by setting "LIBNM_CLIENT_DEBUG"
environment variable. That mechanism uses g_printerr() (or g_print()).

When testing an application it's useful to combine printf debugging
with this debug logging. However, python's print() statement is
additionally buffered and not in sync with the logging functions that
libnm uses.

As far as I see, g_print() and g_printerr() is not accessible via
introspections/pygobject, probably because these are variadic functions.

Add nm_utils_print() to libnm. This ensures to use the same logging
mechanism as libnm.
2020-11-09 17:25:25 +01:00
Thomas Haller
336270edd5
shared/strbuf: add nm_str_buf_get_char() and nm_str_buf_get_str_at_unsafe() helpers 2020-11-09 17:25:25 +01:00
Thomas Haller
a3aa3725e5
shared,all: cleanup nm_utils_hashtable_equal*() functions
We have:

- nm_utils_hashtable_cmp(): this does a full cmp of two hash
  tables, with the intent to provide a stable sort order.
  It thus takes a GCompareDataFunc() argument.

- nm_utils_hashtable_cmp_equal(): this is like nm_utils_hashtable_cmp(),
  except that the caller won't get a compare value, only a boolean
  value that indicates equality.
  This was previously called nm_utils_hashtable_equal().

- nm_utils_hashtable_equal(): this takes a GEqualFunc function
  for comparing the values for equality. It takes thus
  a different kind of predicate, but otherwise is similar to
  nm_utils_hashtable_cmp_equal().
  This was previously called nm_utils_hash_table_equal().

Unify the naming of these functions.
2020-11-09 17:25:25 +01:00
Thomas Haller
d52c3b3c94
shared: use GEqualFunc instead of NMUtilsHashTableEqualFunc typedef 2020-11-09 17:25:25 +01:00
Thomas Haller
f4d472beab
shared: add nm_g_array_unref() helper 2020-11-09 17:25:24 +01:00
Thomas Haller
0cf4250021
shared: add nm_utils_strdict_clone() helper 2020-11-09 17:25:24 +01:00
Thomas Haller
571aeec933
shared: add nm_utils_named_value_clear_with_g_free() helper 2020-11-09 17:25:24 +01:00
Thomas Haller
c4d981959e
shared: add nm_utils_strdup_reset_take() helper 2020-11-09 17:25:24 +01:00
Thomas Haller
ac626c6892
libnm: fix assertion in nm_setting_user_set_data() to check input argument 2020-11-09 17:25:24 +01:00
Thomas Haller
9c3cfebe14
contrib: fix failure for "fedora/REQUIRED_PACKAGES" on CentOS 8 for "black"
Fixes: 86d3022ef5 ('contrib: add xargs/black/clang packages to fedora/REQUIRED_PACKAGES')
2020-11-09 15:48:29 +01:00
Yuri Chornoivan
d98bb16a65
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/674
2020-11-09 12:55:33 +01:00
Thomas Haller
aab7cf2065
gitlab-ci: don't explicitly install black/clang/gettext during checkpatch stage
"checkpatch" is based on the default image (currently fedora:33). It
already has these dependencies installed.
2020-11-09 10:53:55 +01:00
Thomas Haller
86d3022ef5
contrib: add xargs/black/clang packages to fedora/REQUIRED_PACKAGES
These packages are also used during CI tests (in the checkpatch
stage). They are also used for formatting C/python code, and thus
useful for developing.

Install them as part of REQUIRED_PACKAGES script.
2020-11-09 10:51:26 +01:00
Thomas Haller
f19f3f74c6
gitlab-ci: add ubuntu:20.04 test and reorder versions 2020-11-09 10:48:05 +01:00
Thomas Haller
cfc7688ec2
gitlab-ci: let Fedora 33 test always run
That is now the one that generates the pages and runs checkpatch stage.
2020-11-09 10:46:19 +01:00
Thomas Haller
b780f9315c
gitlab-ci: generate pages on Fedora 33 image
On one image we do extra work, like generating documentation (gitlab-pages).
The same image is currently also used for the "checkpatch" step. That step
checks code formatting using clang-format. The formatting depends on the
clang version, and we currently choose Fedora 33 as the desired version
for formatting.

It means, the "checkpatch" step requires Fedora 33. We could choose a
different image for generating pages and run check patch. However, that
might not be best. Just also generate the pages using Fedora 33.
2020-11-09 10:34:19 +01:00
Thomas Haller
52c6891534
gitlab-ci: reorder jobs for checkpatch test
All the steps of "checkpatch" test (except the last) check
the current tree for consistency. Those checks must always
pass.

Only the last step calls the "checkpatch-feature-branch.sh".
That script checks for common patterns, like avoiding g_assert()
(in favor of other assertion types). That last check only checks
the current patch, and there are many cases where the test is
known to fail (because these are just heuristics). As such, the
step that may fail should be called as last.
2020-11-09 09:35:59 +01:00