pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sccp/+/34611?usp=email )
Change subject: asp: Support adding new local addresses after the ASP was started
......................................................................
asp: Support adding new local addresses after the ASP was started
Related: OS#6077
Depends: libosmocore.git Change-Id Ifc6e7d643c2a0c53f479bfd0d5c36d08c0c01953
Change-Id: I8318d2693f3a9c479b18ab1d660431c1ec77c004
---
M TODO-RELEASE
M src/osmo_ss7_asp.c
M src/osmo_ss7_vty.c
M src/ss7_internal.h
4 files changed, 48 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/11/34611/1
diff --git a/TODO-RELEASE b/TODO-RELEASE
index d0852fc..b1b533c 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
# If any interfaces have been added since the last public release: c:r:a + 1.
# If any interfaces have been removed or changed since the last public release: c:r:0.
#library what description / commit summary line
+libosmocore >1.9.0 osmo_sock_multiaddr_add_local_addr()
\ No newline at end of file
diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c
index f26e2e1..68bd0ca 100644
--- a/src/osmo_ss7_asp.c
+++ b/src/osmo_ss7_asp.c
@@ -168,6 +168,25 @@
};
static unsigned int g_ss7_asp_rcg_idx;
+int ss7_asp_apply_new_local_address(const struct osmo_ss7_asp *asp, unsigned int
loc_idx)
+{
+ const char *new_loc_addr;
+ struct osmo_fd *ofd;
+
+ OSMO_ASSERT(loc_idx < asp->cfg.local.host_cnt);
+ new_loc_addr = asp->cfg.local.host[loc_idx];
+
+ LOGPASP(asp, DLSS7, LOGL_INFO, "Add local address %s\n",
+ new_loc_addr);
+
+ if (asp->cfg.is_server)
+ ofd = osmo_stream_srv_get_ofd(asp->server);
+ else
+ ofd = osmo_stream_cli_get_ofd(asp->client);
+
+ return osmo_sock_multiaddr_add_local_addr(ofd->fd, &new_loc_addr, 1);
+}
+
int ss7_asp_apply_peer_primary_address(const struct osmo_ss7_asp *asp)
{
struct osmo_fd *ofd;
diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index cdca10d..f9c1ada 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -715,6 +715,7 @@
struct osmo_ss7_asp *asp = vty->index;
bool is_primary = argc > 1;
int old_idx_primary = asp->cfg.local.idx_primary;
+ int old_host_count = asp->cfg.local.host_cnt;
int rc;
if (osmo_ss7_asp_peer_add_host2(&asp->cfg.local, asp, argv[0], is_primary) != 0)
{
@@ -726,8 +727,21 @@
return CMD_SUCCESS;
if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA)
return CMD_SUCCESS;
+ /* The SCTP socket is already created. */
- /* The SCTP socket is already created, dynamically apply the new primary if it changed:
*/
+ /* dynamically apply the new address if it was added to the set: */
+ if (asp->cfg.local.host_cnt > old_host_count) {
+ if ((rc = ss7_asp_apply_new_local_address(asp, asp->cfg.local.host_cnt - 1)) < 0)
{
+ /* Failed, rollback changes: */
+ TALLOC_FREE(asp->cfg.local.host[asp->cfg.local.host_cnt - 1]);
+ asp->cfg.local.host_cnt--;
+ vty_out(vty, "%% Failed adding new local address '%s'%s", argv[0],
VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ vty_out(vty, "%% Local address '%s' added to the active socket bind
set%s", argv[0], VTY_NEWLINE);
+ }
+
+ /* 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: */
@@ -735,6 +749,7 @@
vty_out(vty, "%% Failed announcing primary '%s' to peer%s", argv[0],
VTY_NEWLINE);
return CMD_WARNING;
}
+ vty_out(vty, "%% Local address '%s' announced as primary to the peer on
the active socket%s", argv[0], VTY_NEWLINE);
}
return CMD_SUCCESS;
}
diff --git a/src/ss7_internal.h b/src/ss7_internal.h
index ad71e83..438fca9 100644
--- a/src/ss7_internal.h
+++ b/src/ss7_internal.h
@@ -27,6 +27,7 @@
int ss7_asp_xua_srv_conn_closed_cb(struct osmo_stream_srv *srv);
int ss7_asp_apply_peer_primary_address(const struct osmo_ss7_asp *asp);
int ss7_asp_apply_primary_address(const struct osmo_ss7_asp *asp);
+int ss7_asp_apply_new_local_address(const struct osmo_ss7_asp *asp, unsigned int
loc_idx);
bool ss7_asp_peer_match_host(const struct osmo_ss7_asp_peer *peer, const char *host, bool
host_is_v6);
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sccp/+/34611?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: I8318d2693f3a9c479b18ab1d660431c1ec77c004
Gerrit-Change-Number: 34611
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange