summaryrefslogtreecommitdiffhomepage
path: root/interface.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-01-24 00:52:32 +0100
committerFelix Fietkau <nbd@openwrt.org>2012-01-24 00:52:32 +0100
commitc6b739e28f2b15789c95dd28af3f193ec8f67531 (patch)
tree231245e5c0429b4dda370fda67aa0dc5b2093fb4 /interface.c
parent5fefb43a4151ee99d4c78ebaf1807043e859021a (diff)
add a generic option for disabling the automatic default route on interfaces
Diffstat (limited to 'interface.c')
-rw-r--r--interface.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/interface.c b/interface.c
index 257eaca..1db2efe 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 = {
@@ -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: