Message ID | 20220603173016.1383423-1-jeffreyjilinux@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | David Ahern |
Headers | show |
Series | [iproute2-next] show rx_otherehost_dropped stat in ip link show | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
On 6/3/22 11:30 AM, Jeffrey Ji wrote: > From: Jeffrey Ji <jeffreyji@google.com> > > This stat was added in commit 794c24e9921f ("net-core: > rx_otherhost_dropped to core_stats") > > Tested: sent packet with wrong MAC address from 1 > network namespace to another, verified that counter showed "1" in > `ip -s -s link sh` and `ip -s -s -j link sh` Add example output for both commands. > > Signed-off-by: Jeffrey Ji <jeffreyji@google.com> > --- > ip/ipaddress.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/ip/ipaddress.c b/ip/ipaddress.c > index 142731933ba3..544c7450b7bf 100644 > --- a/ip/ipaddress.c > +++ b/ip/ipaddress.c > @@ -692,6 +692,7 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s, > strlen("heartbt"), > strlen("overrun"), > strlen("compressed"), > + strlen("otherhost_dropped"), This should be shortened to just "otherhost". > }; > > if (is_json_context()) { > @@ -730,6 +731,10 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s, > if (s->rx_nohandler) > print_u64(PRINT_JSON, > "nohandler", NULL, s->rx_nohandler); > + if (s->rx_otherhost_dropped) > + print_u64(PRINT_JSON, > + "otherhost_dropped", NULL, > + s->rx_otherhost_dropped); > } > close_json_object(); > > @@ -811,11 +816,14 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s, > /* RX error stats */ > if (show_stats > 1) { > fprintf(fp, "%s", _SL_); > - fprintf(fp, " RX errors:%*s %*s %*s %*s %*s %*s %*s%s", > + fprintf(fp, " RX errors:%*s %*s %*s %*s %*s %*s%*s%*s%s", > cols[0] - 10, "", cols[1], "length", > cols[2], "crc", cols[3], "frame", > cols[4], "fifo", cols[5], "overrun", > - cols[6], s->rx_nohandler ? "nohandler" : "", > + s->rx_nohandler ? cols[6] + 1 : 0, > + s->rx_nohandler ? " nohandler" : "", > + s->rx_otherhost_dropped ? cols[7] + 1 : 0, > + s->rx_otherhost_dropped ? " otherhost_dropped" : "", This is getting ugly. Just "otherhost" here as well. Before this print there are a few calls to size_columns; seems like rx_otherhost_dropped should be added to the rx one. > _SL_); > fprintf(fp, "%*s", cols[0] + 5, ""); > print_num(fp, cols[1], s->rx_length_errors); > @@ -825,6 +833,9 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s, > print_num(fp, cols[5], s->rx_over_errors); > if (s->rx_nohandler) > print_num(fp, cols[6], s->rx_nohandler); > + if (s->rx_otherhost_dropped) > + print_num(fp, cols[7], > + s->rx_otherhost_dropped); > } > fprintf(fp, "%s", _SL_); >
diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 142731933ba3..544c7450b7bf 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -692,6 +692,7 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s, strlen("heartbt"), strlen("overrun"), strlen("compressed"), + strlen("otherhost_dropped"), }; if (is_json_context()) { @@ -730,6 +731,10 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s, if (s->rx_nohandler) print_u64(PRINT_JSON, "nohandler", NULL, s->rx_nohandler); + if (s->rx_otherhost_dropped) + print_u64(PRINT_JSON, + "otherhost_dropped", NULL, + s->rx_otherhost_dropped); } close_json_object(); @@ -811,11 +816,14 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s, /* RX error stats */ if (show_stats > 1) { fprintf(fp, "%s", _SL_); - fprintf(fp, " RX errors:%*s %*s %*s %*s %*s %*s %*s%s", + fprintf(fp, " RX errors:%*s %*s %*s %*s %*s %*s%*s%*s%s", cols[0] - 10, "", cols[1], "length", cols[2], "crc", cols[3], "frame", cols[4], "fifo", cols[5], "overrun", - cols[6], s->rx_nohandler ? "nohandler" : "", + s->rx_nohandler ? cols[6] + 1 : 0, + s->rx_nohandler ? " nohandler" : "", + s->rx_otherhost_dropped ? cols[7] + 1 : 0, + s->rx_otherhost_dropped ? " otherhost_dropped" : "", _SL_); fprintf(fp, "%*s", cols[0] + 5, ""); print_num(fp, cols[1], s->rx_length_errors); @@ -825,6 +833,9 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s, print_num(fp, cols[5], s->rx_over_errors); if (s->rx_nohandler) print_num(fp, cols[6], s->rx_nohandler); + if (s->rx_otherhost_dropped) + print_num(fp, cols[7], + s->rx_otherhost_dropped); } fprintf(fp, "%s", _SL_);