aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc_nat
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-03-31 13:42:11 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-04-01 13:40:59 +0200
commite827812051f1597db89da2b90e2899b5cd1955ea (patch)
tree6f1225e43215499ed079688e13fcf41021c465c9 /openbsc/src/osmo-bsc_nat
parent8a158bb1ea36d0f88da18d0f034884b30f09fda2 (diff)
ipa: Use enhanced ipa_msg_recv_buffered() to cope with partioned IPA messages
The old ipa_msg_recv() implementation didn't support partial receive, so IPA connections got disconnected when this happened. This patch adds the handling of the temporary message buffers and uses ipa_msg_recv_buffered(). It has been successfully tested by jerlbeck with osmo-nitb and osmo-bsc. Ticket: OW#768 Sponsored-by: On-Waves ehf
Diffstat (limited to 'openbsc/src/osmo-bsc_nat')
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c19
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_ussd.c8
2 files changed, 21 insertions, 6 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index d9fc0ca48..524186a55 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -796,14 +796,16 @@ static void msc_send_reset(struct bsc_msc_connection *msc_con)
static int ipaccess_msc_read_cb(struct osmo_fd *bfd)
{
struct bsc_msc_connection *msc_con;
- struct msgb *msg;
+ struct msgb *msg = NULL;
struct ipaccess_head *hh;
int ret;
msc_con = (struct bsc_msc_connection *) bfd->data;
- ret = ipa_msg_recv(bfd->fd, &msg);
+ ret = ipa_msg_recv_buffered(bfd->fd, &msg, &msc_con->pending_msg);
if (ret <= 0) {
+ if (ret == -EAGAIN)
+ return 0;
if (ret == 0)
LOGP(DNAT, LOGL_FATAL,
"The connection the MSC(%s) was lost, exiting\n",
@@ -912,6 +914,13 @@ void bsc_close_connection(struct bsc_connection *connection)
osmo_wqueue_clear(&connection->write_queue);
llist_del(&connection->list_entry);
+ if (connection->pending_msg) {
+ LOGP(DNAT, LOGL_ERROR, "Dropping partial message on connection %d.\n",
+ connection->cfg->nr);
+ msgb_free(connection->pending_msg);
+ connection->pending_msg = NULL;
+ }
+
talloc_free(connection);
}
@@ -1206,13 +1215,15 @@ exit3:
static int ipaccess_bsc_read_cb(struct osmo_fd *bfd)
{
struct bsc_connection *bsc = bfd->data;
- struct msgb *msg;
+ struct msgb *msg = NULL;
struct ipaccess_head *hh;
struct ipaccess_head_ext *hh_ext;
int ret;
- ret = ipa_msg_recv(bfd->fd, &msg);
+ ret = ipa_msg_recv_buffered(bfd->fd, &msg, &bsc->pending_msg);
if (ret <= 0) {
+ if (ret == -EAGAIN)
+ return 0;
if (ret == 0)
LOGP(DNAT, LOGL_ERROR,
"The connection to the BSC Nr: %d was lost. Cleaning it\n",
diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
index 8da818119..5f073bf4f 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c
@@ -66,6 +66,8 @@ static void bsc_nat_ussd_destroy(struct bsc_nat_ussd_con *con)
osmo_fd_unregister(&con->queue.bfd);
osmo_timer_del(&con->auth_timeout);
osmo_wqueue_clear(&con->queue);
+
+ msgb_free(con->pending_msg);
talloc_free(con);
}
@@ -117,12 +119,14 @@ static int forward_sccp(struct bsc_nat *nat, struct msgb *msg)
static int ussd_read_cb(struct osmo_fd *bfd)
{
struct bsc_nat_ussd_con *conn = bfd->data;
- struct msgb *msg;
+ struct msgb *msg = NULL;
struct ipaccess_head *hh;
int ret;
- ret = ipa_msg_recv(bfd->fd, &msg);
+ ret = ipa_msg_recv_buffered(bfd->fd, &msg, &conn->pending_msg);
if (ret <= 0) {
+ if (ret == -EAGAIN)
+ return 0;
LOGP(DNAT, LOGL_ERROR, "USSD Connection was lost.\n");
bsc_nat_ussd_destroy(conn);
return -1;