wireless: fix use-after-free bug
[project/netifd.git] / bridge.c
index c48381b..4ef0d7e 100644 (file)
--- a/bridge.c
+++ b/bridge.c
@@ -1,3 +1,16 @@
+/*
+ * netifd - network interface daemon
+ * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
 enum {
        BRIDGE_ATTR_IFNAME,
        BRIDGE_ATTR_STP,
 enum {
        BRIDGE_ATTR_IFNAME,
        BRIDGE_ATTR_STP,
+       BRIDGE_ATTR_FORWARD_DELAY,
+       BRIDGE_ATTR_PRIORITY,
+       BRIDGE_ATTR_IGMP_SNOOP,
+       BRIDGE_ATTR_AGEING_TIME,
+       BRIDGE_ATTR_HELLO_TIME,
+       BRIDGE_ATTR_MAX_AGE,
+       BRIDGE_ATTR_BRIDGE_EMPTY,
        __BRIDGE_ATTR_MAX
 };
 
 static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = {
        [BRIDGE_ATTR_IFNAME] = { "ifname", BLOBMSG_TYPE_ARRAY },
        [BRIDGE_ATTR_STP] = { "stp", BLOBMSG_TYPE_BOOL },
        __BRIDGE_ATTR_MAX
 };
 
 static const struct blobmsg_policy bridge_attrs[__BRIDGE_ATTR_MAX] = {
        [BRIDGE_ATTR_IFNAME] = { "ifname", BLOBMSG_TYPE_ARRAY },
        [BRIDGE_ATTR_STP] = { "stp", BLOBMSG_TYPE_BOOL },
+       [BRIDGE_ATTR_FORWARD_DELAY] = { "forward_delay", BLOBMSG_TYPE_INT32 },
+       [BRIDGE_ATTR_PRIORITY] = { "priority", BLOBMSG_TYPE_INT32 },
+       [BRIDGE_ATTR_AGEING_TIME] = { "ageing_time", BLOBMSG_TYPE_INT32 },
+       [BRIDGE_ATTR_HELLO_TIME] = { "hello_time", BLOBMSG_TYPE_INT32 },
+       [BRIDGE_ATTR_MAX_AGE] = { "max_age", BLOBMSG_TYPE_INT32 },
+       [BRIDGE_ATTR_IGMP_SNOOP] = { "igmp_snooping", BLOBMSG_TYPE_BOOL },
+       [BRIDGE_ATTR_BRIDGE_EMPTY] = { "bridge_empty", BLOBMSG_TYPE_BOOL },
 };
 
 };
 
-static const union config_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = {
+static const struct uci_blob_param_info bridge_attr_info[__BRIDGE_ATTR_MAX] = {
        [BRIDGE_ATTR_IFNAME] = { .type = BLOBMSG_TYPE_STRING },
 };
 
        [BRIDGE_ATTR_IFNAME] = { .type = BLOBMSG_TYPE_STRING },
 };
 
-static const struct config_param_list bridge_attr_list = {
+static const struct uci_blob_param_list bridge_attr_list = {
        .n_params = __BRIDGE_ATTR_MAX,
        .params = bridge_attrs,
        .info = bridge_attr_info,
        .n_params = __BRIDGE_ATTR_MAX,
        .params = bridge_attrs,
        .info = bridge_attr_info,
@@ -33,36 +60,75 @@ static const struct config_param_list bridge_attr_list = {
        .next = { &device_attr_list },
 };
 
        .next = { &device_attr_list },
 };
 
-static struct device *bridge_create(struct blob_attr *attr);
+static struct device *bridge_create(const char *name, struct blob_attr *attr);
+static void bridge_config_init(struct device *dev);
 static void bridge_free(struct device *dev);
 static void bridge_free(struct device *dev);
-static void bridge_dump_status(struct device *dev, struct blob_buf *b);
+static void bridge_dump_info(struct device *dev, struct blob_buf *b);
+enum dev_change_type
+bridge_reload(struct device *dev, struct blob_attr *attr);
 
 const struct device_type bridge_device_type = {
        .name = "Bridge",
        .config_params = &bridge_attr_list,
 
        .create = bridge_create,
 
 const struct device_type bridge_device_type = {
        .name = "Bridge",
        .config_params = &bridge_attr_list,
 
        .create = bridge_create,
+       .config_init = bridge_config_init,
+       .reload = bridge_reload,
        .free = bridge_free,
        .free = bridge_free,
-       .dump_status = bridge_dump_status,
+       .dump_info = bridge_dump_info,
 };
 
 struct bridge_state {
        struct device dev;
        device_state_cb set_state;
 
 };
 
 struct bridge_state {
        struct device dev;
        device_state_cb set_state;
 
+       struct blob_attr *config_data;
+       struct bridge_config config;
+       struct blob_attr *ifnames;
        bool active;
        bool active;
+       bool force_active;
 
 
-       struct list_head members;
+       struct bridge_member *primary_port;
+       struct vlist_tree members;
        int n_present;
 };
 
 struct bridge_member {
        int n_present;
 };
 
 struct bridge_member {
-       struct list_head list;
+       struct vlist_node node;
        struct bridge_state *bst;
        struct device_user dev;
        bool present;
        struct bridge_state *bst;
        struct device_user dev;
        bool present;
+       char name[];
 };
 
 };
 
+static void
+bridge_reset_primary(struct bridge_state *bst)
+{
+       struct bridge_member *bm;
+
+       if (!bst->primary_port &&
+           (bst->dev.settings.flags & DEV_OPT_MACADDR))
+               return;
+
+       bst->primary_port = NULL;
+       bst->dev.settings.flags &= ~DEV_OPT_MACADDR;
+       vlist_for_each_element(&bst->members, bm, node) {
+               uint8_t *macaddr;
+
+               if (!bm->present)
+                       continue;
+
+               bst->primary_port = bm;
+               if (bm->dev.dev->settings.flags & DEV_OPT_MACADDR)
+                       macaddr = bm->dev.dev->settings.macaddr;
+               else
+                       macaddr = bm->dev.dev->orig_settings.macaddr;
+               memcpy(bst->dev.settings.macaddr, macaddr, 6);
+               bst->dev.settings.flags |= DEV_OPT_MACADDR;
+               return;
+       }
+}
+
 static int
 bridge_disable_member(struct bridge_member *bm)
 {
 static int
 bridge_disable_member(struct bridge_member *bm)
 {
@@ -91,8 +157,10 @@ bridge_enable_member(struct bridge_member *bm)
                goto error;
 
        ret = system_bridge_addif(&bst->dev, bm->dev.dev);
                goto error;
 
        ret = system_bridge_addif(&bst->dev, bm->dev.dev);
-       if (ret < 0)
+       if (ret < 0) {
+               D(DEVICE, "Bridge device %s could not be added\n", bm->dev.dev->ifname);
                goto error;
                goto error;
+       }
 
        return 0;
 
 
        return 0;
 
@@ -103,6 +171,54 @@ error:
 }
 
 static void
 }
 
 static void
+bridge_remove_member(struct bridge_member *bm)
+{
+       struct bridge_state *bst = bm->bst;
+
+       if (!bm->present)
+               return;
+
+       if (bm == bst->primary_port)
+               bridge_reset_primary(bst);
+
+       if (bst->dev.active)
+               bridge_disable_member(bm);
+
+       bm->present = false;
+       bm->bst->n_present--;
+
+       if (bst->config.bridge_empty)
+               return;
+
+       bst->force_active = false;
+       if (bst->n_present == 0)
+               device_set_present(&bst->dev, false);
+}
+
+static void
+bridge_free_member(struct bridge_member *bm)
+{
+       struct device *dev = bm->dev.dev;
+
+       bridge_remove_member(bm);
+       device_remove_user(&bm->dev);
+
+       /*
+        * When reloading the config and moving a device from one bridge to
+        * another, the other bridge may have tried to claim this device
+        * before it was removed here.
+        * Ensure that claiming the device is retried by toggling its present
+        * state
+        */
+       if (dev->present) {
+               device_set_present(dev, false);
+               device_set_present(dev, true);
+       }
+
+       free(bm);
+}
+
+static void
 bridge_member_cb(struct device_user *dev, enum device_event ev)
 {
        struct bridge_member *bm = container_of(dev, struct bridge_member, dev);
 bridge_member_cb(struct device_user *dev, enum device_event ev)
 {
        struct bridge_member *bm = container_of(dev, struct bridge_member, dev);
@@ -122,16 +238,13 @@ bridge_member_cb(struct device_user *dev, enum device_event ev)
 
                break;
        case DEV_EVENT_REMOVE:
 
                break;
        case DEV_EVENT_REMOVE:
-               if (!bm->present)
+               if (dev->hotplug) {
+                       vlist_delete(&bst->members, &bm->node);
                        return;
                        return;
+               }
 
 
-               if (bst->dev.active)
-                       bridge_disable_member(bm);
-
-               bm->present = false;
-               bm->bst->n_present--;
-               if (bst->n_present == 0)
-                       device_set_present(&bst->dev, false);
+               if (bm->present)
+                       bridge_remove_member(bm);
 
                break;
        default:
 
                break;
        default:
@@ -146,7 +259,7 @@ bridge_set_down(struct bridge_state *bst)
 
        bst->set_state(&bst->dev, false);
 
 
        bst->set_state(&bst->dev, false);
 
-       list_for_each_entry(bm, &bst->members, list)
+       vlist_for_each_element(&bst->members, bm, node)
                bridge_disable_member(bm);
 
        system_bridge_delbr(&bst->dev);
                bridge_disable_member(bm);
 
        system_bridge_delbr(&bst->dev);
@@ -160,23 +273,24 @@ bridge_set_up(struct bridge_state *bst)
        struct bridge_member *bm;
        int ret;
 
        struct bridge_member *bm;
        int ret;
 
-       if (!bst->n_present)
+       if (!bst->force_active && !bst->n_present)
                return -ENOENT;
 
                return -ENOENT;
 
-       ret = system_bridge_addbr(&bst->dev);
+       ret = system_bridge_addbr(&bst->dev, &bst->config);
        if (ret < 0)
                goto out;
 
        if (ret < 0)
                goto out;
 
-       list_for_each_entry(bm, &bst->members, list)
+       vlist_for_each_element(&bst->members, bm, node)
                bridge_enable_member(bm);
 
                bridge_enable_member(bm);
 
-       if (!bst->n_present) {
+       if (!bst->force_active && !bst->n_present) {
                /* initialization of all member interfaces failed */
                system_bridge_delbr(&bst->dev);
                device_set_present(&bst->dev, false);
                return -ENOENT;
        }
 
                /* initialization of all member interfaces failed */
                system_bridge_delbr(&bst->dev);
                device_set_present(&bst->dev, false);
                return -ENOENT;
        }
 
+       bridge_reset_primary(bst);
        ret = bst->set_state(&bst->dev, true);
        if (ret < 0)
                bridge_set_down(bst);
        ret = bst->set_state(&bst->dev, true);
        if (ret < 0)
                bridge_set_down(bst);
@@ -199,38 +313,54 @@ bridge_set_state(struct device *dev, bool up)
 }
 
 static struct bridge_member *
 }
 
 static struct bridge_member *
-bridge_create_member(struct bridge_state *bst, struct device *dev)
+bridge_create_member(struct bridge_state *bst, struct device *dev, bool hotplug)
 {
        struct bridge_member *bm;
 
 {
        struct bridge_member *bm;
 
-       bm = calloc(1, sizeof(*bm));
+       bm = calloc(1, sizeof(*bm) + strlen(dev->ifname) + 1);
+       if (!bm)
+               return NULL;
+
        bm->bst = bst;
        bm->dev.cb = bridge_member_cb;
        bm->bst = bst;
        bm->dev.cb = bridge_member_cb;
-       device_add_user(&bm->dev, dev);
-
-       list_add_tail(&bm->list, &bst->members);
-
-       if (bst->dev.active)
-               bridge_enable_member(bm);
+       bm->dev.hotplug = hotplug;
+       strcpy(bm->name, dev->ifname);
+       bm->dev.dev = dev;
+       vlist_add(&bst->members, &bm->node, bm->name);
+       if (hotplug)
+               bm->node.version = -1;
 
        return bm;
 }
 
 static void
 
        return bm;
 }
 
 static void
-bridge_free_member(struct bridge_member *bm)
+bridge_member_update(struct vlist_tree *tree, struct vlist_node *node_new,
+                    struct vlist_node *node_old)
 {
 {
-       if (bm->present) {
-               bridge_member_cb(&bm->dev, DEV_EVENT_REMOVE);
-               bm->bst->n_present--;
-               if (bm->bst->dev.active)
-                       bridge_disable_member(bm);
+       struct bridge_member *bm;
+       struct device *dev;
+
+       if (node_new) {
+               bm = container_of(node_new, struct bridge_member, node);
+
+               if (node_old) {
+                       free(bm);
+                       return;
+               }
+
+               dev = bm->dev.dev;
+               bm->dev.dev = NULL;
+               device_add_user(&bm->dev, dev);
        }
 
        }
 
-       list_del(&bm->list);
-       device_remove_user(&bm->dev);
-       free(bm);
+
+       if (node_old) {
+               bm = container_of(node_old, struct bridge_member, node);
+               bridge_free_member(bm);
+       }
 }
 
 }
 
+
 static void
 bridge_add_member(struct bridge_state *bst, const char *name)
 {
 static void
 bridge_add_member(struct bridge_state *bst, const char *name)
 {
@@ -240,7 +370,7 @@ bridge_add_member(struct bridge_state *bst, const char *name)
        if (!dev)
                return;
 
        if (!dev)
                return;
 
-       bridge_create_member(bst, dev);
+       bridge_create_member(bst, dev, false);
 }
 
 static int
 }
 
 static int
@@ -248,7 +378,7 @@ bridge_hotplug_add(struct device *dev, struct device *member)
 {
        struct bridge_state *bst = container_of(dev, struct bridge_state, dev);
 
 {
        struct bridge_state *bst = container_of(dev, struct bridge_state, dev);
 
-       bridge_create_member(bst, member);
+       bridge_create_member(bst, member, true);
 
        return 0;
 }
 
        return 0;
 }
@@ -259,18 +389,28 @@ bridge_hotplug_del(struct device *dev, struct device *member)
        struct bridge_state *bst = container_of(dev, struct bridge_state, dev);
        struct bridge_member *bm;
 
        struct bridge_state *bst = container_of(dev, struct bridge_state, dev);
        struct bridge_member *bm;
 
-       list_for_each_entry(bm, &bst->members, list) {
-               if (bm->dev.dev != member)
-                       continue;
+       bm = vlist_find(&bst->members, member->ifname, bm, node);
+       if (!bm)
+               return UBUS_STATUS_NOT_FOUND;
 
 
-               bridge_free_member(bm);
-               return 0;
-       }
+       vlist_delete(&bst->members, &bm->node);
+       return 0;
+}
+
+static int
+bridge_hotplug_prepare(struct device *dev)
+{
+       struct bridge_state *bst;
 
 
-       return -ENOENT;
+       bst = container_of(dev, struct bridge_state, dev);
+       bst->force_active = true;
+       device_set_present(&bst->dev, true);
+
+       return 0;
 }
 
 static const struct device_hotplug_ops bridge_ops = {
 }
 
 static const struct device_hotplug_ops bridge_ops = {
+       .prepare = bridge_hotplug_prepare,
        .add = bridge_hotplug_add,
        .del = bridge_hotplug_del
 };
        .add = bridge_hotplug_add,
        .del = bridge_hotplug_del
 };
