summaryrefslogtreecommitdiff
path: root/src/devices/wwan/nm-device-modem.c
Commit message (Collapse)AuthorAgeFilesLines
* all: move "src/" directory to "src/core/"Thomas Haller2021-02-041-957/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently "src/" mostly contains the source code of the daemon. I say mostly, because that is not true, there are also the device, settings, wwan, ppp plugins, the initrd generator, the pppd and dhcp helper, and probably more. Also we have source code under libnm-core/, libnm/, clients/, and shared/ directories. That is all confusing. We should have one "src" directory, that contains subdirectories. Those subdirectories should contain individual parts (libraries or applications), that possibly have dependencies on other subdirectories. There should be a flat hierarchy of directories under src/, which contains individual modules. As the name "src/" is already taken, that prevents any sensible restructuring of the code. As a first step, move "src/" to "src/core/". This gives space to reorganize the code better by moving individual components into "src/". For inspiration, look at systemd's "src/" directory. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/743
* all: update deprecated SPDX license identifiersThomas Haller2021-01-051-1/+1
| | | | | | | | | | | | | | | | These SPDX license identifiers are deprecated ([1]). Update them. [1] https://spdx.org/licenses/ sed \ -e '1 s%^/\* SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+ \*/$%/* SPDX-License-Identifier: \1-or-later */%' \ -e '1,2 s%^\(--\|#\|//\) SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+$%\1 SPDX-License-Identifier: \2-or-later%' \ -i \ $(git grep -l SPDX-License-Identifier -- \ ':(exclude)shared/c-*/' \ ':(exclude)shared/n-*/' \ ':(exclude)shared/systemd/src' \ ':(exclude)src/systemd/src')
* device: improve "nm-device-logging.h" to support a self pointer of NMDevice typeThomas Haller2020-11-091-1/+1
| | | | | | | | | | | | | | "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.
* all: unify comment style for SPDX-License-Identifier tagThomas Haller2020-09-291-1/+1
| | | | | | | | | | Our coding style recommends C style comments (/* */) instead of C++ (//). Also, systemd (which we partly fork) uses C style comments for the SPDX-License-Identifier. Unify the style. $ sed -i '1 s#// SPDX-License-Identifier: \([^ ]\+\)$#/* SPDX-License-Identifier: \1 */#' -- $(git ls-files -- '*.[hc]' '*.[hc]pp')
* format: manually replace remaining tabs with spaces and reformatThomas Haller2020-09-291-2/+2
|
* format: replace tabs for indentation in code commentsac/clang-formatThomas Haller2020-09-281-34/+34
| | | | | | | | | | | | sed -i \ -e 's/^'$'\t'' \*/ */g' \ -e 's/^'$'\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t\t\t\t'' \*/ */g' \ -e 's/^'$'\t\t\t\t\t\t\t'' \*/ */g' \ $(git ls-files -- '*.[hc]')
* all: reformat all with new clang-format styleAntonio Cardace2020-09-281-673/+681
| | | | | | | | | | | | Run: ./contrib/scripts/nm-code-format.sh -i ./contrib/scripts/nm-code-format.sh -i Yes, it needs to run twice because the first run doesn't yet produce the final result. Signed-off-by: Antonio Cardace <acardace@redhat.com>
* nm-device-modem: deactivate device when modem unlockedArnaud Ferraris2020-03-271-0/+9
| | | | | | | | | | | | | | | When the modem is unlocked externally to NetworkManager, it is kept in the 'need-auth' state. The current connection activation continues as if nothing had changed, and the secrets request for the PIN code (which is no longer necessary) eventually times out. The device state is then changed to 'failed', meaning there won't be a new try at activating the default connection automatically. In order to prevent this, and retry activating the default connection when the modem gets unlocked, we change the device state to 'deactivating' when we identify the modem has been unlocked externally. Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
* all: use nm_clear_g_free() instead of g_clear_pointer()Thomas Haller2020-03-231-3/+3
| | | | | | | | | I think it's preferable to use nm_clear_g_free() instead of g_clear_pointer(, g_free). The reasons are not very strong, but I think it is overall preferable to have a shorthand for this frequently used functionality. sed 's/\<g_clear_pointer *(\([^;]*\), *\(g_free\) *)/nm_clear_g_free (\1)/g' $(git grep -l g_clear_pointer) -i
* device: allow scheduling nm_device_activate_schedule_stage1_prepare() right awayThomas Haller2020-03-171-2/+2
| | | | | | | | | | | There was only API to schedule the stage on an idle handler. Sometimes, we are just in the right situation to schedule the stage right away. It should be possibly to avoid going through the extra hop. For now, none of the caller makes use of this. So, there isn't any actual change in behavior. But by adding this possibility, we may do use in the future.
* device: various code cleanups in devicesThomas Haller2020-03-171-1/+0
| | | | Mostly just cleanups, there should be no significant change in behavior.
* device/trivial: rename get_dhcp_timeout() virtual function to have a unique nameThomas Haller2020-02-171-2/+2
| | | | | | | | This is C, we have almost no IDE support. And ctags/cscope is much more helpful if we use unique names. Don't use the get_dhcp_timeout() name, because that is already used in "src/devices/nm-device.c" already. Rename.
* all: manually drop code comments with file descriptionThomas Haller2019-10-011-2/+1
|
* wwan: simplify API of nm_modem_act_stage2_config() to never failThomas Haller2019-09-221-5/+2
| | | | | | | | | | | | | | The previous function arguments of nm_modem_act_stage2_config() act as if the function could fail or even postpone the action. It never did. We cannot treat this generic. A caller needs to know whether nm_modem_act_stage2_config() can postpone the action, and when it does, which signal is emitted upon completion. That is, the caller needs to know how to proceed after postponing. In other words, since this function currently cannot fail or postpone the stage, so must all callers already rely on that. At this point it makes no sense to pretend that the function could be any different, if all callers assume it is not. Simplify the API.
* wwan: mark modems that are taken by a NMDevice as "claimed"Thomas Haller2019-09-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NMModem-s are either used by NMDeviceModem or by NMDeviceBt. The mechanism how that is coordinated it odd: - the factory emits component-added, and then NMDeviceBt might take the device (and claim it). In that case, component-added would return TRUE to indicate that the modem should not be also used by NMDeviceModem. - next, if the modem has a driver that looks like bluetooth, NMDeviceModem ignores it too. - finally, NMDeviceModem claims the modem (which is now considered to be non-bluetooth). I think the first problem is that the device factory tries to have this generic mechanism of "component-added". It's literally only used to cover this special case. Note that NMDeviceBt is aware of modems. So, abstracting this just adds lots of code that could be solved better by handling the case (of giving the modem to either NMDeviceBt or NMDeviceModem) specifically. NMWWanFactory itself registers to the NM_MODEM_MANAGER_MODEM_ADDED signal and emits nm_device_factory_emit_component_added(). We could just have NMWWanFactory and NMDeviceBt both register to that signal. Signals even support priorities, so we could have NMDeviceBt be called first to claim the device. Anyway, as the modem can only have one owner, the modem should have a flag that indicates whether it's claimed or not. That will allow multiple components all look at the same modem and moderate who is going to take ownership.
* all: SPDX header conversionLubomir Rintel2019-09-101-14/+1
| | | | | $ find * -type f |xargs perl contrib/scripts/spdx.pl $ git rm contrib/scripts/spdx.pl
* device: let devices call stage1 again after being ready to proceedThomas Haller2019-08-281-15/+37
| | | | | | | | | | | | | | | I am about to change the when stage1 gets postponed, then the way to proceed it is to schedule stage1 again (instead of scheduling stage2). The reason is that stage1 handling should be reentrant and we should keep entering it until there is no more reason to postpone it. If a subclass postpones stage1 and then later progresses it by directly scheduling stage2, then only the subclass is in control over postponing stage 2. Instead, anybody should be able to delay stage2 independently. That can only work if everybody signals readyness to proceed by scheduling stage1 again.
* device: don't let subclasses call NMDevice's act_stage1_prepare()Thomas Haller2019-08-281-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | NMDevice's act_stage1_prepare() now does nothing. Calling it is not useful and has no effect. In general, when a subclass overwrites a virtual function, it must be defined whether the subclass must, may or must-not call the parents implementation. Likewise, it must be clear when the parents implementation should be chained: first, as last, does it matter? In any case, that very much depends on how the parent is implemented and this can only be solved by documentation and common conventions. It's a forgiving approach to have a parents implementation do nothing, then the subclass may call it at any time (or not call it at all). This is especially useful if classes don't know their parent class well. But in NetworkManager code the relationship between classes are known at compile time, so every of these classes knows it derives directly from NMDevice. This forgingin approach was what NMDevice's act_stage1_prepare() was doing. However, it also adds lines of code resulting in a different kind of complexity. So, it's not clear that this forgiving approach is really better. Note that it also has a (tiny) runtime and code-size overhead. Change the expectation of how NMDevice's act_stage1_prepare() should be called: it is no longer implemented, and subclasses *MUST* not chain up.
* device: various minor style cleanupThomas Haller2019-08-281-1/+3
|
* device/modem: drop unnecessary cast for NM_DEVICE_MODEM_GET_PRIVATE() macroThomas Haller2019-08-281-13/+13
| | | | | | NM_DEVICE_MODEM_GET_PRIVATE() is based on _NM_GET_PRIVATE(), which has some smarts to check the pointer type, but is fine with well-known parent pointer types like "NMDevice *".
* all: drop emacs file variables from source filesThomas Haller2019-06-111-1/+0
| | | | | | | | | | | | | | | | | | | | | | We no longer add these. If you use Emacs, configure it yourself. Also, due to our "smart-tab" usage the editor anyway does a subpar job handling our tabs. However, on the upside every user can choose whatever tab-width he/she prefers. If "smart-tabs" are used properly (like we do), every tab-width will work. No manual changes, just ran commands: F=($(git grep -l -e '-\*-')) sed '1 { /\/\* *-\*- *[mM]ode.*\*\/$/d }' -i "${F[@]}" sed '1,4 { /^\(#\|--\|dnl\) *-\*- [mM]ode/d }' -i "${F[@]}" Check remaining lines with: git grep -e '-\*-' The ultimate purpose of this is to cleanup our files and eventually use SPDX license identifiers. For that, first get rid of the boilerplate lines.
* wwan: expose the APN on the D-BusLubomir Rintel2019-06-051-0/+29
| | | | | This is going to be useful for UIs to know which plan we're actually using.
* wwan: expose the network id on the D-BusLubomir Rintel2019-06-051-1/+28
| | | | | This is going to be useful for UIs to find out which network is the device actually registered with.
* wwan: expose device id on the busLubomir Rintel2019-06-051-1/+20
| | | | | | The device id is useful to pinpoint the connection to a particular device. However, we don't expose it anywhere and it's sort of hard to guess.
* modem: use set conn.interface upon completing the CDMA connectionsLubomir Rintel2019-05-281-1/+5
| | | | | There doesn't seem to be a better way to pinpoint a CDMA connection to a device. This will have to do for now.
* Revert "wwan/device-modem: don't enter available state until registered"Lubomir Rintel2019-03-181-7/+6
| | | | | | | | This is wrong -- we may want to start activating before device is registered if it the SIM needs unlocking with a PIN code that's included in the connection. This reverts commit 2e8f43e379c61d79b6dd1b27ee1d9cb950447ad5.
* wwan/device-modem: don't enter available state until registeredLubomir Rintel2019-03-121-6/+7
| | | | | | | | | | | | | | Based on Ubuntu's "Modify NMDeviceModem's available logic" patch by Tony Espy <espy@canonical.com>. The original commit message: This patch modifies NMDeviceModem's available logic such that the device is only considered available if the modem_state is >= NM_MODEM_STATE_REGISTERED. NMDevice defines 'available' as meaning the device is in such a state that it can be activated. This change prevents NM from trying to activate a modem which is not yet ready to be activated. Bug-Ubuntu: https://bugs.launchpad.net/bugs/1445080 https://github.com/NetworkManager/NetworkManager/pull/312
* device: merge stage3 and stage4 ip-config function for IPv4 and IPv6Thomas Haller2019-03-051-23/+25
|
* device/trivial: rename wwan_ip_config to dev2_ip_configThomas Haller2019-03-051-2/+2
| | | | | | | | | | dev2_ip_config (formerly wwan_ip_config) is only set by nm_device_set_dev2_ip_config() (formerly nm_device_set_wwan_ip_config()), which is only called by NMDeviceModem. For NMDeviceWireGuard we will also inject additional configuration in the parent class. Rename and give it a wider purpose. The new name merely indicates that this IP configuration is injected by a subclass of NMDevice.
* device: merge IPv4 and IPv6 variant of nm_device_set_wwan_ip_config()Thomas Haller2019-03-051-2/+3
|
* device: unify IPv4 and IPv6 device methods for IP configsThomas Haller2019-03-051-5/+5
| | | | | | | | | | | | | | It is preferable to treat IPv4 and IPv6 in a similar manner. This moves the places where we differ down the call-stack. It also make it clearer how IPv6 behaves differently. I think this is a bug, but leave it for now. + /* If IP had previously failed, move it back to IP_CONF since we + * clearly now have configuration. + */ + if (priv->ip6_state == IP_FAIL) + _set_ip_state (self, AF_INET6, IP_CONF);
* all: drop unnecessary includes of <errno.h> and <string.h>Thomas Haller2019-02-121-2/+0
| | | | | "nm-macros-interal.h" already includes <errno.h> and <string.h>. No need to include it everywhere else too.
* device/trivial: rename device's sysctl functionThomas Haller2018-12-191-2/+2
| | | | | | | | | | | | | | | | These functions call platform's sysctl getter and setters. Note that the called platform functions are called nm_platform_sysctl_get() and nm_platform_sysctl_set(). Also, in this case they use the ip-conf path via nm_utils_sysctl_ip_conf_path(). Also, next we will add API nm_platform_sysctl_ip_conf_get() and nm_platform_sysctl_ip_conf_set(), which will be wrappers around nm_platform_sysctl_get() and nm_platform_sysctl_set(), using the ip-conf paths as well. Rename the device functions, to be more similar to the existing and future naming in platform.
* device: merge IPv4 and IPv6 variants of nm_device_ipv4_sysctl_set()Thomas Haller2018-12-191-2/+2
| | | | | | | | | | | | | | | For one, next we will drop setting rp_filter, hence there are no more users of an IPv4 variant and nm_device_ipv4_sysctl_set() would have to be dropped anyway. However, instead of doing that, merge the IPv4 and IPv6 variant. With this, the fallback to the default is now also supported for IPv6 (though unused). Also, don't access nm_device_get_ip_iface(). The interface name might not be right, we should only rely on the ifindex. Load the interface name from platform cache instead.
* wwan: rework when settings/device are blocked for autoconnectionAleksander Morgado2018-12-141-6/+32
| | | | | | | | | | | | | | | | | | | | | | The reasons to block autoconnection at settings level are not the same as the ones to block autoconnection at device level. E.g. if the SIM-PIN is wrong, you may want to block autoconnection both at settings level (as the PIN configured in settings is wrong) and at device level (so that no other setting is tried automatically). For some other reasons, you may want to block autoconnection only at setting level (e.g. wrong APN). And for some other reasons you may want to block autoconnection at device level only (e.g. SIM missing), so that the autoconnection blocking is removed when the device goes away. This is especially important with SIM hotplug events processed by ModemManager, as a device without SIM will be removed from MM when a new SIM is inserted, so that a completely new object is exposed in MM with the newly detected SIM. https://github.com/NetworkManager/NetworkManager/pull/259
* modem: don't use GAsyncResult pattern for disconnecting modemThomas Haller2018-10-171-27/+17
| | | | | | | | | We should not use GAsyncResult. At least, not for internal API. It's more cumbersome then helpful, in my opinion. It requires this awkward async_finish() pattern. Instead, let the caller pass a suitable callback of the right type.
* docs: misc. typosluz.paz2018-09-151-1/+1
| | | | | | Found via `codespell -q 3 --skip="*.po"` https://github.com/NetworkManager/NetworkManager/pull/203
* core: give better error reason why device is incompatible with profileThomas Haller2018-07-241-3/+20
| | | | | | | | | | | | | | | | Note the special error codes NM_UTILS_ERROR_CONNECTION_AVAILABLE_*. This will be used to determine, whether the profile is fundamentally incompatible with the device, or whether just some other properties mismatch. That information will be importand during a plain `nmcli connection up`, where NetworkManager searches all devices for a device to activate. If no device is found (and multiple errors happened), we want to show the error that is most likely relevant for the user. Also note, how NMDevice's check_connection_compatible() uses the new class field "device_class->connection_type_check_compatible" to simplify checks for compatible profiles. The error reason is still unused.
* core: give better error reason why device is unavailableThomas Haller2018-07-241-4/+20
| | | | The error reason is still unused.
* wwan: ensure the route parameters are set on IPv6 only configurationlr/wwan-ppp-route-rh1585611Lubomir Rintel2018-06-131-1/+1
|
* core: avoid clone of all-connections list for nm_utils_complete_generic()Thomas Haller2018-03-201-1/+1
| | | | | | | | | | | | | | | | | | | NMSettings exposes a cached list of all connection. We don't need to clone it. Note that this is not save against concurrent modification, meaning, add/remove of connections in NMSettings will invalidate the list. However, it wasn't save against that previously either, because altough we cloned the container (GSList), we didn't take an additional reference to the elements. This is purely a performance optimization, we don't need to clone the list. Also, since the original list is of type "NMConnection *const*", use that type insistently, instead of dependent API requiring GSList. IMO, GSList is anyway not a very nice API for many use cases because it requires an additional slice allocation for each element. It's slower, and often less convenient to use.
* core/dbus: rework D-Bus implementation to use lower layer GDBusConnection APIThomas Haller2018-03-121-9/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, we used the generated GDBusInterfaceSkeleton types and glued them via the NMExportedObject base class to our NM types. We also used GDBusObjectManagerServer. Don't do that anymore. The resulting code was more complicated despite (or because?) using generated classes. It was hard to understand, complex, had ordering-issues, and had a runtime and memory overhead. This patch refactors this entirely and uses the lower layer API GDBusConnection directly. It replaces the generated code, GDBusInterfaceSkeleton, and GDBusObjectManagerServer. All this is now done by NMDbusObject and NMDBusManager and static descriptor instances of type GDBusInterfaceInfo. This adds a net plus of more then 1300 lines of hand written code. I claim that this implementation is easier to understand. Note that previously we also required extensive and complex glue code to bind our objects to the generated skeleton objects. Instead, now glue our objects directly to GDBusConnection. The result is more immediate and gets rid of layers of code in between. Now that the D-Bus glue us more under our control, we can address issus and bottlenecks better, instead of adding code to bend the generated skeletons to our needs. Note that the current implementation now only supports one D-Bus connection. That was effectively the case already, although there were places (and still are) where the code pretends it could also support connections from a private socket. We dropped private socket support mainly because it was unused, untested and buggy, but also because GDBusObjectManagerServer could not export the same objects on multiple connections. Now, it would be rather straight forward to fix that and re-introduce ObjectManager on each private connection. But this commit doesn't do that yet, and the new code intentionally supports only one D-Bus connection. Also, the D-Bus startup was simplified. There is no retry, either nm_dbus_manager_start() succeeds, or it detects the initrd case. In the initrd case, bus manager never tries to connect to D-Bus. Since the initrd scenario is not yet used/tested, this is good enough for the moment. It could be easily extended later, for example with polling whether the system bus appears (like was done previously). Also, restart of D-Bus daemon isn't supported either -- just like before. Note how NMDBusManager now implements the ObjectManager D-Bus interface directly. Also, this fixes race issues in the server, by no longer delaying PropertiesChanged signals. NMExportedObject would collect changed properties and send the signal out in idle_emit_properties_changed() on idle. This messes up the ordering of change events w.r.t. other signals and events on the bus. Note that not only NMExportedObject messed up the ordering. Also the generated code would hook into notify() and process change events in and idle handle, exhibiting the same ordering issue too. No longer do that. PropertiesChanged signals will be sent right away by hooking into dispatch_properties_changed(). This means, changing a property in quick succession will no longer be combined and is guaranteed to emit signals for each individual state. Quite possibly we emit now more PropertiesChanged signals then before. However, we are now able to group a set of changes by using standard g_object_freeze_notify()/g_object_thaw_notify(). We probably should make more use of that. Also, now that our signals are all handled in the right order, we might find places where we still emit them in the wrong order. But that is then due to the order in which our GObjects emit signals, not due to an ill behavior of the D-Bus glue. Possibly we need to identify such ordering issues and fix them. Numbers (for contrib/rpm --without debug on x86_64): - the patch changes the code size of NetworkManager by - 2809360 bytes + 2537528 bytes (-9.7%) - Runtime measurements are harder because there is a large variance during testing. In other words, the numbers are not reproducible. Currently, the implementation performs no caching of GVariants at all, but it would be rather simple to add it, if that turns out to be useful. Anyway, without strong claim, it seems that the new form tends to perform slightly better. That would be no surprise. $ time (for i in {1..1000}; do nmcli >/dev/null || break; echo -n .; done) - real 1m39.355s + real 1m37.432s $ time (for i in {1..2000}; do busctl call org.freedesktop.NetworkManager /org/freedesktop org.freedesktop.DBus.ObjectManager GetManagedObjects > /dev/null || break; echo -n .; done) - real 0m26.843s + real 0m25.281s - Regarding RSS size, just looking at the processes in similar conditions, doesn't give a large difference. On my system they consume about 19MB RSS. It seems that the new version has a slightly smaller RSS size. - 19356 RSS + 18660 RSS
* wwan: rework setting modem's data-portThomas Haller2018-02-211-9/+14
| | | | | | | | | | | | | | | | | Depending on the bearer's configuration method, the data-port is either a networking interface, or an tty for ppp. Let's treat them strictily separate. Also, rework how NM_MODEM_DATA_PORT was used in both contexts. Instead, use the that we actually care about. Also, when nm_device_set_ip_ifindex() fails, fail activation right away. Also, we early try to resolve the network interface's name to an ifindex. If that fails, the device is already gone and we fail early.
* device: don't set NMDeviceModem's ip-iface right after constuctionThomas Haller2018-02-211-12/+1
| | | | | | | | | | | | nm_device_modem_new() is only called with a newly created NMModemBroadband or NMModemOfono instance. See the callers - NMModemManager:handle_new_modem() - NMWwanFactory:modem_added_cb() - NMDeviceModem:nm_device_modem_new() Hence, at that point, the modem cannot yet have a data-port or ip-iface set, because that is only obtained later.
* wwan: make NM_MODEM_DATA_PORT not a construct propertyThomas Haller2018-02-211-19/+15
| | | | | The property was never set at construct time. Don't make it a construct property.
* device: refactor nm_device_set_ip_ifindex() and set_ip_iface()Thomas Haller2018-02-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | - don't even bother to look into the platform cache, but use if_indextoname() / if_nametoindex(). In most cases, we obtained the ifindex/ifname not from the platform cache in the first place. Hence, there is a race, where the interface might not exist. However, try to process events of the platform cache, hoping that the cache contains an interface for the given ifindex/ifname. - let set_ip_ifindex() and set_ip_iface() both return a boolean value to indicate whether a ip-interface is set or not. That is, whether we have a positive ip_ifindex. That seems more interesting information, then to return whether anything changed. - as before, set_ip_ifindex() can only clear an ifindex/ifname, or error out without doing anything. That is different from set_ip_iface(), which will also set an ifname if no ifindex can be resolved. That is curreently ugly, because then ip-ifindex and ip-iface don't agree. That shall be improved in the future by: - trying to set an interface that cannot be resolved shall lead to a disconnect in any case. - we shall make less use of the ip-iface and rely more on the ifindex.
* wwan: disconnect signals from ppp-manager before clearing instanceThomas Haller2018-02-211-2/+3
|
* device: improve tracking autoconnect-blocked flags of NMDeviceThomas Haller2017-11-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | - split NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN in two parts: "wrong-pin" and "manual-disconnect". Setting/unsetting them should be tracked differently, as their reason differs. - no longer initialize/clear the autoconnect-blocked reasons during realize/unrealize of the device. Instead, initialize it once when the object gets created (nm_device_init()), and keep the settings beyond unrealize/realize cycles. This only matters for software devices, as regular devices get deleted after unrealizing once. But for software devices it is essential, because we don't want to forget the autoconnect settings of the device instance. - drop verbose logging about blocking autoconnect due to failed pin. We already log changes to autoconnect-blocked flags with TRACE level. An additional message about this particular issue seems not necessary at INFO level. - in NMManager's do_sleep_wake(), no longer block autoconnect for devices during sleep. We already unmanage the device, which is a far more effective measure to prevent activation. We should not also block autoconnect. (cherry picked from commit 3c2b9485a7d3bbc7f411e29560f92dd9178b044b)
* device: refactor autoconnect blocking by introducing ↵Thomas Haller2017-11-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | NMDeviceAutoconnectBlockedFlags enum The flags allow for more then two reasons. Currently the only reasons for allowing or disallowing autoconnect are "user" and "intern". It's a bit odd, that NMDeviceAutoconnectBlockedFlags has a negative meaning. So nm_device_set_autoconnect_intern (device, FALSE); gets replaced by nm_device_set_autoconnect_blocked_set (device, NM_DEVICE_AUTOCONNECT_BLOCKED_INTERN); and so on. However, it's chosen this way, because autoconnect shall be allowed, unless any blocked-reason is set. That is, to check whether autoconnect is allowed, we do if (!nm_device_get_autoconnect_blocked (device, NM_DEVICE_AUTOCONNECT_BLOCKED_ALL)) The alternative check would be if (nm_device_get_autoconnect_allowed (device, NM_DEVICE_AUTOCONNECT_ALLOWED_ALL) == NM_DEVICE_AUTOCONNECT_ALLOWED_ALL) which seems odd too. So, add the inverse flags to block autoconnect. Beside refactoring and inverting the meaning of the autoconnect settings, there is no change in behavior. (cherry picked from commit 5279ab5be6326b911682e53d8c29d20a501d61b8)
* policy: move blocking autoconnect from NMDeviceModem to NMPolicyThomas Haller2017-10-311-25/+1
| | | | | | | | | | Only NMPolicy should be concerned with handling autoconnect, and blocking it. Move the code. Note that there is a slight possible change in behavior, as the order of when the connection is blocked changes, based on the different times when the device changed signal gets executed. But that shouldn't be a problem.