Commit Graph

24524 Commits

Author SHA1 Message Date
Thomas Haller
ee52656ce3 libnm: merge branch 'th/libnm-no-dbus-codegen-4'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/331
2019-11-25 15:16:36 +01:00
Thomas Haller
ce0e898fb4 libnm: refactor caching of D-Bus objects in NMClient
No longer use GDBusObjectMangaerClient and gdbus-codegen generated classes
for the NMClient cache. Instead, use GDBusConnection directly and a
custom implementation (NMLDBusObject) for caching D-Bus' ObjectManager
data.

CHANGES
-------

- This is a complete rework. I think the previous implementation was
difficult to understand. There were unfixed bugs and nobody understood
the code well enough to fix them. Maybe somebody out there understood the
code, but I certainly did not. At least nobody provided patches to fix those
issues. I do believe that this implementation is more straightforward and
easier to understand. It removes a lot of layers of code. Whether this claim
of simplicity is true, each reader must decide for himself/herself. Note
that it is still fairly complex.

- There was a lingering performance issue with large number of D-Bus
objects. The patch tries hard that the implementation scales well. Of
course, when we cache N objects that have N-to-M references to other,
we still are fundamentally O(N*M) for runtime and memory consumption (with
M being the number of references between objects). But each part should behave
efficiently and well.

- Play well with GMainContext. libnm code (NMClient) is generally not
thread safe. However, it should work to use multiple instances in
parallel, as long as each access to a NMClient is through the caller's
GMainContext. This follows glib's style and effectively allows to use NMClient
in a multi threaded scenario. This implies to stick to a main context
upon construction and ensure that callbacks are only invoked when
iterating that context. Also, NMClient itself shall never iterate the
caller's context. This also means, libnm must never use g_idle_add() or
g_timeout_add(), as those enqueue sources in the g_main_context_default()
context.

- Get ordering of messages right. All events are consistently enqueued
in a GMainContext and processed strictly in order. For example,
previously "nm-object.c" tried to combine signals and emit them on an
idle handler. That is wrong, signals must be emitted in the right order
and when they happen. Note that when using GInitable's synchronous initialization
to initialize the NMClient instance, NMClient internally still operates fully
asynchronously. In that case NMClient has an internal main context.

- NMClient takes over most of the functionality. When using D-Bus'
ObjectManager interface, one needs to handle basically the entire state
of the D-Bus interface. That cannot be separated well into distinct
parts, and even if you try, you just end up having closely related code
in different source files. Spreading related code does not make it
easier to understand, on the contrary. That means, NMClient is
inherently complex as it contains most of the logic. I think that is
not avoidable, but it's not as bad as it sounds.

- NMClient processes D-Bus messages and state changes in separate steps.
First NMClient unpacks the message (e.g. _dbus_handle_properties_changed()) and
keeps track of the changed data. Then we update the GObject instances
(_dbus_handle_obj_changed_dbus()) without emitting any signals yet. Finally,
we emit all signals and notifications that were collected
(_dbus_handle_changes_commit()). Note that for example during the initial
GetManagedObjects() reply, NMClient receive a large amount of state at once.
But we first apply all the changes to our GObject instances before
emitting any signals. The result is that signals are always emitted in a moment
when the cache is consistent. The unavoidable downside is that when you receive
a property changed signal, possibly many other properties changed
already and more signals are about to be emitted.

- NMDeviceWifi no longer modifies the content of the cache from client side
during poke_wireless_devices_with_rf_status(). The content of the cache
should be determined by D-Bus alone and follow what NetworkManager
service exposes. Local modifications should be avoided.

- This aims to bring no API/ABI change, though it does of course bring
various subtle changes in behavior. Those should be all for the better, but the
goal is not to break any existing clients. This does change internal
(albeit externally visible) API, like dropping NM_OBJECT_DBUS_OBJECT_MANAGER
property and NMObject no longer implementing GInitableIface and GAsyncInitableIface.

