]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/ipaddress.c
ip: add IP_LIB_DIR environment variable
[mirror_iproute2.git] / ip / ipaddress.c
index ccf67d1dd55cfac916db45350b2b4cb180e643a0..571346b15cc358db7315cbdde4ff3dc45eeafdfc 100644 (file)
@@ -744,7 +744,7 @@ static void __print_link_stats(FILE *fp, struct rtattr *tb[])
                close_json_object();
        } else {
                /* RX stats */
-               fprintf(fp, "    RX: bytes  packets  errors  dropped overrun mcast   %s%s",
+               fprintf(fp, "    RX: bytes  packets  errors  dropped missed  mcast   %s%s",
                        s->rx_compressed ? "compressed" : "", _SL_);
 
                fprintf(fp, "    ");
@@ -752,7 +752,7 @@ static void __print_link_stats(FILE *fp, struct rtattr *tb[])
                print_num(fp, 8, s->rx_packets);
                print_num(fp, 7, s->rx_errors);
                print_num(fp, 7, s->rx_dropped);
-               print_num(fp, 7, s->rx_over_errors);
+               print_num(fp, 7, s->rx_missed_errors);
                print_num(fp, 7, s->multicast);
                if (s->rx_compressed)
                        print_num(fp, 7, s->rx_compressed);
@@ -760,14 +760,14 @@ static void __print_link_stats(FILE *fp, struct rtattr *tb[])
                /* RX error stats */
                if (show_stats > 1) {
                        fprintf(fp, "%s", _SL_);
-                       fprintf(fp, "    RX errors: length   crc     frame   fifo    missed%s%s",
+                       fprintf(fp, "    RX errors: length   crc     frame   fifo    overrun%s%s",
                                s->rx_nohandler ? "   nohandler" : "", _SL_);
                        fprintf(fp, "               ");
                        print_num(fp, 8, s->rx_length_errors);
                        print_num(fp, 7, s->rx_crc_errors);
                        print_num(fp, 7, s->rx_frame_errors);
                        print_num(fp, 7, s->rx_fifo_errors);
-                       print_num(fp, 7, s->rx_missed_errors);
+                       print_num(fp, 7, s->rx_over_errors);
                        if (s->rx_nohandler)
                                print_num(fp, 7, s->rx_nohandler);
                }
@@ -874,6 +874,45 @@ static void print_link_event(FILE *f, __u32 event)
        }
 }
 
+static void print_proto_down(FILE *f, struct rtattr *tb[])
+{
+       struct rtattr *preason[IFLA_PROTO_DOWN_REASON_MAX+1];
+
+       if (tb[IFLA_PROTO_DOWN]) {
+               if (rta_getattr_u8(tb[IFLA_PROTO_DOWN]))
+                       print_bool(PRINT_ANY,
+                                  "proto_down", " protodown on ", true);
+       }
+
+       if (tb[IFLA_PROTO_DOWN_REASON]) {
+               char buf[255];
+               __u32 reason;
+               int i, start = 1;
+
+               parse_rtattr_nested(preason, IFLA_PROTO_DOWN_REASON_MAX,
+                                  tb[IFLA_PROTO_DOWN_REASON]);
+               if (!tb[IFLA_PROTO_DOWN_REASON_VALUE])
+                       return;
+
+               reason = rta_getattr_u8(preason[IFLA_PROTO_DOWN_REASON_VALUE]);
+               if (!reason)
+                       return;
+
+               open_json_array(PRINT_ANY,
+                               is_json_context() ? "proto_down_reason" : "protodown_reason <");
+               for (i = 0; reason; i++, reason >>= 1) {
+                       if (reason & 0x1) {
+                               if (protodown_reason_n2a(i, buf, sizeof(buf)))
+                                       break;
+                               print_string(PRINT_ANY, NULL,
+                                            start ? "%s" : ",%s", buf);
+                               start = 0;
+                       }
+               }
+               close_json_array(PRINT_ANY, ">");
+       }
+}
+
 int print_linkinfo(struct nlmsghdr *n, void *arg)
 {
        FILE *fp = (FILE *)arg;
@@ -1066,11 +1105,8 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
                print_int(PRINT_FP, NULL, " new-ifindex %d", id);
        }
 
-       if (tb[IFLA_PROTO_DOWN]) {
-               if (rta_getattr_u8(tb[IFLA_PROTO_DOWN]))
-                       print_bool(PRINT_ANY,
-                                  "proto_down", " protodown on ", true);
-       }
+       if (tb[IFLA_PROTO_DOWN])
+               print_proto_down(fp, tb);
 
        if (show_details) {
                if (tb[IFLA_PROMISCUITY])
@@ -1249,8 +1285,8 @@ static const struct ifa_flag_data_t {
        { .name = "tentative",          .mask = IFA_F_TENTATIVE,        .readonly = true,       .v6only = true},
        { .name = "permanent",          .mask = IFA_F_PERMANENT,        .readonly = true,       .v6only = true},
        { .name = "mngtmpaddr",         .mask = IFA_F_MANAGETEMPADDR,   .readonly = false,      .v6only = true},
-       { .name = "noprefixroute",      .mask = IFA_F_NOPREFIXROUTE,    .readonly = false,      .v6only = true},
-       { .name = "autojoin",           .mask = IFA_F_MCAUTOJOIN,       .readonly = false,      .v6only = true},
+       { .name = "noprefixroute",      .mask = IFA_F_NOPREFIXROUTE,    .readonly = false,      .v6only = false},
+       { .name = "autojoin",           .mask = IFA_F_MCAUTOJOIN,       .readonly = false,      .v6only = false},
        { .name = "stable-privacy",     .mask = IFA_F_STABLE_PRIVACY,   .readonly = true,       .v6only = true},
 };