X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=device.c;h=43881e5f71a7cfe74350b20394f7e4b9b29aa8dd;hp=a7d18af7d1d489d61c88411ab503e6e0daf04352;hb=abf52371db75eb449f12209ca1b7ffaa9d2baa22;hpb=83d3a901d3178a8840092b6e4f7f829b89da4ba0 diff --git a/device.c b/device.c index a7d18af..43881e5 100644 --- a/device.c +++ b/device.c @@ -58,6 +58,7 @@ static const struct blobmsg_policy dev_attrs[__DEV_ATTR_MAX] = { [DEV_ATTR_MULTICAST] = { .name ="multicast", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_LEARNING] = { .name ="learning", .type = BLOBMSG_TYPE_BOOL }, [DEV_ATTR_UNICAST_FLOOD] = { .name ="unicast_flood", .type = BLOBMSG_TYPE_BOOL }, + [DEV_ATTR_SENDREDIRECTS] = { .name = "sendredirects", .type = BLOBMSG_TYPE_BOOL }, }; const struct uci_blob_param_list device_attr_list = { @@ -82,16 +83,6 @@ int device_type_add(struct device_type *devtype) return 0; } -/* initialize device type list and add known types */ -static void __init devtypes_init(void) -{ - device_type_add(&simple_device_type); - device_type_add(&bridge_device_type); - device_type_add(&tunnel_device_type); - device_type_add(&macvlan_device_type); - device_type_add(&vlandev_device_type); -} - /* Retrieve the device type for the given name. If 'bridge' is true, the type * must have bridge capabilities */ @@ -235,6 +226,8 @@ device_merge_settings(struct device *dev, struct device_settings *n) n->multicast_fast_leave = s->multicast_fast_leave; n->learning = s->learning; n->unicast_flood = s->unicast_flood; + n->sendredirects = s->flags & DEV_OPT_SENDREDIRECTS ? + s->sendredirects : os->sendredirects; n->flags = s->flags | os->flags | os->valid_flags; } @@ -250,12 +243,12 @@ device_init_settings(struct device *dev, struct blob_attr **tb) if ((cur = tb[DEV_ATTR_ENABLED])) disabled = !blobmsg_get_bool(cur); - if ((cur = tb[DEV_ATTR_MTU])) { + if ((cur = tb[DEV_ATTR_MTU]) && blobmsg_get_u32(cur) >= 68) { s->mtu = blobmsg_get_u32(cur); s->flags |= DEV_OPT_MTU; } - if ((cur = tb[DEV_ATTR_MTU6])) { + if ((cur = tb[DEV_ATTR_MTU6]) && blobmsg_get_u32(cur) >= 1280) { s->mtu6 = blobmsg_get_u32(cur); s->flags |= DEV_OPT_MTU6; } @@ -373,6 +366,11 @@ device_init_settings(struct device *dev, struct blob_attr **tb) s->flags |= DEV_OPT_UNICAST_FLOOD; } + if ((cur = tb[DEV_ATTR_SENDREDIRECTS])) { + s->sendredirects = blobmsg_get_bool(cur); + s->flags |= DEV_OPT_SENDREDIRECTS; + } + device_set_disabled(dev, disabled); } @@ -460,6 +458,10 @@ void device_release(struct device_user *dep) device_broadcast_event(dev, DEV_EVENT_TEARDOWN); if (!dev->external) dev->set_state(dev, false); + + if (dev->active) + return; + device_broadcast_event(dev, DEV_EVENT_DOWN); } @@ -943,7 +945,7 @@ device_create(const char *name, struct device_type *type, struct device *odev = NULL, *dev; enum dev_change_type change; - odev = device_get(name, false); + odev = device_find(name); if (odev) { odev->current_config = true; change = device_apply_config(odev, type, config); @@ -1056,6 +1058,8 @@ device_dump_status(struct blob_buf *b, struct device *dev) blobmsg_add_u8(b, "learning", st.learning); if (st.flags & DEV_OPT_UNICAST_FLOOD) blobmsg_add_u8(b, "unicast_flood", st.unicast_flood); + if (st.flags & DEV_OPT_SENDREDIRECTS) + blobmsg_add_u8(b, "sendredirects", st.sendredirects); } s = blobmsg_open_table(b, "statistics"); @@ -1065,3 +1069,8 @@ device_dump_status(struct blob_buf *b, struct device *dev) system_if_dump_stats(dev, b); blobmsg_close_table(b, s); } + +static void __init simple_device_type_init(void) +{ + device_type_add(&simple_device_type); +}