Change in libosmocore[master]: gprs_ns2: fix crash when changing the MTU

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Jul 5 12:06:18 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/24824 )

Change subject: gprs_ns2: fix crash when changing the MTU
......................................................................

gprs_ns2: fix crash when changing the MTU

When the MTU changes for any fr device, all
NSE will recalculate their MTU. If any NSE is alive,
libosmocore will crash.

Related: OS#5192
Change-Id: I31ba5cefea7bbb0b74060d6664b42c58815ee2a1
---
M src/gb/gprs_ns2.c
M tests/gb/gprs_ns2_test.c
2 files changed, 12 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  daniel: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 720e836..a8e646b 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -1552,7 +1552,7 @@
 
 	nse->mtu = mtu;
 	if (nse->alive)
-		ns2_prim_status_ind(nsvc->nse, NULL, 0, GPRS_NS2_AFF_CAUSE_MTU_CHANGE);
+		ns2_prim_status_ind(nse, NULL, 0, GPRS_NS2_AFF_CAUSE_MTU_CHANGE);
 }
 
 /*! calculate the transfer capabilities for a nse
diff --git a/tests/gb/gprs_ns2_test.c b/tests/gb/gprs_ns2_test.c
index c53cc6d..b96e739 100644
--- a/tests/gb/gprs_ns2_test.c
+++ b/tests/gb/gprs_ns2_test.c
@@ -41,6 +41,7 @@
 static struct log_info info = {};
 static struct osmo_wqueue *unitdata = NULL;
 static struct osmo_gprs_ns2_prim last_nse_recovery = {};
+static struct osmo_gprs_ns2_prim last_nse_mtu_change = {};
 
 static int ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
 {
@@ -54,8 +55,12 @@
 			msgb_free(oph->msg);
 		}
 	}
-	if (oph->primitive == GPRS_NS2_PRIM_STATUS && nsp->u.status.cause == GPRS_NS2_AFF_CAUSE_RECOVERY) {
-		last_nse_recovery = *nsp;
+	if (oph->primitive == GPRS_NS2_PRIM_STATUS) {
+		if (nsp->u.status.cause == GPRS_NS2_AFF_CAUSE_RECOVERY) {
+			last_nse_recovery = *nsp;
+		} else if (nsp->u.status.cause == GPRS_NS2_AFF_CAUSE_MTU_CHANGE) {
+			last_nse_mtu_change = *nsp;
+		}
 	}
 	return 0;
 }
@@ -579,6 +584,10 @@
 	/* 1b NS PDU type, 1b NS SDU control, 2b BVCI */
 	OSMO_ASSERT(last_nse_recovery.u.status.mtu == 123 - 4);
 
+	bind[0]->mtu = 100;
+	ns2_nse_update_mtu(nse);
+	OSMO_ASSERT(last_nse_mtu_change.u.status.mtu == 100 - 4);
+
 	gprs_ns2_free(nsi);
 	printf("--- Finish unitdata test\n");
 }

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/24824
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I31ba5cefea7bbb0b74060d6664b42c58815ee2a1
Gerrit-Change-Number: 24824
Gerrit-PatchSet: 2
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210705/d6df2004/attachment.htm>


More information about the gerrit-log mailing list