Commit graph

31337 commits

Author SHA1 Message Date
Thomas Haller
412a5d2d08
libnm: show ethtool options in "gen-metadata-nm-settings-libnm-core.xml" 2022-11-10 13:00:50 +01:00
Thomas Haller
171f2c4ce3
libnm: skip "name" property for "gen-metadata-nm-settings-libnm-core.xml" 2022-11-10 09:36:53 +01:00
Thomas Haller
a0370e0efa
ethtool: add and use nm_ethtool_id_get_variant_type() helper 2022-11-10 09:36:53 +01:00
Thomas Haller
7f22835328
wwan/ofono: merge branch 'peat-psuwit:for-upstream/mr773-plus'
https://bugs.launchpad.net/bugs/1565717
https://bugs.launchpad.net/bugs/1579098
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/771
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/773

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1392
2022-11-10 07:56:28 +01:00
Ratchanan Srirattanamet
e34e38e744
wwan/ofono: cleanup comments and warnings in existing code 2022-11-10 07:54:24 +01:00
Ratchanan Srirattanamet
61e99ed715
wwan/ofono: fix memory leak in handle_settings()
[thaller@redhat.com: modified original patch.]

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')
2022-11-10 07:54:10 +01:00
Ratchanan Srirattanamet
f0ef4a440f
wwan/device-modem: re-check device availability after enable
It's possible that the modem is enabled outside of NM. If not
re-check, device could stay disabled throughout until something else
about the modem changes again.
2022-11-10 07:44:59 +01:00
Ratchanan Srirattanamet
2f3a0eaa0b
wwan/modem: return early if set_mm_enable is not implemented
We don't want to e.g. pre-empt the state change signal, because it's not
gonna happen.
2022-11-10 07:44:59 +01:00
Ratchanan Srirattanamet
580453d376
wwan/device-modem: disabled but not enable-able modem is unavailable
If a modem is disabled, and it has no method to enable it, then by no
mean it's "available" to NM.
2022-11-10 07:44:58 +01:00
Ratchanan Srirattanamet
f914df4f79
wwan/ofono: avoid bogus IP failure when not connecting
If modem is not at least "registered", a connection is not happening, which
means IP settings change is probably not interesting. Avoid trying to
parse it, so that we don't trigger connection failure when there isn't
one.
2022-11-10 07:44:58 +01:00
Ratchanan Srirattanamet
e7809a2bd7
wwan/ofono: clear current_octx on disconnect
This way, we won't signal failure when "PropertyChanged" signal for an
empty "Settings" eventually arrive.
2022-11-10 07:44:57 +01:00
Ratchanan Srirattanamet
5abc6f5911
wwan/ofono: also recognize connman's "Powered" property
This property "controls [oFono] whether packet radio use is allowed". It
makes sense to consider the value of FALSE to mean DISABLED.
2022-11-10 07:44:57 +01:00
Ratchanan Srirattanamet
ffbb8d2f51
wwan/ofono: when connect while searching, wait a bit
We don't have to outright refuse to connect if we're not registered.
Instead, wait up to 60 seconds for modem to register.
2022-11-10 07:44:56 +01:00
Bhushan Shah
9fc72bf75d
wwan/ofono: create connections based on available contexts
Downstream patches for this does it through NMSettings plugin, however
settings plugin are hard to maintain and complicated architecture wise
as well.

So directly create a connection profiles in-memory from the
nm-modem-ofono side. Those profiles are created in /run, and are not
added as a persistent connection, because connection state quite depends
on the state of ofono

This also allows us to drop the hack where we are keeping track of
active context/APN through the connection name, i.e if connection name
was in /imsi/context1 format, it was used. Instead now, Connection name
is actual context name which is user friendly ("Vodafone Connect" e.g.
in my case), and details like IMSI and context are stored internally.

[ratchanan@ubports.com:
- forward-ported to main branch.
- fold "wwan/ofono: handle context removal" into this commit.
- track the "preferred"-ness of the context and react accordingly.
  Creates proxies for all retrived contexts to listen to changes.
  While at it, also track name and type.
- use, instead of ignore, internet APN. Also support internet+mms APN.
- correct priv->contexts' value destroy function.
- factor out UUID generation as a helper function.
- handle the case where context dictionary is missing required keys.
- simplify nm_ofono_connection_new's arguments and rename to
  add_or_update_connection. Makes it handle the case where the
  connection already exists.
- also simplify other functions' arguments.
- clean up code and comments. Fix memory problems. Get rid of warnings.
]

