aboutsummaryrefslogtreecommitdiffstats
path: root/src/sgsn
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2020-10-23 13:11:02 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2020-10-23 13:23:18 +0200
commit25998ddcc56ff8c11bf7d2e19e672e3f1d4f034f (patch)
treed22e0d6d58d2bd7d2ed060ced23b3c5f38a34f4a /src/sgsn
parent60581ae7c9a8bf2ee6ba9c7efa567a3b207d7161 (diff)
process_ms_ctx_status: refactor to avoid code duplication
Diffstat (limited to 'src/sgsn')
-rw-r--r--src/sgsn/gprs_gmm.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c
index bf72cd6f..0ad60037 100644
--- a/src/sgsn/gprs_gmm.c
+++ b/src/sgsn/gprs_gmm.c
@@ -1524,21 +1524,16 @@ static void process_ms_ctx_status(struct sgsn_mm_ctx *mmctx,
* being in state PDP-INACTIVE. */
llist_for_each_entry_safe(pdp, pdp2, &mmctx->pdp_list, list) {
- if (pdp->nsapi < 8) {
- if (!(pdp_status[0] & (1 << pdp->nsapi))) {
- LOGMMCTXP(LOGL_NOTICE, mmctx, "Dropping PDP context for NSAPI=%u "
- "due to PDP CTX STATUS IE= 0x%02x%02x\n",
- pdp->nsapi, pdp_status[1], pdp_status[0]);
- sgsn_delete_pdp_ctx(pdp);
- }
- } else {
- if (!(pdp_status[1] & (1 << (pdp->nsapi - 8)))) {
- LOGMMCTXP(LOGL_NOTICE, mmctx, "Dropping PDP context for NSAPI=%u "
- "due to PDP CTX STATUS IE= 0x%02x%02x\n",
- pdp->nsapi, pdp_status[1], pdp_status[0]);
- sgsn_delete_pdp_ctx(pdp);
- }
- }
+ bool inactive = (pdp->nsapi < 8) ?
+ !(pdp_status[0] & (1 << pdp->nsapi)) :
+ !(pdp_status[1] & (1 << (pdp->nsapi - 8)));
+ if (!inactive)
+ continue;
+
+ LOGMMCTXP(LOGL_NOTICE, mmctx, "Dropping PDP context for NSAPI=%u "
+ "due to PDP CTX STATUS IE=0x%02x%02x\n",
+ pdp->nsapi, pdp_status[1], pdp_status[0]);
+ sgsn_delete_pdp_ctx(pdp);
}
}