2 * netifd - network interface daemon
3 * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
20 #include "interface.h"
21 #include "interface-ip.h"
27 struct vlist_tree interfaces;
28 static LIST_HEAD(iface_all_users);
34 IFACE_ATTR_DEFAULTROUTE,
37 IFACE_ATTR_DNS_SEARCH,
49 static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
50 [IFACE_ATTR_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING },
51 [IFACE_ATTR_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING },
52 [IFACE_ATTR_AUTO] = { .name = "auto", .type = BLOBMSG_TYPE_BOOL },
53 [IFACE_ATTR_DEFAULTROUTE] = { .name = "defaultroute", .type = BLOBMSG_TYPE_BOOL },
54 [IFACE_ATTR_PEERDNS] = { .name = "peerdns", .type = BLOBMSG_TYPE_BOOL },
55 [IFACE_ATTR_METRIC] = { .name = "metric", .type = BLOBMSG_TYPE_INT32 },
56 [IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
57 [IFACE_ATTR_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
58 [IFACE_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING },
59 [IFACE_ATTR_IP6ASSIGN] = { .name = "ip6assign", .type = BLOBMSG_TYPE_INT32 },
60 [IFACE_ATTR_IP6HINT] = { .name = "ip6hint", .type = BLOBMSG_TYPE_STRING },
61 [IFACE_ATTR_IP4TABLE] = { .name = "ip4table", .type = BLOBMSG_TYPE_STRING },
62 [IFACE_ATTR_IP6TABLE] = { .name = "ip6table", .type = BLOBMSG_TYPE_STRING },
63 [IFACE_ATTR_IP6CLASS] = { .name = "ip6class", .type = BLOBMSG_TYPE_ARRAY },
64 [IFACE_ATTR_DELEGATE] = { .name = "delegate", .type = BLOBMSG_TYPE_BOOL },
67 static const struct uci_blob_param_info iface_attr_info[IFACE_ATTR_MAX] = {
68 [IFACE_ATTR_DNS] = { .type = BLOBMSG_TYPE_STRING },
69 [IFACE_ATTR_IP6CLASS] = { .type = BLOBMSG_TYPE_STRING },
72 const struct uci_blob_param_list interface_attr_list = {
73 .n_params = IFACE_ATTR_MAX,
74 .params = iface_attrs,
75 .info = iface_attr_info,
79 interface_clear_errors(struct interface *iface)
81 struct interface_error *error, *tmp;
83 list_for_each_entry_safe(error, tmp, &iface->errors, list) {
84 list_del(&error->list);
89 void interface_add_error(struct interface *iface, const char *subsystem,
90 const char *code, const char **data, int n_data)
92 struct interface_error *error;
95 char *dest, *d_subsys, *d_code;
98 len = n_data * sizeof(char *);
99 datalen = alloca(len);
100 for (i = 0; i < n_data; i++) {
101 datalen[i] = strlen(data[i]) + 1;
106 error = calloc_a(sizeof(*error) + sizeof(char *) + len,
107 &d_subsys, subsystem ? strlen(subsystem) + 1 : 0,
108 &d_code, code ? strlen(code) + 1 : 0);
112 list_add_tail(&error->list, &iface->errors);
114 dest = (char *) &error->data[n_data + 1];
115 for (i = 0; i < n_data; i++) {
116 error->data[i] = dest;
117 memcpy(dest, data[i], datalen[i]);
120 error->data[n_data++] = NULL;
123 error->subsystem = strcpy(d_subsys, subsystem);
126 error->code = strcpy(d_code, code);
130 interface_data_del(struct interface *iface, struct interface_data *data)
132 avl_delete(&iface->data, &data->node);
137 interface_data_flush(struct interface *iface)
139 struct interface_data *d, *tmp;
141 avl_for_each_element_safe(&iface->data, d, node, tmp)
142 interface_data_del(iface, d);
146 interface_add_data(struct interface *iface, const struct blob_attr *data)
148 struct interface_data *n, *o;
150 if (!blobmsg_check_attr(data, true))
151 return UBUS_STATUS_INVALID_ARGUMENT;
153 const char *name = blobmsg_name(data);
154 unsigned len = blob_pad_len(data);
156 o = avl_find_element(&iface->data, name, o, node);
158 if (blob_pad_len(o->data) == len && !memcmp(o->data, data, len))
161 interface_data_del(iface, o);
164 n = calloc(1, sizeof(*n) + len);
165 memcpy(n->data, data, len);
166 n->node.key = blobmsg_name(n->data);
167 avl_insert(&iface->data, &n->node);
169 iface->updated |= IUF_DATA;
174 interface_event(struct interface *iface, enum interface_event ev)
176 struct interface_user *dep, *tmp;
177 struct device *adev = NULL;
179 list_for_each_entry_safe(dep, tmp, &iface->users, list)
180 dep->cb(dep, iface, ev);
182 list_for_each_entry_safe(dep, tmp, &iface_all_users, list)
183 dep->cb(dep, iface, ev);
187 adev = iface->l3_dev.dev;
190 alias_notify_device(iface->name, adev);
198 interface_flush_state(struct interface *iface)
200 if (iface->l3_dev.dev)
201 device_release(&iface->l3_dev);
202 interface_data_flush(iface);
206 mark_interface_down(struct interface *iface)
208 enum interface_state state = iface->state;
210 iface->state = IFS_DOWN;
212 interface_event(iface, IFEV_DOWN);
213 interface_ip_set_enabled(&iface->config_ip, false);
214 interface_ip_flush(&iface->proto_ip);
215 interface_flush_state(iface);
216 system_flush_routes();
220 __interface_set_down(struct interface *iface, bool force)
222 if (iface->state == IFS_DOWN ||
223 iface->state == IFS_TEARDOWN)
226 if (iface->state == IFS_UP)
227 interface_event(iface, IFEV_DOWN);
228 iface->state = IFS_TEARDOWN;
229 interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
231 interface_flush_state(iface);
234 vlist_delete(&interfaces, &iface->node);
238 interface_cb(struct device_user *dep, enum device_event ev)
240 struct interface *iface;
243 iface = container_of(dep, struct interface, main_dev);
248 case DEV_EVENT_REMOVE:
255 interface_set_available(iface, new_state);
256 if (!new_state && dep->dev->external)
257 interface_set_main_dev(iface, NULL);
261 interface_set_available(struct interface *iface, bool new_state)
263 if (iface->available == new_state)
266 D(INTERFACE, "Interface '%s', available=%d\n", iface->name, new_state);
267 iface->available = new_state;
270 if (iface->autostart && !config_init)
271 interface_set_up(iface);
273 __interface_set_down(iface, true);
277 interface_add_user(struct interface_user *dep, struct interface *iface)
280 list_add(&dep->list, &iface_all_users);
285 list_add(&dep->list, &iface->users);
286 if (iface->state == IFS_UP)
287 dep->cb(dep, iface, IFEV_UP);
291 interface_remove_user(struct interface_user *dep)
293 list_del_init(&dep->list);
298 interface_add_assignment_classes(struct interface *iface, struct blob_attr *list)
300 struct blob_attr *cur;
303 blobmsg_for_each_attr(cur, list, rem) {
304 if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING)
307 if (!blobmsg_check_attr(cur, NULL))
310 struct interface_assignment_class *c = malloc(sizeof(*c) + blobmsg_data_len(cur));
311 memcpy(c->name, blobmsg_data(cur), blobmsg_data_len(cur));
312 list_add(&c->head, &iface->assignment_classes);
317 interface_clear_assignment_classes(struct interface *iface)
319 while (!list_empty(&iface->assignment_classes)) {
320 struct interface_assignment_class *c = list_first_entry(&iface->assignment_classes,
321 struct interface_assignment_class, head);
328 interface_merge_assignment_data(struct interface *old, struct interface *new)
330 bool changed = (old->assignment_hint != new->assignment_hint ||
331 old->assignment_length != new->assignment_length ||
332 list_empty(&old->assignment_classes) != list_empty(&new->assignment_classes));
334 struct interface_assignment_class *c;
335 list_for_each_entry(c, &new->assignment_classes, head) {
336 // Compare list entries one-by-one to see if there was a change
337 if (list_empty(&old->assignment_classes)) // The new list is longer
343 struct interface_assignment_class *c_old = list_first_entry(&old->assignment_classes,
344 struct interface_assignment_class, head);
346 if (strcmp(c_old->name, c->name)) // An entry didn't match
349 list_del(&c_old->head);
353 // The old list was longer than the new one or the last entry didn't match
354 if (!list_empty(&old->assignment_classes)) {
355 interface_clear_assignment_classes(old);
359 list_splice_init(&new->assignment_classes, &old->assignment_classes);
362 old->assignment_hint = new->assignment_hint;
363 old->assignment_length = new->assignment_length;
364 interface_refresh_assignments(true);
369 interface_alias_cb(struct interface_user *dep, struct interface *iface, enum interface_event ev)
371 struct interface *alias = container_of(dep, struct interface, parent_iface);
372 struct device *dev = iface->l3_dev.dev;
379 interface_set_main_dev(alias, dev);
380 interface_set_available(alias, true);
383 interface_set_available(alias, false);
384 interface_set_main_dev(alias, NULL);
387 interface_remove_user(dep);
396 interface_claim_device(struct interface *iface)
398 struct interface *parent;
399 struct device *dev = NULL;
401 if (iface->parent_iface.iface)
402 interface_remove_user(&iface->parent_iface);
404 if (iface->parent_ifname) {
405 parent = vlist_find(&interfaces, iface->parent_ifname, parent, node);
406 iface->parent_iface.cb = interface_alias_cb;
407 interface_add_user(&iface->parent_iface, parent);
408 } else if (iface->ifname &&
409 !(iface->proto_handler->flags & PROTO_FLAG_NODEV)) {
410 dev = device_get(iface->ifname, true);
414 interface_set_main_dev(iface, dev);
416 if (iface->proto_handler->flags & PROTO_FLAG_INIT_AVAILABLE)
417 interface_set_available(iface, true);
421 interface_cleanup_state(struct interface *iface)
423 interface_set_available(iface, false);
425 interface_flush_state(iface);
426 interface_clear_errors(iface);
427 interface_set_proto_state(iface, NULL);
429 if (iface->main_dev.dev)
430 interface_set_main_dev(iface, NULL);
434 interface_cleanup(struct interface *iface)
436 struct interface_user *dep, *tmp;
438 if (iface->parent_iface.iface)
439 interface_remove_user(&iface->parent_iface);
441 list_for_each_entry_safe(dep, tmp, &iface->users, list)
442 interface_remove_user(dep);
444 interface_clear_assignment_classes(iface);
445 interface_ip_flush(&iface->config_ip);
446 interface_cleanup_state(iface);
450 interface_do_free(struct interface *iface)
452 interface_event(iface, IFEV_FREE);
453 interface_cleanup(iface);
455 netifd_ubus_remove_interface(iface);
456 avl_delete(&interfaces.avl, &iface->node.avl);
461 interface_do_reload(struct interface *iface)
463 interface_event(iface, IFEV_RELOAD);
464 interface_cleanup_state(iface);
465 proto_init_interface(iface, iface->config);
466 interface_claim_device(iface);
470 interface_handle_config_change(struct interface *iface)
472 enum interface_config_state state = iface->config_state;
474 iface->config_state = IFC_NORMAL;
479 interface_do_reload(iface);
482 interface_do_free(iface);
485 if (iface->autostart && iface->available)
486 interface_set_up(iface);
490 interface_proto_cb(struct interface_proto_state *state, enum interface_proto_event ev)
492 struct interface *iface = state->iface;
496 if (iface->state != IFS_SETUP) {
497 interface_event(iface, IFEV_UPDATE);
501 interface_ip_set_enabled(&iface->config_ip, true);
502 system_flush_routes();
503 iface->state = IFS_UP;
504 iface->start_time = system_get_rtime();
505 interface_event(iface, IFEV_UP);
506 netifd_log_message(L_NOTICE, "Interface '%s' is now up\n", iface->name);
509 if (iface->state == IFS_DOWN)
512 netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name);
513 mark_interface_down(iface);
514 if (iface->main_dev.dev)
515 device_release(&iface->main_dev);
516 interface_handle_config_change(iface);
518 case IFPEV_LINK_LOST:
519 if (iface->state != IFS_UP)
522 netifd_log_message(L_NOTICE, "Interface '%s' has lost the connection\n", iface->name);
523 mark_interface_down(iface);
524 iface->state = IFS_SETUP;
528 interface_write_resolv_conf();
531 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state)
534 iface->proto->free(iface->proto);
537 iface->state = IFS_DOWN;
538 iface->proto = state;
542 state->proto_event = interface_proto_cb;
543 state->iface = iface;
547 interface_alloc(const char *name, struct blob_attr *config)
549 struct interface *iface;
550 struct blob_attr *tb[IFACE_ATTR_MAX];
551 struct blob_attr *cur;
552 const char *proto_name = NULL;
555 iface = calloc_a(sizeof(*iface), &iface_name, strlen(name) + 1);
556 iface->name = strcpy(iface_name, name);
557 INIT_LIST_HEAD(&iface->errors);
558 INIT_LIST_HEAD(&iface->users);
559 INIT_LIST_HEAD(&iface->hotplug_list);
560 INIT_LIST_HEAD(&iface->assignment_classes);
561 interface_ip_init(iface);
562 avl_init(&iface->data, avl_strcmp, false, NULL);
563 iface->config_ip.enabled = false;
565 iface->main_dev.cb = interface_cb;
567 blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
568 blob_data(config), blob_len(config));
570 if ((cur = tb[IFACE_ATTR_PROTO]))
571 proto_name = blobmsg_data(cur);
573 proto_attach_interface(iface, proto_name);
575 iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true);
576 iface->proto_ip.no_defaultroute =
577 !blobmsg_get_bool_default(tb[IFACE_ATTR_DEFAULTROUTE], true);
578 iface->proto_ip.no_dns =
579 !blobmsg_get_bool_default(tb[IFACE_ATTR_PEERDNS], true);
581 if ((cur = tb[IFACE_ATTR_DNS]))
582 interface_add_dns_server_list(&iface->config_ip, cur);
584 if ((cur = tb[IFACE_ATTR_DNS_SEARCH]))
585 interface_add_dns_search_list(&iface->config_ip, cur);
587 if ((cur = tb[IFACE_ATTR_METRIC]))
588 iface->metric = blobmsg_get_u32(cur);
590 if ((cur = tb[IFACE_ATTR_IP6ASSIGN]))
591 iface->assignment_length = blobmsg_get_u32(cur);
593 iface->assignment_hint = -1;
594 if ((cur = tb[IFACE_ATTR_IP6HINT]))
595 iface->assignment_hint = strtol(blobmsg_get_string(cur), NULL, 16) &
596 ~((1 << (64 - iface->assignment_length)) - 1);
598 if ((cur = tb[IFACE_ATTR_IP6CLASS]))
599 interface_add_assignment_classes(iface, cur);
602 if ((cur = tb[IFACE_ATTR_IP4TABLE])) {
603 if (!system_resolve_rt_table(blobmsg_data(cur), &iface->ip4table))
604 DPRINTF("Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur));
607 if ((cur = tb[IFACE_ATTR_IP6TABLE])) {
608 if (!system_resolve_rt_table(blobmsg_data(cur), &iface->ip6table))
609 DPRINTF("Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur));
612 iface->proto_ip.no_delegation = !blobmsg_get_bool_default(tb[IFACE_ATTR_DELEGATE], true);
614 iface->config_autostart = iface->autostart;
618 void interface_set_dynamic(struct interface *iface)
620 iface->dynamic = true;
621 iface->node.version = -1; // Don't delete on reload
624 static bool __interface_add(struct interface *iface, struct blob_attr *config, bool alias)
626 struct blob_attr *tb[IFACE_ATTR_MAX];
627 struct blob_attr *cur;
629 blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
630 blob_data(config), blob_len(config));
633 if ((cur = tb[IFACE_ATTR_INTERFACE]))
634 iface->parent_ifname = blobmsg_data(cur);
636 if (!iface->parent_ifname)
639 if ((cur = tb[IFACE_ATTR_IFNAME]))
640 iface->ifname = blobmsg_data(cur);
644 iface->config = config;
645 vlist_add(&interfaces, &iface->node, iface->name);
650 interface_add(struct interface *iface, struct blob_attr *config)
652 __interface_add(iface, config, false);
656 interface_add_alias(struct interface *iface, struct blob_attr *config)
658 if (iface->proto_handler->flags & PROTO_FLAG_NODEV)
661 return __interface_add(iface, config, true);
665 interface_set_l3_dev(struct interface *iface, struct device *dev)
667 bool enabled = iface->config_ip.enabled;
668 bool claimed = iface->l3_dev.claimed;
670 if (iface->l3_dev.dev == dev)
673 interface_ip_set_enabled(&iface->config_ip, false);
674 interface_ip_flush(&iface->proto_ip);
675 device_add_user(&iface->l3_dev, dev);
679 device_claim(&iface->l3_dev);
680 interface_ip_set_enabled(&iface->config_ip, enabled);
685 interface_set_main_dev(struct interface *iface, struct device *dev)
687 bool set_l3 = (iface->main_dev.dev == iface->l3_dev.dev);
688 bool claimed = iface->l3_dev.claimed;
690 if (iface->main_dev.dev == dev)
694 interface_set_l3_dev(iface, dev);
696 device_add_user(&iface->main_dev, dev);
701 device_claim(&iface->l3_dev);
703 if (!iface->l3_dev.dev)
704 interface_set_l3_dev(iface, dev);
708 interface_remove_link(struct interface *iface, struct device *dev)
710 struct device *mdev = iface->main_dev.dev;
712 if (mdev && mdev->hotplug_ops)
713 return mdev->hotplug_ops->del(mdev, dev);
715 if (!iface->main_dev.hotplug)
716 return UBUS_STATUS_INVALID_ARGUMENT;
718 if (dev != iface->main_dev.dev)
719 return UBUS_STATUS_INVALID_ARGUMENT;
721 device_remove_user(&iface->main_dev);
726 interface_add_link(struct interface *iface, struct device *dev)
728 struct device *mdev = iface->main_dev.dev;
733 if (iface->main_dev.hotplug)
734 device_remove_user(&iface->main_dev);
737 if (mdev->hotplug_ops)
738 return mdev->hotplug_ops->add(mdev, dev);
740 return UBUS_STATUS_NOT_SUPPORTED;
743 interface_set_main_dev(iface, dev);
744 iface->main_dev.hotplug = true;
749 interface_handle_link(struct interface *iface, const char *name, bool add)
756 dev = device_get(name, add ? 2 : 0);
758 ret = UBUS_STATUS_NOT_FOUND;
763 device_set_present(dev, true);
764 if (iface->device_config)
765 device_set_config(dev, &simple_device_type, iface->config);
767 system_if_apply_settings(dev, &dev->settings);
768 ret = interface_add_link(iface, dev);
770 ret = interface_remove_link(iface, dev);
780 interface_set_up(struct interface *iface)
784 iface->autostart = true;
786 if (iface->state != IFS_DOWN)
789 interface_clear_errors(iface);
790 if (!iface->available) {
791 interface_add_error(iface, "interface", "NO_DEVICE", NULL, 0);
795 if (iface->main_dev.dev) {
796 ret = device_claim(&iface->main_dev);
801 iface->state = IFS_SETUP;
802 ret = interface_proto_event(iface->proto, PROTO_CMD_SETUP, false);
804 mark_interface_down(iface);
812 interface_set_down(struct interface *iface)
815 vlist_for_each_element(&interfaces, iface, node)
816 __interface_set_down(iface, false);
818 iface->autostart = false;
819 __interface_set_down(iface, false);
826 interface_start_pending(void)
828 struct interface *iface;
830 vlist_for_each_element(&interfaces, iface, node) {
831 if (iface->available && iface->autostart)
832 interface_set_up(iface);
837 set_config_state(struct interface *iface, enum interface_config_state s)
839 iface->config_state = s;
840 if (iface->state == IFS_DOWN)
841 interface_handle_config_change(iface);
843 __interface_set_down(iface, false);
847 interface_update_start(struct interface *iface)
850 interface_ip_update_start(&iface->proto_ip);
854 interface_update_complete(struct interface *iface)
856 interface_ip_update_complete(&iface->proto_ip);
860 interface_replace_dns(struct interface_ip_settings *new, struct interface_ip_settings *old)
862 vlist_simple_replace(&new->dns_servers, &old->dns_servers);
863 vlist_simple_replace(&new->dns_search, &old->dns_search);
867 interface_change_config(struct interface *if_old, struct interface *if_new)
869 struct blob_attr *old_config = if_old->config;
870 bool reload = false, reload_ip = false;
872 #define FIELD_CHANGED_STR(field) \
873 ((!!if_old->field != !!if_new->field) || \
875 strcmp(if_old->field, if_new->field) != 0))
877 if (FIELD_CHANGED_STR(parent_ifname)) {
878 if (if_old->parent_iface.iface)
879 interface_remove_user(&if_old->parent_iface);
883 if (FIELD_CHANGED_STR(ifname) ||
884 if_old->proto_handler != if_new->proto_handler)
887 if (!if_old->proto_handler->config_params)
888 D(INTERFACE, "No config parameters for interface '%s'\n",
890 else if (!uci_blob_check_equal(if_old->config, if_new->config,
891 if_old->proto_handler->config_params))
894 #define UPDATE(field, __var) ({ \
895 bool __changed = (if_old->field != if_new->field); \
896 if_old->field = if_new->field; \
897 __var |= __changed; \
900 if_old->config = if_new->config;
901 if (!if_old->config_autostart && if_new->config_autostart)
902 if_old->autostart = true;
904 if_old->device_config = if_new->device_config;
905 if_old->config_autostart = if_new->config_autostart;
906 if_old->ifname = if_new->ifname;
907 if_old->parent_ifname = if_new->parent_ifname;
908 if_old->proto_handler = if_new->proto_handler;
910 if_old->proto_ip.no_dns = if_new->proto_ip.no_dns;
911 interface_replace_dns(&if_old->config_ip, &if_new->config_ip);
913 UPDATE(metric, reload_ip);
914 UPDATE(proto_ip.no_defaultroute, reload_ip);
915 UPDATE(ip4table, reload_ip);
916 UPDATE(ip6table, reload_ip);
917 interface_merge_assignment_data(if_old, if_new);
922 D(INTERFACE, "Reload interface '%s' because of config changes\n",
924 interface_clear_errors(if_old);
925 set_config_state(if_old, IFC_RELOAD);
930 interface_ip_set_enabled(&if_old->config_ip, false);
931 interface_ip_set_enabled(&if_old->proto_ip, false);
932 interface_ip_set_enabled(&if_old->proto_ip, if_new->proto_ip.enabled);
933 interface_ip_set_enabled(&if_old->config_ip, if_new->config_ip.enabled);
936 interface_write_resolv_conf();
939 if_new->config = NULL;
940 interface_cleanup(if_new);
946 interface_update(struct vlist_tree *tree, struct vlist_node *node_new,
947 struct vlist_node *node_old)
949 struct interface *if_old = container_of(node_old, struct interface, node);
950 struct interface *if_new = container_of(node_new, struct interface, node);
952 if (node_old && node_new) {
953 D(INTERFACE, "Update interface '%s'\n", if_new->name);
954 interface_change_config(if_old, if_new);
955 } else if (node_old) {
956 D(INTERFACE, "Remove interface '%s'\n", if_old->name);
957 set_config_state(if_old, IFC_REMOVE);
958 } else if (node_new) {
959 D(INTERFACE, "Create interface '%s'\n", if_new->name);
960 proto_init_interface(if_new, if_new->config);
961 interface_claim_device(if_new);
962 netifd_ubus_add_interface(if_new);
968 interface_init_list(void)
970 vlist_init(&interfaces, avl_strcmp, interface_update);
971 interfaces.keep_old = true;
972 interfaces.no_delete = true;