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/.
lynxis lazus gerrit-no-reply at lists.osmocom.orglynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/22197 ) Change subject: gprs_ns2: check if persistent nsei or nsvc exists when creating dynamic NSE ...................................................................... gprs_ns2: check if persistent nsei or nsvc exists when creating dynamic NSE When receiving a NS Reset over an unknown NSVC the NS code would create a dynamic NSE. If the NSEI or NSVCI is already configured to a persistant NSE/NSVC the packet should be ignored. Change-Id: I855911e7d364f2e5b08ea05857747aa63fcf1cd3 --- M src/gb/gprs_ns2.c 1 file changed, 34 insertions(+), 4 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/97/22197/1 diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c index e43b636..0335ad6 100644 --- a/src/gb/gprs_ns2.c +++ b/src/gb/gprs_ns2.c @@ -858,18 +858,49 @@ return GPRS_NS2_CS_REJECTED; } - /* find or create NSE */ nsei = tlvp_val16be(&tp, NS_IE_NSEI); + nsvci = tlvp_val16be(&tp, NS_IE_VCI); + + /* find or create NSE */ nse = gprs_ns2_nse_by_nsei(bind->nsi, nsei); if (!nse) { - if (!bind->nsi->create_nse) { + /* only create nse for udp & ipaccess */ + if (bind->ll != GPRS_NS2_LL_UDP || dialect != NS2_DIALECT_IPACCESS) return GPRS_NS2_CS_SKIPPED; - } + + if (!bind->nsi->create_nse || !bind->accept_ipaccess) + return GPRS_NS2_CS_SKIPPED; nse = gprs_ns2_create_nse(bind->nsi, nsei, bind->ll, dialect); if (!nse) { + LOGP(DLNS, LOGL_ERROR, "Failed to create NSE(%d)\n", nsei); return GPRS_NS2_CS_ERROR; } + } else { + /* nsei already known */ + if (nse->ll != bind->ll) { + LOGP(DLNS, LOGL_ERROR, "Received NS-RESET NS-VCI(%d) with wrong linklayer(%s) for already known NSE(%d/%s)\n", + nsei, gprs_ns2_lltype_str(bind->ll), nse->nsei, gprs_ns2_lltype_str(nse->ll)); + return GPRS_NS2_CS_SKIPPED; + } + } + + nsvc = gprs_ns2_nsvc_by_nsvci(bind->nsi, nsvci); + if (nsvc) { + if (nsvc->persistent) { + LOGP(DLNS, LOGL_ERROR, "Received NS-RESET for a persistent NSE(%d) NS-VCI(%d) over wrong connection.\n", + nsei, nsvci); + return GPRS_NS2_CS_SKIPPED; + } + /* destroy old dynamic nsvc */ + gprs_ns2_free_nsvc(nsvc); + } + + /* do nse persistent check late to be more precise on the error message */ + if (nse->persistent) { + LOGP(DLNS, LOGL_ERROR, "Received NS-RESET for a persistent NSE(%d) but the unknown NS-VCI(%d)\n", + nsei, nsvci); + return GPRS_NS2_CS_SKIPPED; } vc_mode = gprs_ns2_dialect_to_vc_mode(dialect); @@ -877,7 +908,6 @@ if (!nsvc) return GPRS_NS2_CS_SKIPPED; - nsvci = tlvp_val16be(&tp, NS_IE_VCI); nsvc->nsvci = nsvci; nsvc->nsvci_is_valid = true; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22197 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I855911e7d364f2e5b08ea05857747aa63fcf1cd3 Gerrit-Change-Number: 22197 Gerrit-PatchSet: 1 Gerrit-Owner: lynxis lazus <lynxis at fe80.eu> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210114/94e5efa1/attachment.htm>