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/+/22343 )
Change subject: gprs_ns2: inform the NS user (BSSGP) about the MTU of a NSE
......................................................................
gprs_ns2: inform the NS user (BSSGP) about the MTU of a NSE
The BSSGP need to know the MTU of the BSSGP layer.
The MTU can be 0 if the NSE doesn't contain any NSVC.
Every status indication will contain the mtu value.
The MTU in the status indication contain the maximum transfer
unit of a BSSGP message. From NS side the maximum SDU.
Change-Id: I5016b295db6185ec131d83089cf6c806e34ef1b6
---
M include/osmocom/gprs/gprs_ns2.h
M src/gb/gprs_ns2.c
M src/gb/gprs_ns2_fr.c
M src/gb/gprs_ns2_frgre.c
M src/gb/gprs_ns2_internal.h
M src/gb/gprs_ns2_udp.c
6 files changed, 65 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/43/22343/1
diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index 1b20298..cf2f86c 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -135,6 +135,8 @@
/* Only true on the first time it's available.
* Allow the BSSGP layer to reset persistent NSE */
bool first;
+ /* MTU of a BSSGP PDU. It's the lowest MTU of all (alive & dead) NSVCs */
+ int mtu;
} status;
} u;
};
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 0c1d564..87cb0ad 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -474,6 +474,7 @@
nsp.u.status.transfer = ns2_count_transfer_cap(nse, bvci);
nsp.u.status.first = nse->first;
nsp.u.status.persistent = nse->persistent;
+ nsp.u.status.mtu = nse->mtu - 4; /* 1b NS PDU type, 1b NS SDU control, 2b BVCI */
if (nsvc)
nsp.u.status.nsvc = gprs_ns2_ll_str_buf(nsvc_str, sizeof(nsvc_str), nsvc);
@@ -519,6 +520,7 @@
llist_add(&nsvc->list, &nse->nsvc);
llist_add(&nsvc->blist, &bind->nsvc);
+ ns2_nse_update_mtu(nse);
return nsvc;
@@ -717,6 +719,7 @@
nse->nsei = nsei;
nse->nsi = nsi;
nse->first = true;
+ nse->mtu = 0;
llist_add(&nse->list, &nsi->nse);
INIT_LLIST_HEAD(&nse->nsvc);
@@ -1316,6 +1319,26 @@
array[i] = bind;
}
+void ns2_nse_update_mtu(struct gprs_ns2_nse *nse)
+{
+ struct gprs_ns2_vc *nsvc;
+ int mtu = 0;
+
+ if (llist_empty(&nse->nsvc)) {
+ nse->mtu = 0;
+ return;
+ }
+
+ llist_for_each_entry(nsvc, &nse->nsvc, list) {
+ if (mtu == 0)
+ mtu = nsvc->bind->mtu;
+ else if (mtu > nsvc->bind->mtu)
+ mtu = nsvc->bind->mtu;
+ }
+
+ nse->mtu = mtu;
+}
+
/*! calculate the transfer capabilities for a nse
* \param nse the nse to count the transfer capability
* \param bvci a bvci - unused
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index 274ed96..00efd8a 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -592,6 +592,9 @@
bind->free_vc = free_vc;
bind->dump_vty = dump_vty;
bind->nsi = nsi;
+ /* 48.016 § 6.1.4.2 default maximum information field size of 1600 octets
+ * FR has 2 byte header */
+ bind->mtu = 1600 - 2;
priv = bind->priv = talloc_zero(bind, struct priv_bind);
if (!priv) {
rc = -ENOSPC;
diff --git a/src/gb/gprs_ns2_frgre.c b/src/gb/gprs_ns2_frgre.c
index 2812e12..1529b48 100644
--- a/src/gb/gprs_ns2_frgre.c
+++ b/src/gb/gprs_ns2_frgre.c
@@ -568,6 +568,8 @@
bind->send_vc = frgre_vc_sendmsg;
bind->free_vc = free_vc;
bind->nsi = nsi;
+ /* TODO: update mtu similiar to UDP - GRE header */
+ bind->mtu = 1500;
priv = bind->priv = talloc_zero(bind, struct priv_bind);
if (!priv) {
diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h
index af8c5f0..42499db 100644
--- a/src/gb/gprs_ns2_internal.h
+++ b/src/gb/gprs_ns2_internal.h
@@ -167,6 +167,9 @@
/*! sum of all the signalling weight of _active_ NS-VCs */
uint32_t sum_sig_weight;
+
+ /*! MTU of a NS PDU. This is the lowest MTU of all NSVCs */
+ int mtu;
};
/*! Structure representing a single NS-VC */
@@ -232,6 +235,9 @@
/*! transfer capability in mbit */
int transfer_capability;
+ /*! MTU of a NS PDU on this bind. */
+ int mtu;
+
/*! which link-layer are we based on? */
enum gprs_ns2_ll ll;
@@ -276,6 +282,7 @@
uint16_t bvci,
enum gprs_ns2_affecting_cause cause);
void ns2_nse_notify_alive(struct gprs_ns2_vc *nsvc, bool alive);
+void ns2_nse_update_mtu(struct gprs_ns2_nse *nse);
/* message */
int gprs_ns2_validate(struct gprs_ns2_vc *nsvc,
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 8bfa184..c468015 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -111,6 +111,32 @@
}
}
+#define SIZE_IPV4_HEADER 20
+#define SIZE_IPV6_HEADER 23
+#define SIZE_UDP_HEADER 8
+
+static void update_mtu(struct gprs_ns2_vc_bind *bind) {
+ struct priv_bind *priv;
+ /* TODO: replace 1500 (default ethernet mtu) with interface mtu */
+ int mtu = 1500;
+
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
+
+ priv = bind->priv;
+ switch (priv->addr.u.sa.sa_family) {
+ case AF_INET:
+ mtu -= SIZE_IPV4_HEADER + SIZE_UDP_HEADER;
+ break;
+ case AF_INET6:
+ mtu -= SIZE_IPV6_HEADER + SIZE_UDP_HEADER;
+ break;
+ default:
+ break;
+ }
+
+ bind->mtu = mtu;
+}
+
/*! Find a NS-VC by its remote socket address.
* \param[in] bind in which to search
@@ -382,6 +408,8 @@
dscp, rc, errno);
}
+ update_mtu(bind);
+
llist_add(&bind->list, &nsi->binding);
if (result)
*result = bind;
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/22343
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I5016b295db6185ec131d83089cf6c806e34ef1b6
Gerrit-Change-Number: 22343
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/20210120/e2333aa7/attachment.htm>