interface: unify status, always include ifname, ingress, egress
authorFelix Fietkau <nbd@nbd.name>
Fri, 19 Nov 2021 22:40:41 +0000 (23:40 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 19 Nov 2021 22:40:41 +0000 (23:40 +0100)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
interface.c

index 3f3bd304452b7dce894f9f5e202e982f65f9b752..4e3497daf22718b0b1347d9ee02d43065fda4101 100644 (file)
@@ -518,27 +518,34 @@ void qosify_iface_check(void)
        uloop_timeout_set(&timer, 10);
 }
 
+static void
+__qosify_iface_status(struct blob_buf *b, struct qosify_iface *iface)
+{
+       void *c;
+
+       c = blobmsg_open_table(b, qosify_iface_name(iface));
+       blobmsg_add_u8(b, "active", iface->active);
+       if (iface->ifname)
+               blobmsg_add_string(b, "ifname", iface->ifname);
+       blobmsg_add_u8(b, "egress", iface->config.egress);
+       blobmsg_add_u8(b, "ingress", iface->config.ingress);
+       blobmsg_close_table(b, c);
+
+}
+
 void qosify_iface_status(struct blob_buf *b)
 {
        struct qosify_iface *iface;
-       void *c, *i;
+       void *c;
 
        c = blobmsg_open_table(b, "devices");
-       vlist_for_each_element(&devices, iface, node) {
-               i = blobmsg_open_table(b, qosify_iface_name(iface));
-               blobmsg_add_u8(b, "active", iface->active);
-               blobmsg_close_table(b, i);
-       }
+       vlist_for_each_element(&devices, iface, node)
+               __qosify_iface_status(b, iface);
        blobmsg_close_table(b, c);
 
        c = blobmsg_open_table(b, "interfaces");
-       vlist_for_each_element(&interfaces, iface, node) {
-               i = blobmsg_open_table(b, qosify_iface_name(iface));
-               blobmsg_add_u8(b, "active", iface->active);
-               if (iface->ifname)
-                       blobmsg_add_string(b, "ifname", iface->ifname);
-               blobmsg_close_table(b, i);
-       }
+       vlist_for_each_element(&interfaces, iface, node)
+               __qosify_iface_status(b, iface);
        blobmsg_close_table(b, c);
 }