map: fix deleting port based rules
[project/qosify.git] / interface.c
index 7979b21d71b822bf302e987169636938556da010..837cb9503f05e12685ff989f969819e4fa846c3c 100644 (file)
@@ -531,6 +531,7 @@ static void qos_iface_check_cb(struct uloop_timeout *t)
                qosify_iface_check_device(iface);
        vlist_for_each_element(&interfaces, iface, node)
                qosify_iface_check_interface(iface);
+       qosify_ubus_update_bridger(false);
 }
 
 void qosify_iface_check(void)
@@ -549,7 +550,7 @@ __qosify_iface_status(struct blob_buf *b, struct qosify_iface *iface)
 
        c = blobmsg_open_table(b, qosify_iface_name(iface));
        blobmsg_add_u8(b, "active", iface->active);
-       if (iface->ifname)
+       if (iface->ifname[0])
                blobmsg_add_string(b, "ifname", iface->ifname);
        blobmsg_add_u8(b, "egress", iface->config.egress);
        blobmsg_add_u8(b, "ingress", iface->config.ingress);
@@ -602,6 +603,25 @@ qosify_nl_error_cb(struct sockaddr_nl *nla, struct nlmsgerr *err,
        return NL_STOP;
 }
 
+static void
+__qosify_iface_get_device(struct blob_buf *b, struct qosify_iface *iface)
+{
+       if (!iface->ifname[0] || !iface->active)
+               return;
+
+       blobmsg_add_string(b, NULL, iface->ifname);
+}
+
+void qosify_iface_get_devices(struct blob_buf *b)
+{
+       struct qosify_iface *iface;
+
+       vlist_for_each_element(&devices, iface, node)
+               __qosify_iface_get_device(b, iface);
+       vlist_for_each_element(&interfaces, iface, node)
+               __qosify_iface_get_device(b, iface);
+}
+
 int qosify_iface_init(void)
 {
        int fd, opt;