X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=tunnel.c;h=cdb83f054b68219e8a6a0132cfca20b04abaf0f5;hp=b45ac98919167230cf06a627acc741689c51f31d;hb=cc8c69f2533e3c85e3631f1371a4207c2d5becce;hpb=cfeabcaf0e69b02bac6c86edc223d2eb2e2367d3 diff --git a/tunnel.c b/tunnel.c index b45ac98..cdb83f0 100644 --- a/tunnel.c +++ b/tunnel.c @@ -1,3 +1,16 @@ +/* + * netifd - network interface daemon + * Copyright (C) 2012 Felix Fietkau + * + * 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 "netifd.h" #include "device.h" #include "config.h" @@ -22,11 +35,32 @@ tunnel_set_state(struct device *dev, bool up) ret = tun->set_state(dev, up); if (ret || !up) - system_del_ip_tunnel(dev->ifname); + system_del_ip_tunnel(dev->ifname, dev->config); 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) { @@ -38,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; @@ -54,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, };