[M] Change in libosmo-sccp[master]: vty: Introduce show cs7 instance asp-assoc-status
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?usp=email ) Change subject: vty: Introduce show cs7 instance asp-assoc-status .. vty: Introduce show cs7 instance asp-assoc-status Change-Id: I96ef4c0500991c9b86ab5991fb338ea20a18ff33 Depends: libosmocore.git Change-Id I3e1c84526b006baff435bbbca49dc6cf7d201cf5 Depends: libosmo-netif.git Change-Id I78a0bd8279a04f4011c7273e0f542981308e482f Related: SYS#6636 --- M TODO-RELEASE M src/osmo_ss7_vty.c M tests/vty/ss7_asp_test.vty 3 files changed, 175 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/84/35284/1 diff --git a/TODO-RELEASE b/TODO-RELEASE index 1913dc6..25eeb6e 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -11,4 +11,4 @@ libosmo-netif >1.4.0 osmo_stream_{srv,cli}_get_fd() libosmocore >1.9.0 osmo_sock_multiaddr_get_ip_and_port(), osmo_multiaddr_ip_and_port_snprintf() libosmocore >1.9.0 osmo_sock_sctp_get_peer_addr_info() -libosmo-netif >1.4.0osmo_sctp_spinfo_state_str() +libosmo-netif >1.4.0osmo_sctp_spinfo_state_str(), osmo_sctp_sstat_state_str() diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 0a1ad92..7896b48 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -1422,6 +1423,154 @@ return show_asp_remaddr(vty, id, asp_name); } +static void show_one_asp_assoc_status_tcp(struct vty *vty, struct osmo_ss7_asp *asp) +{ + struct osmo_sockaddr osa = {}; + struct tcp_info tcpi = {}; + socklen_t len; + int fd, rc; + int rx_pend_bytes = 0; + + fd = ss7_asp_get_fd(asp); + if (fd < 0) { + vty_out(vty, "%-12s uninitialized%s", asp->cfg.name, VTY_NEWLINE); + return; + } + + len = sizeof(osa.u.sas); + rc = getpeername(fd, &osa.u.sa, &len); + + len = sizeof(tcpi); + rc = getsockopt(fd, SOL_TCP, TCP_INFO, &tcpi, &len); + if (rc < 0) { + char buf_err[128]; + strerror_r(errno, buf_err, sizeof(buf_err)); + vty_out(vty, "%-12s getsockopt(TCP_INFO) failed: %s%s", + asp->cfg.name, buf_err, VTY_NEWLINE); + return; + } + + rc = ioctl(fd, FIONREAD, &rx_pend_bytes); + + vty_out(vty, "%-12s TCP_%-19s %-9s %-10s %-8u %-9u %-7u %-9u %-46s%s", + asp->cfg.name, + get_value_string(tcp_info_state_values, tcpi.tcpi_state), + "-", "-", tcpi.tcpi_rcv_wnd, tcpi.tcpi_unacked, rx_pend_bytes, + tcpi.tcpi_pmtu, osmo_sockaddr_to_str(&osa), + VTY_NEWLINE); +} + +#ifdef HAVE_LIBSCTP +static void show_one_asp_assoc_status_sctp(struct vty *vty, struct osmo_ss7_asp *asp) +{ + struct osmo_sockaddr osa = {}; + struct sctp_status st; + socklen_t len; + int fd, rc; + + fd = ss7_asp_get_fd(asp); + if (fd < 0) { + vty_out(vty, "%-12s uninitialized%s", asp->cfg.name, VTY_NEWLINE); + return; + } + + memset(&st, 0, sizeof(st)); + len = sizeof(st); + rc = getsockopt(fd, IPPROTO_SCTP, SCTP_STATUS, &st, &len); + if (rc < 0) { + char buf_err[128]; + strerror_r(errno, buf_err, sizeof(buf_err)); + vty_out(vty, "%-12s getsockopt(SCTP_STATUS) failed: %s%s", asp->cfg.name, buf_err, VTY_NEWLINE); + return; + } + + osa.u.sas = st.sstat_primary.spinfo_address; + vty_out(vty, "%-12s SCTP_%-18s %-9u %-10u %-8u %-9u %-7u %-9u %-46s%s", + asp->cfg.name, + osmo_sctp_sstat_state_str(st.sstat_state), + st.sstat_instrms, st.sstat_outstrms, + st.sstat_rwnd, st.sstat_unackdata, st.sstat_penddata, + st.sstat_fragmentation_point, + osmo_sockaddr_to_str(&osa), + VTY_NEWLINE); +} +#endif + +static void show_one_asp_assoc_status(struct vty *vty, struct osmo_ss7_asp *asp) +{ + int proto = ss7_asp_proto_to_ip_proto(asp->cfg.proto); + + switch (proto) { + case IPPROTO_TCP: + show_one_asp_assoc_status_tcp(vty, asp); + break; +#ifdef HAVE_LIBSCTP + case IPPROTO_SCTP: + show_one_asp_assoc_status_sctp(vty, asp); + break; +#endif + default: + vty_out(vty, "%-12s unknown proto %u%s", asp->cfg.name, proto, VTY_NEWLINE); + break; + } +} + +static int show_asp_assoc_status(struct vty *vty, int id, const char *asp_name) +{ + struct osmo_ss7_instance *inst; + struct osmo_ss7_asp *asp = NULL; + + inst = osmo_ss7_instance_find(id); + if (!inst) { + vty_out(vty, "No SS7 instance %d found%s", id, VTY_NEWLINE); + return CMD_WARNING; + } + +
[M] Change in libosmo-sccp[master]: vty: Introduce show cs7 instance asp-assoc-status
Attention is currently required from: pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?usp=email ) Change subject: vty: Introduce show cs7 instance asp-assoc-status .. Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?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: I96ef4c0500991c9b86ab5991fb338ea20a18ff33 Gerrit-Change-Number: 35284 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: osmith Gerrit-Attention: pespin Gerrit-Comment-Date: Tue, 12 Dec 2023 12:44:55 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: Introduce show cs7 instance asp-assoc-status
Attention is currently required from: pespin. daniel has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?usp=email ) Change subject: vty: Introduce show cs7 instance asp-assoc-status .. Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?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: I96ef4c0500991c9b86ab5991fb338ea20a18ff33 Gerrit-Change-Number: 35284 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: osmith Gerrit-Attention: pespin Gerrit-Comment-Date: Tue, 12 Dec 2023 13:13:30 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: Introduce show cs7 instance asp-assoc-status
Attention is currently required from: daniel, osmith, pespin. Hello Jenkins Builder, daniel, osmith, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?usp=email to look at the new patch set (#2). The following approvals got outdated and were removed: Code-Review+1 by daniel, Code-Review+1 by osmith, Verified-1 by Jenkins Builder Change subject: vty: Introduce show cs7 instance asp-assoc-status .. vty: Introduce show cs7 instance asp-assoc-status Change-Id: I96ef4c0500991c9b86ab5991fb338ea20a18ff33 Depends: libosmocore.git Change-Id I3e1c84526b006baff435bbbca49dc6cf7d201cf5 Depends: libosmo-netif.git Change-Id I78a0bd8279a04f4011c7273e0f542981308e482f Related: SYS#6636 --- M TODO-RELEASE M src/osmo_ss7_vty.c M tests/vty/ss7_asp_test.vty 3 files changed, 182 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/84/35284/2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?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: I96ef4c0500991c9b86ab5991fb338ea20a18ff33 Gerrit-Change-Number: 35284 Gerrit-PatchSet: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: osmith Gerrit-Attention: osmith Gerrit-Attention: pespin Gerrit-Attention: daniel Gerrit-MessageType: newpatchset
[M] Change in libosmo-sccp[master]: vty: Introduce show cs7 instance asp-assoc-status
Attention is currently required from: daniel, pespin. osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?usp=email ) Change subject: vty: Introduce show cs7 instance asp-assoc-status .. Patch Set 2: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?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: I96ef4c0500991c9b86ab5991fb338ea20a18ff33 Gerrit-Change-Number: 35284 Gerrit-PatchSet: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: osmith Gerrit-Attention: pespin Gerrit-Attention: daniel Gerrit-Comment-Date: Tue, 12 Dec 2023 15:26:18 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: Introduce show cs7 instance asp-assoc-status
Attention is currently required from: daniel. pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?usp=email ) Change subject: vty: Introduce show cs7 instance asp-assoc-status .. Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?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: I96ef4c0500991c9b86ab5991fb338ea20a18ff33 Gerrit-Change-Number: 35284 Gerrit-PatchSet: 2 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel Gerrit-Reviewer: osmith Gerrit-Reviewer: pespin Gerrit-Attention: daniel Gerrit-Comment-Date: Tue, 12 Dec 2023 15:26:59 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
[M] Change in libosmo-sccp[master]: vty: Introduce show cs7 instance asp-assoc-status
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/35284?usp=email ) Change subject: vty: Introduce show cs7 instance asp-assoc-status .. vty: Introduce show cs7 instance asp-assoc-status Change-Id: I96ef4c0500991c9b86ab5991fb338ea20a18ff33 Depends: libosmocore.git Change-Id I3e1c84526b006baff435bbbca49dc6cf7d201cf5 Depends: libosmo-netif.git Change-Id I78a0bd8279a04f4011c7273e0f542981308e482f Related: SYS#6636 --- M TODO-RELEASE M src/osmo_ss7_vty.c M tests/vty/ss7_asp_test.vty 3 files changed, 182 insertions(+), 7 deletions(-) Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified osmith: Looks good to me, but someone else must approve diff --git a/TODO-RELEASE b/TODO-RELEASE index 1913dc6..25eeb6e 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -11,4 +11,4 @@ libosmo-netif >1.4.0 osmo_stream_{srv,cli}_get_fd() libosmocore >1.9.0 osmo_sock_multiaddr_get_ip_and_port(), osmo_multiaddr_ip_and_port_snprintf() libosmocore >1.9.0 osmo_sock_sctp_get_peer_addr_info() -libosmo-netif >1.4.0osmo_sctp_spinfo_state_str() +libosmo-netif >1.4.0osmo_sctp_spinfo_state_str(), osmo_sctp_sstat_state_str() diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index fe015d9..1483ac0 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -1422,6 +1423,161 @@ return show_asp_remaddr(vty, id, asp_name); } +static void show_one_asp_assoc_status_tcp(struct vty *vty, struct osmo_ss7_asp *asp) +{ + struct osmo_sockaddr osa = {}; + struct tcp_info tcpi = {}; + socklen_t len; + int fd, rc; + int rx_pend_bytes = 0; + + fd = ss7_asp_get_fd(asp); + if (fd < 0) { + vty_out(vty, "%-12s uninitialized%s", asp->cfg.name, VTY_NEWLINE); + return; + } + + len = sizeof(osa.u.sas); + rc = getpeername(fd, &osa.u.sa, &len); + + len = sizeof(tcpi); + rc = getsockopt(fd, SOL_TCP, TCP_INFO, &tcpi, &len); + if (rc < 0) { + char buf_err[128]; + strerror_r(errno, buf_err, sizeof(buf_err)); + vty_out(vty, "%-12s getsockopt(TCP_INFO) failed: %s%s", + asp->cfg.name, buf_err, VTY_NEWLINE); + return; + } + + rc = ioctl(fd, FIONREAD, &rx_pend_bytes); + + /* FIXME: RWND: struct tcp_info from linux/tcp.h contains more fields +* than the one from netinet/tcp.h we currently use, including +* "tcpi_rcv_wnd" which we could use to print RWND here. However, +* linux/tcp.h seems to be missing the state defines used in +* "tcp_info_state_values", so we cannot use that one instead. +*/ + + vty_out(vty, "%-12s TCP_%-19s %-9s %-10s %-8s %-9u %-7u %-9u %-46s%s", + asp->cfg.name, + get_value_string(tcp_info_state_values, tcpi.tcpi_state), + "-", "-", "-", tcpi.tcpi_unacked, rx_pend_bytes, + tcpi.tcpi_pmtu, osmo_sockaddr_to_str(&osa), + VTY_NEWLINE); +} + +#ifdef HAVE_LIBSCTP +static void show_one_asp_assoc_status_sctp(struct vty *vty, struct osmo_ss7_asp *asp) +{ + struct osmo_sockaddr osa = {}; + struct sctp_status st; + socklen_t len; + int fd, rc; + + fd = ss7_asp_get_fd(asp); + if (fd < 0) { + vty_out(vty, "%-12s uninitialized%s", asp->cfg.name, VTY_NEWLINE); + return; + } + + memset(&st, 0, sizeof(st)); + len = sizeof(st); + rc = getsockopt(fd, IPPROTO_SCTP, SCTP_STATUS, &st, &len); + if (rc < 0) { + char buf_err[128]; + strerror_r(errno, buf_err, sizeof(buf_err)); + vty_out(vty, "%-12s getsockopt(SCTP_STATUS) failed: %s%s", asp->cfg.name, buf_err, VTY_NEWLINE); + return; + } + + osa.u.sas = st.sstat_primary.spinfo_address; + vty_out(vty, "%-12s SCTP_%-18s %-9u %-10u %-8u %-9u %-7u %-9u %-46s%s", + asp->cfg.name, + osmo_sctp_sstat_state_str(st.sstat_state), + st.sstat_instrms, st.sstat_outstrms, + st.sstat_rwnd, st.sstat_unackdata, st.sstat_penddata, + st.sstat_fragmentation_point, + osmo_sockaddr_to_str(&osa), + VTY_NEWLINE); +} +#endif + +static void show_one_asp_assoc_status(struct vty *vty, struct osmo_ss7_asp *asp) +{ + int proto = ss7_asp_proto_to_ip_proto(asp->cfg.proto); + + switch (proto) { + case IPPROTO_TCP: + show_one_asp_assoc_status_tcp(vty, asp); + break; +#ifdef HAVE_LIBSCTP + case IPPROTO_SCTP: + show_one_asp_assoc_status_sctp(vty, asp); + break; +#endif + default: + vty_out(vty, "%-12s unknown proto %u%s", asp->cfg.name, proto, VTY_