Change in libosmocore[master]: gprs_ns2: truncate the NS_STATUS to 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/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Fri Feb 19 10:41:55 UTC 2021


lynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/22910 )

Change subject: gprs_ns2: truncate the NS_STATUS to the MTU
......................................................................

gprs_ns2: truncate the NS_STATUS to the MTU

A NS Status can contain the original NS message which might result
in a NS PDU which exceeds the MTU of the NS-VC.
Truncate the original message to the maximum possible.
Based on truncate BSSGP status message.

Related: OS#4889
Change-Id: I35d8f8bf0eae890f4db56423da0b23b638d24311
---
M src/gb/gprs_ns2_message.c
1 file changed, 7 insertions(+), 2 deletions(-)

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



diff --git a/src/gb/gprs_ns2_message.c b/src/gb/gprs_ns2_message.c
index bfb8781..7f52c4b 100644
--- a/src/gb/gprs_ns2_message.c
+++ b/src/gb/gprs_ns2_message.c
@@ -432,6 +432,7 @@
 	struct msgb *msg = ns2_msgb_alloc();
 	struct gprs_ns_hdr *nsh;
 	uint16_t nsvci = osmo_htons(nsvc->nsvci);
+	unsigned int orig_len, max_orig_len;
 
 	log_set_context(LOG_CTX_GB_NSE, nsvc->nse);
 	log_set_context(LOG_CTX_GB_NSVC, nsvc);
@@ -461,8 +462,12 @@
 	case NS_CAUSE_PROTO_ERR_UNSPEC:
 	case NS_CAUSE_INVAL_ESSENT_IE:
 	case NS_CAUSE_MISSING_ESSENT_IE:
-		msgb_tvlv_put(msg, NS_IE_PDU, msgb_l2len(orig_msg),
-			      orig_msg->l2h);
+		/* ensure the PDU doesn't exceed the MTU */
+		orig_len = msgb_l2len(orig_msg);
+		max_orig_len = msgb_length(msg) + TVLV_GROSS_LEN(orig_len);
+		if (max_orig_len > nsvc->bind->mtu)
+			orig_len -= max_orig_len - nsvc->bind->mtu;
+		msgb_tvlv_put(msg, NS_IE_PDU, orig_len, orig_msg->l2h);
 		break;
 	default:
 		break;

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I35d8f8bf0eae890f4db56423da0b23b638d24311
Gerrit-Change-Number: 22910
Gerrit-PatchSet: 10
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
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/20210219/ae5c72c9/attachment.htm>


More information about the gerrit-log mailing list