diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-09-13 10:02:32 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2019-09-13 18:13:26 +0000 |
commit | 80703b667bbf8e23298e9d6bded3ef3250986cc9 (patch) | |
tree | 75364dfcfc87bbe844d65bbbe41f0963465b217b /src/mm-broadband-bearer.c | |
parent | e7881e4e29770b87e60cc633ee0980ce68f2e01f (diff) |
broadband-bearer: fix logic looking for unused CID
When looking for the first unused CID, we should also consider those
contexts defined with a different PDP type, not just the ones with the
same PDP type.
Diffstat (limited to 'src/mm-broadband-bearer.c')
-rw-r--r-- | src/mm-broadband-bearer.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c index d93fa529..d91cee90 100644 --- a/src/mm-broadband-bearer.c +++ b/src/mm-broadband-bearer.c @@ -892,22 +892,23 @@ parse_pdp_list (MMBaseModem *modem, break; } - /* If an unused CID was not found yet and the previous CID is not (CID - 1), - * this means that (previous CID + 1) is an unused CID that can be used. - * This logic will allow us using unused CIDs that are available in the gaps - * between already defined contexts. - */ - if (!unused_cid && prev_cid && ((prev_cid + 1) < pdp->cid)) { - unused_cid = prev_cid + 1; - mm_dbg ("Found the first unused PDP context with CID %u", unused_cid); - } /* PDP with no APN set? we may use that one if no exact match found */ - else if ((!pdp->apn || !pdp->apn[0]) && !ctx->blank_cid) { + if ((!pdp->apn || !pdp->apn[0]) && !ctx->blank_cid) { ctx->blank_cid = pdp->cid; mm_dbg ("Found the first PDP context with no APN with CID %u", ctx->blank_cid); } } + /* If an unused CID was not found yet and the previous CID is not (CID - 1), + * this means that (previous CID + 1) is an unused CID that can be used. + * This logic will allow us using unused CIDs that are available in the gaps + * between already defined contexts. + */ + if (!unused_cid && prev_cid && ((prev_cid + 1) < pdp->cid)) { + unused_cid = prev_cid + 1; + mm_dbg ("Found the first unused PDP context with CID %u", unused_cid); + } + /* Update previous CID value to the current CID for use in the next loop, * unless an unused CID was already found. */ |