diff options
-rw-r--r-- | system-linux.c | 7 | ||||
-rw-r--r-- | system.c | 15 | ||||
-rw-r--r-- | system.h | 1 | ||||
-rw-r--r-- | tunnel.c | 24 |
4 files changed, 37 insertions, 10 deletions
diff --git a/system-linux.c b/system-linux.c index d01d7e3..58210a6 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1435,8 +1435,11 @@ int system_add_ip_tunnel(const char *name, struct blob_attr *attr) 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])) { @@ -16,13 +16,14 @@ #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 = { @@ -25,6 +25,7 @@ enum tunnel_param { TUNNEL_ATTR_TYPE, TUNNEL_ATTR_REMOTE, TUNNEL_ATTR_LOCAL, + TUNNEL_ATTR_MTU, TUNNEL_ATTR_TTL, TUNNEL_ATTR_6RD_PREFIX, TUNNEL_ATTR_6RD_RELAY_PREFIX, @@ -40,6 +40,27 @@ tunnel_set_state(struct device *dev, bool up) 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) { @@ -51,6 +72,7 @@ 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; @@ -67,7 +89,7 @@ tunnel_free(struct device *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, }; |