diff options
author | Felix Fietkau <nbd@openwrt.org> | 2012-03-19 23:26:44 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2012-03-19 23:26:44 +0100 |
commit | a609b5e8f39b132ff72476761add46d263c4147f (patch) | |
tree | 788468b7b5ce0396cd9409e6c8dfcc78028e3178 /interface.c | |
parent | 257bfc6392bf8a1c215f0bd6889db4694a405c1d (diff) |
add support for updating route metrics
Diffstat (limited to 'interface.c')
-rw-r--r-- | interface.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/interface.c b/interface.c index 4ad89f5..f281a9b 100644 --- a/interface.c +++ b/interface.c @@ -18,6 +18,7 @@ enum { IFACE_ATTR_PROTO, IFACE_ATTR_AUTO, IFACE_ATTR_DEFAULTROUTE, + IFACE_ATTR_METRIC, IFACE_ATTR_MAX }; @@ -26,6 +27,7 @@ static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { [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 }, + [IFACE_ATTR_METRIC] = { .name = "metric", .type = BLOBMSG_TYPE_INT32 }, }; const struct config_param_list interface_attr_list = { @@ -516,11 +518,21 @@ 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); +#define UPDATE(field) ({ \ + bool __changed = (if_old->field != if_new->field); \ + if_old->field = if_new->field; \ + __changed; \ + }) + + if (UPDATE(metric) || UPDATE(proto_ip.no_defaultroute)) { + interface_ip_set_enabled(&if_old->config_ip, false); + interface_ip_set_enabled(&if_old->config_ip, if_new->config_ip.enabled); + interface_ip_set_enabled(&if_old->proto_ip, false); + interface_ip_set_enabled(&if_old->proto_ip, if_new->proto_ip.enabled); } +#undef UPDATE + goto out; reload: |