- Some uses of gdbus-codegen classes remain in NMVpnPluginOld, NMVpnServicePlugin
and NMSecretAgentOld. These are independent of NMClient/NMObject and
should be reworked separately.

- While we no longer use generated classes from gdbus-codegen, we don't
need more glue code than before. Also before we constructed NMPropertiesInfo and
a had large amount of code to propagate properties from NMDBus* to NMObject.
That got completely reworked, but did not fundamentally change. You still need
about the same effort to create the NMLDBusMetaIface. Not using
generated bindings did not make anything worse (which tells about the
usefulness of generated code, at least in the way it was used).

- NMLDBusMetaIface and other meta data is static and immutable. This
avoids copying them around. Also, macros like NML_DBUS_META_PROPERTY_INIT_U()
have compile time checks to ensure the property types matches. It's pretty hard
to misuse them because it won't compile.

- The meta data now explicitly encodes the expected D-Bus types and
makes sure never to accept wrong data. That would only matter when the
server (accidentally or intentionally) exposes unexpected types on
D-Bus. I don't think that was previously ensured in all cases.
For example, demarshal_generic() only cared about the GObject property
type, it didn't know the expected D-Bus type.

- Previously GDBusObjectManager would sometimes emit warnings (g_log()). Those
probably indicated real bugs. In any case, it prevented us from running CI
with G_DEBUG=fatal-warnings, because there would be just too many
unrelated crashes. Now we log debug messages that can be enabled with
"LIBNM_CLIENT_DEBUG=trace". Some of these messages can also be turned
into g_warning()/g_critical() by setting LIBNM_CLIENT_DEBUG=warning,error.
Together with G_DEBUG=fatal-warnings, this turns them into assertions.
Note that such "assertion failures" might also happen because of a server
bug (or change). Thus these are not common assertions that indicate a bug
in libnm and are thus not armed unless explicitly requested. In our CI we
should now always run with LIBNM_CLIENT_DEBUG=warning,error and
G_DEBUG=fatal-warnings and to catch bugs. Note that currently
NetworkManager has bugs in this regard, so enabling this will result in
assertion failures. That should be fixed first.

- Note that this changes the order in which we emit "notify:devices" and
"device-added" signals. I think it makes the most sense to emit first
"device-removed", then "notify:devices", and finally "device-added"
signals.
This changes behavior for commit 52ae28f6e5 ('libnm: queue
added/removed signals and suppress uninitialized notifications'),
but I don't think that users should actually rely on the order. Still,
the new order makes the most sense to me.

- In NetworkManager, profiles can be invisible to the user by setting
"connection.permissions". Such profiles would be hidden by NMClient's
nm_client_get_connections() and their "connection-added"/"connection-removed"
signals.
Note that NMActiveConnection's nm_active_connection_get_connection()
and NMDevice's nm_device_get_available_connections() still exposes such
hidden NMRemoteConnection instances. This behavior was preserved.

NUMBERS
-------

I compared 3 versions of libnm.

  [1] 962297f9085d, current tip of nm-1-20 branch
  [2] 4fad8c7c64, current master, immediate parent of this patch
  [3] this patch

All tests were done on Fedora 31, x86_64, gcc 9.2.1-1.fc31.
The libraries were build with

  $ ./contrib/fedora/rpm/build_clean.sh -g -w test -W debug

Note that RPM build already stripped the library.

---

N1) File size of libnm.so.0.1.0 in bytes. There currently seems to be a issue
  on Fedora 31 generating wrong ELF notes. Usually, libnm is smaller but
  in these tests it had large (and bogus) ELF notes. Anyway, the point
  is to show the relative sizes, so it doesn't matter).

  [1] 4075552 (102.7%)
  [2] 3969624 (100.0%)
  [3] 3705208 ( 93.3%)

---

N2) `size /usr/lib64/libnm.so.0.1.0`:

          text             data              bss                dec               hex   filename
  [1]  1314569 (102.0%)   69980 ( 94.8%)   10632 ( 80.4%)   1395181 (101.4%)   1549ed   /usr/lib64/libnm.so.0.1.0
  [2]  1288410 (100.0%)   73796 (100.0%)   13224 (100.0%)   1375430 (100.0%)   14fcc6   /usr/lib64/libnm.so.0.1.0
  [3]  1229066 ( 95.4%)   65248 ( 88.4%)   13400 (101.3%)   1307714 ( 95.1%)   13f442   /usr/lib64/libnm.so.0.1.0

---

N3) Performance test with test-client.py. With checkout of [2], run

```
prepare_checkout() {
    rm -rf /tmp/nm-test && \
    git checkout -B test 4fad8c7c64 && \
    git clean -fdx && \
    ./autogen.sh --prefix=/tmp/nm-test && \
    make -j 5 install && \
    make -j 5 check-local-clients-tests-test-client
}
prepare_test() {
    NM_TEST_REGENERATE=1 NM_TEST_CLIENT_BUILDDIR="/data/src/NetworkManager" NM_TEST_CLIENT_NMCLI_PATH=/usr/bin/nmcli python3 ./clients/tests/test-client.py -v
}
do_test() {
  for i in {1..10}; do
      NM_TEST_CLIENT_BUILDDIR="/data/src/NetworkManager" NM_TEST_CLIENT_NMCLI_PATH=/usr/bin/nmcli python3 ./clients/tests/test-client.py -v || return -1
  done
  echo "done!"
}
prepare_checkout
prepare_test
time do_test
```

  [1]  real 2m14.497s (101.3%)     user 5m26.651s (100.3%)     sys  1m40.453s (101.4%)
  [2]  real 2m12.800s (100.0%)     user 5m25.619s (100.0%)     sys  1m39.065s (100.0%)
  [3]  real 1m54.915s ( 86.5%)     user 4m18.585s ( 79.4%)     sys  1m32.066s ( 92.9%)

---

N4) Performance. Run NetworkManager from build [2] and setup a large number
of profiles (551 profiles and 515 devices, mostly unrealized). This
setup is already at the edge of what NetworkManager currently can
handle. Of course, that is a different issue. Here we just check how
long plain `nmcli` takes on the system.

```
do_cleanup() {
    for UUID in $(nmcli -g NAME,UUID connection show | sed -n 's/^xx-c-.*:\([^:]\+\)$/\1/p'); do
        nmcli connection delete uuid "$UUID"
    done
    for DEVICE in $(nmcli -g DEVICE device status | grep '^xx-i-'); do
        nmcli device delete "$DEVICE"
    done
}

do_setup() {
    do_cleanup
    for i in {1..30}; do
        nmcli connection add type bond autoconnect no con-name xx-c-bond-$i ifname xx-i-bond-$i ipv4.method disabled ipv6.method ignore
        for j in $(seq $i 30); do
            nmcli connection add type vlan autoconnect no con-name xx-c-vlan-$i-$j vlan.id $j ifname xx-i-vlan-$i-$j vlan.parent xx-i-bond-$i  ipv4.method disabled ipv6.method ignore
        done
    done
    systemctl restart NetworkManager.service
    sleep 5
}

do_test() {
    perf stat -r 50 -B nmcli 1>/dev/null
}

do_test
```

  [1]

   Performance counter stats for 'nmcli' (50 runs):

              456.33 msec task-clock:u              #    1.093 CPUs utilized            ( +-  0.44% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
               5,900      page-faults:u             #    0.013 M/sec                    ( +-  0.02% )
       1,408,675,453      cycles:u                  #    3.087 GHz                      ( +-  0.48% )
       1,594,741,060      instructions:u            #    1.13  insn per cycle           ( +-  0.02% )
         368,744,018      branches:u                #  808.061 M/sec                    ( +-  0.02% )
           4,566,058      branch-misses:u           #    1.24% of all branches          ( +-  0.76% )

             0.41761 +- 0.00282 seconds time elapsed  ( +-  0.68% )

  [2]

   Performance counter stats for 'nmcli' (50 runs):

              477.99 msec task-clock:u              #    1.088 CPUs utilized            ( +-  0.36% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
               5,948      page-faults:u             #    0.012 M/sec                    ( +-  0.03% )
       1,471,133,482      cycles:u                  #    3.078 GHz                      ( +-  0.36% )
       1,655,275,369      instructions:u            #    1.13  insn per cycle           ( +-  0.02% )
         382,595,152      branches:u                #  800.433 M/sec                    ( +-  0.02% )
           4,746,070      branch-misses:u           #    1.24% of all branches          ( +-  0.49% )

             0.43923 +- 0.00242 seconds time elapsed  ( +-  0.55% )

  [3]

   Performance counter stats for 'nmcli' (50 runs):

              352.36 msec task-clock:u              #    1.027 CPUs utilized            ( +-  0.32% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
               4,790      page-faults:u             #    0.014 M/sec                    ( +-  0.26% )
       1,092,341,186      cycles:u                  #    3.100 GHz                      ( +-  0.26% )
       1,209,045,283      instructions:u            #    1.11  insn per cycle           ( +-  0.02% )
         281,708,462      branches:u                #  799.499 M/sec                    ( +-  0.01% )
           3,101,031      branch-misses:u           #    1.10% of all branches          ( +-  0.61% )

             0.34296 +- 0.00120 seconds time elapsed  ( +-  0.35% )

---

N5) same setup as N4), but run `PAGER= /bin/time -v nmcli`:

  [1]

        Command being timed: "nmcli"
        User time (seconds): 0.42
        System time (seconds): 0.04
        Percent of CPU this job got: 107%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.43
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 34456
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 6128
        Voluntary context switches: 1298
        Involuntary context switches: 1106
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

  [2]
        Command being timed: "nmcli"
        User time (seconds): 0.44
        System time (seconds): 0.04
        Percent of CPU this job got: 108%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.44
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 34452
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 6169
        Voluntary context switches: 1849
        Involuntary context switches: 142
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

  [3]

        Command being timed: "nmcli"
        User time (seconds): 0.32
        System time (seconds): 0.02
        Percent of CPU this job got: 102%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.34
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 29196
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 5059
        Voluntary context switches: 919
        Involuntary context switches: 685
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0

---

N6) same setup as N4), but run `nmcli monitor` and look at `ps aux` for
  the RSS size.

      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
  [1] me     1492900 21.0  0.2 461348 33248 pts/10   Sl+  15:02   0:00 nmcli monitor
  [2] me     1490721  5.0  0.2 461496 33548 pts/10   Sl+  15:00   0:00 nmcli monitor
  [3] me     1495801 16.5  0.1 459476 28692 pts/10   Sl+  15:04   0:00 nmcli monitor
2019-11-25 15:08:00 +01:00
Thomas Haller
4fad8c7c64 shared: add nm_utils_g_main_context_create_integrate_source() for integrating a GMainContext in another
We will rework NMClient entirely. Then, the synchronous initialization will also use
the asynchronous code paths. The difference will be that with synchronous initialization,
all D-Bus interaction will be done with an internal GMainContext as current thread default,
and that internal context will run until initialization completes.

Note that even after initialization completes, it cannot be swapped back to the user's
(outer) GMainContext. That is because contexts are essentially the queue for our
D-Bus events, and we cannot swap from one queue to the other in a race
free manner (or a full resync). In other words, the two contexts are not in sync,
so after using the internal context NMClient needs to stick to that (at least, until
the name owner gets lost, which gives an opportunity to resync and switch back to the
user's main context).

We thus need to hook the internal (inner) GMainContext with the user's (outer) context,
so when the user iterates the outer context, events on the inner context get dispatched.

Add nm_utils_g_main_context_create_integrate_source() to create such a GSource for
integrating two contexts.

Note that the use-case here is limited: the integrated, inner main context must
not be explicitly iterated except from being dispatched by the integrating
source. Otherwise, you'd get recursive runs, possible deadlocks and general
ugliness. NMClient must show restrain how to use the inner context while it is
integrated.
2019-11-25 12:58:33 +01:00
Thomas Haller
45c9f3c39b shared: make NM_STRUCT_OFFSET_ENSURE_TYPE() work with arrays
Some compilers don't convert arrays as _Generic() type selectors to
their pointer type. That means, for those compilers the generic type
would be an array and not a pointer. Work around that by adding zero
to the pointer/array argument.

Also, I cannot get this to work with "clang-3.4.2-9.el7". Disable it
for that compiler. The value of the generic check is anyway that it only
needs to work with some compiler combinations. That will trigger a
compilation failure and we can fix the implementation also for compilers
that don't support the macro.

See-also: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1930.htm
2019-11-25 12:58:33 +01:00
Thomas Haller
b8b8ef7600 shared: mark _notify() function as "_nm_unused"
There are two macros: NM_GOBJECT_PROPERTIES_DEFINE_BASE() and
NM_GOBJECT_PROPERTIES_DEFINE(). The former just defines the
property enums and the obj_properties array. The latter also
defines the functions _notify() and _nm_gobject_notify_together_impl().

That means, depending on whether you actually use _notify(), you have
to choose one of the macros. I think that is unnecessarily cumbersome.
Let's mark the function as _nm_unused so that the compiler doesn't
complain about the unused function. I don't think it's a problem
to use NM_GOBJECT_PROPERTIES_DEFINE() even if you don't actually use
_notify().
2019-11-25 12:58:33 +01:00
Thomas Haller
58811e019d shared: add nm_auto_unref_gmaincontext macro 2019-11-25 12:58:33 +01:00
Thomas Haller
bc9baf0fd5 shared: add nm_pint_hash()/nm_pint_equals() utils 2019-11-25 12:58:33 +01:00
Thomas Haller
d0f385ce34 sd: cleanup integrating systemd's event loop with GMainContext
Get rid of the default_source_id global for tracking the default
event. It's not useful to track this.
2019-11-25 12:58:33 +01:00
Rafael Fontenelle
52cd4878a6 po: update Brazilian Portuguese (pt_BR) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/346
2019-11-25 10:24:42 +01:00
Beniamino Galvani
a73efb059f manager: don't activate device if the parent is missing
In multiple places we currently proceed to creating a virtual device
even if the connection specifies a parent device which is
missing. This can be easily reproduced with:

  nmcli con add type vxlan ifname vxlan1 \
                vxlan.parent not-exists \
                id 43 remote 172.25.1.1

which creates a vxlan1 interface without activating any
connection. Add a check to prevent this.

https://bugzilla.redhat.com/show_bug.cgi?id=1774074
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/344
2019-11-25 08:58:27 +01:00
Thomas Haller
0521e06ff1 contrib/rpm: avoid warning in specfile about tokens after %endif
warning: extra tokens at the end of %endif directive in line 717:  %endif # end autotools
warning: extra tokens at the end of %endif directive in line 775:  %endif # end autotools
2019-11-23 17:01:41 +01:00
Thomas Haller
d3c7083f97 dhcp: switch IPv4 "internal" DHCP client to use "nettools" backend instead of "systemd"
Previously, our "internal" DHCPv4 client is based on a fork of
systemd code. This manner of maintaining the fork is problematic.
The solution is to use a proper library: n-dhcp4 from the nettools
project.

We already have these two as undocumented plugins available, by
setting either "dhcp=systemd" or "dhcp=nettools". This is only for
testing. Users are only supposed to use the "internal" plugin.

Up until now, the "internal" DHCPv4 plugin was based on "systemd" code.
Change that to use "nettools" instead.

Possibly this breaks something, and we need to fix it. But do this
early so we have time to test the nettools plugin and identify issues.

For the user, this change should be entirely transparant.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/302
2019-11-23 09:21:55 +01:00
Beniamino Galvani
ccfc3370af iface-helper: accept new DHCP4 leases
The new lease must be accepted or the nettools client will not renew
it.
2019-11-23 09:14:14 +01:00
Thomas Haller
6cf1262ac5 all: merge branch 'th/connectivity-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/343
2019-11-23 08:06:23 +01:00
Thomas Haller
21845ae4e3 build/meson: cleanup "meson-post-install.sh"
- the variables in meson.build and in the meson-post-install.sh script
  should have the same names.

- the positional command line arguments should be assigned to variables,
  because the variable name acts like a documentation what the variable
  means (contrary to the argument number).

- the boolean flags should not map to other special values, like
  "enable_docs ? 'install_docs' : ''". The name "enable_docs" is
  good already, it shall be either passed as 1 or 0 and use the name
  consistently.
2019-11-22 16:07:02 +01:00
Thomas Haller
6d7270e222 build/meson: cleanup configuration_data() for paths
We don't need such data duplicated. The build setup should
have only one configuration_data() for patching such values.

Now we only have one global, immutable data_conf dictionary with
configuration values. Note that none of the users of data_conf uses all
entries, but as the entries are basically only dependent on the
meson/configure option and valid for the entire project, this simplifies
to handling.
2019-11-22 15:59:31 +01:00
Thomas Haller
18c5ce50fb build: create base directories for install-data-hook first
The dependencies of make are exectured in the order as they appear.
We probably should start by creating the directories, before invoking
other install hooks. Currently there is no difference, because none of
the other hooks depend on the base directories. Still split it to
a special target.
2019-11-22 15:59:31 +01:00
Thomas Haller
d1eb52f8ce build: cleanup Makefile.am by moving "data_edit" first
$(data_edit) will be used later at an earlier place in the
makefile (to edit "clients/cloud-setup/nm-cloud-setup.service",
which will be handled earlier). Move it.

Also minor cleanups, like allowing to incrementally build
systemdsystemunit_DATA variable.
2019-11-22 15:59:31 +01:00
Thomas Haller
033c2b82c2 core: move _LOG*() macros to "shared/nm-glib-aux/nm-logging-fwd.h"
We preferably should use our convenience macros like _LOGD().
Since those macros expand to _NMLOG() (which needs to be defined
separately), we can move it to "nm-logging-fwd.h" and reuse.
2019-11-22 15:32:52 +01:00
Thomas Haller
c24f122e22 connectivity: fix using curl_multi_strerror() for CURLMcode error code 2019-11-22 15:32:52 +01:00
Thomas Haller
0871c9533f connectivity: don't use the GIOChannel but poll the file descriptor directly
I guess, if you write portable applications, then GIOChannel makes a lot of sense.
But we know that this is on Linux. We don't need to pretend that we
cannot poll on the file descriptor directly.
2019-11-22 15:32:52 +01:00
Thomas Haller
05c31da4d9 connectivity: don't cancel curl timerfunction from timeout
Curl documents about CURLMOPT_TIMERFUNCTION:

  The timer_callback will only be called when the timeout expire time is
  changed.

That means, we should not cancel the timeout when it happend, but
only when the callback is called again (or during cleanup).

See-also: https://curl.haxx.se/libcurl/c/CURLMOPT_TIMERFUNCTION.html
2019-11-22 15:32:52 +01:00
Thomas Haller
ec868916c8 shared: move nm_utils_ip._address_clear_host_address() helpers to shared 2019-11-22 15:32:52 +01:00
Thomas Haller
2ef5014f98 shared: add nm_clear_g_source_inst()
glib really likes the numeric source IDs. That is, g_idle_add(), g_timeout_add(),
etc. return those IDs, that can then be destroyed with g_remove_source() (or
nm_clear_g_source()).

I think these numeric IDs are really not great.

- API like g_idle_add() and g_remove_source() only works with the g_main_context_get_default()
  instance. That means, you cannot use this API for any other contexts. If you'd insist on using
  numeric IDs, you'd need to call g_main_context_find_source_by_id() on the right context
  first (but you'd also have to track the context alongside the ID).
- g_remove_source() requires first a call to g_main_context_find_source_by_id(). This involves
  taking a mutex and doing an extra hash lookup.

Instead, it often seems preferable to use the GSource instance directly. It works
with any context, it can be referenced and unreferenced, and it can be destroyed, and
avoids the overhead of g_main_context_find_source_by_id().

The only downside really is that keeping a GSource pointer takes one pointer size, while
the guint source ID is usually only 4 bytes.

Anyway, I think we should deal more with GSource instances directly. Hence, add this
convenience macro, that works like nm_clear_g_source().
2019-11-22 15:32:52 +01:00
Thomas Haller
c40ff42ae6 shared: add nm_g_*_source_new() and nm_g_source_attach() helpers
Small utilities to make is more convenient to create and attach GSource
instances.
2019-11-22 15:32:52 +01:00
Thomas Haller
9c5741ccd2 shared/nm-glib: add compat implementation for G_SOURCE_FUNC()
G_SOURCE_FUNC() was only added in glib 2.58.
2019-11-22 15:32:52 +01:00
Thomas Haller
0f4819ab36 contrib/rpm: use proper check for nmtui conditional build 2019-11-22 15:32:52 +01:00
Thomas Haller
09e5a0e805 dhcp/nettools: fix format-nonliteral warning for printf in nettools_log()
../src/dhcp/nm-dhcp-nettools.c:1048:27: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
                    msg = g_strdup_vprintf (fmt, ap);
                                            ^~~

Fixes: 97a8785148 ('nettools: enable logging')
2019-11-22 14:34:01 +01:00
Thomas Haller
b733d477e8 gitlab-ci: run tests on extra distributions only manually
For the moment, we use docker images from dockerhub, which require
a lot of extra overhead to prepare and install the test environment.
This should be improved, by using more suitable container images.

Anyway, for now to alleviate the pressure on the freedesktop gitlab
infrastructure, disable most test to only run manually.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/241#note_282521
2019-11-22 13:46:22 +01:00
Thomas Haller
339df56887 gitlab-ci: use Fedora 30 to build documentation and archived tarball 2019-11-22 13:46:22 +01:00
Thomas Haller
c1dca47619 ifcfg: merge branch 'th/ifcfg-8021x-system-ca-certs' 2019-11-22 11:44:38 +01:00
Thomas Haller
5028206ec4 ifcfg: various cleanup in ifcfg writer
svUnsetValue (ifcfg, KEY);
    if (condition)
         svSetValue* (ifcfg, KEY, ...);

is not good. It requires first clearing the value, before setting
it again.

Various cleanup to fix such uses.
2019-11-22 11:39:47 +01:00
Thomas Haller
2a4fb75d3b ifcfg: add support for "802-1x.system-ca-certs" setting 2019-11-22 11:39:47 +01:00
Thomas Haller
87af96a9d6 ifcfg: add svSetValueBoolean_cond_true() helper 2019-11-22 11:39:47 +01:00
Beniamino Galvani
234cb5a923 dhcp: merge branch 'bg/nettools-log'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/337
2019-11-22 10:36:20 +01:00
Beniamino Galvani
97a8785148 nettools: enable logging 2019-11-22 10:24:49 +01:00
Beniamino Galvani
72270b9e0e n-dhcp4: log outgoing packets
Add log messages for outgoing packets.

https://github.com/nettools/n-dhcp4/pull/8
2019-11-22 10:24:49 +01:00
Beniamino Galvani
440f541672 n-dhcp4: log incoming packets
Add log messages for incoming packets.

https://github.com/nettools/n-dhcp4/pull/8
2019-11-22 10:24:49 +01:00
Beniamino Galvani
87a26ea594 n-dhcp4: add logging API
In some cases it is useful to have the library log what it is doing
for debugging purposes; add a simple API that allows setting a
syslog-style logging level and specifying a logging function.

https://github.com/nettools/n-dhcp4/pull/8
2019-11-22 10:24:49 +01:00
Beniamino Galvani
d99c91a05a merge: branch 'bg/carrier-rh1722024'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/306
https://bugzilla.redhat.com/show_bug.cgi?id=1722024
2019-11-22 10:21:17 +01:00
Beniamino Galvani
b232b5013f introspection: deprecate Carrier properties
Deprecate the 'Carrier' property present in some Device sub-interfaces
in favor of the 'Carrier' flag in the InterfaceFlags property, which
is more general as it is available for all interfaces.
2019-11-22 10:18:27 +01:00
Beniamino Galvani
2b7def052f all: add device carrier flag
Add a new 'carrier' flag to the InterfaceFlags property of devices to
indicate the current carrier state.

The new flag is equivalent to the 'lower-up' flag for all devices
except the ones that use a non-standard carrier detection mechanism
like NMDeviceAdsl.
2019-11-22 10:18:27 +01:00
Beniamino Galvani
62c811b2bd cli: print interface flags 2019-11-22 10:18:26 +01:00
Beniamino Galvani
e397582cca libnm: export interface flags
Add libnm support for the new InterfaceFlags property of NMDevice.
2019-11-22 10:18:26 +01:00
Beniamino Galvani
1b90ad41bb core: export interface flags of devices
Add a new read-only "InterfaceFlags" property to the Device interface
to export via D-Bus kernel flags and possibly other NM specific
flags. At the moment IFF_UP and IFF_LOWERUP are implemented.
2019-11-22 10:18:26 +01:00
Beniamino Galvani
6c86f68ac4 device: remove useless doc comment
D-Bus properties are already documented in the introspection xml
files.
2019-11-22 10:18:26 +01:00
Thomas Haller
037aa02aba dhcp/nettools: fix assertion failure to calculate lease lifetimes
Fixes: 0108d74866 ('dhcp/nettools: exactly calculate lease lifetimes')
2019-11-21 13:48:31 +01:00
Beniamino Galvani
838e5b87c2 ethernet: wait for carrier before starting supplicant
After we set link parameters (auto-negotiation, speed, duplex) in
stage1, the carrier can go down for several seconds because the
Ethernet PHY needs to renegotiate the link. Wait that carrier goes up
before starting the supplicant or the EAPoL start packet can be lost
causing an authentication failure.

https://bugzilla.redhat.com/show_bug.cgi?id=1759797
2019-11-21 10:20:47 +01:00
Beniamino Galvani
4b4f18e77b device: check for disconnected state before activating NMActRequest
When a new activation request comes and the device is currently
activated, we move the device state to 'deactivating' and wait that it
reaches 'disconnected' before starting the new activation request.

In the meantime, a carrier change could happen but still we have to
wait that device finishes any pending deactivation.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/339
2019-11-21 10:08:20 +01:00
Thomas Haller
2025e3585f device: allow reapply of all "user" settings
[user] are arbitrary strings that can be attached to a connection.
NetworkManager itself does not care about them, they are only here
for other applications.

Allow reapplying changes to the user setting. Usually the reason to
reject reapplying a setting is because it's either not implemented
or not possible to change (without a full reactivation of the device).
In this case there is nothing to implement, and of course it's possible
to do so.
2019-11-20 17:48:03 +01:00