@@ -279,18 +419,14 @@ static void
 bridge_free(struct device *dev)
 {
        struct bridge_state *bst;
 bridge_free(struct device *dev)
 {
        struct bridge_state *bst;
-       struct bridge_member *bm;
 
        bst = container_of(dev, struct bridge_state, dev);
 
        bst = container_of(dev, struct bridge_state, dev);
-       while (!list_empty(&bst->members)) {
-               bm = list_first_entry(&bst->members, struct bridge_member, list);
-               bridge_free_member(bm);
-       }
+       vlist_flush_all(&bst->members);
        free(bst);
 }
 
 static void
        free(bst);
 }
 
 static void
-bridge_dump_status(struct device *dev, struct blob_buf *b)
+bridge_dump_info(struct device *dev, struct blob_buf *b)
 {
        struct bridge_state *bst;
        struct bridge_member *bm;
 {
        struct bridge_state *bst;
        struct bridge_member *bm;
@@ -298,36 +434,137 @@ bridge_dump_status(struct device *dev, struct blob_buf *b)
 
        bst = container_of(dev, struct bridge_state, dev);
 
 
        bst = container_of(dev, struct bridge_state, dev);
 
+       system_if_dump_info(dev, b);
        list = blobmsg_open_array(b, "bridge-members");
        list = blobmsg_open_array(b, "bridge-members");
-       list_for_each_entry(bm, &bst->members, list) {
+
+       vlist_for_each_element(&bst->members, bm, node)
                blobmsg_add_string(b, NULL, bm->dev.dev->ifname);
                blobmsg_add_string(b, NULL, bm->dev.dev->ifname);
-       }
+
        blobmsg_close_array(b, list);
 }
 
        blobmsg_close_array(b, list);
 }
 
