[PATCH] osmo-ggsn[master]: libgtp: Allow each PDP context to specify if it transmits G-...

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Sep 24 08:54:43 UTC 2017


Review at  https://gerrit.osmocom.org/4041

libgtp: Allow each PDP context to specify if it transmits G-PDU sequence numbers

GTP sequence numbers on GTP-U are optional for G-PDU type messages (i.e.
user-ip messages).  Let's allow the user to specify this behavior by
a new pdu_t.tx_gpdu_seq flag.  The flag is enabled by default to stay
compatible with the prior behaviour.

Related: OS#2519
Change-Id: Icf22a2ddd5c4a968ef5bda7c202b921d93fb49e6
---
M TODO-RELEASE
M gtp/gtp.c
M gtp/pdp.c
M gtp/pdp.h
4 files changed, 23 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-ggsn refs/changes/41/4041/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index d0852fc..e38e18c 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public release: c:r:0.
 #library	what		description / commit summary line
+libgtp		pdp.h		Addition of new tx_gpdu_seq struct member member
diff --git a/gtp/gtp.c b/gtp/gtp.c
index ebbad91..fee49b5 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -3186,20 +3186,30 @@
 
 		get_default_gtp(0, GTP_GPDU, &packet);
 		packet.gtp0.h.length = hton16(len);
-		packet.gtp0.h.seq = hton16(pdp->gtpsntx++);
+		if (pdp->tx_gpdu_seq)
+			packet.gtp0.h.seq = hton16(pdp->gtpsntx++);
+		else
+			packet.gtp0.h.seq = 0;
 		packet.gtp0.h.flow = hton16(pdp->flru);
 		packet.gtp0.h.tid = htobe64(pdp_gettid(pdp->imsi, pdp->nsapi));
 	} else if (pdp->version == 1) {
 
-		iov[0].iov_len = GTP1_HEADER_SIZE_LONG;
 		addr.sin_port = htons(GTP1U_PORT);
 		fd = gsn->fd1u;
 
 		get_default_gtp(1, GTP_GPDU, &packet);
-		packet.gtp1l.h.length = hton16(len - GTP1_HEADER_SIZE_SHORT +
-					       GTP1_HEADER_SIZE_LONG);
-		packet.gtp1l.h.seq = hton16(pdp->gtpsntx++);
-		packet.gtp1l.h.tei = hton32(pdp->teid_gn);
+		if (pdp->tx_gpdu_seq) {
+			packet.gtp1l.h.seq = hton16(pdp->gtpsntx++);
+			packet.gtp1l.h.length = hton16(len - GTP1_HEADER_SIZE_SHORT +
+						       GTP1_HEADER_SIZE_LONG);
+			packet.gtp1l.h.tei = hton32(pdp->teid_gn);
+			iov[0].iov_len = GTP1_HEADER_SIZE_LONG;
+		} else {
+			packet.gtp1s.h.flags &= ~GTP1HDR_F_SEQ;
+			packet.gtp1s.h.length = hton16(len);
+			packet.gtp1s.h.tei = hton32(pdp->teid_gn);
+			iov[0].iov_len = GTP1_HEADER_SIZE_SHORT;
+		}
 	} else {
 		LOGP(DLGTP, LOGL_ERROR, "Unknown version: %d\n", pdp->version);
 		return EOF;
diff --git a/gtp/pdp.c b/gtp/pdp.c
index ff9c681..d3e9232 100644
--- a/gtp/pdp.c
+++ b/gtp/pdp.c
@@ -149,6 +149,8 @@
 				     1].secondary_tei[(*pdp)->nsapi & 0x0f] =
 				    (*pdp)->teid_own;
 			}
+			/* Default: Generate G-PDU sequence numbers on Tx */
+			(*pdp)->tx_gpdu_seq = true;
 
 			return 0;
 		}
diff --git a/gtp/pdp.h b/gtp/pdp.h
index cb98920..f8b0df8 100644
--- a/gtp/pdp.h
+++ b/gtp/pdp.h
@@ -13,6 +13,8 @@
 #ifndef _PDP_H
 #define _PDP_H
 
+#include <stdbool.h>
+
 struct gsn_t;
 
 #define PDP_MAX 1024		/* Max number of PDP contexts */
@@ -226,6 +228,8 @@
 	void *priv;
 
 	struct gsn_t *gsn;
+
+	bool tx_gpdu_seq;		/* Transmit (true) or suppress G-PDU sequence numbers */
 };
 
 /* functions related to pdp_t management */

-- 
To view, visit https://gerrit.osmocom.org/4041
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf22a2ddd5c4a968ef5bda7c202b921d93fb49e6
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ggsn
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list