}
static struct device *
-device_create_default(const char *name)
+device_create_default(const char *name, bool external)
{
struct device *dev;
D(DEVICE, "Create simple device '%s'\n", name);
dev = calloc(1, sizeof(*dev));
+ dev->external = external;
device_init(dev, &simple_device_type, name);
dev->default_config = true;
return dev;
}
struct device *
-device_get(const char *name, bool create)
+device_get(const char *name, int create)
{
struct device *dev;
if (!create)
return NULL;
- return device_create_default(name);
+ return device_create_default(name, create > 1);
}
static void
if (dev->type != &simple_device_type)
continue;
- ndev = device_create_default(dev->ifname);
+ ndev = device_create_default(dev->ifname, dev->external);
device_replace(ndev, dev);
}
}
bool config_pending;
bool present;
int active;
+ bool external;
bool current_config;
bool default_config;
void device_init_virtual(struct device *dev, const struct device_type *type, const char *name);
int device_init(struct device *iface, const struct device_type *type, const char *ifname);
void device_cleanup(struct device *iface);
-struct device *device_get(const char *name, bool create);
+struct device *device_get(const char *name, int create);
void device_add_user(struct device_user *dep, struct device *iface);
void device_remove_user(struct device_user *dep);
{
struct interface_ip_settings *ip;
struct blob_attr *cur;
+ int dev_create = 1;
bool addr_ext = false;
bool up;
return 0;
}
+ if ((cur = tb[NOTIFY_ADDR_EXT]) != NULL) {
+ addr_ext = blobmsg_get_bool(cur);
+ if (addr_ext)
+ dev_create = 2;
+ }
+
if (!tb[NOTIFY_IFNAME]) {
if (!state->proto.iface->main_dev.dev)
return UBUS_STATUS_INVALID_ARGUMENT;
device_remove_user(&state->l3_dev);
device_add_user(&state->l3_dev,
- device_get(blobmsg_data(tb[NOTIFY_IFNAME]), true));
+ device_get(blobmsg_data(tb[NOTIFY_IFNAME]), dev_create));
state->proto.iface->l3_dev = &state->l3_dev;
device_claim(&state->l3_dev);
}
ip = &state->proto.iface->proto_ip;
interface_update_start(state->proto.iface);
- if ((cur = tb[NOTIFY_ADDR_EXT]) != NULL)
- addr_ext = blobmsg_get_bool(cur);
-
if ((cur = tb[NOTIFY_IPADDR]) != NULL)
proto_shell_parse_addr_list(ip, cur, false, addr_ext);
char buf[256];
char *bridge;
+ if (dev->external)
+ return;
+
dev->ifindex = system_if_resolve(dev);
if (!dev->ifindex)
return;