diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-09-28 18:51:16 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2023-09-29 18:23:39 +0200 |
commit | 3ed3b2c2ed2fbd0dd186700bc9b08e479f2f8714 (patch) | |
tree | 330b07a076323f8695311c297e06bff824fb6939 | |
parent | 4a744e223420c6d4003fb825e9e2b674ee79a216 (diff) |
asp: Apply SCTP primary address changes after the ASP was started
Related: OS#6077
Change-Id: I2beb597b2e98d8983177fb21882a461219b3aa58
-rw-r--r-- | src/osmo_ss7_asp.c | 8 | ||||
-rw-r--r-- | src/osmo_ss7_vty.c | 17 | ||||
-rw-r--r-- | src/ss7_internal.h | 2 |
3 files changed, 27 insertions, 0 deletions
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 @@ bool osmo_ss7_asp_active(const struct osmo_ss7_asp *asp) 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 @@ DEFUN_ATTR(asp_remote_ip, asp_remote_ip_cmd, { 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 @@ struct osmo_ss7_asp *ss7_asp_alloc(struct osmo_ss7_instance *inst, const char *n 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); |