struct interface *iface;
const char *type;
struct blob_attr *config;
+ struct device *dev;
blob_buf_init(&b, 0);
memcpy(config, b.head, blob_pad_len(b.head));
interface_add(iface, config);
+
+ dev = iface->main_dev.dev;
+ if (!dev || !dev->default_config)
+ return;
+
+ blob_buf_init(&b, 0);
+ uci_to_blob(&b, s, dev->type->config_params);
+ if (blob_len(b.head) == 0)
+ return;
+
+ device_set_config(dev, dev->type, b.head);
}
static void
{
struct blob_attr **tb1, **tb2;
+ if (!!c1 ^ !!c2)
+ return false;
+
+ if (!c1 && !c2)
+ return true;
+
tb1 = alloca(config->n_params * sizeof(struct blob_attr *));
blobmsg_parse(config->params, config->n_params, tb1,
blob_data(c1), blob_len(c1));
option netmask 255.0.0.0
config device
- option name br-lan
- option type bridge
- list ifname eth0.1
- list ifname eth0.2
- option mtu 1500
+ option name br-lan
+ option type bridge
+ list ifname eth0.1
+ list ifname eth0.2
+ option mtu 1500
config device
option name dummy
config interface dummy
option ifname eth0.4
+ option mtu 1500
option proto none
config interface lan2
}
}
-enum dev_change_type
+static enum dev_change_type
device_reload_config(struct device *dev, struct blob_attr *attr)
{
struct blob_attr *tb[__DEV_ATTR_MAX];
if (cfg == &device_attr_list) {
memset(tb, 0, sizeof(tb));
- if (dev->config)
+ if (attr)
blobmsg_parse(dev_attrs, __DEV_ATTR_MAX, tb,
blob_data(attr), blob_len(attr));
return DEV_CONFIG_RECREATE;
}
-static enum dev_change_type
-device_check_config(struct device *dev, const struct device_type *type,
- struct blob_attr *attr)
+enum dev_change_type
+device_set_config(struct device *dev, const struct device_type *type,
+ struct blob_attr *attr)
{
if (type != dev->type)
return DEV_CONFIG_RECREATE;
odev = device_get(name, false);
if (odev) {
odev->current_config = true;
- change = device_check_config(odev, type, config);
+ change = device_set_config(odev, type, config);
switch (change) {
case DEV_CONFIG_APPLIED:
D(DEVICE, "Device '%s': config applied\n", odev->ifname);
void device_init_settings(struct device *dev, struct blob_attr **tb);
void device_init_pending(void);
+enum dev_change_type
+device_set_config(struct device *dev, const struct device_type *type,
+ struct blob_attr *attr);
+
void device_reset_config(void);
void device_reset_old(void);
snprintf(vldev->dev.ifname, IFNAMSIZ, "%s.%d", dev->ifname, id);
device_init(&vldev->dev, &vlan_type, NULL);
+ vldev->dev.default_config = true;
vldev->set_state = vldev->dev.set_state;
vldev->dev.set_state = vlan_set_device_state;