X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=macvlan.c;h=051fe058960cd693410ace438c0b5423a6b58183;hp=bf813407726bb3bf48b3886b9181f4633bcab79c;hb=212288ba1518c0fd4d44f22e7c2af09022944a9f;hpb=5dd87fd8ad3a42c71d90a8fecc893af973e552bf diff --git a/macvlan.c b/macvlan.c index bf81340..051fe05 100644 --- a/macvlan.c +++ b/macvlan.c @@ -17,7 +17,11 @@ #include #include #include +#include + +#ifdef linux #include +#endif #include "netifd.h" #include "device.h" @@ -40,6 +44,9 @@ static const struct blobmsg_policy macvlan_attrs[__MACVLAN_ATTR_MAX] = { static const struct uci_blob_param_list macvlan_attr_list = { .n_params = __MACVLAN_ATTR_MAX, .params = macvlan_attrs, + + .n_next = 1, + .next = { &device_attr_list }, }; struct macvlan_device { @@ -65,6 +72,12 @@ macvlan_base_cb(struct device_user *dev, enum device_event ev) case DEV_EVENT_REMOVE: device_set_present(&mvdev->dev, false); break; + case DEV_EVENT_LINK_UP: + device_set_link(&mvdev->dev, true); + break; + case DEV_EVENT_LINK_DOWN: + device_set_link(&mvdev->dev, false); + break; default: return; } @@ -127,6 +140,7 @@ macvlan_free(struct device *dev) mvdev = container_of(dev, struct macvlan_device, dev); device_remove_user(&mvdev->parent); + free(mvdev->config_data); free(mvdev); } @@ -184,6 +198,7 @@ macvlan_reload(struct device *dev, struct blob_attr *attr) struct macvlan_device *mvdev; mvdev = container_of(dev, struct macvlan_device, dev); + attr = blob_memdup(attr); blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, tb_dev, blob_data(attr), blob_len(attr)); @@ -213,6 +228,7 @@ macvlan_reload(struct device *dev, struct blob_attr *attr) macvlan_config_init(dev); } + free(mvdev->config_data); mvdev->config_data = attr; return ret; } @@ -245,6 +261,7 @@ macvlan_create(const char *name, struct blob_attr *attr) const struct device_type macvlan_device_type = { .name = "MAC VLAN", .config_params = &macvlan_attr_list, + .keep_link_status = true, .create = macvlan_create, .config_init = macvlan_config_init,