[M] Change in libosmo-sccp[master]: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email ) Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket .. vty: show cs7 instance asp: Print loc and rem addr retrieved from socket Until now, we were in general printing the list of remote addresses that were stored in config, because we didn't have an easy way to retrieve the addresses from the socket. Since recently some libosmocore APIs make that easy, so use them now. If the socket is not yet created, then log the addrress list from the config. Furthermore, take the chance to print now both local and remote addresses. Related: SYS#6636 Change-Id: I607e4c2dd37f07bf1c07c88681918184e92202ea --- M src/osmo_ss7_asp.c M src/osmo_ss7_vty.c M src/ss7_internal.h M tests/vty/ss7_asp_test.vty 4 files changed, 104 insertions(+), 46 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, approved osmith: Looks good to me, but someone else must approve diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c index 55e5a29..f867ce5 100644 --- a/src/osmo_ss7_asp.c +++ b/src/osmo_ss7_asp.c @@ -1134,3 +1134,19 @@ { return asp->cfg.proto; } + +/*! \brief Get the fd of a given ASP + * \param[in] asp The ASP for which the fd is requested + * \returns The fd of the ASP if acailable, negative otherwise + */ +int ss7_asp_get_fd(const struct osmo_ss7_asp *asp) +{ + if (asp->cfg.is_server) { + if (asp->server) + return osmo_stream_srv_get_fd(asp->server); + } else { + if (asp->client) + return osmo_stream_cli_get_fd(asp->client); + } + return -1; +} diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 39d5b3b..7350c13 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -1133,13 +1133,39 @@ return buf; } +/* Similar to osmo_sock_multiaddr_get_name_buf(), but aimed at listening sockets (only local part): */ +static char *get_sockname_buf(char *buf, size_t buf_len, int fd, int proto, bool local) +{ + char hostbuf[OSMO_SOCK_MAX_ADDRS][INET6_ADDRSTRLEN]; + size_t num_hostbuf = ARRAY_SIZE(hostbuf); + char portbuf[6]; + struct osmo_strbuf sb = { .buf = buf, .len = buf_len }; + bool need_more_bufs; + int rc; + + rc = osmo_sock_multiaddr_get_ip_and_port(fd, proto, [0][0], +_hostbuf, sizeof(hostbuf[0]), +portbuf, sizeof(portbuf), local); + if (rc < 0) + return NULL; + + need_more_bufs = num_hostbuf > ARRAY_SIZE(hostbuf); + if (need_more_bufs) + num_hostbuf = ARRAY_SIZE(hostbuf); + OSMO_STRBUF_APPEND(sb, osmo_multiaddr_ip_and_port_snprintf, + [0][0], num_hostbuf, sizeof(hostbuf[0]), portbuf); + if (need_more_bufs) + OSMO_STRBUF_PRINTF(sb, ""); + + return buf; +} + DEFUN(show_cs7_asp, show_cs7_asp_cmd, "show cs7 instance <0-15> asp", SHOW_STR CS7_STR INST_STR INST_STR "Application Server Process (ASP)\n") { struct osmo_ss7_instance *inst; struct osmo_ss7_asp *asp; - char buf[512]; char as_buf[64]; int id = atoi(argv[0]); @@ -1149,28 +1175,32 @@ return CMD_WARNING; } - vty_out(vty, " Current Primary Link%s", VTY_NEWLINE); - vty_out(vty, "ASP Name AS Name State Type Role SCTP Role Remote Addresses%s", VTY_NEWLINE); - vty_out(vty, " - - ---%s", VTY_NEWLINE); + vty_out(vty, "ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses%s", VTY_NEWLINE); + vty_out(vty, " - - --- ---%s", VTY_NEWLINE); llist_for_each_entry(asp, >asp_list, list) { - if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA && asp->cfg.remote.port == 0 && asp->server) { - int fd = osmo_stream_srv_get_fd(asp->server); - char hostbuf[64]; - char portbuf[16]; - osmo_sock_get_ip_and_port(fd, hostbuf, sizeof(hostbuf), - portbuf, sizeof(portbuf), false); - snprintf(buf, sizeof(buf), "%s:%s", hostbuf, portbuf); - } else - osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), >cfg.remote); - vty_out(vty, "%-12s %-12s %-13s %-4s %-4s %-9s %-23s%s", + char buf_loc[OSMO_SOCK_MULTIADDR_PEER_STR_MAXLEN]; + char
[M] Change in libosmo-sccp[master]: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
Attention is currently required from: fixeria. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email ) Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket .. Patch Set 3: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?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: I607e4c2dd37f07bf1c07c88681918184e92202ea Gerrit-Change-Number: 35274 Gerrit-PatchSet: 3 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-CC: fixeria Gerrit-Attention: fixeria Gerrit-Comment-Date: Tue, 12 Dec 2023 15:25:19 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
Attention is currently required from: fixeria, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email ) Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket .. Patch Set 3: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?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: I607e4c2dd37f07bf1c07c88681918184e92202ea Gerrit-Change-Number: 35274 Gerrit-PatchSet: 3 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-CC: fixeria Gerrit-Attention: pespin Gerrit-Attention: fixeria Gerrit-Comment-Date: Tue, 12 Dec 2023 15:24:47 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
Attention is currently required from: fixeria, osmith. Hello Jenkins Builder, osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email to look at the new patch set (#3). The following approvals got outdated and were removed: Code-Review+1 by osmith, Verified+1 by Jenkins Builder Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket .. vty: show cs7 instance asp: Print loc and rem addr retrieved from socket Until now, we were in general printing the list of remote addresses that were stored in config, because we didn't have an easy way to retrieve the addresses from the socket. Since recently some libosmocore APIs make that easy, so use them now. If the socket is not yet created, then log the addrress list from the config. Furthermore, take the chance to print now both local and remote addresses. Related: SYS#6636 Change-Id: I607e4c2dd37f07bf1c07c88681918184e92202ea --- M src/osmo_ss7_asp.c M src/osmo_ss7_vty.c M src/ss7_internal.h M tests/vty/ss7_asp_test.vty 4 files changed, 104 insertions(+), 46 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/74/35274/3 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?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: I607e4c2dd37f07bf1c07c88681918184e92202ea Gerrit-Change-Number: 35274 Gerrit-PatchSet: 3 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-CC: fixeria Gerrit-Attention: osmith Gerrit-Attention: fixeria Gerrit-MessageType: newpatchset
[M] Change in libosmo-sccp[master]: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
Attention is currently required from: fixeria, osmith. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email ) Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket .. Patch Set 2: (2 comments) File src/osmo_ss7_vty.c: https://gerrit.osmocom.org/c/libosmo-sccp/+/35274/comment/8ed22aba_8713fd2a PS2, Line 1152: Current Primary Link > So `Current Primary Link` is not the case anymore? […] It is added in a follow-up patch where one can print the assoc info. In here I opted for printing more general information to identify each ASP. https://gerrit.osmocom.org/c/libosmo-sccp/+/35274/comment/7aad8305_fe8db384 PS2, Line 1182: OSMO_SOCK_MAX_ADDRS * INET6_ADDRSTRLEN + OSMO_SOCK_MAX_ADDRS + 2 + 6 + 1 > (put in a define somewhere? https://gerrit.osmocom. […] Done -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?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: I607e4c2dd37f07bf1c07c88681918184e92202ea Gerrit-Change-Number: 35274 Gerrit-PatchSet: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-CC: fixeria Gerrit-Attention: osmith Gerrit-Attention: fixeria Gerrit-Comment-Date: Tue, 12 Dec 2023 15:06:20 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: osmith Comment-In-Reply-To: fixeria Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
Attention is currently required from: pespin. fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email ) Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket .. Patch Set 2: (2 comments) File src/osmo_ss7_vty.c: https://gerrit.osmocom.org/c/libosmo-sccp/+/35274/comment/e84f0109_9e024c62 PS2, Line 1152: Current Primary Link So `Current Primary Link` is not the case anymore? Or how do I know which one is the primary address:port? https://gerrit.osmocom.org/c/libosmo-sccp/+/35274/comment/682c09df_bc145f9f PS2, Line 1158: "" `"(+%zu more addresses)"` would be more informative. -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?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: I607e4c2dd37f07bf1c07c88681918184e92202ea Gerrit-Change-Number: 35274 Gerrit-PatchSet: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-CC: fixeria Gerrit-Attention: pespin Gerrit-Comment-Date: Tue, 12 Dec 2023 14:09:48 + Gerrit-HasComments: Yes Gerrit-Has-Labels: No Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
Attention is currently required from: pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email ) Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket .. Patch Set 2: Code-Review+1 (1 comment) File src/osmo_ss7_vty.c: https://gerrit.osmocom.org/c/libosmo-sccp/+/35274/comment/9da3d264_dde4ee0e PS2, Line 1182: OSMO_SOCK_MAX_ADDRS * INET6_ADDRSTRLEN + OSMO_SOCK_MAX_ADDRS + 2 + 6 + 1 (put in a define somewhere? https://gerrit.osmocom.org/c/libosmo-netif/+/35287/comment/82dc01d3_b7055e6e/ https://gerrit.osmocom.org/c/libosmo-sccp/+/35242/comment/086979e2_84eb283b/) -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?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: I607e4c2dd37f07bf1c07c88681918184e92202ea Gerrit-Change-Number: 35274 Gerrit-PatchSet: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-Attention: pespin Gerrit-Comment-Date: Tue, 12 Dec 2023 12:37:34 + Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35274?usp=email ) Change subject: vty: show cs7 instance asp: Print loc and rem addr retrieved from socket .. vty: show cs7 instance asp: Print loc and rem addr retrieved from socket Until now, we were in general printing the list of remote addresses that were stored in config, because we didn't have an easy way to retrieve the addresses from the socket. Since recently some libosmocore APIs make that easy, so use them now. If the socket is not yet created, then log the addrress list from the config. Furthermore, take the chance to print now both local and remote addresses. Related: SYS#6636 Change-Id: I607e4c2dd37f07bf1c07c88681918184e92202ea --- M src/osmo_ss7_asp.c M src/osmo_ss7_vty.c M src/ss7_internal.h M tests/vty/ss7_asp_test.vty 4 files changed, 104 insertions(+), 46 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/74/35274/1 diff --git a/src/osmo_ss7_asp.c b/src/osmo_ss7_asp.c index 55e5a29..f867ce5 100644 --- a/src/osmo_ss7_asp.c +++ b/src/osmo_ss7_asp.c @@ -1134,3 +1134,19 @@ { return asp->cfg.proto; } + +/*! \brief Get the fd of a given ASP + * \param[in] asp The ASP for which the fd is requested + * \returns The fd of the ASP if acailable, negative otherwise + */ +int ss7_asp_get_fd(const struct osmo_ss7_asp *asp) +{ + if (asp->cfg.is_server) { + if (asp->server) + return osmo_stream_srv_get_fd(asp->server); + } else { + if (asp->client) + return osmo_stream_cli_get_fd(asp->client); + } + return -1; +} diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 35f0dda..91a1eb7 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -1133,13 +1133,39 @@ return buf; } +/* Similar to osmo_sock_multiaddr_get_name_buf(), but aimed at listening sockets (only local part): */ +static char *get_sockname_buf(char *buf, size_t buf_len, int fd, int proto, bool local) +{ + char hostbuf[OSMO_SOCK_MAX_ADDRS][INET6_ADDRSTRLEN]; + size_t num_hostbuf = ARRAY_SIZE(hostbuf); + char portbuf[6]; + struct osmo_strbuf sb = { .buf = buf, .len = buf_len }; + bool need_more_bufs; + int rc; + + rc = osmo_sock_multiaddr_get_ip_and_port(fd, proto, [0][0], +_hostbuf, sizeof(hostbuf[0]), +portbuf, sizeof(portbuf), local); + if (rc < 0) + return NULL; + + need_more_bufs = num_hostbuf > ARRAY_SIZE(hostbuf); + if (need_more_bufs) + num_hostbuf = ARRAY_SIZE(hostbuf); + OSMO_STRBUF_APPEND(sb, osmo_multiaddr_ip_and_port_snprintf, + [0][0], num_hostbuf, sizeof(hostbuf[0]), portbuf); + if (need_more_bufs) + OSMO_STRBUF_PRINTF(sb, ""); + + return buf; +} + DEFUN(show_cs7_asp, show_cs7_asp_cmd, "show cs7 instance <0-15> asp", SHOW_STR CS7_STR INST_STR INST_STR "Application Server Process (ASP)\n") { struct osmo_ss7_instance *inst; struct osmo_ss7_asp *asp; - char buf[512]; char as_buf[64]; int id = atoi(argv[0]); @@ -1149,28 +1175,32 @@ return CMD_WARNING; } - vty_out(vty, " Current Primary Link%s", VTY_NEWLINE); - vty_out(vty, "ASP Name AS Name State Type Role SCTP Role Remote Addresses%s", VTY_NEWLINE); - vty_out(vty, " - - ---%s", VTY_NEWLINE); + vty_out(vty, "ASP Name AS Name State Type Role SCTP Role Local Addresses Remote Addresses%s", VTY_NEWLINE); + vty_out(vty, " - - --- ---%s", VTY_NEWLINE); llist_for_each_entry(asp, >asp_list, list) { - if (asp->cfg.proto == OSMO_SS7_ASP_PROT_IPA && asp->cfg.remote.port == 0 && asp->server) { - int fd = osmo_stream_srv_get_fd(asp->server); - char hostbuf[64]; - char portbuf[16]; - osmo_sock_get_ip_and_port(fd, hostbuf, sizeof(hostbuf), - portbuf, sizeof(portbuf), false); - snprintf(buf, sizeof(buf), "%s:%s", hostbuf, portbuf); - } else - osmo_ss7_asp_peer_snprintf(buf, sizeof(buf), >cfg.remote); - vty_out(vty, "%-12s %-12s %-13s %-4s %-4s %-9s %-23s%s", + char buf_loc[OSMO_SOCK_MAX_ADDRS * INET6_ADDRSTRLEN + OSMO_SOCK_MAX_ADDRS + 2 + 6 + 1]; + char