rewrite resolv.conf after any interface state change (not just up)
[project/netifd.git] / interface.c
1 /*
2 * netifd - network interface daemon
3 * Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
4 *
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
8 *
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.
13 */
14 #include <string.h>
15 #include <stdlib.h>
16 #include <stdio.h>
17
18 #include "netifd.h"
19 #include "device.h"
20 #include "interface.h"
21 #include "interface-ip.h"
22 #include "proto.h"
23 #include "ubus.h"
24 #include "config.h"
25 #include "system.h"
26
27 struct vlist_tree interfaces;
28 static LIST_HEAD(iface_all_users);
29
30 enum {
31 IFACE_ATTR_IFNAME,
32 IFACE_ATTR_PROTO,
33 IFACE_ATTR_AUTO,
34 IFACE_ATTR_DEFAULTROUTE,
35 IFACE_ATTR_PEERDNS,
36 IFACE_ATTR_DNS,
37 IFACE_ATTR_DNS_SEARCH,
38 IFACE_ATTR_METRIC,
39 IFACE_ATTR_INTERFACE,
40 IFACE_ATTR_MAX
41 };
42
43 static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = {
44 [IFACE_ATTR_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING },
45 [IFACE_ATTR_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING },
46 [IFACE_ATTR_AUTO] = { .name = "auto", .type = BLOBMSG_TYPE_BOOL },
47 [IFACE_ATTR_DEFAULTROUTE] = { .name = "defaultroute", .type = BLOBMSG_TYPE_BOOL },
48 [IFACE_ATTR_PEERDNS] = { .name = "peerdns", .type = BLOBMSG_TYPE_BOOL },
49 [IFACE_ATTR_METRIC] = { .name = "metric", .type = BLOBMSG_TYPE_INT32 },
50 [IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
51 [IFACE_ATTR_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY },
52 [IFACE_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING },
53 };
54
55 static const union config_param_info iface_attr_info[IFACE_ATTR_MAX] = {
56 [IFACE_ATTR_DNS] = { .type = BLOBMSG_TYPE_STRING },
57 };
58
59 const struct config_param_list interface_attr_list = {
60 .n_params = IFACE_ATTR_MAX,
61 .params = iface_attrs,
62 .info = iface_attr_info,
63 };
64
65 static void
66 interface_clear_errors(struct interface *iface)
67 {
68 struct interface_error *error, *tmp;
69
70 list_for_each_entry_safe(error, tmp, &iface->errors, list) {
71 list_del(&error->list);
72 free(error);
73 }
74 }
75
76 void interface_add_error(struct interface *iface, const char *subsystem,
77 const char *code, const char **data, int n_data)
78 {
79 struct interface_error *error;
80 int i, len = 0;
81 int *datalen = NULL;
82 char *dest;
83
84 if (n_data) {
85 len = n_data * sizeof(char *);
86 datalen = alloca(len);
87 for (i = 0; i < n_data; i++) {
88 datalen[i] = strlen(data[i]) + 1;
89 len += datalen[i];
90 }
91 }
92
93 error = calloc(1, sizeof(*error) + sizeof(char *) + len);
94 if (!error)
95 return;
96
97 list_add_tail(&error->list, &iface->errors);
98 error->subsystem = subsystem;
99 error->code = code;
100
101 dest = (char *) &error->data[n_data + 1];
102 for (i = 0; i < n_data; i++) {
103 error->data[i] = dest;
104 memcpy(dest, data[i], datalen[i]);
105 dest += datalen[i];
106 }
107 error->data[n_data] = NULL;
108 }
109
110 static void
111 interface_data_del(struct interface *iface, struct interface_data *data)
112 {
113 avl_delete(&iface->data, &data->node);
114 free(data);
115 }
116
117 static void
118 interface_data_flush(struct interface *iface)
119 {
120 struct interface_data *d, *tmp;
121
122 avl_for_each_element_safe(&iface->data, d, node, tmp)
123 interface_data_del(iface, d);
124 }
125
126 int
127 interface_add_data(struct interface *iface, const struct blob_attr *data)
128 {
129 struct interface_data *n, *o;
130
131 if (!blobmsg_check_attr(data, true))
132 return UBUS_STATUS_INVALID_ARGUMENT;
133
134 n = calloc(1, sizeof(*n) + blob_pad_len(data));
135 memcpy(n->data, data, blob_pad_len(data));
136 n->node.key = blobmsg_name(data);
137
138 o = avl_find_element(&iface->data, n->node.key, o, node);
139 if (o)
140 interface_data_del(iface, o);
141
142 avl_insert(&iface->data, &n->node);
143 return 0;
144 }
145
146 static void
147 interface_event(struct interface *iface, enum interface_event ev)
148 {
149 struct interface_user *dep, *tmp;
150 struct device *adev = NULL;
151
152 list_for_each_entry_safe(dep, tmp, &iface->users, list)
153 dep->cb(dep, iface, ev);
154
155 list_for_each_entry_safe(dep, tmp, &iface_all_users, list)
156 dep->cb(dep, iface, ev);
157
158 switch (ev) {
159 case IFEV_UP:
160 adev = iface->main_dev.dev;
161 /* fall through */
162 case IFEV_DOWN:
163 alias_notify_device(iface->name, adev);
164 break;
165 default:
166 break;
167 }
168 }
169
170 static void
171 interface_flush_state(struct interface *iface)
172 {
173 if (iface->l3_dev.dev)
174 device_release(&iface->l3_dev);
175 interface_data_flush(iface);
176 }
177
178 static void
179 mark_interface_down(struct interface *iface)
180 {
181 enum interface_state state = iface->state;
182
183 iface->state = IFS_DOWN;
184 if (state == IFS_UP)
185 interface_event(iface, IFEV_DOWN);
186 interface_ip_set_enabled(&iface->config_ip, false);
187 interface_ip_flush(&iface->proto_ip);
188 interface_flush_state(iface);
189 system_flush_routes();
190 }
191
192 void
193 __interface_set_down(struct interface *iface, bool force)
194 {
195 interface_clear_errors(iface);
196
197 if (iface->state == IFS_DOWN ||
198 iface->state == IFS_TEARDOWN)
199 return;
200
201 if (iface->state == IFS_UP)
202 interface_event(iface, IFEV_DOWN);
203 iface->state = IFS_TEARDOWN;
204 interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
205 if (force)
206 interface_flush_state(iface);
207 }
208
209 static void
210 interface_cb(struct device_user *dep, enum device_event ev)
211 {
212 struct interface *iface;
213 bool new_state;
214
215 iface = container_of(dep, struct interface, main_dev);
216 switch (ev) {
217 case DEV_EVENT_ADD:
218 new_state = true;
219 break;
220 case DEV_EVENT_REMOVE:
221 new_state = false;
222 break;
223 default:
224 return;
225 }
226
227 interface_set_available(iface, new_state);
228 if (!new_state && dep->dev->external)
229 interface_set_main_dev(iface, NULL);
230 }
231
232 void
233 interface_set_available(struct interface *iface, bool new_state)
234 {
235 if (iface->available == new_state)
236 return;
237
238 D(INTERFACE, "Interface '%s', available=%d\n", iface->name, new_state);
239 iface->available = new_state;
240
241 if (new_state) {
242 if (iface->autostart && !config_init)
243 interface_set_up(iface);
244 } else
245 __interface_set_down(iface, true);
246 }
247
248 void
249 interface_add_user(struct interface_user *dep, struct interface *iface)
250 {
251 if (!iface) {
252 list_add(&dep->list, &iface_all_users);
253 return;
254 }
255
256 dep->iface = iface;
257 list_add(&dep->list, &iface->users);
258 if (iface->state == IFS_UP)
259 dep->cb(dep, iface, IFEV_UP);
260 }
261
262 void
263 interface_remove_user(struct interface_user *dep)
264 {
265 list_del_init(&dep->list);
266 dep->iface = NULL;
267 }
268
269 static void
270 interface_alias_cb(struct interface_user *dep, struct interface *iface, enum interface_event ev)
271 {
272 struct interface *alias = container_of(dep, struct interface, parent_iface);
273 struct device *dev = iface->l3_dev.dev;
274
275 switch (ev) {
276 case IFEV_UP:
277 if (!dev)
278 return;
279
280 interface_set_main_dev(alias, dev);
281 interface_set_available(alias, true);
282 break;
283 case IFEV_DOWN:
284 interface_set_available(alias, false);
285 interface_set_main_dev(alias, NULL);
286 break;
287 case IFEV_FREE:
288 interface_remove_user(dep);
289 break;
290 case IFEV_RELOAD:
291 break;
292 }
293 }
294
295 static void
296 interface_claim_device(struct interface *iface)
297 {
298 struct interface *parent;
299 struct device *dev = NULL;
300
301 if (iface->parent_iface.iface)
302 interface_remove_user(&iface->parent_iface);
303
304 if (iface->parent_ifname) {
305 parent = vlist_find(&interfaces, iface->parent_ifname, parent, node);
306 iface->parent_iface.cb = interface_alias_cb;
307 interface_add_user(&iface->parent_iface, parent);
308 } else if (iface->ifname &&
309 !(iface->proto_handler->flags & PROTO_FLAG_NODEV)) {
310 dev = device_get(iface->ifname, true);
311 }
312
313 if (dev)
314 interface_set_main_dev(iface, dev);
315
316 if (iface->proto_handler->flags & PROTO_FLAG_INIT_AVAILABLE)
317 interface_set_available(iface, true);
318 }
319
320
321 static void
322 interface_cleanup(struct interface *iface, bool reload)
323 {
324 struct interface_user *dep, *tmp;
325
326 if (iface->parent_iface.iface)
327 interface_remove_user(&iface->parent_iface);
328
329 list_for_each_entry_safe(dep, tmp, &iface->users, list)
330 interface_remove_user(dep);
331
332 interface_ip_flush(&iface->config_ip);
333 interface_flush_state(iface);
334 interface_clear_errors(iface);
335
336 if (iface->main_dev.dev && !reload)
337 interface_set_main_dev(iface, NULL);
338 interface_set_proto_state(iface, NULL);
339 }
340
341 static void
342 interface_do_free(struct interface *iface)
343 {
344 interface_event(iface, IFEV_FREE);
345 interface_cleanup(iface, false);
346 free(iface->config);
347 netifd_ubus_remove_interface(iface);
348 avl_delete(&interfaces.avl, &iface->node.avl);
349 free(iface);
350 }
351
352 static void
353 interface_do_reload(struct interface *iface)
354 {
355 interface_event(iface, IFEV_RELOAD);
356 interface_cleanup(iface, true);
357 proto_init_interface(iface, iface->config);
358 interface_claim_device(iface);
359 }
360
361 static void
362 interface_handle_config_change(struct interface *iface)
363 {
364 enum interface_config_state state = iface->config_state;
365
366 iface->config_state = IFC_NORMAL;
367 switch(state) {
368 case IFC_NORMAL:
369 break;
370 case IFC_RELOAD:
371 interface_do_reload(iface);
372 break;
373 case IFC_REMOVE:
374 interface_do_free(iface);
375 return;
376 }
377 if (iface->autostart && iface->available)
378 interface_set_up(iface);
379 }
380
381 static void
382 interface_proto_cb(struct interface_proto_state *state, enum interface_proto_event ev)
383 {
384 struct interface *iface = state->iface;
385
386 switch (ev) {
387 case IFPEV_UP:
388 if (iface->state != IFS_SETUP)
389 return;
390
391 interface_ip_set_enabled(&iface->config_ip, true);
392 system_flush_routes();
393 iface->state = IFS_UP;
394 iface->start_time = system_get_rtime();
395 interface_event(iface, IFEV_UP);
396 netifd_log_message(L_NOTICE, "Interface '%s' is now up\n", iface->name);
397 break;
398 case IFPEV_DOWN:
399 if (iface->state == IFS_DOWN)
400 return;
401
402 netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name);
403 mark_interface_down(iface);
404 if (iface->main_dev.dev)
405 device_release(&iface->main_dev);
406 interface_handle_config_change(iface);
407 break;
408 case IFPEV_LINK_LOST:
409 if (iface->state != IFS_UP)
410 return;
411
412 netifd_log_message(L_NOTICE, "Interface '%s' has lost the connection\n", iface->name);
413 mark_interface_down(iface);
414 iface->state = IFS_SETUP;
415 break;
416 }
417
418 interface_write_resolv_conf();
419 }
420
421 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state)
422 {
423 if (iface->proto) {
424 iface->proto->free(iface->proto);
425 iface->proto = NULL;
426 }
427 iface->state = IFS_DOWN;
428 iface->proto = state;
429 if (!state)
430 return;
431
432 state->proto_event = interface_proto_cb;
433 state->iface = iface;
434 }
435
436 void
437 interface_init(struct interface *iface, const char *name,
438 struct blob_attr *config)
439 {
440 struct blob_attr *tb[IFACE_ATTR_MAX];
441 struct blob_attr *cur;
442 const char *proto_name = NULL;
443
444 strncpy(iface->name, name, sizeof(iface->name) - 1);
445 INIT_LIST_HEAD(&iface->errors);
446 INIT_LIST_HEAD(&iface->users);
447 INIT_LIST_HEAD(&iface->hotplug_list);
448 interface_ip_init(iface);
449 avl_init(&iface->data, avl_strcmp, false, NULL);
450 iface->config_ip.enabled = false;
451
452 iface->main_dev.cb = interface_cb;
453
454 blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
455 blob_data(config), blob_len(config));
456
457 if ((cur = tb[IFACE_ATTR_PROTO]))
458 proto_name = blobmsg_data(cur);
459
460 proto_attach_interface(iface, proto_name);
461
462 iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true);
463 iface->proto_ip.no_defaultroute =
464 !blobmsg_get_bool_default(tb[IFACE_ATTR_DEFAULTROUTE], true);
465 iface->proto_ip.no_dns =
466 !blobmsg_get_bool_default(tb[IFACE_ATTR_PEERDNS], true);
467
468 if ((cur = tb[IFACE_ATTR_DNS]))
469 interface_add_dns_server_list(&iface->config_ip, cur);
470
471 if ((cur = tb[IFACE_ATTR_DNS_SEARCH]))
472 interface_add_dns_search_list(&iface->config_ip, cur);
473
474 if ((cur = tb[IFACE_ATTR_METRIC]))
475 iface->metric = blobmsg_get_u32(cur);
476
477 iface->config_autostart = iface->autostart;
478 }
479
480 static bool __interface_add(struct interface *iface, struct blob_attr *config, bool alias)
481 {
482 struct blob_attr *tb[IFACE_ATTR_MAX];
483 struct blob_attr *cur;
484
485 blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
486 blob_data(config), blob_len(config));
487
488 if (alias) {
489 if ((cur = tb[IFACE_ATTR_INTERFACE]))
490 iface->parent_ifname = blobmsg_data(cur);
491
492 if (!iface->parent_ifname)
493 return false;
494 } else {
495 if ((cur = tb[IFACE_ATTR_IFNAME]))
496 iface->ifname = blobmsg_data(cur);
497 }
498
499
500 iface->config = config;
501 vlist_add(&interfaces, &iface->node, iface->name);
502 return true;
503 }
504
505 void
506 interface_add(struct interface *iface, struct blob_attr *config)
507 {
508 __interface_add(iface, config, false);
509 }
510
511 bool
512 interface_add_alias(struct interface *iface, struct blob_attr *config)
513 {
514 if (iface->proto_handler->flags & PROTO_FLAG_NODEV)
515 return false;
516
517 return __interface_add(iface, config, true);
518 }
519
520 void
521 interface_set_l3_dev(struct interface *iface, struct device *dev)
522 {
523 bool enabled = iface->config_ip.enabled;
524 bool claimed = iface->l3_dev.claimed;
525
526 if (iface->l3_dev.dev == dev)
527 return;
528
529 interface_ip_set_enabled(&iface->config_ip, false);
530 interface_ip_flush(&iface->proto_ip);
531 device_add_user(&iface->l3_dev, dev);
532
533 if (dev) {
534 if (claimed)
535 device_claim(&iface->l3_dev);
536 interface_ip_set_enabled(&iface->config_ip, enabled);
537 }
538 }
539
540 void
541 interface_set_main_dev(struct interface *iface, struct device *dev)
542 {
543 bool set_l3 = (iface->main_dev.dev == iface->l3_dev.dev);
544 bool claimed = iface->l3_dev.claimed;
545
546 if (iface->main_dev.dev == dev)
547 return;
548
549 if (set_l3)
550 interface_set_l3_dev(iface, dev);
551
552 device_add_user(&iface->main_dev, dev);
553 if (claimed)
554 device_claim(&iface->l3_dev);
555
556 if (!iface->l3_dev.dev)
557 interface_set_l3_dev(iface, dev);
558 }
559
560 int
561 interface_remove_link(struct interface *iface, struct device *dev)
562 {
563 struct device *mdev = iface->main_dev.dev;
564
565 if (mdev && mdev->hotplug_ops)
566 return mdev->hotplug_ops->del(mdev, dev);
567
568 if (!iface->main_dev.hotplug)
569 return UBUS_STATUS_INVALID_ARGUMENT;
570
571 if (dev != iface->main_dev.dev)
572 return UBUS_STATUS_INVALID_ARGUMENT;
573
574 device_remove_user(&iface->main_dev);
575 return 0;
576 }
577
578 int
579 interface_add_link(struct interface *iface, struct device *dev)
580 {
581 struct device *mdev = iface->main_dev.dev;
582
583 if (mdev == dev)
584 return 0;
585
586 if (iface->main_dev.hotplug)
587 device_remove_user(&iface->main_dev);
588
589 if (mdev) {
590 if (mdev->hotplug_ops)
591 return mdev->hotplug_ops->add(mdev, dev);
592 else
593 return UBUS_STATUS_NOT_SUPPORTED;
594 }
595
596 interface_set_main_dev(iface, dev);
597 iface->main_dev.hotplug = true;
598 return 0;
599 }
600
601 int
602 interface_set_up(struct interface *iface)
603 {
604 int ret;
605
606 iface->autostart = true;
607
608 if (iface->state != IFS_DOWN)
609 return 0;
610
611 interface_clear_errors(iface);
612 if (!iface->available) {
613 interface_add_error(iface, "interface", "NO_DEVICE", NULL, 0);
614 return -1;
615 }
616
617 if (iface->main_dev.dev) {
618 ret = device_claim(&iface->main_dev);
619 if (ret)
620 return ret;
621 }
622
623 iface->state = IFS_SETUP;
624 ret = interface_proto_event(iface->proto, PROTO_CMD_SETUP, false);
625 if (ret) {
626 mark_interface_down(iface);
627 return ret;
628 }
629
630 return 0;
631 }
632
633 int
634 interface_set_down(struct interface *iface)
635 {
636 if (!iface) {
637 vlist_for_each_element(&interfaces, iface, node)
638 __interface_set_down(iface, false);
639 } else {
640 iface->autostart = false;
641 __interface_set_down(iface, false);
642 }
643
644 return 0;
645 }
646
647 void
648 interface_start_pending(void)
649 {
650 struct interface *iface;
651
652 vlist_for_each_element(&interfaces, iface, node) {
653 if (iface->available && iface->autostart)
654 interface_set_up(iface);
655 }
656 }
657
658 static void
659 set_config_state(struct interface *iface, enum interface_config_state s)
660 {
661 iface->config_state = s;
662 if (iface->state == IFS_DOWN)
663 interface_handle_config_change(iface);
664 else
665 __interface_set_down(iface, false);
666 }
667
668 void
669 interface_update_start(struct interface *iface)
670 {
671 interface_ip_update_start(&iface->proto_ip);
672 }
673
674 void
675 interface_update_complete(struct interface *iface)
676 {
677 interface_ip_update_complete(&iface->proto_ip);
678 }
679
680 static void
681 interface_replace_dns(struct interface_ip_settings *new, struct interface_ip_settings *old)
682 {
683 vlist_simple_replace(&new->dns_servers, &old->dns_servers);
684 vlist_simple_replace(&new->dns_search, &old->dns_search);
685 }
686
687 static void
688 interface_change_config(struct interface *if_old, struct interface *if_new)
689 {
690 struct blob_attr *old_config = if_old->config;
691 const char *old_ifname = if_old->ifname;
692 const char *old_parent_ifname = if_old->parent_ifname;
693 const struct proto_handler *proto = if_old->proto_handler;
694
695 interface_clear_errors(if_old);
696 if_old->config = if_new->config;
697 if (!if_old->config_autostart && if_new->config_autostart)
698 if_old->autostart = true;
699
700 if_old->device_config = if_new->device_config;
701 if_old->config_autostart = if_new->config_autostart;
702 if_old->ifname = if_new->ifname;
703 if_old->parent_ifname = if_new->parent_ifname;
704 if_old->proto_handler = if_new->proto_handler;
705
706 #define FIELD_CHANGED_STR(field) \
707 ((!!if_old->field != !!old_ ## field) || \
708 (old_ ## field && \
709 strcmp(old_ ## field, if_old->field) != 0))
710
711 if (FIELD_CHANGED_STR(parent_ifname)) {
712 if (if_old->parent_iface.iface)
713 interface_remove_user(&if_old->parent_iface);
714 goto reload;
715 }
716
717 if (FIELD_CHANGED_STR(ifname) || proto != if_new->proto_handler) {
718 D(INTERFACE, "Reload interface '%s' because of ifname/proto change\n",
719 if_old->name);
720 goto reload;
721 }
722
723 if (!proto->config_params)
724 D(INTERFACE, "No config parameters for interface '%s'\n",
725 if_old->name);
726 else if (!config_check_equal(old_config, if_new->config,
727 proto->config_params)) {
728 D(INTERFACE, "Reload interface '%s because of config changes\n",
729 if_old->name);
730 goto reload;
731 }
732
733 #define UPDATE(field) ({ \
734 bool __changed = (if_old->field != if_new->field); \
735 if_old->field = if_new->field; \
736 __changed; \
737 })
738
739 if (UPDATE(metric) || UPDATE(proto_ip.no_defaultroute)) {
740 interface_ip_set_enabled(&if_old->config_ip, false);
741 interface_ip_set_enabled(&if_old->config_ip, if_new->config_ip.enabled);
742 interface_ip_set_enabled(&if_old->proto_ip, false);
743 interface_ip_set_enabled(&if_old->proto_ip, if_new->proto_ip.enabled);
744 }
745
746 UPDATE(proto_ip.no_dns);
747 interface_replace_dns(&if_old->config_ip, &if_new->config_ip);
748 interface_write_resolv_conf();
749
750 #undef UPDATE
751
752 goto out;
753
754 reload:
755 set_config_state(if_old, IFC_RELOAD);
756 out:
757 if_new->config = NULL;
758 interface_cleanup(if_new, false);
759 free(old_config);
760 free(if_new);
761 }
762
763 static void
764 interface_update(struct vlist_tree *tree, struct vlist_node *node_new,
765 struct vlist_node *node_old)
766 {
767 struct interface *if_old = container_of(node_old, struct interface, node);
768 struct interface *if_new = container_of(node_new, struct interface, node);
769
770 if (node_old && node_new) {
771 D(INTERFACE, "Update interface '%s'\n", if_new->name);
772 interface_change_config(if_old, if_new);
773 } else if (node_old) {
774 D(INTERFACE, "Remove interface '%s'\n", if_old->name);
775 set_config_state(if_old, IFC_REMOVE);
776 } else if (node_new) {
777 D(INTERFACE, "Create interface '%s'\n", if_new->name);
778 proto_init_interface(if_new, if_new->config);
779 interface_claim_device(if_new);
780 netifd_ubus_add_interface(if_new);
781 }
782 }
783
784
785 static void __init
786 interface_init_list(void)
787 {
788 vlist_init(&interfaces, avl_strcmp, interface_update);
789 interfaces.keep_old = true;
790 interfaces.no_delete = true;
791 }