-static struct device *
-bridge_create(struct blob_attr *attr)
+static void
+bridge_config_init(struct device *dev)
+{
+       struct bridge_state *bst;
+       struct blob_attr *cur;
+       int rem;
+
+       bst = container_of(dev, struct bridge_state, dev);
+
+       if (bst->config.bridge_empty) {
+               bst->force_active = true;
+               device_set_present(&bst->dev, true);
+       }
+
+       vlist_update(&bst->members);
+       if (bst->ifnames) {
+               blobmsg_for_each_attr(cur, bst->ifnames, rem) {
+                       bridge_add_member(bst, blobmsg_data(cur));
+               }
+       }
+       vlist_flush(&bst->members);
+}
+
+static void
+bridge_apply_settings(struct bridge_state *bst, struct blob_attr **tb)
+{
+       struct bridge_config *cfg = &bst->config;
+       struct blob_attr *cur;
+
+       /* defaults */
+       cfg->stp = false;
+       cfg->forward_delay = 2;
+       cfg->igmp_snoop = false;
+       cfg->bridge_empty = false;
+       cfg->priority = 0x7FFF;
+
+       if ((cur = tb[BRIDGE_ATTR_STP]))
+               cfg->stp = blobmsg_get_bool(cur);
+
+       if ((cur = tb[BRIDGE_ATTR_FORWARD_DELAY]))
+               cfg->forward_delay = blobmsg_get_u32(cur);
+
+       if ((cur = tb[BRIDGE_ATTR_PRIORITY]))
+               cfg->priority = blobmsg_get_u32(cur);
+
+       if ((cur = tb[BRIDGE_ATTR_IGMP_SNOOP]))
+               cfg->igmp_snoop = blobmsg_get_bool(cur);
+
+       if ((cur = tb[BRIDGE_ATTR_AGEING_TIME])) {
+               cfg->ageing_time = blobmsg_get_u32(cur);
+               cfg->flags |= BRIDGE_OPT_AGEING_TIME;
+       }
+
+       if ((cur = tb[BRIDGE_ATTR_HELLO_TIME])) {
+               cfg->hello_time = blobmsg_get_u32(cur);
+               cfg->flags |= BRIDGE_OPT_HELLO_TIME;
+       }
+
+       if ((cur = tb[BRIDGE_ATTR_MAX_AGE])) {
+               cfg->max_age = blobmsg_get_u32(cur);
+               cfg->flags |= BRIDGE_OPT_MAX_AGE;
+       }
+
+       if ((cur = tb[BRIDGE_ATTR_BRIDGE_EMPTY]))
+               cfg->bridge_empty = blobmsg_get_bool(cur);
+}
+
+enum dev_change_type
+bridge_reload(struct device *dev, struct blob_attr *attr)
 {
        struct blob_attr *tb_dev[__DEV_ATTR_MAX];
        struct blob_attr *tb_br[__BRIDGE_ATTR_MAX];
 {
        struct blob_attr *tb_dev[__DEV_ATTR_MAX];
        struct blob_attr *tb_br[__BRIDGE_ATTR_MAX];
-       struct blob_attr *cur;
+       enum dev_change_type ret = DEV_CONFIG_APPLIED;
+       unsigned long diff;
        struct bridge_state *bst;
        struct bridge_state *bst;
-       struct device *dev = NULL;
-       const char *name;
-       int rem;
+
+       BUILD_BUG_ON(sizeof(diff) < __BRIDGE_ATTR_MAX / 8);
+       BUILD_BUG_ON(sizeof(diff) < __DEV_ATTR_MAX / 8);
+
+       bst = container_of(dev, struct bridge_state, dev);
 
        blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, tb_dev,
                blob_data(attr), blob_len(attr));
        blobmsg_parse(bridge_attrs, __BRIDGE_ATTR_MAX, tb_br,
                blob_data(attr), blob_len(attr));
 
 
        blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, tb_dev,
                blob_data(attr), blob_len(attr));
        blobmsg_parse(bridge_attrs, __BRIDGE_ATTR_MAX, tb_br,
                blob_data(attr), blob_len(attr));
 
