pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sccp/+/34609?usp=email )
Change subject: asp: Apply SCTP primary address changes after the ASP was started
......................................................................
asp: Apply SCTP primary address changes after the ASP was started
Related: OS#6077
Change-Id: I2beb597b2e98d8983177fb21882a461219b3aa58
---
M src/osmo_ss7_asp.c
M src/osmo_ss7_vty.c
M src/ss7_internal.h
3 files changed, 37 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/09/34609/1
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index 6068a9d..f26e2e1 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -617,6 +617,14 @@
return asp->fi->state == XUA_ASP_S_ACTIVE;
}
+bool ss7_asp_is_started(const struct osmo_ss7_asp *asp)
+{
+ if (asp->cfg.is_server)
+ return !!asp->server;
+ else
+ return !!asp->client;
+}
+
/***********************************************************************
* libosmo-netif integration for SCTP stream server/client
***********************************************************************/
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 4e13522..000b1cf 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -732,11 +732,28 @@
{
struct osmo_ss7_asp *asp = vty->index;
bool is_primary = argc > 1;
+ int old_idx_primary = asp->cfg.remote.idx_primary;
+ int rc;
if (osmo_ss7_asp_peer_add_host2(&asp->cfg.remote, asp, argv[0], is_primary) != 0)
{
vty_out(vty, "%% Failed adding host '%s' to set%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
+
+ if (!ss7_asp_is_started(asp))
+ return CMD_SUCCESS;
+ if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA)
+ return CMD_SUCCESS;
+
+ /* The SCTP socket is already created, dynamically apply the new primary if it changed:
*/
+ if (asp->cfg.proto != OSMO_SS7_ASP_PROT_IPA && ss7_asp_is_started(asp)) {
+ if ((rc = ss7_asp_apply_primary_address(asp)) < 0) {
+ /* Failed, rollback changes: */
+ asp->cfg.remote.idx_primary = old_idx_primary;
+ vty_out(vty, "%% Failed applying primary on host '%s'%s", argv[0],
VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
return CMD_SUCCESS;
}
diff --git a/src/ss7_internal.h b/src/ss7_internal.h
index 6449c5b..ad71e83 100644
--- a/src/ss7_internal.h
+++ b/src/ss7_internal.h
@@ -18,7 +18,9 @@
uint16_t remote_port, uint16_t local_port,
enum osmo_ss7_asp_protocol proto);
bool ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp);
+bool ss7_asp_is_started(const struct osmo_ss7_asp *asp);
struct osmo_ss7_asp *ss7_asp_find_by_socket_addr(int fd);
+
int ss7_asp_proto_to_ip_proto(enum osmo_ss7_asp_protocol proto);
int ss7_asp_ipa_srv_conn_cb(struct osmo_stream_srv *conn);
int ss7_asp_xua_srv_conn_cb(struct osmo_stream_srv *conn);
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/34609?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: I2beb597b2e98d8983177fb21882a461219b3aa58
Gerrit-Change-Number: 34609
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange