aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2023-09-29 16:17:18 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2023-09-29 18:24:01 +0200
commit44cf7c8231198c92e4fc4fdbbd63bc79749d48df (patch)
treed8b869dfd78eb4fdc5bd06eb97701a25fd6df57b
parent3ed3b2c2ed2fbd0dd186700bc9b08e479f2f8714 (diff)
asp: Apply SCTP peer primary address changes after the ASP was started
-rw-r--r--src/osmo_ss7_vty.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 000b1cf..cdca10d 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -714,11 +714,28 @@ DEFUN_ATTR(asp_local_ip, asp_local_ip_cmd,
{
struct osmo_ss7_asp *asp = vty->index;
bool is_primary = argc > 1;
+ int old_idx_primary = asp->cfg.local.idx_primary;
+ int rc;
if (osmo_ss7_asp_peer_add_host2(&asp->cfg.local, 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 (is_primary && asp->cfg.local.idx_primary != old_idx_primary) {
+ if ((rc = ss7_asp_apply_peer_primary_address(asp)) < 0) {
+ /* Failed, rollback changes: */
+ asp->cfg.local.idx_primary = old_idx_primary;
+ vty_out(vty, "%% Failed announcing primary '%s' to peer%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
return CMD_SUCCESS;
}