If __x is signed and its value is the minimum allowed for the type,
(__x - 1) causes a signed overflow, which has an undefined
behavior. Compiling with -fsanitize=undefined produces the warnings:
test-general.c:4499:619: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
test-general.c:4506:681: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'TEST_IS_POWER_OF_TWP_ENUM_SIGNED'
test-general.c:4501:619: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long int'
test-general.c:4509:691: runtime error: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'TEST_IS_POWER_OF_TWP_ENUM_UNSIGNED_64'
Change the order of expressions to avoid this.
Fixes: 0a3c1f5774
When exiting after an error we must set the quitting flag in
nm-exported-object.c because during program destruction there can be
still exported objects which get disposed.
Fixes the following assertion:
NetworkManager[14241]: (nm-exported-object.c:826):nm_exported_object_dispose: code should not be reached
Process terminating with default action of signal 5 (SIGTRAP)
at 0x7ACFD3B: _g_log_abort (gmessages.c:315)
by 0x7ACFD3B: g_logv (gmessages.c:1041)
by 0x7ACFEAE: g_log (gmessages.c:1079)
by 0x7AD0196: g_warn_message (gmessages.c:1112)
by 0x20F5B0: nm_exported_object_dispose (nm-exported-object.c:826)
by 0x316FC4: dispose (nm-settings.c:2222)
by 0x7841A5B: g_object_unref (gobject.c:3137)
by 0x2330F3: dispose (nm-manager.c:5249)
by 0x7841A5B: g_object_unref (gobject.c:3137)
by 0x23C511: _nm_singleton_instance_destroy (NetworkManagerUtils.c:174)
by 0x400FBE6: _dl_fini (in /usr/lib64/ld-2.21.so)
by 0x8009647: __run_exit_handlers (in /usr/lib64/libc-2.21.so)
by 0x8009694: exit (in /usr/lib64/libc-2.21.so)
Now that NM follows the supplicant's scan list and CurrentBSS, any AP that isn't
known to the supplicant will be 'fake', and priv->current_ap always tracks
CurrentBSS.
We can then simplify link_timeout_cb() because any AP that would have been
force-removed before will now be marked "fake" if it's unknown to the supplicant,
and will always be removed by set_current_ap(), so we can remove the force
argument. To better fix#733105 we never want to remove an AP known to
the supplicant, even if it we failed to connect to it.
https://bugzilla.gnome.org/show_bug.cgi?id=733105
Since commit 7cb323d923,
nm_ap_new_from_properties() will always return an
AP with BSSID set. Restore the assertion during
try_fill_ssid_for_hidden_ap().
This reverts commit e9bc18d2a7.
Differently from GLib timeout sources, systemd ones are always
one-shot and therefore we must return G_SOURCE_REMOVE in the callback,
otherwise the timer will be scheduled again.
In most cases things were working correctly because usually the
callback also unreferences the source event, but when this doesn't
happen the timer will trigger multiple times as reported in the bug
below.
https://bugzilla.redhat.com/show_bug.cgi?id=1278506
Fixes: 1b1222ffdf
gi now emits a warning when not loading a specific library
version [1]:
./generate-setting-docs.py:21: PyGIWarning: NM was imported without specifying a version first. Use gi.require_version(NM, 1.0) before import to ensure that the right version gets loaded.
from gi.repository import NM, GObject
Seems require_version() is reasonably old to just always use it without
breaking on older versions [2].
[1] Related: https://bugzilla.gnome.org/show_bug.cgi?id=727379
[2] https://git.gnome.org/browse/pygobject/commit/?id=76758efb6579752237a0dc4d56cf9518de6c6e55
$ nmcli dev wifi connect 00:22:6B:EB:1D:CA hidden yes
Warning: '00:22:6B:EB:1D:CA' should be SSID for hidden APs; but it looks like a BSSID.
Error: Failed to add/activate new connection: 802-11-wireless.ssid: connection does not match access point
The autoconf macro for GIR passes $CFLAGS to g-ir-scanner.
g-ir-scanner extends those flags with the system-default which
includes -D_FORTIFY_SOURCE=2. Probably it should not do that,
but if you disable optimization, this results in a compler warning
in "/usr/include/features.h" [1]
export CFLAGS='-O0'
# Happens both with clang or gcc.
#export CC=clang
git clean -fdx
./autogen.sh
make
Work around that by injecting -Wno-error to $CFLAGS when invoking
g-ir-scanner.
[1] Related: https://sourceware.org/bugzilla/show_bug.cgi?id=13979
Prevsiouly, the ifcfg-rh service and the regular NetworkManager
were both exported on the same D-Bus connection. That had the
effect, that on both services ("com.redhat.ifcfgrh1" and
"org.freedesktop.NetworkManager") all objects were visible.
This is also problematic later when we use GDBusObjectManager
for the org.freedesktop.NetworkManager service.
Export the ifcfg service on a separate bus connection.
One downside is, that we don't bother exporting the service
on the private socket and thus the service is not available
without D-Bus daemon.
Also, if the bus disconnects, we don't retry or recover. Instead
the D-Bus service is dead until restart.
Previously most objects were implicitly unexported when they were
destroyed, but since refcounts may make the object live longer than
intended, we should explicitly unexport them when they should no
longer be present on the bus.
This means we can assume that objects will always be un-exported
already when they are destroyed, *except* when quitting where most
objects will live until exit because NM leaves interfaces up and
running on quit.
The @aps hash has the D-Bus path of the exported
object as key. It already rightly saved to additionally
copy the string and relied on the path being stable.
When doing that, we can just go one step further and
use direct-hashing instead of string-hashing.
Note that NMExportedObject already promises that
the path will not change as long as the object is
exported. See code comments in the export/unexport
functions.
For future use of ObjectManager, we must explicitly unexport
the AP and no longer depend on having it unexported during
deconstruction (because object manager keeps the instance alive).
Also refactor adding/removal of APs and move the export/unexport
calls to the place where we emit the signal.
First add the new AP, before setting it as current.
Also set the AP *after* thawing the notifications. Otherwise
it is not clear which notification gets raised first as their
order is undefined. But we want that the client first sees
the new AP and later gets a notification about having a new
current.
Exporting the object already in the *_init() function will later
break because the object is not yet fully initialized at that point.
Add a convenient flag so that the NMExportedObject parent implementation
automatically can export itself. This saves the derived class from
overwriting the constructed() method.
Also add an assertion to catch such bugs.
The list of LLDP neighbors is available through the D-Bus interface
and libnm already provides functions to retrieve it; make the list
available through nmcli as well. Sample output:
$ nmcli device lldp
NEIGHBOR[0].DEVICE: eth0
NEIGHBOR[0].CHASSIS-ID: 00:13:21:58:CA:42
NEIGHBOR[0].PORT-ID: 1
NEIGHBOR[0].PORT-DESCRIPTION: 1
NEIGHBOR[0].SYSTEM-NAME: ProCurve Switch 2600-8-PWR
NEIGHBOR[0].SYSTEM-DESCRIPTION: ProCurve J8762A Switch 2600-8-PWR, revision H.08.89
NEIGHBOR[0].SYSTEM-CAPABILITIES: 20 (mac-bridge,router)
NEIGHBOR[1].DEVICE: eth2
NEIGHBOR[1].CHASSIS-ID: 00:01:30:F8:AD:A2
NEIGHBOR[1].PORT-ID: 1/1
NEIGHBOR[1].PORT-DESCRIPTION: Summit300-48-Port 1001
NEIGHBOR[1].SYSTEM-NAME: Summit300-48
NEIGHBOR[1].SYSTEM-DESCRIPTION: Summit300-48 - Version 7.4e.1 (Build 5)
NEIGHBOR[1].SYSTEM-CAPABILITIES: 20 (mac-bridge,router)
https://bugzilla.gnome.org/show_bug.cgi?id=757307