Co-authored-by: Ratchanan Srirattanamet <ratchanan@ubports.com>
2022-11-10 07:44:56 +01:00
Thomas Haller
9e2ff9dabd
libnm: merge branch 'th/more-libnm-metadata-xml'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1449
2022-11-09 11:19:13 +01:00
Thomas Haller
112a399a17
libnm: add nm_utils_ensure_gtypes() helper to API
"gen-metadata-nm-settings-libnm-core.xml" now contains also the names of
the NMSetting types, like "NMSettingConnection". That can be useful
to create NMSetting instances generically (that is, without knowing
the C API that gets called).

So you might be tempted to run

    #!/bin/python

    import gi

    gi.require_version("NM", "1.0")
    from gi.repository import GObject, NM

    connection = NM.SimpleConnection()

    # NM.utils_ensure_gtypes()

    gtype_name = "NMSetting6Lowpan"
    gtype = GObject.type_from_name(gtype_name)
    setting = GObject.new(gtype)

    connection.add_setting(setting)

However, without NM.utils_ensure_gtypes() that would not work, because
the GType is not yet created. For a user who doesn't know a priory all
setting types, it's not entirely clear how to make this work. Well, a
GObject introspection user could iterate over al NM.Setting* names and
try to instantiate the classes. However, that is still cumbersome, and not
accessible to a C user (without GI) and the currently loaded libnm
library may be newer and have unknown setting types.

In particular plain C user would need to know to call all the right
nm_setting_*_get_type(), functions, so it needs to know all the existing
52 type getters (and cannot support those from a newer libnm version).

With nm_utils_ensure_gtypes(), the user can get the typename and create
instances generically only using g_type_from_name().

Possible alternatives:

 - libnm also has _nm_utils_init() which runs as __attribute__((constructor)).
   We could also always instantiate all GType there. However, I don't like running
   non-trivial, absolutely necessary code before main().
 - hook nm_setting_get_type() to create all GType for the NMSetting
   subclasses too. The problem is, that it's not entirely trivial to
   avoid deadlock.
 - hook nm_connection_get_type() to create all NMSetting types. That
   would not deadlock, but it still is questionable whether we should
   automatically, at non-obvious times instantiate all GTypes.
2022-11-08 13:13:59 +01:00
Thomas Haller
fd2d66953c
libnm: show NMSetting gtype in "gen-metadata-nm-settings-libnm-core.xml" 2022-11-08 13:13:58 +01:00
Thomas Haller
0f7117b4d2
libnm: show gprop-data,is-secret,is-secret-flags in "gen-metadata-nm-settings-libnm-core.xml" 2022-11-08 13:13:58 +01:00
Thomas Haller
7d9f65ebc4
libnm: add code comment in "gen-metadata-nm-settings-libnm-core.xml" 2022-11-08 13:13:58 +01:00
Thomas Haller
4f4f9807a4
libnm: use NMStrBuf in "gen-metadata-nm-settings-libnm-core.c"
It's more convenient to use, because we don't need to keep track
(and free) the allocated string.
2022-11-08 13:13:58 +01:00
Thomas Haller
82384b8fd8
platform: merge branch 'th/nmp-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1448
2022-11-08 12:58:27 +01:00
Thomas Haller
57b23c12cc
platform: only initialize actual data for stackinit NMPObject
The NMPObject is a tagged union. There is no need to initialize anything
after the size of the actually used union field. Change this, so maybe we
get a valgrind warning about uninitialized memory if we wrongly try to
access it.

On the other hand, the object really is supposed to be a full
NMPObject. Previously, we would get a valgrind warning, if we tried to
pass fewer data there.

It really doesn't matter much, but all other functions don't assume
that there is any important data after the size indicated by the class.
2022-11-08 12:57:24 +01:00
Thomas Haller
dd2c5044f6
platform: add internal helper function to get full NMPObject size 2022-11-08 12:54:44 +01:00
Thomas Haller
c9123c2ece
platform: extend cmd_obj_{hash_update,cmp}() hooks to check for identity
We will extend IPv4 routes with the list of next hops. This field will
be heap allocated and be part of the NMPObjectIP4Route object, while
also being part of the identity. To support the ID operator that checks
fields of the NMPObject, add a "for_id" argument to the hash/cmp hooks.

Also, a function that sets cmd_obj_{hash_update,cmp}() MUST not set
cmd_plobj_id_{hashupdate,cmp}(), as it would have overlapping
functionality. Therefore, the objects that define
cmd_obj_{hash_update,cmp}() need to fully implement the ID comparison.
2022-11-08 12:54:44 +01:00
Thomas Haller
ff63b2eb6e
platform: unify full/id hash/cmp implementations for NMPObject 2022-11-08 12:54:44 +01:00
Thomas Haller
5da0d18fbe
platform/tests: add unit test checking consistency of NMPClass 2022-11-08 12:54:35 +01:00
Thomas Haller
8feeb199ad
platform: drop redundant hook implementations from NMPObject classes
A NMPClass that has data outside the plobj part, needs
to implement the cmd_obj_*() hooks, instead of cmd_plobj_*().

