option proto pptp
option server 1.1.1.1
option peerdns 0
+ option dns 192.168.10.1
config route
option target 192.168.0.1
void
interface_ip_update_start(struct interface_ip_settings *ip)
{
- vlist_simple_update(&ip->dns_servers);
- vlist_simple_update(&ip->dns_search);
+ if (ip != &ip->iface->config_ip) {
+ vlist_simple_update(&ip->dns_servers);
+ vlist_simple_update(&ip->dns_search);
+ }
vlist_update(&ip->route);
vlist_update(&ip->addr);
}
IFACE_ATTR_AUTO,
IFACE_ATTR_DEFAULTROUTE,
IFACE_ATTR_PEERDNS,
+ IFACE_ATTR_DNS,
+ IFACE_ATTR_DNS_SEARCH,
IFACE_ATTR_METRIC,
IFACE_ATTR_MAX
};
[IFACE_ATTR_DEFAULTROUTE] = { .name = "defaultroute", .type = BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_PEERDNS] = { .name = "peerdns", .type = BLOBMSG_TYPE_BOOL },
[IFACE_ATTR_METRIC] = { .name = "metric", .type = BLOBMSG_TYPE_INT32 },
+ [IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
+ [IFACE_ATTR_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
+};
+
+static const union config_param_info iface_attr_info[IFACE_ATTR_MAX] = {
+ [IFACE_ATTR_DNS] = { .type = BLOBMSG_TYPE_STRING },
};
const struct config_param_list interface_attr_list = {
.n_params = IFACE_ATTR_MAX,
.params = iface_attrs,
+ .info = iface_attr_info,
};
static void
iface->proto_ip.no_dns =
!blobmsg_get_bool_default(tb[IFACE_ATTR_PEERDNS], true);
+ if ((cur = tb[IFACE_ATTR_DNS]))
+ interface_add_dns_server_list(&iface->config_ip, cur);
+
+ if ((cur = tb[IFACE_ATTR_DNS_SEARCH]))
+ interface_add_dns_search_list(&iface->config_ip, cur);
+
iface->config_autostart = iface->autostart;
}
interface_ip_update_complete(&iface->proto_ip);
}
+static void
+interface_replace_dns(struct interface_ip_settings *old, struct interface_ip_settings *new)
+{
+ vlist_simple_replace(&new->dns_servers, &old->dns_servers);
+ vlist_simple_replace(&new->dns_search, &old->dns_search);
+}
+
static void
interface_change_config(struct interface *if_old, struct interface *if_new)
{
interface_ip_set_enabled(&if_old->proto_ip, false);
interface_ip_set_enabled(&if_old->proto_ip, if_new->proto_ip.enabled);
}
- if (UPDATE(proto_ip.no_dns))
- interface_write_resolv_conf();
+
+ UPDATE(proto_ip.no_dns);
+ interface_replace_dns(&if_old->config_ip, &if_new->config_ip);
+ interface_replace_dns(&if_old->proto_ip, &if_new->proto_ip);
+ interface_write_resolv_conf();
#undef UPDATE
NOTIFY_DATA,
NOTIFY_KEEP,
NOTIFY_HOST,
+ NOTIFY_DNS,
+ NOTIFY_DNS_SEARCH,
__NOTIFY_LAST
};
[NOTIFY_DATA] = { .name = "data", .type = BLOBMSG_TYPE_TABLE },
[NOTIFY_KEEP] = { .name = "keep", .type = BLOBMSG_TYPE_BOOL },
[NOTIFY_HOST] = { .name = "host", .type = BLOBMSG_TYPE_STRING },
+ [NOTIFY_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
+ [NOTIFY_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
};
static int
if ((cur = tb[NOTIFY_ROUTES6]) != NULL)
proto_shell_parse_route_list(state->proto.iface, cur, true);
+ if ((cur = tb[NOTIFY_DNS]))
+ interface_add_dns_server_list(&iface->proto_ip, cur);
+
+ if ((cur = tb[NOTIFY_DNS_SEARCH]))
+ interface_add_dns_search_list(&iface->proto_ip, cur);
+
interface_update_complete(state->proto.iface);
if (!keep)
OPT_BROADCAST,
OPT_GATEWAY,
OPT_IP6GW,
- OPT_DNS,
- OPT_DNS_SEARCH,
__OPT_MAX,
};
[OPT_BROADCAST] = { .name = "broadcast", .type = BLOBMSG_TYPE_STRING },
[OPT_GATEWAY] = { .name = "gateway", .type = BLOBMSG_TYPE_STRING },
[OPT_IP6GW] = { .name = "ip6gw", .type = BLOBMSG_TYPE_STRING },
- [OPT_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
- [OPT_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
};
static const union config_param_info proto_ip_attr_info[__OPT_MAX] = {
[OPT_IPADDR] = { .type = BLOBMSG_TYPE_STRING },
[OPT_IP6ADDR] = { .type = BLOBMSG_TYPE_STRING },
- [OPT_DNS] = { .type = BLOBMSG_TYPE_STRING },
};
const struct config_param_list proto_ip_attr = {
goto out;
}
- if ((cur = tb[OPT_DNS]))
- interface_add_dns_server_list(&iface->proto_ip, cur);
-
- if ((cur = tb[OPT_DNS_SEARCH]))
- interface_add_dns_search_list(&iface->proto_ip, cur);
-
return 0;
error:
goto out;
}
- if ((cur = tb[OPT_DNS]))
- interface_add_dns_server_list(&iface->proto_ip, cur);
-
- if ((cur = tb[OPT_DNS_SEARCH]))
- interface_add_dns_search_list(&iface->proto_ip, cur);
-
return 0;
error:
}
}
+void
+vlist_simple_replace(struct vlist_simple_tree *dest, struct vlist_simple_tree *old)
+{
+ struct vlist_simple_node *n, *tmp;
+
+ list_for_each_entry_safe(n, tmp, &old->list, list) {
+ list_del(&n->list);
+ vlist_simple_add(dest, n);
+ }
+}
+
void
vlist_simple_flush_all(struct vlist_simple_tree *tree)
{
void vlist_simple_delete(struct vlist_simple_tree *tree, struct vlist_simple_node *node);
void vlist_simple_flush(struct vlist_simple_tree *tree);
void vlist_simple_flush_all(struct vlist_simple_tree *tree);
+void vlist_simple_replace(struct vlist_simple_tree *dest, struct vlist_simple_tree *old);
static inline void vlist_simple_update(struct vlist_simple_tree *tree)
{