From: Daniele Di Proietto ddiproietto@google.com
This is useful to monitor the arp_ping and nsna_ping link watches.
The value is exported as a string, because int in jansson is limited to 32-bits (and in general JSON implementations do not handle 64-bits values very well).
Signed-off-by: Daniele Di Proietto ddiproietto@google.com --- teamd/teamd_link_watch.h | 6 ++++++ teamd/teamd_lw_arp_ping.c | 5 +++++ teamd/teamd_lw_nsna_ping.c | 5 +++++ teamd/teamd_lw_psr.c | 25 ++++++++++++++++++++++++- 4 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/teamd/teamd_link_watch.h b/teamd/teamd_link_watch.h index ea7ef87..46030aa 100644 --- a/teamd/teamd_link_watch.h +++ b/teamd/teamd_link_watch.h @@ -1,6 +1,8 @@ #ifndef _TEAMD_LINK_WATCH_H_ #define _TEAMD_LINK_WATCH_H_
+#include <stdint.h> + #include "teamd_state.h"
struct teamd_link_watch { @@ -40,6 +42,7 @@ struct lw_psr_port_priv { unsigned int missed_max; int sock; unsigned int missed; + uint64_t total_probes_sent; bool reply_received; };
@@ -77,5 +80,8 @@ int lw_psr_state_missed_max_get(struct teamd_context *ctx, int lw_psr_state_missed_get(struct teamd_context *ctx, struct team_state_gsc *gsc, void *priv); +int lw_psr_state_total_probes_sent_get(struct teamd_context *ctx, + struct team_state_gsc *gsc, + void *priv);
#endif diff --git a/teamd/teamd_lw_arp_ping.c b/teamd/teamd_lw_arp_ping.c index c3d4710..d429e31 100644 --- a/teamd/teamd_lw_arp_ping.c +++ b/teamd/teamd_lw_arp_ping.c @@ -477,6 +477,11 @@ static const struct teamd_state_val lw_ap_state_vals[] = { .type = TEAMD_STATE_ITEM_TYPE_INT, .getter = lw_psr_state_missed_get, }, + { + .subpath = "total_probes_sent", + .type = TEAMD_STATE_ITEM_TYPE_STRING, + .getter = lw_psr_state_total_probes_sent_get, + }, };
const struct teamd_link_watch teamd_link_watch_arp_ping = { diff --git a/teamd/teamd_lw_nsna_ping.c b/teamd/teamd_lw_nsna_ping.c index 9273462..9468788 100644 --- a/teamd/teamd_lw_nsna_ping.c +++ b/teamd/teamd_lw_nsna_ping.c @@ -324,6 +324,11 @@ static const struct teamd_state_val lw_nsnap_state_vals[] = { .type = TEAMD_STATE_ITEM_TYPE_INT, .getter = lw_psr_state_missed_get, }, + { + .subpath = "total_probes_sent", + .type = TEAMD_STATE_ITEM_TYPE_STRING, + .getter = lw_psr_state_total_probes_sent_get, + }, };
const struct teamd_link_watch teamd_link_watch_nsnap = { diff --git a/teamd/teamd_lw_psr.c b/teamd/teamd_lw_psr.c index b0a41f4..68e028d 100644 --- a/teamd/teamd_lw_psr.c +++ b/teamd/teamd_lw_psr.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
+#include <inttypes.h> +#include <stdio.h> #include <private/misc.h> #include "teamd.h" #include "teamd_link_watch.h" @@ -58,7 +60,10 @@ static int lw_psr_callback_periodic(struct teamd_context *ctx, int events, void return err; psr_ppriv->reply_received = false;
- return psr_ppriv->ops->send(psr_ppriv); + err = psr_ppriv->ops->send(psr_ppriv); + if (!err) + psr_ppriv->total_probes_sent++; + return err; }
#define LW_SOCKET_CB_NAME "lw_socket" @@ -235,3 +240,21 @@ int lw_psr_state_missed_get(struct teamd_context *ctx, gsc->data.int_val = psr_ppriv->missed; return 0; } + +int lw_psr_state_total_probes_sent_get(struct teamd_context *ctx, + struct team_state_gsc *gsc, + void *priv) +{ + struct lw_common_port_priv *common_ppriv = priv; + struct lw_psr_port_priv *psr_ppriv = lw_psr_ppriv_get(common_ppriv); + char *str; + int err; + + err = asprintf(&str, "%"PRIu64, psr_ppriv->total_probes_sent); + if (err == -1) + return -ENOMEM; + + gsc->data.str_val.ptr = str; + gsc->data.str_val.free = true; + return 0; +}
From: Daniele Di Proietto ddiproietto@google.com
There already is a counter for missed probes, but:
* It is reset when the port comes up * It is increased when the port is simply not active (unless send_always is true).
This new counter is not reset and it is increased only if the probe was effectively sent.
The value is exported as a string, because int in jansson is limited to 32-bits (and in general JSON implementations do not handle 64-bits values very well).
Signed-off-by: Daniele Di Proietto ddiproietto@google.com --- teamd/teamd_link_watch.h | 5 +++++ teamd/teamd_lw_arp_ping.c | 21 +++++++++++++++------ teamd/teamd_lw_nsna_ping.c | 7 +++++++ teamd/teamd_lw_psr.c | 22 +++++++++++++++++++++- 4 files changed, 48 insertions(+), 7 deletions(-)
diff --git a/teamd/teamd_link_watch.h b/teamd/teamd_link_watch.h index 46030aa..3734322 100644 --- a/teamd/teamd_link_watch.h +++ b/teamd/teamd_link_watch.h @@ -43,6 +43,8 @@ struct lw_psr_port_priv { int sock; unsigned int missed; uint64_t total_probes_sent; + uint64_t total_probes_missed; + bool probe_sent; bool reply_received; };
@@ -83,5 +85,8 @@ int lw_psr_state_missed_get(struct teamd_context *ctx, int lw_psr_state_total_probes_sent_get(struct teamd_context *ctx, struct team_state_gsc *gsc, void *priv); +int lw_psr_state_total_probes_missed_get(struct teamd_context *ctx, + struct team_state_gsc *gsc, + void *priv);
#endif diff --git a/teamd/teamd_lw_arp_ping.c b/teamd/teamd_lw_arp_ping.c index d429e31..feb8f03 100644 --- a/teamd/teamd_lw_arp_ping.c +++ b/teamd/teamd_lw_arp_ping.c @@ -296,15 +296,19 @@ static int lw_ap_send(struct lw_psr_port_priv *psr_ppriv) avp.vlanh.h_vlan_encapsulated_proto = htons(ETH_P_ARP); avp.vlanh.h_vlan_TCI = htons(ap_ppriv->vlanid); ll_bcast.sll_protocol = htons(ETH_P_8021Q); - return teamd_sendto(psr_ppriv->sock, &avp, sizeof(avp), - 0, (struct sockaddr *) &ll_bcast, - sizeof(ll_bcast)); + err = teamd_sendto(psr_ppriv->sock, &avp, sizeof(avp), + 0, (struct sockaddr *) &ll_bcast, + sizeof(ll_bcast)); } else { ll_bcast.sll_protocol = htons(ETH_P_ARP); - return teamd_sendto(psr_ppriv->sock, &ap, sizeof(ap), - 0, (struct sockaddr *) &ll_bcast, - sizeof(ll_bcast)); + err = teamd_sendto(psr_ppriv->sock, &ap, sizeof(ap), + 0, (struct sockaddr *) &ll_bcast, + sizeof(ll_bcast)); } + + if (!err) + psr_ppriv->probe_sent = true; + return err; }
static int lw_ap_receive(struct lw_psr_port_priv *psr_ppriv) @@ -482,6 +486,11 @@ static const struct teamd_state_val lw_ap_state_vals[] = { .type = TEAMD_STATE_ITEM_TYPE_STRING, .getter = lw_psr_state_total_probes_sent_get, }, + { + .subpath = "total_probes_missed", + .type = TEAMD_STATE_ITEM_TYPE_STRING, + .getter = lw_psr_state_total_probes_missed_get, + }, };
const struct teamd_link_watch teamd_link_watch_arp_ping = { diff --git a/teamd/teamd_lw_nsna_ping.c b/teamd/teamd_lw_nsna_ping.c index 9468788..f7737f7 100644 --- a/teamd/teamd_lw_nsna_ping.c +++ b/teamd/teamd_lw_nsna_ping.c @@ -227,6 +227,8 @@ static int lw_nsnap_send(struct lw_psr_port_priv *psr_ppriv) err = teamd_sendto(nsnap_ppriv->tx_sock, &nsp, sizeof(nsp), 0, (struct sockaddr *) &sendto_addr, sizeof(sendto_addr)); + if (!err) + psr_ppriv->probe_sent = true; return err; }
@@ -329,6 +331,11 @@ static const struct teamd_state_val lw_nsnap_state_vals[] = { .type = TEAMD_STATE_ITEM_TYPE_STRING, .getter = lw_psr_state_total_probes_sent_get, }, + { + .subpath = "total_probes_missed", + .type = TEAMD_STATE_ITEM_TYPE_STRING, + .getter = lw_psr_state_total_probes_missed_get, + }, };
const struct teamd_link_watch teamd_link_watch_nsnap = { diff --git a/teamd/teamd_lw_psr.c b/teamd/teamd_lw_psr.c index 68e028d..0f53fd6 100644 --- a/teamd/teamd_lw_psr.c +++ b/teamd/teamd_lw_psr.c @@ -47,6 +47,8 @@ static int lw_psr_callback_periodic(struct teamd_context *ctx, int events, void psr_ppriv->missed = 0; } else { psr_ppriv->missed++; + if (psr_ppriv->probe_sent) + psr_ppriv->total_probes_missed++; if (psr_ppriv->missed > psr_ppriv->missed_max && link_up) { teamd_log_dbg(ctx, "%s: Missed %u replies (max %u).", tdport->ifname, psr_ppriv->missed, @@ -59,7 +61,7 @@ static int lw_psr_callback_periodic(struct teamd_context *ctx, int events, void if (err) return err; psr_ppriv->reply_received = false; - + psr_ppriv->probe_sent = false; err = psr_ppriv->ops->send(psr_ppriv); if (!err) psr_ppriv->total_probes_sent++; @@ -258,3 +260,21 @@ int lw_psr_state_total_probes_sent_get(struct teamd_context *ctx, gsc->data.str_val.free = true; return 0; } + +int lw_psr_state_total_probes_missed_get(struct teamd_context *ctx, + struct team_state_gsc *gsc, + void *priv) +{ + struct lw_common_port_priv *common_ppriv = priv; + struct lw_psr_port_priv *psr_ppriv = lw_psr_ppriv_get(common_ppriv); + char *str; + int err; + + err = asprintf(&str, "%"PRIu64, psr_ppriv->total_probes_missed); + if (err == -1) + return -ENOMEM; + + gsc->data.str_val.ptr = str; + gsc->data.str_val.free = true; + return 0; +}
Any reason you sent this 4 times?
On Thu, Sep 2, 2021 at 8:46 AM Jiri Pirko jiri@resnulli.us wrote:
Any reason you sent this 4 times?
Apologies for the spam. I tried sending the series 3 times to the mailing list without success (but it worked for the individual cc'd addresses). I then realized that I needed to be subscribed to the mailing list in order to send. Only the 4th attempt made it to the mailing list (there's only one copy in the mailing list archives).
Thu, Jul 01, 2021 at 11:05:30AM CEST, daniele.di.proietto@gmail.com wrote:
From: Daniele Di Proietto ddiproietto@google.com
This is useful to monitor the arp_ping and nsna_ping link watches.
The value is exported as a string, because int in jansson is limited to 32-bits (and in general JSON implementations do not handle 64-bits values very well).
Could you please adjust the patch description to be written in imperative mood, as you would command the codebase what to do?
Thanks!
On Thu, Sep 2, 2021 at 8:48 AM Jiri Pirko jiri@resnulli.us wrote:
Thu, Jul 01, 2021 at 11:05:30AM CEST, daniele.di.proietto@gmail.com wrote:
From: Daniele Di Proietto ddiproietto@google.com
This is useful to monitor the arp_ping and nsna_ping link watches.
The value is exported as a string, because int in jansson is limited to 32-bits (and in general JSON implementations do not handle 64-bits values very well).
Could you please adjust the patch description to be written in imperative mood, as you would command the codebase what to do?
Sure, I sent a v2 of the series (with another small change) here: https://lists.fedorahosted.org/archives/list/libteam@lists.fedorahosted.org/...
Thanks!
Thanks!
libteam@lists.fedorahosted.org