Commit graph

27137 commits

Author SHA1 Message Date
Beniamino Galvani 740191f7c0 core: add nm_ip_config_get_first_address() 2020-11-16 16:43:39 +01:00
Beniamino Galvani dfd2fcde0f shared: add c-list macros to iterate backwards 2020-11-16 16:43:39 +01:00
Aleksander Morgado 5b7ce438d9
wwan: update default connection timeout to 200s
The following merge request in ModemManager introduces a more or less
common timeout value for the connection attempts in all plugin and
protocol implementations:

  https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/merge_requests/391

The value chosen by default for the steps that may take long to
complete in a connection attempt is 180s, and 120s for the steps in
the disconnection path.

Until now, every different plugin or protocol had a different timeout
value, all of them <= 180s, and with that change in ModemManager, the
values are now aligned for all.

Note, though, that this does not mean that a connection attempt will
take always less than 180s, as there may be multiple other steps in
addition to the one that took the maximum timeout. The value chosen
for NetworkManager is a compromise between the new defaults from MM
and what the user would expect under e.g. very low quality conditions.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/678
2020-11-16 16:04:06 +01:00
Andrew Zaborowski c1ff06e119 iwd: Fix a use after free
In connection_removed we use the id.name that was being g_freed a few
lines further down.

Fixes: bea6c40367 ('wifi/iwd: handle forgetting connection profiles')
2020-11-12 19:58:08 +01:00
Thomas Haller ab3f18b906
ppp: drop unnecessary cast for return value of g_object_new() (manually) 2020-11-12 16:08:17 +01:00
Thomas Haller a2b5e22f82
all: drop unnecessary cast for return value of g_object_new()
C casts unconditionally force the type, and as such they don't
necessarily improve type safety, but rather overcome restrictions
from the compiler when necessary.

Casting a void pointer is unnecessary (in C), it does not make the
code more readable nor more safe. In particular for g_object_new(),
which is known to return a void pointer of the right type.

Drop such casts.

  sed 's/([A-Za-z_0-9]\+ *\* *) *g_object_new/g_object_new/g' $(git grep -l g_object_new) -i
  ./contrib/scripts/nm-code-format-container.sh
2020-11-12 16:03:09 +01:00
Thomas Haller 2f83777054
core/trivial: fix clang-format code formatting 2020-11-12 15:34:59 +01:00
Andrew Zaborowski 33b9fa3a3c manager: Keep volatile/external connections while referenced by async_op_lst
If an NMSettingsConnection with the VOLATILE or EXTENRAL flags is created
and passed to nm_manager_activate_connection, it's immediately scheduled
for deletion in an idle callback and will likely be deleted before the
authorization step in nm_manager_activate_connection finishes and the
connection will be aborted.  This is because there's no
NMActiveConnection in priv->active_connection_lst_head referencing it
until _internal_activate_device().  Change
active_connection_find_by_connection to also look for connections in
priv->async_op_lst_head.

New _delete_volatile_connection_do() calls are added.  Previously it
would be called when an active connection may have been removed from
priv->active_connection_lst_head, now also call it when an active
connection may have been removed from priv->async_op_lst_head without
being added to priv->active_connection_lst_head.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/671
2020-11-12 15:04:56 +01:00
Yuri Chornoivan a68903f05a
po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/676
2020-11-11 11:37:03 +01:00
Thomas Haller 8df0dee3e8
gitlab-ci: automatically run prep-container to fix hanging tests
The goal is to run most distros only manually. However, it would be nice
to avoid (manually) clicking twice to start the tests for one distro:
once for the container preparation, and once for the actual test.

Previously, the container prep part was set to manual and the actual
test automatic. It worked almost as desired, except that this leads
to the entire gitlab-ci pipeline be be in running state indefinitely.

To fix that, always run the container prep steps. If the container is
cached, this is supposed to be fast and cheap. Now only the actual tests
are marked as "manual".
2020-11-11 08:50:17 +01:00
Thomas Haller 767c83f443
gitlab-ci: add "needs" for pages test
It seems "pages" test does not get properly triggered, if only
t_fedora:33 completes. It should, because the other distros are
optional. Try to set "needs" to fix that.
2020-11-11 08:47:16 +01:00
Thomas Haller 31940037fa
device: fix _Generic() types for _NM_DEVICE_CAST() macro (2)
clang (x86_64, 3.4.2-9.el7) fails:

    ../src/devices/nm-device.c:957:9: error: controlling expression type 'typeof (*self) *const' (aka 'struct _NMDevice *const') not compatible with any generic association type
            _LOGT(LOGD_DEVICE,
            ^~~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-logging-fwd.h:162:20: note: expanded from macro '_LOGT'
    #define _LOGT(...) _NMLOG(_LOGL_TRACE, __VA_ARGS__)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/devices/nm-device-logging.h:34:81: note: expanded from macro '_NMLOG'
                const char *const    _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \
                                                                                    ^~~~~
    ../src/devices/nm-device-logging.h:14:63: note: expanded from macro '_NM_DEVICE_CAST'
        #define _NM_DEVICE_CAST(self) _NM_ENSURE_TYPE(NMDevice *, self)
                                                                  ^
    ../shared/nm-glib-aux/nm-macros-internal.h:664:53: note: expanded from macro '_NM_ENSURE_TYPE'
        #define _NM_ENSURE_TYPE(type, value) (_Generic((value), type : (value)))
                                                        ^

Fixes: cc35dc3bdf ('device: improve "nm-device-logging.h" to support a self pointer of NMDevice type')
2020-11-10 22:54:32 +01:00
Thomas Haller ebbc2c9c0d
build: fix handling NMTST_SKIP_PYTHON_BLACK for skipping make check-python-black test
Fixes: c537852231 ('build: optionally skip python black check by setting NMTST_SKIP_PYTHON_BLACK=1')
2020-11-10 20:21:03 +01:00
Thomas Haller 71eeec8c78
device: fix _Generic() types for _NM_DEVICE_CAST() macro
clang (x86_64, 3.4.2-9.el7) fails:

    ../src/devices/nm-device-6lowpan.c:161:9: error: controlling expression type 'typeof (*self) *const' (aka 'struct _NMDevice6Lowpan *const') not compatible with any generic association type
            _LOGW(LOGD_DEVICE, "could not get 6lowpan properties");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../shared/nm-glib-aux/nm-logging-fwd.h:165:20: note: expanded from macro '_LOGW'
    #define _LOGW(...) _NMLOG(_LOGL_WARN, __VA_ARGS__)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/devices/nm-device-logging.h:32:81: note: expanded from macro '_NMLOG'
                const char *const    _ifname = _nm_device_get_iface(_NM_DEVICE_CAST(_self)); \
                                                                                    ^~~~~
    ../src/devices/nm-device-logging.h:17:19: note: expanded from macro '_NM_DEVICE_CAST'
            _Generic((self), _NMLOG_DEVICE_TYPE *        \
                      ^

Fixes: cc35dc3bdf ('device: improve "nm-device-logging.h" to support a self pointer of NMDevice type')
2020-11-10 19:44:10 +01:00
Thomas Haller b96d48efca
gitlab-ci: fix building artifacts (pages) during gitlab-ci test 2020-11-10 19:43:55 +01:00
Thomas Haller 129756a9c2
gitlab-ci: skip python black check during make check for builds
We now install black by default via REQUIRED_PACKAGES script.
Thus, also when we build on Fedora 30, `make check` would run
python black. However, the formatting depends on the version
of python black, and the one in Fedora 30 is not right.

Skip all black tests during `make check`. We have a deicated
gitlab-ci test that runs black already (with the desired version
of black).
2020-11-10 19:06:03 +01:00
Thomas Haller 869ff96ad1
contrib/checkpatch: fix shallow repository for checkpatch script
The checkpatch test tests the patches on the merg-request, as they
branch off from master (or one of the stable branches).

It thus need the full git history, but the git repository might be a
shallow clone. Fix it.
2020-11-10 18:23:36 +01:00
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