From 95eef34d37948118c212962d63490f6f78caa30b Mon Sep 17 00:00:00 2001 From: Sven Schwermer Date: Tue, 8 Mar 2022 15:30:50 +0100 Subject: [PATCH] modem-helpers: Consider minimum ID when choosing best profile +CGDCONT? may list profiles with IDs that are illegal to write, i.e. +CGDCONT=? returns a minimum ID larger than some of the existing profiles. E.g. for Fibocom L610-EU, +CGDCONT=? returns +CGDCONT: (1-7),"IP",,,(0-3),(0-4) +CGDCONT: (1-7),"IPV6",,,(0-3),(0-4) +CGDCONT: (1-7),"IPV4V6",,,(0-3),(0-4) +CGDCONT: (1-7),"PPP",,,(0-3),(0-4) +CGDCONT: (1-7),"Non-IP",,,(0-3),(0-4) while the default EPS bearer is established at profile 0: +CGDCONT: 0,"IP","xxx","xxx.xxx.xxx.xxx",0,0 [...] Signed-off-by: Sven Schwermer --- src/mm-modem-helpers.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index c969b665..a780b15f 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -1629,6 +1629,11 @@ mm_3gpp_profile_list_find_best (GList *profile_list, iter_profile_id = mm_3gpp_profile_get_profile_id (iter_profile); + if (iter_profile_id < min_profile_id) { + mm_obj_dbg (log_object, "skipping context at profile %d: out of bounds", iter_profile_id); + continue; + } + /* Always prefer an exact match; compare all supported fields except for profile id */ if (mm_3gpp_profile_cmp (iter_profile, requested, cmp_apn, cmp_flags)) { mm_obj_dbg (log_object, "found exact context at profile %d", iter_profile_id);