mirror of https://gerrit.osmocom.org/libosmocore
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
This commit is contained in:
parent
d9825c0a2c
commit
db7b2ab36b
|
@ -1552,7 +1552,7 @@ void ns2_nse_update_mtu(struct gprs_ns2_nse *nse)
|
|||
|
||||
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
|
||||
|
|
|
@ -41,6 +41,7 @@ int bssgp_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
|
|||
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 @@ static int ns_prim_cb(struct osmo_prim_hdr *oph, void *ctx)
|
|||
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 @@ void test_mtu(void *ctx)
|
|||
/* 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");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue