aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
10 daysdnsproxy: Do not use untrusted value in computationHEADmasterBrian Fukano1-1/+1
static analysis tools are much happier when untrusted data sources are not used in computations. In particular, the preferred form for boundary checking is to compute the bounds using trusted sources and compare to the length obtained in the untrusted source.
10 daysdnsproxy: zero-terminate the buffer after recvfromBrian Fukano1-3/+7
in the case of udp_listener_event(), recvfrom reads into a buffer which is then passed down into: resolv() ns_resolv() ns_try_to_resolve_from_cache() cache_check() which finally invokes strlen on the buffer. It isn't clear whether the read-in length is ever taken into account, so zero-terminate the buffer for now. Similarly, in tcp_client_event, the buffer filled by recvfrom is sent to read_tcp_data() cache_check()
10 daysdnsproxy: Check sendto error returnBrian Fukano1-3/+4
Make sure to check the sendto error return value like is done elsewhere.
10 daysdnsproxy: Check fcntl return valueBrian Fukano1-1/+6
It is astronomically unlikely that fcntl would fail, but check the error return just in case.
2024-04-22dnsproxy: Fix cached ttl updateBrian Fukano1-4/+2
This bug was exposed after fixing the signedness comparison warnings found in dnsproxy.c update_cached_ttl() consistently comes up two bytes short when processing the last record.
2024-04-22iwd: set network to connected if it is alreadyRam Subramanian1-0/+3
Without this, connman will wait for a "Connected" signal from iwd, which is only emitted when iwd connects to a network. If it is already connected by the time create_network() is run, that network will be stuck in limbo.
2024-04-18technology: Fix memory leak.Robert Tiemann1-1/+3
2024-04-18wifi: Fix indentation.Robert Tiemann1-5/+5
2024-04-18wifi: Fix memory leak.Robert Tiemann1-1/+3
A GSupplicantSSID instance was leaked in ssid_ap_init() in case connman_technology_get_wifi_tethering() didn't succeed.
2024-04-18wifi: Fix use-after-free when tethering is disabled.Robert Tiemann1-30/+24
The bug frequently causes junk being written to the Tethering.Identifier and Tethering.Passphrase entries in the settings file. This in turn prevents Connman from starting up at all the next time it is run. To reproduce with connmanctl, use the following commands: enable wifi tether wifi on MyNetwork ThePassphrase tether wifi off Then have a look at the settings file. Disabling tethering causes a call of remove_ssid() from interface_select_network_result() in gsupplicant/supplicant.c, which frees the SSID and passphrase strings of the given GSupplicantSSID structure (originally initialized by the wifi plugin). These strings, however, are shared with a connman_technology structure, and they are accessed in technology_save() (called indirectly from set_property() in technology.c) after they have been freed. To fix this bug, the affected strings are copied into the GSupplicantSSID structure instead of simply assigning them. We make sure (1) to free them in case supplicant didn't take the GSupplicantSSID structure due to an error, and (2) to avoid double frees in ap_create_callback() and sta_remove_callback(). Originally, there were two GSupplicantSSID instances in the wifi plugin: one for the supplicant, and one stored in the wifi_data's tethering_param structure. The latter, however, was never used, so this commit removes its allocation to avoid a new memory leak, to save memory, and to generally avoid confusion. The bug fixed by this commit was introduced in 481d08f108.
2024-04-17dnsproxy: fix signedness warningsBrian Fukano1-13/+24
This fixes the signdness warnings found in dnsproxy.c
2024-04-17inet: Ignore network devices used by NBDŁukasz Stelmach1-0/+6
Add support for ignoring devices used by NBD to mount root the same way ConnMan ignores devices used for NFS roots. nbdroot= nbddev= parameters are used by Debian and Tizen initramfs scripts to configure NBD for mounting as root device.
2024-04-17ofono: delay device creation until lte settings are provisionedDenis Kenzior1-0/+40
For LTE capable devices, successful network registration typically requires the default attach APN to be configured. Some carriers will allow the device to register to the network even if this setting is empty or missing. Sometimes devices will utilize carrier specific settings present on the device itself (such as profiles in modem NVRAM, etc). However, there may be situations where missing default attach APN settings preclude successful registration, or registration is performed with an incorrect profile. Currently ConnMan does not take oFono's LTE support into consideration when setting the modem 'Online'. This can result in the modem attempting registration too early, when the default attach settings have not been applied. oFono has recently introduced Modem.Capabilities property which can provide an early hint whether the modem is LTE capable. If the modem is LTE capable, then ConnMan should wait until oFono LongTermEvolution interface is available (and thus default attach settings have been applied) prior to setting the device 'Online'.
2024-04-17ofono: combine create_device and ready_to_create_deviceDenis Kenzior1-47/+28
These two functions are called one after the other, repeating the same comment in multiple places. Combine them into a single function that takes care of checking whether the device can be created, and if so, creating it. Move the repeated comment to the new function. While here, refactor handling of 'ident' which removes the need for the 'out' label. Also, simplify some logic left over from CDMA support that was checking whether modem->imsi exists.
2024-04-17ofono: Set modem->interfaces earlierDenis Kenzior1-9/+6
Update modem->interfaces earlier so that handlers invoked on an interface being added or removed can check the current interface list.
2024-04-17ofono: Add generic method to convert a list of strings to flagsDenis Kenzior1-9/+40
oFono D-Bus APIs are string based, with several string list based properties that convey information that might require tracking. For example: - Interfaces -> list of interfaces supported - Features -> list of features supported - Capabilities -> modem capabilities Introduce a new convenience method that can be used to convert such string lists to a set of flags (bitmap). Make extract_interfaces() use it. While here, tighten up error checking and do not attempt to parse non-string list signatures.
2024-04-17gdhcp: Allow client to work on veth devicesDenis Kenzior1-2/+7
veth devices do not compute a checksum over the entire message. They simply pre-compute the pseudo-header portion and include this in the checksum field. Support such devices by computing the partial checksum. If the partial checksum matches, accept the packet.
2024-04-03gdhcp: Set pkt_len for packets received in L3 modeJohn Mark1-0/+1
The packet length is not set correctly when an IPv4 L3 ACK is received from a DHCP server. This causes the packet to be rejected for having no MESSAGE_TYPE option and the lease is not renewed at the T1 point (or any subsequent retry). Instead, the lease gets re-bound at the T2 point. Fixes: 58d397ba7487 ("gdhcp: Avoid reading invalid data in dhcp_get_option")
2024-02-15build: Remove really not needed tap-test utilityMarcel Holtmann3-200/+1
2024-01-26ofono: Don't invoke SetProperty unnecessarilyDenis Kenzior1-3/+2
When org.ofono.Modem.Powered property changes, connman invokes the SetProperty method again with the new value. This is pointless and only creates unnecessary DBus traffic. connmand[30]: plugins/ofono.c:modem_set_powered() /phonesim powered 1 connmand[30]: plugins/ofono.c:set_property() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:set_property_reply() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:modem_changed() /phonesim Powered 1 connmand[30]: plugins/ofono.c:modem_set_powered() /phonesim powered 1 connmand[30]: plugins/ofono.c:set_property() /phonesim path /phonesim org.ofono.Modem.Powered connmand[30]: plugins/ofono.c:set_property_reply() /phonesim path /phonesim org.ofono.Modem.Powered Fixes: 054dacc71c6a ("ofono: Set "powered" property according to value")
2024-01-26ofono: Remove support for CDMADenis Kenzior1-417/+8
oFono 2.2 removed all support for CDMA since most CDMA networks have now been shut down. Remove support for CDMA inside the ofono plugin as well.
2023-12-28main: Use preprocessor definition rather than 'General' string literal.Grant Erickson1-36/+39
This converts a potential run time error due to a mis-spelling of the "General" configuration group name repeatedly used as a string literal into a potential compile time error due to a mis-spelling of the preprocessor definition that now references it. There is no change in code size to .bss, .data, or .text due to this change.
2023-12-27service: Log service default, error, and state changes.Grant Erickson1-6/+51
Service default, error, and state changes are significant enough and low-frequency enough to warrant logging at the info level. This adds log entries for each in the form: ... [Ii]nterface <interface name> [ <service type> ] ... to achieve: Interface eth0 [ ethernet ] is the default Interface eth0 [ ethernet ] error "online-check-failed" Interface eth0 [ ethernet ] state is online log entries for default, error, and state changes, respectively.
2023-12-27service: Make log output of 'online_check_is_enabled_check' consistent.Grant Erickson1-2/+10
This makes the info-level log output of 'online_check_is_enabled_check' consistent with other messages using the format of: ... [Ii]nterface <interface name> [ <service type> ] ... to achieve: Online check disabled; interface wlan0 [ wifi ] remains in ready state.
2023-12-27doc: Remove 'Experimental' designation from 'EnableOnlineToReadyTransition'.Grant Erickson1-1/+0
This removes the "Experimental" designation from "OnlineCheckMode=continuous" / "EnableOnlineToReadyTransition=true" as it is functional, verified, and no longer experimental.
2023-12-23timezone: Fix resolving of proper ISO3166 code from tz dataJussi Laakkonen1-26/+152
It is possible that the region set as localtime region may have matches in either of the zone map files. And in some cases there may be ISO3166 codes in the deprecated files that are not supported by the backends such as gsupplicant to set the regulatory domain. Ålands/Mariehamn is an example of this since as a region it only exists in zone.tab and provides ISO3166 code AX which cannot be supported as regulatory domain. But zone1970.tab contains the ISO3166 as a sub-region code for Finland (FI) that should be set. Furthermore, the timezone files for sub-regions, like with Ålands in Finland and Pacific/Midway as UM -> AS, are identical copies and cannot be compared solely by checking the mmap()'d entries. The path needs to be taken into account or wrong region might be generated as a search parameter for getting the ISO3166 code. Otherwise the results in some cases might be ambiguous and the localtime set would yield another region as a search parameter for the ISO3661 code. Therefore, these changes add the real path utilized from the Localtime path set in ConnMan settings to be used along the comparison of timezone files. And the resolving of the ISO3661 code supports now more laborous search if the code is not found using the region as a search parameter. In such case the ISO3661 code is attempted to be searched from the deprecated tz map and when found this code is used to search the zone1970.tab again for a match in any of the defined ISO3166 string lists. As a result the ISO3166 code of the main region is set that should be supported by the varying backends to set the WiFi regulatory domain.
2023-12-23device: Setup regdom when powering up to maintain consistencyJussi Laakkonen1-0/+11
If the regdom has been set for the technology or for all the technologies as a global setting apply it when powering up a device that supports changing regdom. Otherwise the changes made to regdom may not have been propagated to the device if the change has been made when the device was powered off, for instance.
2023-12-23technology: Add global regdom and regdom getterJussi Laakkonen2-0/+28
Add a global regdom to be saved when setting technology regdom because the technologies are not loaded yet at bootup. Loading of plugins initializes technologies which then sets up the regdom if it has been set up earlier by timezone.c. The getter prioritizes the technology regdom and then the global regdom and is to be used by devices when powering up.
2023-12-23doc: Correct 'OnlineCheck{Initial,Max}Interval' units.Grant Erickson1-1/+1
This corrects the 'OnlineCheck{Initial,Max}Interval' units from 'secs' to 'interval'. Ultimately, in conjunction with a function associated with 'OnlineCheckIntervalStyle', 'OnlineCheck{Initial,Max}Interval' can be translated into seconds; however, the values themselves are simply unitless interval indices.
2023-12-23main: Add deprecation warnings for 'EnableOnlineCheck' and ↵Grant Erickson1-0/+8
'EnableOnlineToReadyTransition'. This adds deprecation warning log messages for 'EnableOnlineCheck' and 'EnableOnlineToReadyTransition' with guidance to transition to 'OnlineCheckMode'.
2023-12-23main: Consolidate logging of online check-related settings.Grant Erickson1-7/+40
This consolidates logging, at the info level, of all online check-related settings to a single place, 'online_check_settings_log' such that when the 'OnlineCheckMode' is "none", the following is logged: Online check mode "none" when 'OnlineCheckMode' is "one-shot", the following are logged: Online check mode "one-shot" Online check IPv4 URL "http://ipv4.connman.net/online/status.html" Online check IPv6 URL "http://ipv6.connman.net/online/status.html" Online check interval style "geometric" Online check interval range [1, 12] Online check connect timeout 12100 ms and when 'OnlineCheckMode' is "continuous the following are logged: Online check mode "continuous" Online check IPv4 URL "http://ipv4.connman.net/online/status.html" Online check IPv6 URL "http://ipv6.connman.net/online/status.html" Online check interval style "geometric" Online check interval range [1, 12] Online check connect timeout 12100 ms Online check continuous mode failures threshold 6 Online check continuous mode successes threshold 6
2023-12-23main: Add comments tags for online check-related settings.Grant Erickson1-1/+13
At this point, there are a sufficient number of settings in 'parse_config' that it is easy to lose track of where the block for one settings handler ends and the next begins. This adds comment tags for online check-related settings to make it easy, at a glance, to see where the block for each is.
2023-12-23doc: Document the 'OnlineCheckMode' setting.Grant Erickson3-67/+203
This documents the 'OnlineCheckMode' configuration setting.
2023-12-23service: Leverage 'OnlineCheckMode' setting.Grant Erickson2-20/+100
This leverages the newly-introduced 'OnlineCheckMode' setting, displacing and deprecating both the use of 'EnableOnlineCheck' and 'EnableOnlineToReadyTransition' in this module.
2023-12-23main/service: Introduce 'OnlineCheckMode' setting.Grant Erickson3-0/+82
This introduces a new 'OnlineCheckMode' configuration setting. This setting is intended to eventually deprecate 'EnableOnlineCheck' (long-term) and 'EnableOnlineToReadyTransition' (short-term). When asserted along with 'EnableOnlineCheck', 'EnableOnlineToReadyTransition' effects what can be thought of as a "continuous" online check mode, which is different from the "one-shot" online check mode when 'EnableOnlineToReadyTransition' is not asserted but 'EnableOnlineCheck' is. Effectively, these two Booleans encode three online check modes: 1. None (!EnableOnlineCheck) 2. One-shot (EnableOnlineCheck && !EnableOnlineToReadyTransition) 3. Continuous (EnableOnlineCheck && EnableOnlineToReadyTransition) With this change, these three modes are all formalized. In "none" mode, as has been the case historically, there are no "online" HTTP-based Internet reachability checks. Any connected service and the manager state will terminate at the "ready" state and will not progress to "online". In "one-shot" mode, as has been the case historically, there is a single, one-shot "online" HTTP-based Internet reachability check for the default service. When the check succeeds, the associated service and the manager state will terminate at the "online" state. When the check fails, subsequent checks will be rescheduled according to "OnlineCheckIntervalStyle", "OnlineCheckInitialInterval", and "OnlineCheckMaxInterval" and will continue indefinitely until one succeeds or until the service is disconnected. In "continuous" mode, which is finalized with this change, there are ongoing "online" HTTP-based Internet reachability check for the default service. As with "one-shot" mode, when the first check succeeds, the associated service and the manager state will terminate at the "online" state. Thereafter, subsequent checks will be scheduled according to "OnlineCheckIntervalStyle" and "OnlineCheckMaxInterval". When the check fails, subsequent checks will be rescheduled according to "OnlineCheckIntervalStyle", "OnlineCheckInitialInterval", and "OnlineCheckMaxInterval". This is largely unchanged. However, what is new with this change is that when and if "OnlineCheckFailuresThreshold" is met, the service and manager state will be demoted to "ready" and the service will have its "Error" property set to "online-check-failed" while subsequent checks will continue. In the interim, if available, another service may be promoted to the default service and online checks will be initiated for it. When and if, for the demoted service, "OnlineCheckSuccessesThreshold" is met, the service "Error" property will be cleared and the service state promoted to "online", potentially causing it to become the default service again.
2023-12-23service: Add 'DBG' to 'downgrade_connected_services'.Grant Erickson1-0/+2
This adds an empty 'DBG' to 'downgrade_connected_services' to make it clear in debug logs that it is the caller of 'service_downgrade_online_state' in that instance.
2023-12-23service: Add @sa documentation reference to 'current_default'.Grant Erickson1-0/+1
This adds an additional @sa ("see also") documentation reference to 'current_default'.
2023-12-23service: Add function parameter to 'default_changed' and 'service_list_sort'.Grant Erickson1-16/+37
There are four (4) invocations of 'default_changed' and nine (9) invocations of 'service_list_sort'. To aid debugging, a function parameter is added to each, which is a pointer to an immutable null-terminated C string, ostenisbly the name of the function that invoked either 'default_changed' or 'service_list_sort'. In addition, 'DEFAULT_CHANGED' and 'SERVICE_LIST_SORT' macros are added and leveraged at those 13 call sites. These macros invoke 'default_changed' or 'service_list_sort', passing the C preprocessor predefined '__func__' macro as the function parameter.
2023-12-23service: Document 'service_route_changed'.Grant Erickson1-0/+19
This adds documentation to the 'service_route_changed' functions.
2023-12-23service: Document 'service_schedule_changed'.Grant Erickson1-0/+9
This adds documentation to the 'service_schedule_changed' functions.
2023-12-23service: Document 'downgrade_connected_services'.Grant Erickson1-0/+13
This adds documentation to the 'downgrade_connected_services' functions.
2023-12-23service: Document interval assignment in '__connman_service_wispr_start'.Grant Erickson1-0/+5
This adds a comment documenting the rationale for setting the check interval to the initial interval in '__connman_service_wispr_start'.
2023-12-23service: Document the internals of 'service_compare'.Grant Erickson1-0/+44
This documents the major internal comparison blocks of the 'service_compare' function.
2023-12-23service: Add @sa documentation references.Grant Erickson1-0/+7
This adds additional @sa ("see also") documentation references to the 'handle_online_check_{failure,success}' and 'complete_online_check' functions.
2023-12-23service: Document 'handle_{continuous,oneshot}_online_check_failure'.Grant Erickson1-0/+81
This adds documentation to the 'handle_{continuous,oneshot}_online_check_failure' functions.
2023-12-23service: Document 'online_check_log_failure'.Grant Erickson1-0/+16
This adds documentation to the 'online_check_log_failure' function.
2023-12-23service: Document 'handle_{continuous,oneshot}_online_check_success'.Grant Erickson1-0/+61
This adds documentation to the 'handle_{continuous,oneshot}_online_check_success' functions.
2023-12-23service: Document ↵Grant Erickson1-0/+51
'continuous_online_check_log_{counter,failures,successes}_threshold_met'. This adds documentation to the 'continuous_online_check_log_{counter,failures,successes}_threshold_met' functions.
2023-12-23service: Document 'online_check_log_success'.Grant Erickson1-0/+14
This adds documentation to the 'online_check_log_success' function.
2023-12-23service: Document 'online_check_counter_increment_and_log'.Grant Erickson1-0/+18
This adds documentation to the 'online_check_counter_increment_and_log' function.
2023-12-23service: Document 'online_check_successes_threshold_is_met'.Grant Erickson1-0/+20
This adds documentation to the 'online_check_successes_threshold_is_met' function.
2023-12-23service: Document 'is_online_check_success_threshold_met_predicate'.Grant Erickson1-0/+26
This adds documentation to the 'is_online_check_success_threshold_met_predicate' function.
2023-12-23service: Document 'online_check_failures_threshold_is_met'.Grant Erickson1-0/+20
This adds documentation to the 'online_check_failures_threshold_is_met' function.
2023-12-23service: Document 'is_online_check_failure_threshold_met_predicate'.Grant Erickson1-0/+26
This adds documentation to the 'is_online_check_failure_threshold_met_predicate' function.
2023-12-23service: Document 'online_check_counter_threshold_is_met'.Grant Erickson1-0/+32
This adds documentation to the 'online_check_counter_threshold_is_met' function.
2023-12-23service: Document 'online_check_counters_log'.Grant Erickson1-0/+20
This adds documentation to the 'online_check_counters_log' function.
2023-12-23service: Document 'online_check_state_reset'.Grant Erickson1-0/+16
This adds documentation to the 'online_check_state_reset' function.
2023-12-23service: Document 'online_check_{failures,successes}_reset'.Grant Erickson1-0/+24
This adds documentation to the 'online_check_{failures,successes}_reset' functions.
2023-12-23service: Document 'online_check_counter_reset'.Grant Erickson1-0/+7
This adds documentation to the 'online_check_counter_reset' function.
2023-12-23service: Document 'online_check_failures_threshold_was_met_{set,clear}'.Grant Erickson1-0/+23
This adds documentation to the 'online_check_failures_threshold_was_met_{set,clear}' functions.
2023-12-23service: Document 'online_check_failures_threshold_was_met_set_value'.Grant Erickson1-0/+14
This adds documentation to the 'online_check_failures_threshold_was_met_set_value' function.
2023-12-23service: Document 'online_check_failures_threshold_was_met'.Grant Erickson1-0/+17
This adds documentation to the 'online_check_failures_threshold_was_met' function.
2023-12-23service: Complete 'continuous' online check mode implementation.Grant Erickson1-18/+643
This completes the implementation of 'EnableOnlineToReadyTransition' begun by Emmanuel Vautrin with commit f0bd0e8fe578 ("service: Add online to ready transition feature"). When asserted along with 'EnableOnlineCheck', 'EnableOnlineToReadyTransition' effects what can be thought of as a "continuous" online check mode, which is different from the "one-shot" online check mode when 'EnableOnlineToReadyTransition' is not asserted but 'EnableOnlineCheck' is. Effectively, these two Booleans encode three online check modes: 1. None (!EnableOnlineCheck) 2. One-shot (EnableOnlineCheck && !EnableOnlineToReadyTransition) 3. Continuous (EnableOnlineCheck && EnableOnlineToReadyTransition) With this change, these three modes are all but formalized. In "none" mode, as has been the case historically, there are no "online" HTTP-based Internet reachability checks. Any connected service and the manager state will terminate at the "ready" state and will not progress to "online". In "one-shot" mode, as has been the case historically, there is a single, one-shot "online" HTTP-based Internet reachability check for the default service. When the check succeeds, the associated service and the manager state will terminate at the "online" state. When the check fails, subsequent checks will be rescheduled according to "OnlineCheckIntervalStyle", "OnlineCheckInitialInterval", and "OnlineCheckMaxInterval" and will continue indefinitely until one succeeds or until the service is disconnected. In "continuous" mode, which is finalized with this change, there are ongoing "online" HTTP-based Internet reachability check for the default service. As with "one-shot" mode, when the first check succeeds, the associated service and the manager state will terminate at the "online" state. Thereafter, subsequent checks will be scheduled according to "OnlineCheckIntervalStyle" and "OnlineCheckMaxInterval". When the check fails, subsequent checks will be rescheduled according to "OnlineCheckIntervalStyle", "OnlineCheckInitialInterval", and "OnlineCheckMaxInterval". This is largely unchanged. However, what is new with this change is that when and if "OnlineCheckFailuresThreshold" is met, the service and manager state will be demoted to "ready" and the service will have its "Error" property set to "online-check-failed" while subsequent checks will continue. In the interim, if available, another service may be promoted to the default service and online checks will be initiated for it. When and if, for the demoted service, "OnlineCheckSuccessesThreshold" is met, the service "Error" property will be cleared and the service state promoted to "online", potentially causing it to become the default service again.
2023-12-23service: Capture IP configuration state by value rather than by pointer.Grant Erickson1-5/+6
With recent refactoring, there is no longer any need to capture the IP configuration state by pointer in 'complete_online_check'. Instead, capture it by value.
2023-12-23service: Move 'set_error' forward declaration earlier in the source.Grant Erickson1-3/+2
This moves the 'set_error' forward declaration earlier in the source such that it may be invoked by functions that precede its position before this change.
2023-12-23service: Document 'connman_service' 'online_check_state_ipv{4,6}' members.Grant Erickson1-0/+8
This documents the 'online_check_state_ipv{4,6}' members of the 'connman_service' structure.
2023-12-23service: Document 'connman_service' 'online_check_failures_met_threshold' ↵Grant Erickson1-0/+6
member. This documents the 'online_check_failures_met_threshold' member of the 'connman_service' structure.
2023-12-23service: Add per-service online check failure threshold state.Grant Erickson1-0/+1
This adds per-service state that tracks whether the service has met the number of sustained, back-to-back "online" reachability check failures for continuous" online check mode.
2023-12-23doc: Document the 'OnlineCheck{Failures,Successes}Threshold' settings.Grant Erickson2-0/+76
This documents the 'OnlineCheck{Failures,Successes}Threshold' settings.
2023-12-23main: Introduce the 'OnlineCheck{Failures,Successes}Threshold' settings.Grant Erickson1-0/+51
When both "EnableOnlineCheck" and "EnableOnlineToReadyTransition" are asserted, "OnlineCheckFailuresThreshold" is the number of failed back-to-back "ready" to "online" HTTP-based Internet reachability checks that will be allowed before marking a service as "failed" from a reachability perspective, sorting it at a lower priority than other services not so marked. When both "EnableOnlineCheck" and "EnableOnlineToReadyTransition" are asserted, "OnlineCheckSuccessesThreshold" is the number of successful back-to-back "ready" to "online" HTTP-based Internet reachability checks that must be met before clearing a service as "failed" from a reachability perspective and allowing it to transition to the "online" state again, allowing it to sort back to a higher priority relative to other network services.
2023-12-23service: Document 'online_check_state' 'failures/successes' members.Grant Erickson1-0/+10
This documents the 'failures/successes' members of the 'online_check_state' structure.
2023-12-23service: Introduce and use online check 'failures/successes' state.Grant Erickson1-0/+2
This introduces a per-IP configuration online check 'failures' and 'successes' state member that represent the number of sustained, back-to-back "online" reachability check failures and successes, respectively, for "continuous" online check mode.
2023-12-23doc/service: Document online check failure service error.Grant Erickson2-1/+9
This adds documentation for the online check failure service error enumeration and string.
2023-12-23service: Add online check failure service error enumeration and string.Grant Erickson2-9/+12
This adds the 'CONNMAN_SERVICE_ERROR_ONLINE_CHECK_FAILED' service error enumeration and "online-check-failed" string, used for services that have met or exceeded the continuous mode online check failure threshold.
2023-12-23session: Add service identifier to 'DBG' in four functions.Grant Erickson1-6/+16
This adds the service identifier to the 'DBG' statements in: * 'service_save' * '__connman_service_nameserver_append' * 'service_schedule_added' * 'service_route_changed' to aid debugging in a multi-technology environment with "EnableOnlineToReadyTransition" asserted and for consistency with other 'DBG' statements in this and other modules.
2023-12-23service: Add an explicit conditional for IPv6 in 'reschedule_online_check'.Grant Erickson1-1/+3
This adds an explicit conditional check for the 'type' parameter against 'CONNMAN_IPCONFIG_TYPE_IPV6' to ensure that neither 'CONNMAN_IPCONFIG_TYPE_ALL' or 'CONNMAN_IPCONFIG_TYPE_UNKNOWN' reschedule an IPv6 online check.
2023-12-23service: Document 'start_online_check_if_connected_with_type'.Grant Erickson1-0/+34
This adds documentation to the 'start_online_check_if_connected_with_type' function.
2023-12-23service: Refactor 'start_online_check_if_connected'.Grant Erickson1-14/+49
This refactors 'start_online_check_if_connected' into a support function, 'start_online_check_if_connected_with_type' to reduce copy-and-paste and to make common, checking the 'type' parameter, returning '-ENOTCONN' if the '__connman_service_is_connected_state' predicate is false, and passing along return status from '__connman_service_wispr_start'.
2023-12-23service: Rename 'start_wispr_if_connected'.Grant Erickson1-7/+7
This renames 'start_wispr_if_connected' to 'start_online_check_if_connected' since it aligns more closely with other '*_online_check' functions and simply uses WISPr to effect the online check.
2023-12-23service: Document 'online_check_active_{clear,set}'.Grant Erickson1-0/+42
This adds documentation to the 'online_check_active_{clear,set}' functions.
2023-12-23service: Document 'online_check_active_set_value'.Grant Erickson1-0/+22
This adds documentation to the 'online_check_active_set_value' function.
2023-12-23service: Document 'online_check_is_active'.Grant Erickson1-0/+22
This adds documentation to the 'online_check_is_active' function.
2023-12-23service: Document 'online_check_state' 'active' member.Grant Erickson1-0/+3
This documents the 'active' member of the 'online_check_state' structure.
2023-12-23service: Introduce and use online check 'active' state.Grant Erickson1-0/+92
This introduces a per-IP configuration online check 'active' state member that tracks whether an online check is active / in-flight. Even with commit 864e48f34e8c ("service: Leverage '__connman_wispr_cancel'.") it remains too easy to inadvertently schedule more outstanding online checks for a service than desired (ideally, there should be one each for IPv4 and IPv6, to the extent they are "connected"). This is all the more so when 'EnableOnlineToReadyTransition' is asserted / online check mode is continuous. Rather than scheduling redundant online check, the 'active' state is now used to enable the return of -EALREADY when it is asserted from functions capable of initiating and scheduling an online check.
2023-12-23service: Change return type of 'start_wispr_if_connected'.Grant Erickson1-2/+12
This changes the return type of 'start_wispr_if_connected' from 'void' to 'int' to allow callers to conditionally handle its return status.
2023-12-23service: Change return type of 'start_online_check'.Grant Erickson1-4/+24
This changes the return type of 'start_online_check' from 'void' to 'int' to allow callers to conditionally handle its return status.
2023-12-23service: Rename 'online_check_enabled_check'.Grant Erickson1-3/+4
Since 'online_check_enabled_check' is a predicate function, follow prevailing function name style for such predicates by adding '_is_' to the name.
2023-12-23service: Sanity check the 'type' param in '__connman_service_wispr_start'.Grant Erickson1-1/+9
This adds sanity checking for the 'type' parameter in '__connman_service_wispr_start'. In addition, it adds an explicit conditional test for the 'CONNMAN_IPCONFIG_TYPE_IPV6'. Both of these ensure that neither 'CONNMAN_IPCONFIG_TYPE_ALL' or 'CONNMAN_IPCONFIG_TYPE_UNKNOWN' trigger a WISPr start but, instead, error out.
2023-12-23service: Change return type of '__connman_service_wispr_start'.Grant Erickson2-2/+10
This changes the return type of '__connman_service_wispr_start' to allow callers to conditionally handle its return status which, as of this revision, is fairly simple but will be expanded over time.
2023-12-23ipconfig: Demote RTNL RTM_{ADD,DEL}ROUTE logs from info to DBG.Grant Erickson1-2/+2
With the "continuous" online check mode, logs can become dominated by Linux Routing Netlink (rtnl) 'RTM_{ADD,DEL}ROUTE' entries every time WISPr adds/deletes a host route for the online check. This demotes those log invocations from 'connman_info' to 'DBG'.
2023-12-23gateway: Expand the @param documentation for ↵Grant Erickson1-4/+8
'yield_default_gateway{,_for_type}'. This expands on the @param documentation for the 'yield_default_gateway{,_for_type}' functions by being more clear about the source of the parameters.
2023-12-23gateway: Add and leveage 'gateway_config_set_{,in}active'.Grant Erickson1-9/+18
This encapsulates and makes symmetric the actions at the "terminal ends" of the gateway configuration lifecycle / state machine by adding and leveraging 'gateway_config_set_{,in}active' to set the gateway configuration state and type appropriately.
2023-12-23gateway: Address unhandled gateway lifecycle events/transitions.Grant Erickson1-12/+21
There were a number of "escapes" or unhandled events and transitions that did not adhere to the documented gateway configuration lifecycle / state machine. This handles those events and transitions. Failure to handle these was resulting in duplicate default routes, no default routes, and incorrect default route priorities for some services and their underlying network interfaces.
2023-12-23gateway: Handle -ESRCH in 'unset_default_gateway_route_common'.Grant Erickson1-3/+25
This maps the error '-ESRCH' in 'unset_default_gateway_route_common' to 0 ("Success"). Generally, we mandate that gateway routes follow the documented lifecycle and finite state machine, using events and down- and upcalls to drive the lifecycle. There is one exception, however. When the Linux kernel recognizes that the next hop (that is, the "via" or RTA_GATEWAY portion of the route) for a route becomes unreachable, it is automatically purged from the routing table with no RTM_DELROUTE RTNL notification. Consequently, routes so purged will return -ESRCH when we attempt to delete them here in the mistaken belief they are still there. By mapping -ESRCH to 0 ("Success") we ensure that gateway configuration for such routes is not indefinitely stuck in the "active" or "added" states but rather is correctly advanced to the "removed" state.
2023-12-23inet: Use '__connman_inet_rtnl_recv' for RTNL default route transaction.Grant Erickson1-0/+6
This leverages '__connman_inet_rtnl_recv', introduced at commit 97967b4aae40 ("inet: Add '__connman_inet_rtnl_recv'."), to complete the Routing Netlink (rtnl) default route addition or deletion transaction in 'iproute_default_modify'. Every rtnl route addition or deletion transaction consists of a request and a response phase. The request phase contains the details of the route to be added or deleted. The response phase contains the status of whether the request succeeded. Unfortunately, to date, 'iproute_default_modify' did not include the response phase. Therefore, it did not complete the route request transaction, rendering the returns status incomplete in that it only reflected the success or failure of the request phase. Unfortunately, for callers of interfaces that, in turn, called 'iproute_default_modify', this made all routing requests appear to artificially succeed even when, in fact, they were failing and elided response status that callers need to conditionally act in the face of the transaction failure. By adding '__connman_inet_rtnl_recv' to complete the response phase of the rtnl route transaction, the return status of 'iproute_default_modify', and those interfaces that call it, now accurately reflect both the request and response status of the transaction.
2023-12-23timeserver: Add service identifier to 'DBG' in 'ts_reset'.Grant Erickson1-1/+2
This adds the service identifier to the 'DBG' statement in 'ts_reset' to aid debugging in a multi-technology environment with "EnableOnlineToReadyTransition" asserted and for consistency with other 'DBG' statements in other modules.
2023-12-23session: Add service identifier to 'DBG' in 'service_state_changed'.Grant Erickson1-1/+3
This adds the service identifier to the 'DBG' statement in 'service_state_changed' to aid debugging in a multi-technology environment with "EnableOnlineToReadyTransition" asserted and for consistency with other 'DBG' statements in other modules.
2023-12-23wispr: Make 'wispr_route_request' route add 'DBG' consistent.Grant Erickson1-12/+18
This makes the route addition 'DBG' in 'wispr_route_request' consistent with the route deletion 'DBG' in 'free_wispr_route'.
2023-12-23service: Qualify call to '__connman_timeserver_sync' with default check.Grant Erickson1-2/+19
This qualifies the call to '__connman_timeserver_sync' in '__connman_service_ipconfig_indicate_state' with a check against 'connman_service_is_default'. In a multi-technology and -service environment, there may be a senior, default service that is providing the network service for time-of-day synchronization. Without the 'connman_service_is_default' qualification, in a multi-technology and -service environment, as junior services transitions to the 'ready' state, each of those service usurp the senior, default service and start trying to provide time-of-day synchronization which is NOT what is desired. So, in a configuration with Ethernet, Wi-Fi, and Cellular in which they are preferred in that order and in which Ethernet is the default and becomes 'ready' first, Ethernet will provide the network service for time-of-day synchronization. Then, once Wi-Fi becomes 'ready', it will usurp time-of-day synchronization from Ethernet. Similarly, when Cellular becomes 'ready' it will usurp time-of-day synchronization from Wi-Fi. In all of those cases, time-of-day synchronization should have remained with Ethernet until such time as it was/is no longer the senior, default service.
2023-12-16inet: Document '__connman_service_nameserver_{add,del}_routes'.Grant Erickson1-0/+44
This adds documentation to the '__connman_service_nameserver_{add,del}_routes' functions.
2023-12-16inet: Document 'nameserver_{add,del}_routes'.Grant Erickson1-0/+50
This adds documentation to the 'nameserver_{add,del}_routes' functions.
2023-12-16inet: Document '{add,del}_nameserver_route'.Grant Erickson1-0/+53
This adds documentation to the '{add,del}_nameserver_route' functions.
2023-12-16service: Add 'DBG' to 'add_nameserver_route'.Grant Erickson1-0/+3
This adds a 'DBG' statement to 'add_nameserver_route' to match that in 'del_nameserver_route'.
2023-12-16service: Const-qualify 'add_nameserver_route'.Grant Erickson1-1/+1
Const-qualify the nameserver argument of 'add_nameserver_route' to make it clear to the compiler, static analyzers, and human readers that the function is strictly a getter with no nameserver argument mutation side effects.
2023-12-16inet: Document 'connman_inet_{add,del}_{,ipv6_}host_route'.Grant Erickson1-0/+144
This adds documentation to the 'connman_inet_{add,del}_{,ipv6_}host_route' functions.
2023-12-16inet: Add gateway parameter to 'connman_inet_del_{,ipv6_}host_route'.Grant Erickson4-22/+77
This adds a gateway address parameter to the 'connman_inet_del_{,ipv6_}host_route' functions. Routing table manipulation, host routes among them, should be fundamentally symmetric. The routing table entry parameters used to add a route should be identical to those used to delete the same route. Otherwise, an ESRCH error may occur which, at present, are suppressed due to commit e03a01d3182d ("inet: Fix error handling when adding/removing routes") that is masking route deletion errors where this gateway parameter asymmetry is occurring. In addition, call sites to 'connman_inet_del_{,ipv6_}host_route' are updated to pass the gateway parameter.
2023-12-16service: Add gateway parameter to DNS host route deletion paths.Grant Erickson3-12/+30
This adds a gateway address parameter to domain name service (DNS) server host route deletion paths. Routing table manipulation, host routes among them, should be fundamentally symmetric. The routing table entry parameters used to add a route should be identical to those used to delete the same route. The following interfaces were missing the gateway address parameter and now have it: * __connman_service_nameserver_del_routes * nameserver_del_routes to match: * __connman_service_nameserver_add_routes * nameserver_add_routes which had such a parameter.
2023-12-16service: Refactor 'nameserver_del_routes'.Grant Erickson1-15/+26
This refactors 'nameserver_del_routes' into a second, helper function 'del_nameserver_route' such that host route deletion is separated from nameserver iteration. In addition, the structure now mirrors that of 'nameserver_add_routes' and 'add_nameserver_route'. This is beneficial since route addition and deletion should be symmetric.
2023-12-16wispr: Leverage '__connman_service_get_route_metric'.Grant Erickson1-0/+11
This leverages '__connman_service_get_route_metric' to select an appropriate service-specific route metric/priority when adding or deleting WISPr host routes. This allows multiple such routes to coexist simultaneously, supporting "continuous" mode online checks in which one or more services may be conducting "online" WISPr-based Internet reachability checks as they move in and out of reachability success/failure.
2023-12-16wispr: Document 'wispr_portal_context_route_ops'.Grant Erickson1-0/+10
This adds documentation to the 'wispr_portal_context_route_ops' structure.
2023-12-16wispr: Document 'wispr_route'.Grant Erickson1-0/+19
This adds documentation to the 'wispr_route' structure.
2023-12-16wispr: Document 'free_wispr_route{,s}'.Grant Erickson1-0/+34
This adds documentation to the 'free_wispr_route{,s}' functions.
2023-12-16wispr: Simplify IPv4 vs. IPv6 host route management.Grant Erickson1-30/+82
This uses the recently-added, symmetric 'connman_inet_{add,del}_{,ipv6_}host_route_with_metric' functions and route operations tables to simplify IPv4 vs. IPv6 host route management for WISPr requests.
2023-12-16wispr: Refactor 'free_wispr_routes'.Grant Erickson1-19/+26
This refactors 'free_wispr_routes' into a second, helper function 'free_wispr_route' such that host route deallocation is separated from container iteration.
2023-12-16wispr: Update 'DBG' in '__connman_wispr_start'.Grant Erickson1-1/+1
This updates the initial 'DBG' in '__connman_wispr_start' to ensure there is space after the connect timeout value and the "ms" unit designation.
2023-12-16wispr: Add 'DBG' to '__connman_wispr_start' error path.Grant Erickson1-0/+2
This adds a 'DBG' to the '__connman_wispr_start' error path that includes both the error and the WISPr portal context associated with the error.
2023-12-16wispr: Expand 'DBG' in 'wispr_portal_detect'.Grant Erickson1-2/+2
This includes both the network interface index and name in the 'DBG' in 'wispr_portal_detect' to make it easier to identify on which network interface the WISPr portal detection is being made.
2023-12-16service: Document '__connman_service_get_route_metric'.Grant Erickson1-0/+34
This adds documentation to the '__connman_service_get_route_metric' function.
2023-12-16service: Add '__connman_service_get_route_metric'.Grant Erickson2-0/+66
This adds a new non-public service interface, '__connman_service_get_route_metric', which attempts to get the route metric/priority for the specified service based on the current service and services state. If the service is the default or if it is the only service, then the metric is zero (0). Otherwise, a low-priority metric (metric > 0) unique toservice and its underlying network interface is computed and returned.
2023-12-15service: Both cancel and stop online checks where appropriate.Grant Erickson1-0/+5
This both cancels, via 'cancel_online_check', and stops, via '__connman_wispr_stop' online checks on service disconnect or free. The former terminates any in-flight or recurring check activity in service.c and the latter terminates the same in wispr.c. Failure to cancel as well as stop can lead to a use-after-free fault in one-shot or continuous online check mode when a latent online check reschedule timer fires after the service has been disconnected or deallocated.
2023-12-15service: Add support for 'CONNMAN_IPCONFIG_TYPE_ALL' to 'cancel_online_check'.Grant Erickson1-10/+28
This adds support for passing 'CONNMAN_IPCONFIG_TYPE_ALL' to 'cancel_online_check' as the IP configuration type parameter to allow for canceling both IPv4 and IPv6 checks in a single function call.
2023-12-15inet: Eliminate dead store in 'iproute_default_modify'.Grant Erickson1-1/+0
In 'iproute_default_modify' there is a dead store to 'rth.req.u.r.rt.rtm_scope' with 'RT_SCOPE_NOWHERE' only to be overwritten two lines later with 'RT_SCOPE_UNIVERSE' without an intervening read. This eliminates the dead store of 'RT_SCOPE_NOWHERE'.
2023-12-15inet: Document IPv{4,6} host/network route functions with metric/priority.Grant Erickson1-0/+338
This adds documentation to the 'connman_inet_{add,del}_{,ipv6_}{host,network}_route_with_metric' functions.
2023-12-15connection: Document 'inet_modify_{,ipv4_,ipv6_}{host,network}_route'.Grant Erickson1-0/+321
This adds documentation to the 'inet_modify_{,ipv4_,ipv6_}{host,network}_route' functions.
2023-12-15connection: Document 'inet_modify_host_or_network_route'.Grant Erickson1-0/+61
This adds documentation to the 'inet_modify_host_or_network_route' function.
2023-12-15connection: Document 'inet_mask_addr_data'.Grant Erickson1-0/+25
This adds documentation to the 'inet_mask_addr_data' function.
2023-12-15connection: Document 'inet_get_addr_data'.Grant Erickson1-0/+31
This adds documentation to the 'inet_get_addr_data' function.
2023-12-15inet: Add IPv{4,6} host/network route functions with metric/priority.Grant Erickson2-32/+479
This adds 'connman_inet_{add,del}_{,ipv6_}{host,network}_route_with_metric' functions that provide the ability to add/delete an IPv4 or IPv6 host or network route with an explicit metric / priority. As a convenience, the 'connman_inet_{add,del}_{,ipv6_}network_route_with_metric' functions allow the caller to provide the IPv4 or IPv6 network address in masked (that is, 169.254.0.0/16) or unmasked (169.254.75.191/16) form. The function will mask the address, based on the provided prefix length, before modifying the route with it.
2023-12-15inet: Reorder IPv6 host and network route function declarations.Grant Erickson1-3/+4
This reorders the IPv6 host and network route function declarations to match that of their IPv4 couterparts.
2023-12-15inet: Relocate 'rtnl_route_cmd2string'.Grant Erickson1-12/+12
This relocates the 'rtnl_route_cmd2string' function earlier in the file to accommodate incorporation by other functions later in the file without the need for a forward declration.
2023-12-15connection: Document '__connman_inet_rtnl_recv'.Grant Erickson1-0/+34
This adds documentation to the '__connman_inet_rtnl_recv' function.
2023-12-15inet: Add '__connman_inet_rtnl_recv'.Grant Erickson2-15/+41
This refactors the private, file-scope interface 'inet_rtnl_recv' into a separate semi-public, project-scope interface '__connman_inet_rtnl_recv'. Currently, 'inet_rtnl_recv' is intended to be used as a glib runloop helper in conjunction with '__connman_inet_rtnl_talk' for longer or multi-phase Routing Netlink (rtnl) interactions. However, for short, concise open/send/recv/close Routing Netlink (rtnl) interactions in which there is a single request/response phase or the complexity of an asynchronous run loop interaction is not needed, there is not an appropriate 'recv' interface to peer with open/send/close. With this change, the core of 'inet_rtnl_recv' is factored out into that missing 'recv' interface, '__connman_inet_rtnl_recv' with 'inet_rtnl_recv' invoking it.
2023-12-14gateway: Rename public and private symbols after file rename.Grant Erickson8-58/+58
This renames public and private symbols in "gateway.c" reflective of the recent name change of the file from "connection.c" to "gateway.c".
2023-12-14gateway: Updated @file comment to reflect recent rename.Grant Erickson1-3/+2
This updates the @file comment to reflect the recent rename of this file from "connection.c" to "gateway.c".
2023-12-14connection: Rename 'connection.c' to 'gateway.c'.Grant Erickson3-2/+2
While historically, "connection.c" might have been a contextually-apt name, today it might be better named "gateway.c" since its primary focus is gateway routes and gateway route management. Reflective of that, this renames "connection.c" to "gateway.c".
2023-12-08connection: Fix typo in @file comment.Grant Erickson1-1/+1
This fixes a minor grammatical typo in the @file comment.
2023-12-08connection: Ensure function attribution 'DBG' output is consistent.Grant Erickson1-3/+3
This ensures that function call attribution 'DBG' output is consistent in the format "from %s()".
2023-12-08connection: Add whitespace around 'del_gateway_routes_if_active'.Grant Erickson1-0/+2
Increase visual visibility of 'del_gateway_routes_if_active' in 'add_gateway' by adding blank lines both before and after the function call.
2023-12-08connection: Add @file comment.Grant Erickson1-0/+208
This adds a detailed @file comment, providing a high-level overview of the module, key issues and principles, and theory of operation.
2023-12-08connection: Update '{un,}set_default_gateway' documentation.Grant Erickson1-28/+64
This updates the '{un,}set_default_gateway' function documentation to reflect changes due to adding support for both high- and low-priority default gateway routes.
2023-12-08connection: Update 'unset_default_gateway_route_common' documentation.Grant Erickson1-0/+3
This updates the "see also" documentation for 'unset_default_gateway_route_common' to reflect other functions it calls or depends on.
2023-12-08connection: Update 'set_default_gateway_route_common' documentation.Grant Erickson1-0/+3
This updates the "see also" documentation for 'set_default_gateway_route_common' to reflect other functions it calls or depends on.
2023-12-08connection: Fix documentation typos.Grant Erickson1-2/+2
This corrects prior documentation '@param' typos for 'check_default_gateway' and 'remove_gateway'.
2023-12-08connection: Document 'unset_low_priority_default_gateway'.Grant Erickson1-0/+44
This adds documentation to the 'unset_low_priority_default_gateway' function.
2023-12-08connection: Document 'unset_ipv4_low_priority_default_gateway'.Grant Erickson1-0/+44
This adds documentation to the 'unset_ipv4_low_priority_default_gateway' function.
2023-12-08connection: Document 'unset_ipv4_low_priority_default_gateway_route_cb'.Grant Erickson1-0/+35
This adds documentation to the 'unset_ipv4_low_priority_default_gateway_route_cb' function.
2023-12-08connection: Document 'set_low_priority_default_gateway'.Grant Erickson1-0/+32
This adds documentation to the 'set_low_priority_default_gateway' function.
2023-12-08connection: Document 'set_ipv4_low_priority_default_gateway'.Grant Erickson1-0/+43
This adds documentation to the 'set_ipv4_low_priority_default_gateway' function.
2023-12-08connection: Document 'set_ipv4_low_priority_default_gateway_route_cb'.Grant Erickson1-0/+36
This adds documentation to the 'set_ipv4_low_priority_default_gateway_route_cb' function.
2023-12-08connection: Document 'unset_ipv6_high_priority_default_gateway'.Grant Erickson1-0/+32
This adds documentation to the 'unset_ipv6_high_priority_default_gateway' function.
2023-12-08connection: Document 'unset_ipv4_high_priority_default_gateway'.Grant Erickson1-0/+32
This adds documentation to the 'unset_ipv4_high_priority_default_gateway' function.
2023-12-08connection: Document 'unset_ipv6_high_priority_default_gateway_route_cb'.Grant Erickson1-0/+36
This adds documentation to the 'unset_ipv6_high_priority_default_gateway_route_cb' function.
2023-12-08connection: Document 'unset_ipv4_high_priority_default_gateway_route_cb'.Grant Erickson1-0/+36
This adds documentation to the 'unset_ipv4_high_priority_default_gateway_route_cb' function.
2023-12-08connection: Document 'set_ipv6_high_priority_default_gateway'.Grant Erickson1-0/+43
This adds documentation to the 'set_ipv6_high_priority_default_gateway' function.
2023-12-08connection: Document 'set_ipv4_high_priority_default_gateway'.Grant Erickson1-0/+43
This adds documentation to the 'set_ipv4_high_priority_default_gateway' function.
2023-12-08connection: Document 'set_ipv6_high_priority_default_gateway_route_cb'.Grant Erickson1-0/+36
This adds documentation to the 'set_ipv6_high_priority_default_gateway_route_cb' function.
2023-12-08connection: Document 'set_ipv4_high_priority_default_gateway_route_cb'.Grant Erickson1-0/+36
This adds documentation to the 'set_ipv4_high_priority_default_gateway_route_cb' function.
2023-12-08connection: Document 'promote_default_gateway'.Grant Erickson1-0/+50
This adds documentation to the 'promote_default_gateway' function.
2023-12-08connection: Document 'demote_default_gateway'.Grant Erickson1-0/+49
This adds documentation to the 'demote_default_gateway' function.
2023-12-08connection: Document call to 'connman_service_unref'.Grant Erickson1-0/+4
This documents the call to 'connman_service_unref' to help point readers or maintainers where its balancing retained reference is located.
2023-12-08connection: Document 'add_host_route'.Grant Erickson1-0/+23
This adds documentation to the 'add_host_route' function.
2023-12-08connection: Document 'compute_low_priority_metric'.Grant Erickson1-0/+45
This adds documentation to the 'compute_low_priority_metric' function.
2023-12-08connection: Update 'find_any_active_gateway_data' documentation.Grant Erickson1-4/+4
This updates documentation to the 'find_any_active_gateway_data' function now that the module supports both high- and low-priority default gateways and their routes.
2023-12-08connection: Document 'is_addr_any_str'.Grant Erickson1-0/+21
This adds documentation to the 'is_addr_any_str' function.
2023-12-08connection: Document 'gateway_hash'.Grant Erickson1-0/+5
This adds documentation to the 'gateway_hash' global.
2023-12-08connection: Document 'gateway_data'.Grant Erickson1-0/+32
This adds documentation to the 'gateway_data' structure.
2023-12-08connection: Document 'gateway_config'.Grant Erickson1-0/+11
This adds documentation to the 'gateway_config' structure.
2023-12-08connection: Document 'gateway_config_ops'.Grant Erickson1-0/+9
This adds documentation to the 'gateway_config_ops' structure and its instantiation in 'gateway_config'.
2023-12-08connection: Document 'gateway_config_state' finite state machine.Grant Erickson1-1/+24
This documents the finite state machine (FSM) implied by 'gateway_config_state' and the implementation leveraging it.
2023-12-08connection: Add 'DBG' else clauses to 'connection_delgateway'.Grant Erickson1-2/+4
This adds 'DBG' else clauses to 'connection_delgateway' to aid in debugging cases that otherwise "skip out" of 'connection_delgateway'.
2023-12-08connection: Refactor 'add_host_route'.Grant Erickson1-42/+32
This refactors 'add_host_route' to take advantage of the recently-introduced gateway configuration 'ops'. This faciliates collapsing the IPv4- and IPv6-specific sub-blocks into one, hanlding both IPv4 and IPv6.
2023-12-08connection: Introduce gateway config 'ops'Grant Erickson1-30/+134
This introduces a gateway configuration 'ops' data structure of IPv4- and IPv6-specific addressing and routing functions. With this introduction, all accesses to these functions are done through a pointer to an "ops" structure. This further neutralizes IPv4- and IPv6-specific code blocks and clears a path towards their unification.
2023-12-08connection: Add 'is_addr_any_str'.Grant Erickson1-8/+17
This adds 'is_addr_any_str' which can successfully determine whether a specified text-formatted IP address is the "any" or "unspecified" address for either an IPv4 or an IPv6 address. Application of 'is_addr_any_str' helps neutralize any/unspecified address string comparisons and moves IPv4- and IPv6-specific blocks of code closer to unification.
2023-12-08connection: Introduce '{de,pro}mote_default_gateway'.Grant Erickson1-81/+100
There are 10 instances of either: UNSET_DEFAULT_GATEWAY(data, type); SET_LOW_PRIORITY_DEFAULT_GATEWAY(data, type); or: UNSET_LOW_PRIORITY_DEFAULT_GATEWAY(data, type); SET_DEFAULT_GATEWAY(data, type); This formalizes the former as 'demote_default_gateway' and the latter as 'promote_default_gateway'. In addition, '{DE,PRO}MOTE_DEFAULT_GATEWAY' macros are added and leveraged at those 10 call sites. These macros invoke '{de,pro}mote_default_gateway', passing the C preprocessor predefined '__func__' macro as the function parameter.
2023-12-08connection: Add support for low-priority default routes.Grant Erickson1-63/+308
This adds support for low-priority (that is, metric > 0) default routes along side the existing high-priority (that is, metric 0) default route taken on by the default service. For IPv6, these are handled and managed automatically by the kernel as part of Router Discovery (RD) Router Advertisements (RAs) and because link-local addresses and multi-homing are a natural part of IPv6, nothing needs to be done for these here. Such routes show up in 'ip -6 route show' as: default via fe80::f29f:c2ff:fe10:271e dev eth0 proto ra metric 1024 expires 1622sec hoplimit 64 pref medium default via fe80::f29f:c2ff:fe10:271e dev wlan0 proto ra metric 1024 expires 1354sec hoplimit 64 pref medium For IPv4, largely invented before the advent of link-local addresses and multi-homing hosts, these need to be fully-managed here and, with such management, should up in 'ip -4 route show' as low-priority (that is, metric > 0) default routes: default via 192.168.2.1 dev wlan0 metric 4294967295 The other alternative to low-priority routes would be to use "def1" default routes commonly used by VPNs that have a prefix length of 1 (hence the "def1" name). These would should up as: 0.0.0.0/1 via 192.168.2.1 dev wlan0 128.0.0.0/1 via 192.168.2.1 dev wlan0 However, since these require twice the number of routing table entries and seem no more effective than the low-priority route approach, this alternative is not used here at present. The low-priority metric is determined on a per-network interface basis and is computed by 'compute_low_priority_metric'. Operationally, down calls from outside this module generally come from the following three functions: 1. __connman_connection_gateway_add 2. __connman_connection_gateway_remove 3. __connman_connection_update_gateway and up calls generally come from the following two functions: 1. connection_newgateway 2. connection_delgateway From these five functions above, we are then either attempting to do the following for a gateway associated with a network service and its underlying network interface: 1. Set, or add, the high- or low-priority default route(s). 2. Unset, or remove, the high- or low-priority default route(s). 3. Promote the default route from low- to high-priority. 4. Demote the default route from high- to low-priority.
2023-12-08inet: Document '__connman_inet_{add,del}_default_{to,from}_table_with_metric'.Grant Erickson1-0/+66
This adds documentation to the '__connman_inet_{add,del}_default_{to,from}_table_with_metric' functions.
2023-12-08inet: Add '__connman_inet_{add,del}_default_{to,from}_table_with_metric'.Grant Erickson2-0/+38
This adds two new functions for adding a gateway default route: '__connman_inet_{add,del}_default_{to,from}_table_with_metric', which expands on the existing '__connman_inet_{add,del}_default_{to,from}_table' by allowing the caller to pass a non-zero metric/priority.
2023-12-08connection: Document '__connman_inet_del_default_to_table'.Grant Erickson1-0/+32
This adds documentation to the '__connman_inet_del_default_to_table' function.
2023-12-08connection: Document '__connman_inet_add_default_to_table'.Grant Erickson1-0/+32
This adds documentation to the '__connman_inet_add_default_to_table' function.
2023-12-08inet: Document 'iproute_default_modify'.Grant Erickson1-0/+39
This adds documentation to the 'iproute_default_modify' function.
2023-12-08inet: Add a metric parameter to 'iproute_default_modify'.Grant Erickson1-12/+35
This adds a Routing Netlink (rtnl) metric/priority parameter to 'iproute_default_modify'.
2023-12-08ipconfig: Use 'RT_SCOPE_*' mnemonics.Grant Erickson1-2/+2
This leverages 'RT_SCOPE_*' mnemonics rather than magic numbers for 'scope2str'.
2023-12-08inet: Include the command value and string in 'DBG'Grant Erickson1-1/+14
This includes the Routing Netlink (rtnl) command value and string in 'DBG' in 'iproute_default_modify' to aid in debugging.
2023-12-08inet: Include interface index and name in 'DBG'.Grant Erickson1-1/+5
This includes both the network interface index and name in the 'DBG' statement in 'iproute_default_modify' to aid in debugging.
2023-12-08ipconfig: Pass the rtnl dst prefixlen to '__connman_ipconfig_{new,del}route'.Grant Erickson3-20/+32
This adds support for extracting and passing the Routing Netlink (rtnl) destination prefix length to '__connman_ipconfig_{new,del}route' from 'process_{new,del}route'.
2023-12-08ipconfig: Pass the rtnl metric to '__connman_ipconfig_{new,del}route'.Grant Erickson3-16/+24
This adds support for extracting and passing the Routing Netlink (rtnl) metric/priority to '__connman_ipconfig_{new,del}route' from 'process_{new,del}route'.
2023-12-08rtnl: Add support for extracting the metric/priority.Grant Erickson1-6/+16
This adds support for extracting the Routing Netlink (rtnl) table metric/priority attribute from rtnl messages.
2023-12-08ipconfig: Pass the rtnl table to '__connman_ipconfig_{new,del}route'.Grant Erickson3-16/+28
This adds support for extracting and passing the Routing Netlink (rtnl) table identifier to '__connman_ipconfig_{new,del}route' from 'process_{new,del}route'.
2023-12-08rtnl: Add support for extracting the table identifier.Grant Erickson1-6/+20
This adds support for extracting the Routing Netlink (rtnl) table identifier attribute from rtnl messages.
2023-12-08inet: Leverage '__connman_inet_table2string'.Grant Erickson1-1/+3
This leverages '__connman_inet_table2string' when logging the Routing Netlink (rtnl) table identifier in 'iproute_default_modify'.
2023-12-08inet: Document '__connman_inet_table2string'.Grant Erickson1-0/+17
This adds documentation to the '__connman_inet_table2string' function.
2023-12-08inet: Add '__connman_inet_table2string'.Grant Erickson2-0/+20
This adds the function '__connman_inet_table2string', which returns a null-terminated C string describing a Linux Routing Netlink (rtnl) routing table identifier.
2023-12-08connection: Document 'unset_default_gateway_route_common'.Grant Erickson1-0/+43
This adds documentation to the 'unset_default_gateway_route_common' function.
2023-12-08connection: Document 'set_default_gateway_route_common'.Grant Erickson1-0/+45
This adds documentation to the 'set_default_gateway_route_common' function.
2023-12-08connection: Document 'mutate_default_gateway_route_cb_t'.Grant Erickson1-0/+17
This adds documentation to the 'mutate_default_gateway_route_cb_t' typedef.
2023-12-08connection: Fan out route manipulation into callbacks.Grant Erickson1-10/+91
There is an appreciable amount of boilerplate copied-and-pasted among the four set/unset IPv4/IPv6 gateway default route mutation functions. This introduces two new functions to handle that common boilerplate: 'set_default_gateway_route_common' and 'unset_default_gateway_route_common' and introduces a new function pointer, 'mutate_default_gateway_route_cb_t' that they take as a parameter. The four remaining set/unset IPv4/IPv6 gateway default route mutation functions are then solely responsible only for making additions or deletions to the routing table(s).
2023-12-08connection: Change return type of 'set_default_gateway'.Grant Erickson1-2/+8
This changes the return signature of 'set_default_gateway' from 'void' to 'int' such that its status can be leveraged for conditional execution where it is called.
2023-12-08connection: Leverage 'unset_default_gateway' in 'del_gateway_routes'.Grant Erickson1-12/+10
Much of the logic in 'del_gateway_routes' is otherwise identical to that of 'unset_default_gateway'. However, it side steps managing the gateway state, type, and flags state, potentially leaving inconsistencies. Rather than this separate-but-equal existence, simply leverage 'unset_default_gateway' in 'del_gateway_routes'.
2023-12-08connection: Change return type of 'unset_default_gateway'.Grant Erickson1-2/+5
This changes the return signature of 'unset_default_gateway' from 'void' to 'int' such that its status can be leveraged for conditional execution where it is called.
2023-12-08connection: Add low-priority default gateway config type.Grant Erickson1-1/+9
This adds a low-priority gateway default route type as a parallel peer to the existing high-priority type.