bridge: make it more clear why the config was applied
[project/netifd.git] / ubus.c
diff --git a/ubus.c b/ubus.c
index a38617928b415c7540338684a1402785d83dd416..3504a4976aacb71d024f7a060ec69a1268d0c1f9 100644 (file)
--- a/ubus.c
+++ b/ubus.c
@@ -54,6 +54,7 @@ enum {
        HR_TARGET,
        HR_V6,
        HR_INTERFACE,
+       HR_EXCLUDE,
        __HR_MAX
 };
 
@@ -61,6 +62,7 @@ static const struct blobmsg_policy route_policy[__HR_MAX] = {
        [HR_TARGET] = { .name = "target", .type = BLOBMSG_TYPE_STRING },
        [HR_V6] = { .name = "v6", .type = BLOBMSG_TYPE_BOOL },
        [HR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING },
+       [HR_EXCLUDE] = { .name = "exclude", .type = BLOBMSG_TYPE_BOOL },
 };
 
 static int
@@ -72,6 +74,7 @@ netifd_add_host_route(struct ubus_context *ctx, struct ubus_object *obj,
        struct interface *iface = NULL;
        union if_addr a;
        bool v6 = false;
+       bool exclude = false;
 
        blobmsg_parse(route_policy, __HR_MAX, tb, blob_data(msg), blob_len(msg));
        if (!tb[HR_TARGET])
@@ -80,6 +83,9 @@ netifd_add_host_route(struct ubus_context *ctx, struct ubus_object *obj,
        if (tb[HR_V6])
                v6 = blobmsg_get_bool(tb[HR_V6]);
 
+       if (tb[HR_EXCLUDE])
+               exclude = blobmsg_get_bool(tb[HR_EXCLUDE]);
+
        if (tb[HR_INTERFACE])
                iface = vlist_find(&interfaces, blobmsg_data(tb[HR_INTERFACE]), iface, node);
 
@@ -87,8 +93,7 @@ netifd_add_host_route(struct ubus_context *ctx, struct ubus_object *obj,
        if (!inet_pton(v6 ? AF_INET6 : AF_INET, blobmsg_data(tb[HR_TARGET]), &a))
                return UBUS_STATUS_INVALID_ARGUMENT;
 
-
-       iface = interface_ip_add_target_route(&a, v6, iface);
+       iface = interface_ip_add_target_route(&a, v6, iface, exclude);
        if (!iface)
                return UBUS_STATUS_NOT_FOUND;
 
@@ -267,7 +272,7 @@ netifd_handle_alias(struct ubus_context *ctx, struct ubus_object *obj,
        struct device *dev = NULL;
        struct blob_attr *tb[__ALIAS_ATTR_MAX];
        struct blob_attr *cur;
-       int rem;
+       size_t rem;
 
        blobmsg_parse(alias_attrs, __ALIAS_ATTR_MAX, tb, blob_data(msg), blob_len(msg));
 
@@ -913,6 +918,9 @@ netifd_dump_status(struct interface *iface)
        }
 
        a = blobmsg_open_table(&b, "data");
+
+       if (iface->zone)
+               blobmsg_add_string(&b, "zone", iface->zone);
        avl_for_each_element(&iface->data, data, node)
                blobmsg_add_blob(&b, data->data);
 
@@ -1124,7 +1132,7 @@ netifd_handle_iface(struct ubus_context *ctx, struct ubus_object *obj,
 {
        struct interface *iface;
        struct blob_attr *tb;
-       int i;
+       size_t i;
 
        blobmsg_parse(&iface_policy, 1, &tb, blob_data(msg), blob_len(msg));
        if (!tb)
@@ -1150,7 +1158,7 @@ netifd_handle_iface(struct ubus_context *ctx, struct ubus_object *obj,
 static void netifd_add_iface_object(void)
 {
        struct ubus_method *methods;
-       int i;
+       size_t i;
 
        methods = calloc(1, sizeof(iface_object_methods));
        if (!methods)