X-Git-Url: https://git.archive.openwrt.org/?a=blobdiff_plain;ds=sidebyside;f=interface.c;h=3dceef07797f4e473d67f327c9643fb03ec1713c;hb=05c0ded29cf9dd7716528e61029886550ba1f7ab;hp=257eaca5a705310e916b4941c43258c15d1b77ed;hpb=5c0c0bb557b17c581d4f238c52b0b44ada34a608;p=project%2Fnetifd.git diff --git a/interface.c b/interface.c index 257eaca..3dceef0 100644 --- a/interface.c +++ b/interface.c @@ -17,6 +17,7 @@ enum { IFACE_ATTR_IFNAME, IFACE_ATTR_PROTO, IFACE_ATTR_AUTO, + IFACE_ATTR_DEFAULTROUTE, IFACE_ATTR_MAX }; @@ -24,6 +25,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [IFACE_ATTR_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING }, [IFACE_ATTR_AUTO] = { .name = "auto", .type = BLOBMSG_TYPE_BOOL }, + [IFACE_ATTR_DEFAULTROUTE] = { .name = "defaultroute", .type = BLOBMSG_TYPE_BOOL }, }; const struct config_param_list interface_attr_list = { @@ -181,7 +183,7 @@ interface_claim_device(struct interface *iface) { struct device *dev; - if (iface->ifname && iface->proto_handler && + if (iface->ifname && !(iface->proto_handler->flags & PROTO_FLAG_NODEV)) { dev = device_get(iface->ifname, true); if (dev) @@ -326,10 +328,10 @@ interface_init(struct interface *iface, const char *name, proto_attach_interface(iface, proto_name); - if ((cur = tb[IFACE_ATTR_AUTO])) - iface->autostart = blobmsg_get_bool(cur); - else - iface->autostart = true; + iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true); + iface->proto_ip.no_defaultroute = + !blobmsg_get_bool_default(tb[IFACE_ATTR_DEFAULTROUTE], true); + iface->config_autostart = iface->autostart; } @@ -499,6 +501,11 @@ interface_change_config(struct interface *if_old, struct interface *if_new) goto reload; } + if (if_old->proto_ip.no_defaultroute != if_new->proto_ip.no_defaultroute) { + if_old->proto_ip.no_defaultroute = if_new->proto_ip.no_defaultroute; + interface_ip_set_enabled(&if_old->proto_ip, if_old->proto_ip.enabled); + } + goto out; reload: