[M] Change in libosmo-sccp[master]: asp: Support removing local & remote addresses
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?usp=email ) Change subject: asp: Support removing local & remote addresses .. asp: Support removing local & remote addresses The local address is removed dynamically from the socket if it is already created. For remote addresses, it doesn't make any sense (and there's no API to do so) because the remote address list passed to it is only used at connect() time, when the socket is created. During the initial hanshake, the remote provides its own list of remote addresses. Related: OS#6077 Related: OS#4607 Depends: libosmocore.git Change-Id Ifc6e7d643c2a0c53f479bfd0d5c36d08c0c01953 Change-Id: I554aee92285bd72eb90c6daf47b37055cb3067aa --- M TODO-RELEASE M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7_asp.c M src/osmo_ss7_asp_peer.c M src/osmo_ss7_vty.c M src/ss7_internal.h M tests/vty/ss7_asp_test.vty 7 files changed, 162 insertions(+), 2 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved osmith: Looks good to me, but someone else must approve diff --git a/TODO-RELEASE b/TODO-RELEASE index b1b533c..ae21a12 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,4 +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 whatdescription / commit summary line -libosmocore >1.9.0 osmo_sock_multiaddr_add_local_addr() \ No newline at end of file +libosmocore >1.9.0 osmo_sock_multiaddr_{add,del}_local_addr() \ No newline at end of file diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 98e1187..841c12b 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -471,6 +471,8 @@ const char *const*hosts, size_t host_cnt, int idx_primary); int osmo_ss7_asp_peer_add_host(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *host); int osmo_ss7_asp_peer_add_host2(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *host, bool is_primary_addr); +int osmo_ss7_asp_peer_del_host(struct osmo_ss7_asp_peer *peer, const char *host); + struct osmo_ss7_asp * osmo_ss7_asp_find_by_name(struct osmo_ss7_instance *inst, const char *name); diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c index 68bd0ca..1ba0a43 100644 --- a/src/osmo_ss7_asp.c +++ b/src/osmo_ss7_asp.c @@ -187,6 +187,25 @@ return osmo_sock_multiaddr_add_local_addr(ofd->fd, &new_loc_addr, 1); } +int ss7_asp_apply_drop_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, "Remove 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_del_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_asp_peer.c b/src/osmo_ss7_asp_peer.c index cf591d9..39a92b1 100644 --- a/src/osmo_ss7_asp_peer.c +++ b/src/osmo_ss7_asp_peer.c @@ -208,6 +208,50 @@ return 0; } +/*! \brief Remove address from a given ASP peer. + * \param[in] peer Application Server Process peer the address is removed from. + * \param[in] host string containing an IP address. + * \returns 0 on success; negative otherwise */ +int osmo_ss7_asp_peer_del_host(struct osmo_ss7_asp_peer *peer, const char *host) +{ + int i; + struct osmo_sockaddr_str addr_str; + bool found = false; + + if (osmo_sockaddr_str_from_str(&addr_str, host, 0) < 0) + return -EINVAL; + + for (i = 0; i < peer->host_cnt; i++) { + if (strcmp(host, peer->host[i]) == 0) { + found = true; + break; + } + } + + if (!found) + return -ENOENT; + + /* If current primary points to addr being removed, unset it: */ + if (peer->idx_primary == i) + peer->idx_primary = -1; + /* If it's after it, update it together with sliding done further below: */ + else if (peer->idx_primary > i) + peer->idx_primary--; + + /* Free addr to remove: */ + TALLOC_FREE(peer->host[i]); + + /* Move the rest of the array: */ + for (; i < peer->host_cnt - 1; i++) + peer->host[i] = peer->host[i + 1]; + peer->host[i] = NULL; + + /* Update array size: */ +
[M] Change in libosmo-sccp[master]: asp: Support removing local & remote addresses
Attention is currently required from: osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?usp=email ) Change subject: asp: Support removing local & remote addresses .. Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?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: I554aee92285bd72eb90c6daf47b37055cb3067aa Gerrit-Change-Number: 34612 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Attention: osmith Gerrit-Comment-Date: Wed, 04 Oct 2023 11:21:01 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: asp: Support removing local & remote addresses
Attention is currently required from: osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?usp=email ) Change subject: asp: Support removing local & remote addresses .. Patch Set 1: (1 comment) File src/osmo_ss7_vty.c: https://gerrit.osmocom.org/c/libosmo-sccp/+/34612/comment/5d63fd37_41cd3a7e PS1, Line 760: of > remove "of" here and in the line below? I'm simply reusing same format of similar commands around it. -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?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: I554aee92285bd72eb90c6daf47b37055cb3067aa Gerrit-Change-Number: 34612 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Attention: osmith Gerrit-Comment-Date: Wed, 04 Oct 2023 10:14:59 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: osmith Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: asp: Support removing local & remote addresses
Attention is currently required from: pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?usp=email ) Change subject: asp: Support removing local & remote addresses .. Patch Set 1: Code-Review+1 (1 comment) File src/osmo_ss7_vty.c: https://gerrit.osmocom.org/c/libosmo-sccp/+/34612/comment/67e1a915_9ff667db PS1, Line 760: of remove "of" here and in the line below? -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?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: I554aee92285bd72eb90c6daf47b37055cb3067aa Gerrit-Change-Number: 34612 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Attention: pespin Gerrit-Comment-Date: Wed, 04 Oct 2023 08:38:12 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: asp: Support removing local & remote addresses
Attention is currently required from: pespin. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?usp=email ) Change subject: asp: Support removing local & remote addresses .. Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?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: I554aee92285bd72eb90c6daf47b37055cb3067aa Gerrit-Change-Number: 34612 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Attention: pespin Gerrit-Comment-Date: Tue, 03 Oct 2023 12:42:22 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: asp: Support removing local & remote addresses
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/34612?usp=email ) Change subject: asp: Support removing local & remote addresses .. asp: Support removing local & remote addresses The local address is removed dynamically from the socket if it is already created. For remote addresses, it doesn't make any sense (and there's no API to do so) because the remote address list passed to it is only used at connect() time, when the socket is created. During the initial hanshake, the remote provides its own list of remote addresses. Related: OS#6077 Related: OS#4607 Depends: libosmocore.git Change-Id Ifc6e7d643c2a0c53f479bfd0d5c36d08c0c01953 Change-Id: I554aee92285bd72eb90c6daf47b37055cb3067aa --- M TODO-RELEASE M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7_asp.c M src/osmo_ss7_asp_peer.c M src/osmo_ss7_vty.c M src/ss7_internal.h M tests/vty/ss7_asp_test.vty 7 files changed, 162 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/12/34612/1 diff --git a/TODO-RELEASE b/TODO-RELEASE index b1b533c..ae21a12 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -7,4 +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 whatdescription / commit summary line -libosmocore >1.9.0 osmo_sock_multiaddr_add_local_addr() \ No newline at end of file +libosmocore >1.9.0 osmo_sock_multiaddr_{add,del}_local_addr() \ No newline at end of file diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 98e1187..841c12b 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -471,6 +471,8 @@ const char *const*hosts, size_t host_cnt, int idx_primary); int osmo_ss7_asp_peer_add_host(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *host); int osmo_ss7_asp_peer_add_host2(struct osmo_ss7_asp_peer *peer, void *talloc_ctx, const char *host, bool is_primary_addr); +int osmo_ss7_asp_peer_del_host(struct osmo_ss7_asp_peer *peer, const char *host); + struct osmo_ss7_asp * osmo_ss7_asp_find_by_name(struct osmo_ss7_instance *inst, const char *name); diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c index 68bd0ca..1ba0a43 100644 --- a/src/osmo_ss7_asp.c +++ b/src/osmo_ss7_asp.c @@ -187,6 +187,25 @@ return osmo_sock_multiaddr_add_local_addr(ofd->fd, &new_loc_addr, 1); } +int ss7_asp_apply_drop_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, "Remove 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_del_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_asp_peer.c b/src/osmo_ss7_asp_peer.c index cf591d9..39a92b1 100644 --- a/src/osmo_ss7_asp_peer.c +++ b/src/osmo_ss7_asp_peer.c @@ -208,6 +208,50 @@ return 0; } +/*! \brief Remove address from a given ASP peer. + * \param[in] peer Application Server Process peer the address is removed from. + * \param[in] host string containing an IP address. + * \returns 0 on success; negative otherwise */ +int osmo_ss7_asp_peer_del_host(struct osmo_ss7_asp_peer *peer, const char *host) +{ + int i; + struct osmo_sockaddr_str addr_str; + bool found = false; + + if (osmo_sockaddr_str_from_str(&addr_str, host, 0) < 0) + return -EINVAL; + + for (i = 0; i < peer->host_cnt; i++) { + if (strcmp(host, peer->host[i]) == 0) { + found = true; + break; + } + } + + if (!found) + return -ENOENT; + + /* If current primary points to addr being removed, unset it: */ + if (peer->idx_primary == i) + peer->idx_primary = -1; + /* If it's after it, update it together with sliding done further below: */ + else if (peer->idx_primary > i) + peer->idx_primary--; + + /* Free addr to remove: */ + TALLOC_FREE(peer->host[i]); + + /* Move the rest of the array: */ + for (; i < peer->host_cnt - 1; i++) + peer->host[i] = peer->host[i + 1]; + peer->host[i] = NULL; + + /* Update array size: */ + peer->host_cnt--; + + return 0; +} + /*! \brief Append (copy) address to a given ASP peer. P