-       if (!tb_dev[DEV_ATTR_NAME])
-               return NULL;
+       bst->ifnames = tb_br[BRIDGE_ATTR_IFNAME];
+       device_init_settings(dev, tb_dev);
+       bridge_apply_settings(bst, tb_br);
 
 
-       if (!tb_br[BRIDGE_ATTR_IFNAME])
-               return NULL;
+       if (bst->config_data) {
+               struct blob_attr *otb_dev[__DEV_ATTR_MAX];
+               struct blob_attr *otb_br[__BRIDGE_ATTR_MAX];
 
 
-       name = blobmsg_data(tb_dev[DEV_ATTR_NAME]);
+               blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, otb_dev,
+                       blob_data(bst->config_data), blob_len(bst->config_data));
+
+               diff = 0;
+               uci_blob_diff(tb_dev, otb_dev, &device_attr_list, &diff);
+               if (diff & ~(1 << DEV_ATTR_IFNAME))
+                   ret = DEV_CONFIG_RESTART;
+
+               blobmsg_parse(bridge_attrs, __BRIDGE_ATTR_MAX, otb_br,
+                       blob_data(bst->config_data), blob_len(bst->config_data));
+
+               diff = 0;
+               uci_blob_diff(tb_br, otb_br, &bridge_attr_list, &diff);
+               if (diff & ~(1 << BRIDGE_ATTR_IFNAME))
+                   ret = DEV_CONFIG_RESTART;
+
+               bridge_config_init(dev);
+       }
+
+       bst->config_data = attr;
+       return ret;
+}
+
+static struct device *
+bridge_create(const char *name, struct blob_attr *attr)
+{
+       struct bridge_state *bst;
+       struct device *dev = NULL;
 
        bst = calloc(1, sizeof(*bst));
        if (!bst)
 
        bst = calloc(1, sizeof(*bst));
        if (!bst)
@@ -335,20 +572,16 @@ bridge_create(struct blob_attr *attr)
 
        dev = &bst->dev;
        device_init(dev, &bridge_device_type, name);
 
        dev = &bst->dev;
        device_init(dev, &bridge_device_type, name);
-       device_init_settings(dev, tb_dev);
+       dev->config_pending = true;
 
        bst->set_state = dev->set_state;
        dev->set_state = bridge_set_state;
 
        dev->hotplug_ops = &bridge_ops;
 
 
        bst->set_state = dev->set_state;
        dev->set_state = bridge_set_state;
 
        dev->hotplug_ops = &bridge_ops;
 
-       INIT_LIST_HEAD(&bst->members);
-
-       blobmsg_for_each_attr(cur, tb_br[BRIDGE_ATTR_IFNAME], rem) {
-               bridge_add_member(bst, blobmsg_data(cur));
-       }
+       vlist_init(&bst->members, avl_strcmp, bridge_member_update);
+       bst->members.keep_old = true;
+       bridge_reload(dev, attr);
 
        return dev;
 }
 
        return dev;
 }
-
-