Age | Commit message (Collapse) | Author | Files | Lines |
|
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.
|
|
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()
|
|
Make sure to check the sendto error return value like is done elsewhere.
|
|
It is astronomically unlikely that fcntl would fail, but check the error
return just in case.
|
|
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.
|
|
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.
|
|
|
|
|
|
A GSupplicantSSID instance was leaked in ssid_ap_init() in case
connman_technology_get_wifi_tethering() didn't succeed.
|
|
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.
|
|
This fixes the signdness warnings found in dnsproxy.c
|
|
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.
|
|
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'.
|
|
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.
|
|
Update modem->interfaces earlier so that handlers invoked on an
interface being added or removed can check the current interface list.
|
|
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.
|
|
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.
|
|
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")
|
|
|
|
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")
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
This removes the "Experimental" designation from
"OnlineCheckMode=continuous" / "EnableOnlineToReadyTransition=true" as
it is functional, verified, and no longer experimental.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
'EnableOnlineToReadyTransition'.
This adds deprecation warning log messages for 'EnableOnlineCheck' and
'EnableOnlineToReadyTransition' with guidance to transition to
'OnlineCheckMode'.
|
|
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
|
|
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.
|
|
This documents the 'OnlineCheckMode' configuration setting.
|
|
This leverages the newly-introduced 'OnlineCheckMode' setting,
displacing and deprecating both the use of 'EnableOnlineCheck' and
'EnableOnlineToReadyTransition' in this module.
|
|
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.
|
|
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.
|
|
This adds an additional @sa ("see also") documentation reference to
'current_default'.
|
|
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.
|
|
This adds documentation to the 'service_route_changed' functions.
|
|
This adds documentation to the 'service_schedule_changed' functions.
|
|
This adds documentation to the 'downgrade_connected_services'
functions.
|
|
This adds a comment documenting the rationale for setting the check
interval to the initial interval in '__connman_service_wispr_start'.
|
|
This documents the major internal comparison blocks of the
'service_compare' function.
|
|
This adds additional @sa ("see also") documentation references to the
'handle_online_check_{failure,success}' and 'complete_online_check'
functions.
|
|
This adds documentation to the
'handle_{continuous,oneshot}_online_check_failure' functions.
|
|
This adds documentation to the 'online_check_log_failure' function.
|
|
This adds documentation to the
'handle_{continuous,oneshot}_online_check_success' functions.
|
|
'continuous_online_check_log_{counter,failures,successes}_threshold_met'.
This adds documentation to the
'continuous_online_check_log_{counter,failures,successes}_threshold_met'
functions.
|
|
This adds documentation to the 'online_check_log_success' function.
|
|
This adds documentation to the
'online_check_counter_increment_and_log' function.
|
|
This adds documentation to the
'online_check_successes_threshold_is_met' function.
|
|
This adds documentation to the
'is_online_check_success_threshold_met_predicate' function.
|
|
This adds documentation to the
'online_check_failures_threshold_is_met' function.
|
|
This adds documentation to the
'is_online_check_failure_threshold_met_predicate' function.
|
|
This adds documentation to the 'online_check_counter_threshold_is_met'
function.
|
|
This adds documentation to the 'online_check_counters_log' function.
|
|
This adds documentation to the 'online_check_state_reset' function.
|
|
This adds documentation to the
'online_check_{failures,successes}_reset' functions.
|
|
This adds documentation to the 'online_check_counter_reset' function.
|
|
This adds documentation to the
'online_check_failures_threshold_was_met_{set,clear}' functions.
|
|
This adds documentation to the
'online_check_failures_threshold_was_met_set_value' function.
|
|
This adds documentation to the
'online_check_failures_threshold_was_met' function.
|
|
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.
|
|
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.
|
|
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.
|
|
This documents the 'online_check_state_ipv{4,6}' members of the
'connman_service' structure.
|
|
member.
This documents the 'online_check_failures_met_threshold' member of the
'connman_service' structure.
|
|
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.
|
|
This documents the 'OnlineCheck{Failures,Successes}Threshold' settings.
|
|
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.
|
|
This documents the 'failures/successes' members of the
'online_check_state' structure.
|
|
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.
|
|
This adds documentation for the online check failure service error
enumeration and string.
|
|
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.
|
|
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.
|
|
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.
|
|
This adds documentation to the
'start_online_check_if_connected_with_type' function.
|
|
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'.
|
|
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.
|
|
This adds documentation to the 'online_check_active_{clear,set}'
functions.
|
|
This adds documentation to the 'online_check_active_set_value'
function.
|
|
This adds documentation to the 'online_check_is_active' function.
|
|
This documents the 'active' member of the 'online_check_state'
structure.
|
|
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.
|
|
This changes the return type of 'start_wispr_if_connected' from 'void'
to 'int' to allow callers to conditionally handle its return status.
|
|
This changes the return type of 'start_online_check' from 'void' to
'int' to allow callers to conditionally handle its return status.
|
|
Since 'online_check_enabled_check' is a predicate function, follow
prevailing function name style for such predicates by adding '_is_' to
the name.
|
|
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.
|
|
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.
|
|
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'.
|
|
'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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
This makes the route addition 'DBG' in 'wispr_route_request'
consistent with the route deletion 'DBG' in 'free_wispr_route'.
|
|
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.
|
|
This adds documentation to the
'__connman_service_nameserver_{add,del}_routes' functions.
|
|
This adds documentation to the 'nameserver_{add,del}_routes'
functions.
|
|
This adds documentation to the '{add,del}_nameserver_route' functions.
|
|
This adds a 'DBG' statement to 'add_nameserver_route' to match that in
'del_nameserver_route'.
|
|
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.
|
|
This adds documentation to the
'connman_inet_{add,del}_{,ipv6_}host_route' functions.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
This adds documentation to the 'wispr_portal_context_route_ops'
structure.
|
|
This adds documentation to the 'wispr_route' structure.
|
|
This adds documentation to the 'free_wispr_route{,s}' functions.
|
|
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.
|
|
This refactors 'free_wispr_routes' into a second, helper function
'free_wispr_route' such that host route deallocation is separated from
container iteration.
|
|
This updates the initial 'DBG' in '__connman_wispr_start' to ensure
there is space after the connect timeout value and the "ms" unit
designation.
|
|
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.
|
|
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.
|
|
This adds documentation to the '__connman_service_get_route_metric'
function.
|
|
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.
|
|
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.
|
|
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.
|
|
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'.
|
|
This adds documentation to the
'connman_inet_{add,del}_{,ipv6_}{host,network}_route_with_metric'
functions.
|
|
This adds documentation to the
'inet_modify_{,ipv4_,ipv6_}{host,network}_route' functions.
|
|
This adds documentation to the 'inet_modify_host_or_network_route'
function.
|
|
This adds documentation to the 'inet_mask_addr_data' function.
|
|
This adds documentation to the 'inet_get_addr_data' function.
|
|
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.
|
|
This reorders the IPv6 host and network route function declarations to
match that of their IPv4 couterparts.
|
|
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.
|
|
This adds documentation to the '__connman_inet_rtnl_recv'
function.
|
|
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.
|
|
This renames public and private symbols in "gateway.c" reflective of
the recent name change of the file from "connection.c" to "gateway.c".
|
|
This updates the @file comment to reflect the recent rename of this
file from "connection.c" to "gateway.c".
|
|
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".
|
|
This fixes a minor grammatical typo in the @file comment.
|
|
This ensures that function call attribution 'DBG' output is consistent
in the format "from %s()".
|
|
Increase visual visibility of 'del_gateway_routes_if_active' in
'add_gateway' by adding blank lines both before and after the function
call.
|
|
This adds a detailed @file comment, providing a high-level overview of
the module, key issues and principles, and theory of operation.
|
|
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.
|
|
This updates the "see also" documentation for
'unset_default_gateway_route_common' to reflect other functions it calls
or depends on.
|
|
This updates the "see also" documentation for
'set_default_gateway_route_common' to reflect other functions it calls
or depends on.
|
|
This corrects prior documentation '@param' typos for
'check_default_gateway' and 'remove_gateway'.
|
|
This adds documentation to the 'unset_low_priority_default_gateway'
function.
|
|
This adds documentation to the
'unset_ipv4_low_priority_default_gateway' function.
|
|
This adds documentation to the
'unset_ipv4_low_priority_default_gateway_route_cb' function.
|
|
This adds documentation to the 'set_low_priority_default_gateway'
function.
|
|
This adds documentation to the 'set_ipv4_low_priority_default_gateway'
function.
|
|
This adds documentation to the
'set_ipv4_low_priority_default_gateway_route_cb' function.
|
|
This adds documentation to the
'unset_ipv6_high_priority_default_gateway' function.
|
|
This adds documentation to the
'unset_ipv4_high_priority_default_gateway' function.
|
|
This adds documentation to the
'unset_ipv6_high_priority_default_gateway_route_cb' function.
|
|
This adds documentation to the
'unset_ipv4_high_priority_default_gateway_route_cb' function.
|
|
This adds documentation to the
'set_ipv6_high_priority_default_gateway' function.
|
|
This adds documentation to the
'set_ipv4_high_priority_default_gateway' function.
|
|
This adds documentation to the
'set_ipv6_high_priority_default_gateway_route_cb' function.
|
|
This adds documentation to the
'set_ipv4_high_priority_default_gateway_route_cb' function.
|
|
This adds documentation to the 'promote_default_gateway' function.
|
|
This adds documentation to the 'demote_default_gateway' function.
|
|
This documents the call to 'connman_service_unref' to help point
readers or maintainers where its balancing retained reference is
located.
|
|
This adds documentation to the 'add_host_route' function.
|
|
This adds documentation to the 'compute_low_priority_metric' function.
|
|
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.
|
|
This adds documentation to the 'is_addr_any_str' function.
|
|
This adds documentation to the 'gateway_hash' global.
|
|
This adds documentation to the 'gateway_data' structure.
|
|
This adds documentation to the 'gateway_config' structure.
|
|
This adds documentation to the 'gateway_config_ops' structure and its
instantiation in 'gateway_config'.
|
|
This documents the finite state machine (FSM) implied by
'gateway_config_state' and the implementation leveraging it.
|
|
This adds 'DBG' else clauses to 'connection_delgateway' to aid in
debugging cases that otherwise "skip out" of 'connection_delgateway'.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
This adds documentation to the
'__connman_inet_{add,del}_default_{to,from}_table_with_metric' functions.
|
|
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.
|
|
This adds documentation to the '__connman_inet_del_default_to_table'
function.
|
|
This adds documentation to the '__connman_inet_add_default_to_table'
function.
|
|
This adds documentation to the 'iproute_default_modify' function.
|
|
This adds a Routing Netlink (rtnl) metric/priority parameter to
'iproute_default_modify'.
|
|
This leverages 'RT_SCOPE_*' mnemonics rather than magic numbers for
'scope2str'.
|
|
This includes the Routing Netlink (rtnl) command value and string in
'DBG' in 'iproute_default_modify' to aid in debugging.
|
|
This includes both the network interface index and name in the 'DBG'
statement in 'iproute_default_modify' to aid in debugging.
|
|
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'.
|
|
This adds support for extracting and passing the Routing Netlink
(rtnl) metric/priority to '__connman_ipconfig_{new,del}route' from
'process_{new,del}route'.
|
|
This adds support for extracting the Routing Netlink (rtnl) table
metric/priority attribute from rtnl messages.
|
|
This adds support for extracting and passing the Routing Netlink
(rtnl) table identifier to '__connman_ipconfig_{new,del}route' from
'process_{new,del}route'.
|
|
This adds support for extracting the Routing Netlink (rtnl) table
identifier attribute from rtnl messages.
|
|
This leverages '__connman_inet_table2string' when logging the Routing
Netlink (rtnl) table identifier in 'iproute_default_modify'.
|
|
This adds documentation to the '__connman_inet_table2string'
function.
|
|
This adds the function '__connman_inet_table2string', which returns a
null-terminated C string describing a Linux Routing Netlink (rtnl)
routing table identifier.
|
|
This adds documentation to the 'unset_default_gateway_route_common'
function.
|
|
This adds documentation to the 'set_default_gateway_route_common'
function.
|
|
This adds documentation to the 'mutate_default_gateway_route_cb_t'
typedef.
|
|
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).
|
|
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.
|
|
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'.
|
|
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.
|
|
This adds a low-priority gateway default route type as a parallel peer
to the existing high-priority type.
|