pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sccp/+/36575?usp=email )
Change subject: ss7_asp: Update stream_cli read_cb2 functions to accomodate for new API
param
......................................................................
ss7_asp: Update stream_cli read_cb2 functions to accomodate for new API param
libosmo-netif (not yet released) stream_cli osmo_io read_cb API was
updated to provide read result status. Hence, now API users (ss/ asp)
can now account for lower layer errors and act properly, like it used to
do with the previous ofd backend.
This commit partially reverts some error code paths removed in
9257cd896e255403822bee6f87f5487a92fd3c11 when converting code to use
osmo_io stream_cli backend.
Change-Id: I579f4101a9e2874e310ff78e4571f38cfe8dfab0
Depends: libosmo-netif.git Change-Id I395c75ff1e9904757ce1d767a9ac2f779593c4c8
---
M src/osmo_ss7_asp.c
1 file changed, 47 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/75/36575/1
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index 90c72a9..6221d7b 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -602,9 +602,9 @@
talloc_free(asp);
}
-static int xua_cli_read_cb(struct osmo_stream_cli *conn, struct msgb *msg);
-static int ipa_cli_read_cb(struct osmo_stream_cli *conn, struct msgb *msg);
-static int m3ua_tcp_cli_read_cb(struct osmo_stream_cli *conn, struct msgb *msg);
+static int xua_cli_read_cb(struct osmo_stream_cli *conn, int res, struct msgb *msg);
+static int ipa_cli_read_cb(struct osmo_stream_cli *conn, int res, struct msgb *msg);
+static int m3ua_tcp_cli_read_cb(struct osmo_stream_cli *conn, int res, struct msgb
*msg);
static int xua_cli_connect_cb(struct osmo_stream_cli *cli);
static int xua_cli_close_and_reconnect(struct osmo_stream_cli *cli);
@@ -953,11 +953,21 @@
}
/* read call-back for IPA/SCCPlite socket */
-static int ipa_cli_read_cb(struct osmo_stream_cli *conn, struct msgb *msg)
+static int ipa_cli_read_cb(struct osmo_stream_cli *conn, int res, struct msgb *msg)
{
int fd = osmo_stream_cli_get_fd(conn);
struct osmo_ss7_asp *asp = osmo_stream_cli_get_data(conn);
+ if (res <= 0) {
+ if (res == -EAGAIN) {
+ msgb_free(msg);
+ return 0;
+ }
+ xua_cli_close_and_reconnect(conn);
+ msgb_free(msg);
+ return res;
+ }
+
msg->dst = asp;
rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL);
/* we can use the 'fd' return value of osmo_stream_srv_get_fd() here unverified
as all we do
@@ -966,7 +976,7 @@
}
/* read call-back for M3UA-over-TCP socket */
-static int m3ua_tcp_cli_read_cb(struct osmo_stream_cli *conn, struct msgb *msg)
+static int m3ua_tcp_cli_read_cb(struct osmo_stream_cli *conn, int res, struct msgb *msg)
{
const struct xua_common_hdr *hdr;
@@ -980,10 +990,10 @@
else
msgb_sctp_stream(msg) = 0;
- return xua_cli_read_cb(conn, msg);
+ return xua_cli_read_cb(conn, res, msg);
}
-static int xua_cli_read_cb(struct osmo_stream_cli *conn, struct msgb *msg)
+static int xua_cli_read_cb(struct osmo_stream_cli *conn, int res, struct msgb *msg)
{
struct osmo_ss7_asp *asp = osmo_stream_cli_get_data(conn);
unsigned int ppid;
@@ -1008,6 +1018,17 @@
default:
break;
}
+ if (rc == 0)
+ xua_cli_close_and_reconnect(conn);
+ rc = 0;
+ goto out;
+ }
+ if (rc < 0) {
+ xua_cli_close_and_reconnect(conn);
+ goto out;
+ } else if (rc == 0) {
+ xua_cli_close_and_reconnect(conn);
+
goto out;
}
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/36575?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I579f4101a9e2874e310ff78e4571f38cfe8dfab0
Gerrit-Change-Number: 36575
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange