]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
show rx_otherehost_dropped stat in ip link show
authorJeffrey Ji <jeffreyji@google.com>
Thu, 9 Jun 2022 21:05:16 +0000 (21:05 +0000)
committerDavid Ahern <dsahern@kernel.org>
Sun, 12 Jun 2022 15:52:24 +0000 (09:52 -0600)
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`

Signed-off-by: Jeffrey Ji <jeffreyji@google.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/ipaddress.c

index 142731933ba3577238d7c53d4e77ce4d1fa2326e..67403185cf22d290bfadd72fefc5b94b5f5bef52 100644 (file)
@@ -692,6 +692,7 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s,
                strlen("heartbt"),
                strlen("overrun"),
                strlen("compressed"),
+               strlen("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", NULL,
+                                          s->rx_otherhost_dropped);
                }
                close_json_object();
 
@@ -778,7 +783,8 @@ void print_stats64(FILE *fp, struct rtnl_link_stats64 *s,
                        size_columns(cols, ARRAY_SIZE(cols), 0,
                                     s->rx_length_errors, s->rx_crc_errors,
                                     s->rx_frame_errors, s->rx_fifo_errors,
-                                    s->rx_over_errors, s->rx_nohandler);
+                                    s->rx_over_errors, s->rx_nohandler,
+                                    s->rx_otherhost_dropped);
                size_columns(cols, ARRAY_SIZE(cols),
                             s->tx_bytes, s->tx_packets, s->tx_errors,
                             s->tx_dropped, s->tx_carrier_errors,
@@ -811,11 +817,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" : "",
                                _SL_);
                        fprintf(fp, "%*s", cols[0] + 5, "");
                        print_num(fp, cols[1], s->rx_length_errors);
@@ -825,6 +834,8 @@ 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_);