For those objects, reasoning only about the plobj part is not
sufficient. Implementing both hooks is also unnecessary and
confusing.

Ensure that if we have cmd_obj_*() hooks set, that the corresponding
cmd_plobj_*() hooks are unset.
2022-11-08 12:53:46 +01:00
Thomas Haller
ee34eeafb9
platform: fix nmp_object_copy(id_only) for object that don't implement cmd_plobj_id_copy()
The if-else-if was wrong. It meant that if an object did not implement
cmd_plobj_id_copy(), nothign was copied (for id-only).

I think this code path was not actually hit, because we never clone
an object only by ID.

Fixes: c91a4617a1 ('nmp-object: allow missing implementations for certain virtual functions')
2022-11-08 12:53:41 +01:00
Yufan You
a275285537
supplicant: add NMSetting8021xAuthFlags for TLS v1.3 / enable a version
In the commit 2a11c57c4e ('libnm/wifi: rework NMSetting8021xAuthFlags
to explicitly disable TLS version'), it said:

> In the future, supplicant may disable options by default, and
> the inverse option can become interesting to configure
> "tls_disable_tlsv1_0=0". When that happens, we can solve it by
> adding another flag NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_ENABLE.

This commit adds the `NM_SETTING_802_1X_AUTH_FLAGS_TLS_1_0_ENABLE`
flag as well as similar flags for other TLS versions.

This commit also adds flags for TLS v1.3, as the corresponding flags
are now provided in wpa_supplicant.

The NMSetting8021xAuthFlags setting is rejected when both enable and
disable are set for the same TLS version. if-else-if is used in
nm_supplicant_config_add_setting_8021x to guarantee this behavior.
It prefers ENABLE over DISABLE to match the behavior of wpa_supplicant.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1450
2022-11-08 07:15:14 +01:00
Thomas Haller
8c779a7d8b
docs: fix typo in docs for upstream mailing list
Fixes: f25a6aad93 ('all: update references to our mailing list')
2022-11-07 17:50:29 +01:00
Lubomir Rintel
a0373a72db client: add_and_activate*() allow NULL device
Fix up the doc comment so that the gir data gets that right.

Fixes: 90d0ae0faf ('libnm: implement nm_client_activate_connection()/nm_client_add_and_activate_connection*() by using GDBusConnection directly')
2022-11-07 15:58:29 +01:00
Thomas Haller
ab6ecbb808
build: merge branch 'th/build-cleanup-compiler-warnings'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1445
2022-11-07 08:50:23 +01:00
Thomas Haller
abbacb1085
build: enable warnings "-Wint-conversion" and "-Wold-style-definition"
See https://lwn.net/Articles/913505/ .
2022-11-07 08:50:07 +01:00
Thomas Haller
4d2cb2d32b
build/autotools: add compiler warnings that we have in meson
Synchronize the compiler warnings for meson and autotools.
2022-11-07 08:50:07 +01:00
Thomas Haller
f3682588b2
build/meson: sort compiler flags in "meson.build"
Also remove duplicates.
2022-11-07 08:50:07 +01:00
Thomas Haller
c884d4d347
nm-setting: fix static assertions for NM_SETTING_PARAM_* flags and numeric values
- the static assertions were wrong, there was a "," instead of "==".

- the numeric values were wrong, as shown by the static assertions.

- move the code comment to the implementation. This does not seem
  relevant for the library user and should not be in the public header.

Fixes: 08e845f651 ('nm-setting: mangle public constant to make g-ir-scanner happy')
2022-11-07 08:36:10 +01:00
Lubomir Rintel
08e845f651 nm-setting: mangle public constant to make g-ir-scanner happy
Some versions of g-ir-scanner's C parser silently coerce unrecognized
symbols into zeroes [1]. Let's avoid that so that we don't end up with
wrong constants in our Gir data.

[1] https://gitlab.gnome.org/GNOME/gobject-introspection/-/merge_requests/366

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1446
2022-11-07 08:23:57 +01:00
Thomas Haller
e7b1fd9dbc
std-aux: add code comment to NM_BOOLEAN_EXPR() 2022-11-04 09:27:37 +01:00
Beniamino Galvani
8bd72d5f2e std-aux: fix NM_LIKELY()/NM_UNLIKELY() macros
Fix this compile error when "defined(__GNUC__) && (__GNUC__ > 2) &&
defined(__OPTIMIZE__)" doesn't match:

  In file included from ../src/libnm-std-aux/nm-default-std.h:102,
                   from ../src/libnm-std-aux/nm-std-utils.c:3:
  ../src/libnm-std-aux/nm-std-aux.h: In function ‘NM_ALIGN_TO’:
  ../src/libnm-std-aux/nm-std-aux.h:160:6: error: expected expression before ‘{’ token
    160 |     ({                                 \
        |      ^
  ../src/libnm-std-aux/nm-std-aux.h:169:31: note: in expansion of macro ‘_NM_BOOLEAN_EXPR_IMPL’
    169 | #define NM_BOOLEAN_EXPR(expr) _NM_BOOLEAN_EXPR_IMPL(NM_UNIQ, expr)
        |                               ^~~~~~~~~~~~~~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:175:27: note: in expansion of macro ‘NM_BOOLEAN_EXPR’
    175 | #define NM_LIKELY(expr)   NM_BOOLEAN_EXPR(expr)
        |                           ^~~~~~~~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:238:19: note: in expansion of macro ‘NM_LIKELY’
    238 |         } else if NM_LIKELY (cond) {                                  \
        |                   ^~~~~~~~~
  ../src/libnm-std-aux/nm-std-aux.h:449:5: note: in expansion of macro ‘nm_assert’
    449 |     nm_assert(nm_utils_is_power_of_two(ali));
        |     ^~~~~~~~~

The NM_LIKELY()/NM_UNLIKELY() macros should be alwas called enclosed
in parentheses like in:

 if (NM_LIKELY(i == 1)) ...

and should be expanded with only a single pair of parentheses so that
expressions like (i = 1) generate a compiler warning.

Fixes: 030d68aef7 ('shared: add nm_assert() to "nm-std-aux.h"')
2022-11-04 09:12:04 +01:00
Lubomir Rintel
941e8b70f8 libnm: export nm_setting_ip_config_get_dhcp_iaid
The export was left out when the symbol was added; apparently by
accident.

Let's also bump the documented version of when is the symbol supposed to
be available, because it actually wasn't.

Fixes: 56a1a5426a ('all: add ipvX.dhcp-iaid properties')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1447
2022-11-03 15:34:08 +01:00
Thomas Haller
dc26e65928
tests: add tests for generating stable UUIDs for keyfile/initrd
Fixes: 7ee0da3eaf ('build: don't "update-po" during make dist')
2022-11-03 09:23:57 +01:00
Thomas Haller
545edb7093
all: fix generating UUIDs for string
https://github.com/coreos/fedora-coreos-tracker/issues/1325

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

Fixes: b5e7e48bc1 ('glib-aux: add and use nm_uuid_generate_from_strings_old()')
2022-11-03 09:23:52 +01:00
Thomas Haller
311c97a83e
release: bump version to 1.41.4 (development) 2022-11-02 18:13:08 +01:00
Thomas Haller
28ab535617
initrd/tests: add unit test for autoconnect-priority setting
Fixes: 98575bd513 ('initrd: generate initrd generator profiles with autoconnect-priority -100')
2022-11-02 13:43:06 +01:00
Thomas Haller
f25a6aad93
all: update references to our mailing list
The mailing list migrated from GNOME (networkmanager-list@gnome.org)
to freedesktop (networkmanager@list.freedesktop.org).

See also https://mail.gnome.org/archives/networkmanager-list/2022-November/msg00000.html.
2022-11-02 12:58:57 +01:00
Thomas Haller
1d767bb1cd
gitignore: ignore "po/.Makefile.patched" file
Fixes: 7ee0da3eaf ('build: don't "update-po" during make dist')
2022-10-31 09:20:53 +01:00
Thomas Haller
c51e0b1f6d
build: merge branch 'th/gen-metadata-nm-settings-libnm-core'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1441
2022-10-31 09:15:23 +01:00
Thomas Haller
d699f76855
libnm: generate "gen-metadata-nm-settings-libnm-core.xml" with meta data
libnm-core-impl has lots of internal meta data about the properties.
In particular, which properties exist (their names), and their D-Bus
type.

We should use this information for our manual pages. For example,
currently `man nm-settings-dbus` has nonsense like: "Value Type: array
of string", when it should be reall "as".

In a first step, generate an XML with that meta data for later use.
2022-10-31 09:11:30 +01:00
Thomas Haller
1bfe908c2e
nmcli: rename "generate-docs-nm-settings-nmcli" to "gen-metadata-nm-settings-nmcli"
This is the better name, becuse this is not in particular about "docs".
It's about generating an XML with the information from the settings
meta data for nmcli.

We will do something similar with the libnm-core meta data.
2022-10-31 09:11:30 +01:00
Thomas Haller
139f4b4b2e
build: pass both filenames to "tools/check-compare-generated.sh" script
It just feels nicer to be explicit about the filenames and
not rely on a specific naming.

Also, in meson we can directly pass the target as argument, which
expands to the filename but also adds a dependency.
2022-10-31 09:11:30 +01:00