pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39949?usp=email )
Change subject: client: Process up to 10 recorded pkts per poll iteration
......................................................................
client: Process up to 10 recorded pkts per poll iteration
This should decrease CPU use of lipcap capturing under high capturing
load, which is welcome now that we support osmo_io with io-uring backend
on the Tx side towards osmo-pcap-server.
The processing number is kept low in order to avoid starving the event
loop, as well as avoid filling up the msgb queue of the Tx side towards
osmo-pcap-server.
Related: SYS#7290
Change-Id: I569fc8489bae2b829ef4040d3c5111a61129de68
---
M src/osmo_client_core.c
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
laforge: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c
index e58439b..daa5fd6 100644
--- a/src/osmo_client_core.c
+++ b/src/osmo_client_core.c
@@ -175,7 +175,9 @@
struct osmo_pcap_handle *ph = fd->data;
int rc;
- rc = pcap_dispatch(ph->handle, 1, pcap_read_one_cb, (u_char *)ph);
+ /* Read up to 10 packets at once, to avoid starving the event loop and
+ * filling up transmit queue towards peer. */
+ rc = pcap_dispatch(ph->handle, 10, pcap_read_one_cb, (u_char *)ph);
if (rc < 0) {
rate_ctr_inc2(ph->ctrg, PH_CTR_PERR);
rate_ctr_inc2(ph->client->ctrg, CLIENT_CTR_PERR);
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39949?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I569fc8489bae2b829ef4040d3c5111a61129de68
Gerrit-Change-Number: 39949
Gerrit-PatchSet: 6
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcap/+/39948?usp=email )
Change subject: client: use pcap_dispatch to avoid extra pkt buffer copy
......................................................................
client: use pcap_dispatch to avoid extra pkt buffer copy
pcap_next() allows use of returned buffer until next time the same API
is called. In order to do so, it internally calls pcap_dispatch() with
an internal handler (in the case of linux pcapint_oneshot_linux()).
That handler basically memcpy()s the pkt buffer obtained in the
pcap_dispatch callback into a temporary static buffer which is then
returned.
We don't need any of that here, and by using pcap_dispatch() directly
(as recommended in pcapint_oneshot_linux() function documentation) we
can skip an extra memcpy() of each packet buffer captured.
Furthermore, it will allow us processing multiple packets from the
captured queue (RA_SOCKET+mmap implementation in linux) in one poll
iteration if several packets have been captured. This will be done in a
follow-up patch.
pcap handle is marked non-blocking to allow polling from it without
ending up blocked. Applying filter is moved beforehand, as seen in
libpcap capturetest example.
Related: SYS#7290
Change-Id: I055efb66fac5e04c541d75ec2c0f654cdfb17838
---
M src/osmo_client_core.c
1 file changed, 28 insertions(+), 14 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c
index 62b2c3c..e58439b 100644
--- a/src/osmo_client_core.c
+++ b/src/osmo_client_core.c
@@ -152,27 +152,36 @@
return check_gprs(payload_data, payload_len);
}
+static void pcap_read_one_cb(u_char *user, const struct pcap_pkthdr *hdr, const u_char *data)
+{
+ struct osmo_pcap_handle *ph = (struct osmo_pcap_handle *)user;
+ struct osmo_pcap_client *client = ph->client;
+ struct osmo_pcap_client_conn *conn;
+
+ /* NOTE: hdr & data are only available during the call of this callback,
+ * and should be copied somewhere else if need be accessed later.
+ * In here we are fine since we generate a msgb and copy over the
+ * content on each loop iteration below. */
+
+ if (!can_forward_packet(client, ph, hdr, data))
+ return;
+
+ llist_for_each_entry(conn, &client->conns, entry)
+ osmo_client_conn_send_data(conn, ph, hdr, data);
+}
static int pcap_read_cb(struct osmo_fd *fd, unsigned int what)
{
struct osmo_pcap_handle *ph = fd->data;
- struct osmo_pcap_client *client = ph->client;
- struct osmo_pcap_client_conn *conn;
- struct pcap_pkthdr hdr;
- const u_char *data;
+ int rc;
- data = pcap_next(ph->handle, &hdr);
- if (!data) {
+ rc = pcap_dispatch(ph->handle, 1, pcap_read_one_cb, (u_char *)ph);
+ if (rc < 0) {
rate_ctr_inc2(ph->ctrg, PH_CTR_PERR);
- rate_ctr_inc2(client->ctrg, CLIENT_CTR_PERR);
+ rate_ctr_inc2(ph->client->ctrg, CLIENT_CTR_PERR);
return -1;
}
- if (!can_forward_packet(client, ph, &hdr, data))
- return 0;
-
- llist_for_each_entry(conn, &client->conns, entry)
- osmo_client_conn_send_data(conn, ph, &hdr, data);
return 0;
}
@@ -448,6 +457,13 @@
return -2;
}
+ if (client->filter_string)
+ osmo_pcap_handle_install_filter(ph);
+
+ errbuf[0] = '\0';
+ if (pcap_setnonblock(ph->handle, 1, errbuf) != 0)
+ LOGPH(ph, LOGL_ERROR, "Failed pcap_setnonblock(): %s\n", errbuf);
+
fd = pcap_fileno(ph->handle);
if (fd == -1) {
LOGPH(ph, LOGL_ERROR, "No file descriptor provided.\n");
@@ -463,7 +479,5 @@
osmo_timer_setup(&ph->pcap_stat_timer, pcap_check_stats_cb, ph);
pcap_check_stats_cb(ph);
- if (client->filter_string)
- osmo_pcap_handle_install_filter(ph);
return 0;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-pcap/+/39948?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-pcap
Gerrit-Branch: master
Gerrit-Change-Id: I055efb66fac5e04c541d75ec2c0f654cdfb17838
Gerrit-Change-Number: 39948
Gerrit-PatchSet: 6
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39984?usp=email )
Change subject: Add function helper hnbgw_decode_ranap_ran_co()
......................................................................
Add function helper hnbgw_decode_ranap_ran_co()
Similar to already existing counterpart hnbgw_decode_ranap_cn_co().
This helps simplifying logic into smaller chunks, and will make both UL
and DL look more similar.
Change-Id: Ifbb058d5340a6cb3a1703415e49c0de04fa6aec1
---
M src/osmo-hnbgw/context_map_sccp.c
1 file changed, 22 insertions(+), 5 deletions(-)
Approvals:
pespin: Looks good to me, approved
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
osmith: Looks good to me, but someone else must approve
diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c
index c933e8d..fc82426 100644
--- a/src/osmo-hnbgw/context_map_sccp.c
+++ b/src/osmo-hnbgw/context_map_sccp.c
@@ -193,10 +193,29 @@
return 0;
}
+/* Decode DL RANAP message with convenient memory freeing: just talloc_free() the returned pointer..
+ * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls
+ * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */
+static ranap_message *hnbgw_decode_ranap_ran_co(struct msgb *ranap_msg)
+{
+ int rc;
+ ranap_message *message;
+
+ if (!msg_has_l2_data(ranap_msg))
+ return NULL;
+ message = talloc_zero(OTC_SELECT, ranap_message);
+ rc = ranap_ran_rx_co_decode(NULL, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg));
+ if (rc != 0) {
+ talloc_free(message);
+ return NULL;
+ }
+ talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies);
+ return message;
+}
+
static int handle_rx_sccp(struct osmo_fsm_inst *fi, struct msgb *ranap_msg)
{
struct hnbgw_context_map *map = fi->priv;
- int rc;
/* If the FSM instance has already terminated, don't dispatch anything. */
if (fi->proc.terminating)
@@ -208,10 +227,8 @@
/* See if it is a RAB Assignment Request message from SCCP to RUA, where we need to change the user plane
* information, for RTP mapping via MGW, or GTP mapping via UPF. */
- ranap_message *message;
- message = talloc_zero(OTC_SELECT, ranap_message);
- rc = ranap_ran_rx_co_decode(message, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg));
- if (rc == 0) {
+ ranap_message *message = hnbgw_decode_ranap_ran_co(ranap_msg);
+ if (message) {
talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies);
LOGPFSML(fi, LOGL_DEBUG, "rx from SCCP: RANAP %s\n",
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39984?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Ifbb058d5340a6cb3a1703415e49c0de04fa6aec1
Gerrit-Change-Number: 39984
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39983?usp=email )
Change subject: Rename function s/hnbgw_decode_ranap_co/hnbgw_decode_ranap_cn_co/g
......................................................................
Rename function s/hnbgw_decode_ranap_co/hnbgw_decode_ranap_cn_co/g
This function is only used to decode UL RANAP messages. Mark it as "CN"
like most other related APIs.
Change-Id: Ia4e5a21a9724ebf759b62c13759a776189b09e91
---
M include/osmocom/hnbgw/hnbgw_rua.h
M src/osmo-hnbgw/context_map_rua.c
M src/osmo-hnbgw/hnbgw_l3.c
3 files changed, 5 insertions(+), 5 deletions(-)
Approvals:
osmith: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
laforge: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/include/osmocom/hnbgw/hnbgw_rua.h b/include/osmocom/hnbgw/hnbgw_rua.h
index b7e7ee6..55e90c0 100644
--- a/include/osmocom/hnbgw/hnbgw_rua.h
+++ b/include/osmocom/hnbgw/hnbgw_rua.h
@@ -13,4 +13,4 @@
int rua_tx_disc(struct hnb_context *hnb, int is_ps, uint32_t context_id,
const RUA_Cause_t *cause, const uint8_t *data, unsigned int len);
-ranap_message *hnbgw_decode_ranap_co(struct msgb *ranap_msg);
+ranap_message *hnbgw_decode_ranap_cn_co(struct msgb *ranap_msg);
diff --git a/src/osmo-hnbgw/context_map_rua.c b/src/osmo-hnbgw/context_map_rua.c
index 2d9fd8d..f73b8e2 100644
--- a/src/osmo-hnbgw/context_map_rua.c
+++ b/src/osmo-hnbgw/context_map_rua.c
@@ -134,10 +134,10 @@
return 0;
}
-/* Decode RANAP message with convenient memory freeing: just talloc_free() the returned pointer..
+/* Decode UL RANAP message with convenient memory freeing: just talloc_free() the returned pointer..
* Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls
* ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */
-ranap_message *hnbgw_decode_ranap_co(struct msgb *ranap_msg)
+ranap_message *hnbgw_decode_ranap_cn_co(struct msgb *ranap_msg)
{
int rc;
ranap_message *message;
@@ -166,7 +166,7 @@
if (!msg_has_l2_data(ranap_msg))
return 0;
- ranap_message *message = hnbgw_decode_ranap_co(ranap_msg);
+ ranap_message *message = hnbgw_decode_ranap_cn_co(ranap_msg);
if (message) {
LOGPFSML(fi, LOGL_DEBUG, "rx from RUA: RANAP %s\n",
get_value_string(ranap_procedure_code_vals, message->procedureCode));
diff --git a/src/osmo-hnbgw/hnbgw_l3.c b/src/osmo-hnbgw/hnbgw_l3.c
index a6c44f7..65d9eff 100644
--- a/src/osmo-hnbgw/hnbgw_l3.c
+++ b/src/osmo-hnbgw/hnbgw_l3.c
@@ -314,7 +314,7 @@
* This is relevant for CN pooling, to decide which CN link to map the RUA context to. */
int hnbgw_peek_l3_ul(struct hnbgw_context_map *map, struct msgb *ranap_msg)
{
- ranap_message *message = hnbgw_decode_ranap_co(ranap_msg);
+ ranap_message *message = hnbgw_decode_ranap_cn_co(ranap_msg);
if (!message) {
LOGP(DCN, LOGL_ERROR, "Failed to decode RANAP PDU\n");
return -EINVAL;
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39983?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Ia4e5a21a9724ebf759b62c13759a776189b09e91
Gerrit-Change-Number: 39983
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-hnbgw/+/39988?usp=email )
Change subject: Move DL CO RANAP processing to its proper layer file
......................................................................
Move DL CO RANAP processing to its proper layer file
Change-Id: Ifcb8a23becb57ccad6c9aa4769b6f27d31a71c96
---
M include/osmocom/hnbgw/hnbgw_ranap.h
M src/osmo-hnbgw/context_map_sccp.c
M src/osmo-hnbgw/hnbgw_ranap.c
3 files changed, 100 insertions(+), 87 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
diff --git a/include/osmocom/hnbgw/hnbgw_ranap.h b/include/osmocom/hnbgw/hnbgw_ranap.h
index 4317ece..2e77246 100644
--- a/include/osmocom/hnbgw/hnbgw_ranap.h
+++ b/include/osmocom/hnbgw/hnbgw_ranap.h
@@ -8,5 +8,6 @@
int hnbgw_ranap_rx_udt_ul(struct msgb *msg, uint8_t *data, size_t len);
int hnbgw_ranap_rx_udt_dl(struct hnbgw_cnlink *cnlink, const struct osmo_scu_unitdata_param *unitdata,
const uint8_t *data, unsigned int len);
+int hnbgw_ranap_rx_data_dl(struct hnbgw_context_map *map, struct msgb *ranap_msg);
int hnbgw_ranap_init(void);
diff --git a/src/osmo-hnbgw/context_map_sccp.c b/src/osmo-hnbgw/context_map_sccp.c
index fc82426..42a0e49 100644
--- a/src/osmo-hnbgw/context_map_sccp.c
+++ b/src/osmo-hnbgw/context_map_sccp.c
@@ -27,18 +27,10 @@
#include <osmocom/sigtran/sccp_helpers.h>
-#include <osmocom/ranap/ranap_common_ran.h>
-
-#if ENABLE_PFCP
-#include <osmocom/pfcp/pfcp_cp_peer.h>
-#endif
-
#include <osmocom/hnbgw/hnbgw_cn.h>
#include <osmocom/hnbgw/context_map.h>
+#include <osmocom/hnbgw/hnbgw_ranap.h>
#include <osmocom/hnbgw/tdefs.h>
-#include <osmocom/hnbgw/mgw_fsm.h>
-#include <osmocom/hnbgw/ps_rab_ass_fsm.h>
-#include <osmocom/hnbgw/kpi.h>
enum map_sccp_fsm_state {
MAP_SCCP_ST_INIT,
@@ -187,32 +179,6 @@
return osmo_sccp_tx_disconn(map->cnlink->hnbgw_sccp_user->sccp_user, map->scu_conn_id, NULL, 0);
}
-static int destruct_ranap_ran_rx_co_ies(ranap_message *ranap_message_p)
-{
- ranap_ran_rx_co_free(ranap_message_p);
- return 0;
-}
-
-/* Decode DL RANAP message with convenient memory freeing: just talloc_free() the returned pointer..
- * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls
- * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */
-static ranap_message *hnbgw_decode_ranap_ran_co(struct msgb *ranap_msg)
-{
- int rc;
- ranap_message *message;
-
- if (!msg_has_l2_data(ranap_msg))
- return NULL;
- message = talloc_zero(OTC_SELECT, ranap_message);
- rc = ranap_ran_rx_co_decode(NULL, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg));
- if (rc != 0) {
- talloc_free(message);
- return NULL;
- }
- talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies);
- return message;
-}
-
static int handle_rx_sccp(struct osmo_fsm_inst *fi, struct msgb *ranap_msg)
{
struct hnbgw_context_map *map = fi->priv;
@@ -225,58 +191,7 @@
if (!msg_has_l2_data(ranap_msg))
return 0;
- /* See if it is a RAB Assignment Request message from SCCP to RUA, where we need to change the user plane
- * information, for RTP mapping via MGW, or GTP mapping via UPF. */
- ranap_message *message = hnbgw_decode_ranap_ran_co(ranap_msg);
- if (message) {
- talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies);
-
- LOGPFSML(fi, LOGL_DEBUG, "rx from SCCP: RANAP %s\n",
- get_value_string(ranap_procedure_code_vals, message->procedureCode));
-
- kpi_ranap_process_dl(map, message);
-
- if (!map->is_ps) {
- /* Circuit-Switched. Set up mapping of RTP ports via MGW */
-
- switch (message->procedureCode) {
- case RANAP_ProcedureCode_id_RAB_Assignment:
- /* mgw_fsm_alloc_and_handle_rab_ass_req() takes ownership of (ranap) message */
- return handle_cs_rab_ass_req(map, ranap_msg, message);
- case RANAP_ProcedureCode_id_Iu_Release:
- /* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the
- * FSM code. It is just forwarded normally by map_rua_tx_dt() below. */
- mgw_fsm_release(map);
- break;
- }
-#if ENABLE_PFCP
- } else {
- switch (message->procedureCode) {
- case RANAP_ProcedureCode_id_RAB_Assignment:
- /* If a UPF is configured, handle the RAB Assignment via ps_rab_ass_fsm, and replace the
- * GTP F-TEIDs in the RAB Assignment message before passing it on to RUA. */
- if (hnb_gw_is_gtp_mapping_enabled()) {
- LOGP(DMAIN, LOGL_DEBUG,
- "RAB Assignment: setting up GTP tunnel mapping via UPF %s\n",
- osmo_sockaddr_to_str_c(OTC_SELECT, osmo_pfcp_cp_peer_get_remote_addr(g_hnbgw->pfcp.cp_peer)));
- return hnbgw_gtpmap_rx_rab_ass_req(map, ranap_msg, message);
- }
- /* If no UPF is configured, directly forward the message as-is (no GTP mapping). */
- LOGP(DMAIN, LOGL_DEBUG, "RAB Assignment: no UPF configured, forwarding as-is\n");
- break;
-
- case RANAP_ProcedureCode_id_Iu_Release:
- /* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the
- * FSM code. It is just forwarded normally by map_rua_tx_dt() below. */
- hnbgw_gtpmap_release(map);
- break;
- }
-#endif
- }
- }
-
- /* It was not a RAB Assignment Request that needed to be intercepted. Forward as-is to RUA. */
- return map_rua_dispatch(map, MAP_RUA_EV_TX_DIRECT_TRANSFER, ranap_msg);
+ return hnbgw_ranap_rx_data_dl(map, ranap_msg);
}
static void map_sccp_init_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
diff --git a/src/osmo-hnbgw/hnbgw_ranap.c b/src/osmo-hnbgw/hnbgw_ranap.c
index d795264..666560c 100644
--- a/src/osmo-hnbgw/hnbgw_ranap.c
+++ b/src/osmo-hnbgw/hnbgw_ranap.c
@@ -18,6 +18,8 @@
*
*/
+#include "config.h"
+
#include <unistd.h>
#include <errno.h>
#include <string.h>
@@ -28,12 +30,21 @@
#include <osmocom/core/utils.h>
#include <osmocom/ranap/ranap_common.h>
+#include <osmocom/ranap/ranap_common_ran.h>
#include <osmocom/ranap/ranap_ies_defs.h>
#include <osmocom/ranap/ranap_msg_factory.h>
+#if ENABLE_PFCP
+#include <osmocom/pfcp/pfcp_cp_peer.h>
+#endif
+
#include <osmocom/hnbgw/hnbgw.h>
#include <osmocom/hnbgw/hnbgw_rua.h>
#include <osmocom/hnbgw/hnbgw_cn.h>
+#include <osmocom/hnbgw/context_map.h>
+#include <osmocom/hnbgw/mgw_fsm.h>
+#include <osmocom/hnbgw/ps_rab_ass_fsm.h>
+#include <osmocom/hnbgw/kpi.h>
/*****************************************************************************
* Processing of RANAP from the endpoint towards RAN (hNodeB), acting as CN
@@ -410,6 +421,92 @@
return rc;
}
+static int destruct_ranap_ran_rx_co_ies(ranap_message *ranap_message_p)
+{
+ ranap_ran_rx_co_free(ranap_message_p);
+ return 0;
+}
+
+/* Decode DL RANAP message with convenient memory freeing: just talloc_free() the returned pointer..
+ * Allocate a ranap_message from OTC_SELECT, decode RANAP msgb into it, attach a talloc destructor that calls
+ * ranap_cn_rx_co_free() upon talloc_free(), and return the decoded ranap_message. */
+static ranap_message *hnbgw_decode_ranap_ran_co(struct msgb *ranap_msg)
+{
+ int rc;
+ ranap_message *message;
+
+ if (!msg_has_l2_data(ranap_msg))
+ return NULL;
+ message = talloc_zero(OTC_SELECT, ranap_message);
+ rc = ranap_ran_rx_co_decode(NULL, message, msgb_l2(ranap_msg), msgb_l2len(ranap_msg));
+ if (rc != 0) {
+ talloc_free(message);
+ return NULL;
+ }
+ talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies);
+ return message;
+}
+
+/* Process a received RANAP PDU through SCCP DATA.ind coming from CN (MSC/SGSN)
+ * Takes ownership of ranap_msg? */
+int hnbgw_ranap_rx_data_dl(struct hnbgw_context_map *map, struct msgb *ranap_msg)
+{
+ OSMO_ASSERT(map);
+ OSMO_ASSERT(msg_has_l2_data(ranap_msg));
+
+ /* See if it is a RAB Assignment Request message from SCCP to RUA, where we need to change the user plane
+ * information, for RTP mapping via MGW, or GTP mapping via UPF. */
+ ranap_message *message = hnbgw_decode_ranap_ran_co(ranap_msg);
+ if (message) {
+ talloc_set_destructor(message, destruct_ranap_ran_rx_co_ies);
+
+ LOG_MAP(map, DCN, LOGL_DEBUG, "rx from SCCP: RANAP %s\n",
+ get_value_string(ranap_procedure_code_vals, message->procedureCode));
+
+ kpi_ranap_process_dl(map, message);
+
+ if (!map->is_ps) {
+ /* Circuit-Switched. Set up mapping of RTP ports via MGW */
+ switch (message->procedureCode) {
+ case RANAP_ProcedureCode_id_RAB_Assignment:
+ /* mgw_fsm_alloc_and_handle_rab_ass_req() takes ownership of (ranap) message */
+ return handle_cs_rab_ass_req(map, ranap_msg, message);
+ case RANAP_ProcedureCode_id_Iu_Release:
+ /* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the
+ * FSM code. It is just forwarded normally by map_rua_tx_dt() below. */
+ mgw_fsm_release(map);
+ break;
+ }
+#if ENABLE_PFCP
+ } else {
+ switch (message->procedureCode) {
+ case RANAP_ProcedureCode_id_RAB_Assignment:
+ /* If a UPF is configured, handle the RAB Assignment via ps_rab_ass_fsm, and replace the
+ * GTP F-TEIDs in the RAB Assignment message before passing it on to RUA. */
+ if (hnb_gw_is_gtp_mapping_enabled()) {
+ LOG_MAP(map, DCN, LOGL_DEBUG,
+ "RAB Assignment: setting up GTP tunnel mapping via UPF %s\n",
+ osmo_sockaddr_to_str_c(OTC_SELECT, osmo_pfcp_cp_peer_get_remote_addr(g_hnbgw->pfcp.cp_peer)));
+ return hnbgw_gtpmap_rx_rab_ass_req(map, ranap_msg, message);
+ }
+ /* If no UPF is configured, directly forward the message as-is (no GTP mapping). */
+ LOG_MAP(map, DCN, LOGL_DEBUG, "RAB Assignment: no UPF configured, forwarding as-is\n");
+ break;
+
+ case RANAP_ProcedureCode_id_Iu_Release:
+ /* Any IU Release will terminate the MGW FSM, the message itsself is not passed to the
+ * FSM code. It is just forwarded normally by map_rua_tx_dt() below. */
+ hnbgw_gtpmap_release(map);
+ break;
+ }
+#endif
+ }
+ }
+
+ /* It was not a RAB Assignment Request that needed to be intercepted. Forward as-is to RUA. */
+ return map_rua_dispatch(map, MAP_RUA_EV_TX_DIRECT_TRANSFER, ranap_msg);
+}
+
int hnbgw_ranap_init(void)
{
return 0;
--
To view, visit https://gerrit.osmocom.org/c/osmo-hnbgw/+/39988?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-hnbgw
Gerrit-Branch: master
Gerrit-Change-Id: Ifcb8a23becb57ccad6c9aa4769b6f27d31a71c96
Gerrit-Change-Number: 39988
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>