str = blobmsg_data(cur);
unsigned int ttl = 0;
- if ((cur = tb[TUNNEL_ATTR_TTL]) && (ttl = blobmsg_get_u32(cur)) > 255)
- return -EINVAL;
+ if ((cur = tb[TUNNEL_ATTR_TTL])) {
+ ttl = blobmsg_get_u32(cur);
+ if (ttl > 255)
+ return -EINVAL;
+ }
unsigned int link = 0;
if ((cur = tb[TUNNEL_ATTR_LINK])) {
#include <fcntl.h>
static const struct blobmsg_policy tunnel_attrs[__TUNNEL_ATTR_MAX] = {
- [TUNNEL_ATTR_TYPE] = { "mode", BLOBMSG_TYPE_STRING },
- [TUNNEL_ATTR_LOCAL] = { "local", BLOBMSG_TYPE_STRING },
- [TUNNEL_ATTR_REMOTE] = { "remote", BLOBMSG_TYPE_STRING },
- [TUNNEL_ATTR_TTL] = { "ttl", BLOBMSG_TYPE_INT32 },
- [TUNNEL_ATTR_6RD_PREFIX] = { "6rd-prefix", BLOBMSG_TYPE_STRING },
- [TUNNEL_ATTR_6RD_RELAY_PREFIX] = { "6rd-relay-prefix", BLOBMSG_TYPE_STRING },
- [TUNNEL_ATTR_LINK] = { "link", BLOBMSG_TYPE_STRING },
+ [TUNNEL_ATTR_TYPE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING },
+ [TUNNEL_ATTR_LOCAL] = { .name = "local", .type = BLOBMSG_TYPE_STRING },
+ [TUNNEL_ATTR_REMOTE] = { .name = "remote", .type = BLOBMSG_TYPE_STRING },
+ [TUNNEL_ATTR_MTU] = { .name = "mtu", .type = BLOBMSG_TYPE_INT32 },
+ [TUNNEL_ATTR_TTL] = { .name = "ttl", .type = BLOBMSG_TYPE_INT32 },
+ [TUNNEL_ATTR_6RD_PREFIX] = {.name = "6rd-prefix", .type = BLOBMSG_TYPE_STRING },
+ [TUNNEL_ATTR_6RD_RELAY_PREFIX] = { .name = "6rd-relay-prefix", .type = BLOBMSG_TYPE_STRING },
+ [TUNNEL_ATTR_LINK] = { .name = "link", .type = BLOBMSG_TYPE_STRING },
};
const struct uci_blob_param_list tunnel_attr_list = {
TUNNEL_ATTR_TYPE,
TUNNEL_ATTR_REMOTE,
TUNNEL_ATTR_LOCAL,
+ TUNNEL_ATTR_MTU,
TUNNEL_ATTR_TTL,
TUNNEL_ATTR_6RD_PREFIX,
TUNNEL_ATTR_6RD_RELAY_PREFIX,
return ret;
}
+static enum dev_change_type
+tunnel_reload(struct device *dev, struct blob_attr *attr)
+{
+ struct blob_attr *tb_dev[__DEV_ATTR_MAX];
+ const struct uci_blob_param_list *cfg = dev->type->config_params;
+
+ if (uci_blob_check_equal(dev->config, attr, cfg))
+ return DEV_CONFIG_NO_CHANGE;
+
+ if (attr) {
+ memset(tb_dev, 0, sizeof(tb_dev));
+
+ blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, tb_dev,
+ blob_data(attr), blob_len(attr));
+ }
+
+ device_init_settings(dev, tb_dev);
+
+ return DEV_CONFIG_RESTART;
+}
+
static struct device *
tunnel_create(const char *name, struct blob_attr *attr)
{
device_init(dev, &tunnel_device_type, name);
tun->set_state = dev->set_state;
dev->set_state = tunnel_set_state;
+ device_set_config(dev, &tunnel_device_type, attr);
device_set_present(dev, true);
return dev;
const struct device_type tunnel_device_type = {
.name = "IP tunnel",
.config_params = &tunnel_attr_list,
-
+ .reload = tunnel_reload,
.create = tunnel_create,
.free = tunnel_free,
};