X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;f=tunnel.c;h=4a6c4093f3fa96bf26ca652c1ed71c4f7a8533ef;hb=cec1ce296eede81dc62628fce33b8cc216727b17;hp=cdb83f054b68219e8a6a0132cfca20b04abaf0f5;hpb=4f5b41cf789fcc30e142dfdb1123a8adc12112d5;p=project%2Fnetifd.git diff --git a/tunnel.c b/tunnel.c index cdb83f0..4a6c409 100644 --- a/tunnel.c +++ b/tunnel.c @@ -49,12 +49,11 @@ tunnel_reload(struct device *dev, struct blob_attr *attr) if (uci_blob_check_equal(dev->config, attr, cfg)) return DEV_CONFIG_NO_CHANGE; - if (attr) { - memset(tb_dev, 0, sizeof(tb_dev)); + memset(tb_dev, 0, sizeof(tb_dev)); + if (attr) blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, tb_dev, blob_data(attr), blob_len(attr)); - } device_init_settings(dev, tb_dev); @@ -68,11 +67,14 @@ tunnel_create(const char *name, struct blob_attr *attr) struct device *dev; tun = calloc(1, sizeof(*tun)); + if (!tun) + return NULL; + dev = &tun->dev; 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_apply_config(dev, &tunnel_device_type, attr); device_set_present(dev, true); return dev;