split alias support into a separate source file for better readability
[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->main_dev.dev)
174 device_release(&iface->main_dev);
175 if (iface->l3_dev.dev)
176 device_release(&iface->l3_dev);
177 interface_data_flush(iface);
178 }
179
180 static void
181 mark_interface_down(struct interface *iface)
182 {
183 enum interface_state state = iface->state;
184
185 iface->state = IFS_DOWN;
186 if (state == IFS_UP)
187 interface_event(iface, IFEV_DOWN);
188 interface_ip_set_enabled(&iface->config_ip, false);
189 interface_ip_flush(&iface->proto_ip);
190 interface_flush_state(iface);
191 system_flush_routes();
192 }
193
194 void
195 __interface_set_down(struct interface *iface, bool force)
196 {
197 interface_clear_errors(iface);
198
199 if (iface->state == IFS_DOWN ||
200 iface->state == IFS_TEARDOWN)
201 return;
202
203 if (iface->state == IFS_UP)
204 interface_event(iface, IFEV_DOWN);
205 iface->state = IFS_TEARDOWN;
206 interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
207 if (force)
208 interface_flush_state(iface);
209 }
210
211 static void
212 interface_cb(struct device_user *dep, enum device_event ev)
213 {
214 struct interface *iface;
215 bool new_state;
216
217 iface = container_of(dep, struct interface, main_dev);
218 switch (ev) {
219 case DEV_EVENT_ADD:
220 new_state = true;
221 break;
222 case DEV_EVENT_REMOVE:
223 new_state = false;
224 break;
225 default:
226 return;
227 }
228
229 interface_set_available(iface, new_state);
230 if (!new_state && dep->dev->external)
231 interface_set_main_dev(iface, NULL);
232 }
233
234 void
235 interface_set_available(struct interface *iface, bool new_state)
236 {
237 if (iface->available == new_state)
238 return;
239
240 D(INTERFACE, "Interface '%s', available=%d\n", iface->name, new_state);
241 iface->available = new_state;
242
243 if (new_state) {
244 if (iface->autostart && !config_init)
245 interface_set_up(iface);
246 } else
247 __interface_set_down(iface, true);
248 }
249
250 void
251 interface_add_user(struct interface_user *dep, struct interface *iface)
252 {
253 if (!iface) {
254 list_add(&dep->list, &iface_all_users);
255 return;
256 }
257
258 dep->iface = iface;
259 list_add(&dep->list, &iface->users);
260 if (iface->state == IFS_UP)
261 dep->cb(dep, iface, IFEV_UP);
262 }
263
264 void
265 interface_remove_user(struct interface_user *dep)
266 {
267 list_del_init(&dep->list);
268 dep->iface = NULL;
269 }
270
271 static void
272 interface_alias_cb(struct interface_user *dep, struct interface *iface, enum interface_event ev)
273 {
274 struct interface *alias = container_of(dep, struct interface, parent_iface);
275 struct device *dev = iface->l3_dev.dev;
276
277 switch (ev) {
278 case IFEV_UP:
279 if (!dev)
280 return;
281
282 interface_set_main_dev(alias, dev);
283 interface_set_available(alias, true);
284 break;
285 case IFEV_DOWN:
286 interface_set_available(alias, false);
287 interface_set_main_dev(alias, NULL);
288 break;
289 case IFEV_FREE:
290 interface_remove_user(dep);
291 break;
292 case IFEV_RELOAD:
293 break;
294 }
295 }
296
297 static void
298 interface_claim_device(struct interface *iface)
299 {
300 struct interface *parent;
301 struct device *dev = NULL;
302
303 if (iface->parent_iface.iface)
304 interface_remove_user(&iface->parent_iface);
305
306 if (iface->parent_ifname) {
307 parent = vlist_find(&interfaces, iface->parent_ifname, parent, node);
308 iface->parent_iface.cb = interface_alias_cb;
309 interface_add_user(&iface->parent_iface, parent);
310 } else if (iface->ifname &&
311 !(iface->proto_handler->flags & PROTO_FLAG_NODEV)) {
312 dev = device_get(iface->ifname, true);
313 }
314
315 if (dev)
316 interface_set_main_dev(iface, dev);
317
318 if (iface->proto_handler->flags & PROTO_FLAG_INIT_AVAILABLE)
319 interface_set_available(iface, true);
320 }
321
322
323 static void
324 interface_cleanup(struct interface *iface, bool reload)
325 {
326 struct interface_user *dep, *tmp;
327
328 if (iface->parent_iface.iface)
329 interface_remove_user(&iface->parent_iface);
330
331 list_for_each_entry_safe(dep, tmp, &iface->users, list)
332 interface_remove_user(dep);
333
334 interface_ip_flush(&iface->config_ip);
335 interface_flush_state(iface);
336 interface_clear_errors(iface);
337
338 if (iface->main_dev.dev && !reload)
339 interface_set_main_dev(iface, NULL);
340 interface_set_proto_state(iface, NULL);
341 }
342
343 static void
344 interface_do_free(struct interface *iface)
345 {
346 interface_event(iface, IFEV_FREE);
347 interface_cleanup(iface, false);
348 free(iface->config);
349 netifd_ubus_remove_interface(iface);
350 avl_delete(&interfaces.avl, &iface->node.avl);
351 free(iface);
352 }
353
354 static void
355 interface_do_reload(struct interface *iface)
356 {
357 interface_event(iface, IFEV_RELOAD);
358 interface_cleanup(iface, true);
359 proto_init_interface(iface, iface->config);
360 interface_claim_device(iface);
361 }
362
363 static void
364 interface_handle_config_change(struct interface *iface)
365 {
366 enum interface_config_state state = iface->config_state;
367
368 iface->config_state = IFC_NORMAL;
369 switch(state) {
370 case IFC_NORMAL:
371 break;
372 case IFC_RELOAD:
373 interface_do_reload(iface);
374 break;
375 case IFC_REMOVE:
376 interface_do_free(iface);
377 return;
378 }
379 if (iface->autostart && iface->available)
380 interface_set_up(iface);
381 }
382
383 static void
384 interface_proto_cb(struct interface_proto_state *state, enum interface_proto_event ev)
385 {
386 struct interface *iface = state->iface;
387
388 switch (ev) {
389 case IFPEV_UP:
390 if (iface->state != IFS_SETUP)
391 return;
392
393 interface_ip_set_enabled(&iface->config_ip, true);
394 system_flush_routes();
395 iface->state = IFS_UP;
396 iface->start_time = system_get_rtime();
397 interface_event(iface, IFEV_UP);
398 interface_write_resolv_conf();
399 netifd_log_message(L_NOTICE, "Interface '%s' is now up\n", iface->name);
400 break;
401 case IFPEV_DOWN:
402 if (iface->state == IFS_DOWN)
403 return;
404
405 netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name);
406 mark_interface_down(iface);
407 interface_handle_config_change(iface);
408 break;
409 case IFPEV_LINK_LOST:
410 if (iface->state != IFS_UP)
411 return;
412
413 netifd_log_message(L_NOTICE, "Interface '%s' has lost the connection\n", iface->name);
414 mark_interface_down(iface);
415 iface->state = IFS_SETUP;
416 break;
417 }
418 }
419
420 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state)
421 {
422 if (iface->proto) {
423 iface->proto->free(iface->proto);
424 iface->proto = NULL;
425 }
426 iface->state = IFS_DOWN;
427 iface->proto = state;
428 if (!state)
429 return;
430
431 state->proto_event = interface_proto_cb;
432 state->iface = iface;
433 }
434
435 void
436 interface_init(struct interface *iface, const char *name,
437 struct blob_attr *config)
438 {
439 struct blob_attr *tb[IFACE_ATTR_MAX];
440 struct blob_attr *cur;
441 const char *proto_name = NULL;
442
443 strncpy(iface->name, name, sizeof(iface->name) - 1);
444 INIT_LIST_HEAD(&iface->errors);
445 INIT_LIST_HEAD(&iface->users);
446 INIT_LIST_HEAD(&iface->hotplug_list);
447 interface_ip_init(iface);
448 avl_init(&iface->data, avl_strcmp, false, NULL);
449 iface->config_ip.enabled = false;
450
451 iface->main_dev.cb = interface_cb;
452
453 blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
454 blob_data(config), blob_len(config));
455
456 if ((cur = tb[IFACE_ATTR_PROTO]))
457 proto_name = blobmsg_data(cur);
458
459 proto_attach_interface(iface, proto_name);
460
461 iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true);
462 iface->proto_ip.no_defaultroute =
463 !blobmsg_get_bool_default(tb[IFACE_ATTR_DEFAULTROUTE], true);
464 iface->proto_ip.no_dns =
465 !blobmsg_get_bool_default(tb[IFACE_ATTR_PEERDNS], true);
466
467 if ((cur = tb[IFACE_ATTR_DNS]))
468 interface_add_dns_server_list(&iface->config_ip, cur);
469
470 if ((cur = tb[IFACE_ATTR_DNS_SEARCH]))
471 interface_add_dns_search_list(&iface->config_ip, cur);
472
473 if ((cur = tb[IFACE_ATTR_METRIC]))
474 iface->metric = blobmsg_get_u32(cur);
475
476 iface->config_autostart = iface->autostart;
477 }
478
479 static bool __interface_add(struct interface *iface, struct blob_attr *config, bool alias)
480 {
481 struct blob_attr *tb[IFACE_ATTR_MAX];
482 struct blob_attr *cur;
483
484 blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb,
485 blob_data(config), blob_len(config));
486
487 if (alias) {
488 if ((cur = tb[IFACE_ATTR_INTERFACE]))
489 iface->parent_ifname = blobmsg_data(cur);
490
491 if (!iface->parent_ifname)
492 return false;
493 } else {
494 if ((cur = tb[IFACE_ATTR_IFNAME]))
495 iface->ifname = blobmsg_data(cur);
496 }
497
498
499 iface->config = config;
500 vlist_add(&interfaces, &iface->node, iface->name);
501 return true;
502 }
503
504 void
505 interface_add(struct interface *iface, struct blob_attr *config)
506 {
507 __interface_add(iface, config, false);
508 }
509
510 bool
511 interface_add_alias(struct interface *iface, struct blob_attr *config)
512 {
513 if (iface->proto_handler->flags & PROTO_FLAG_NODEV)
514 return false;
515
516 return __interface_add(iface, config, true);
517 }
518
519 void
520 interface_set_l3_dev(struct interface *iface, struct device *dev)
521 {
522 bool enabled = iface->config_ip.enabled;
523 bool claimed = iface->l3_dev.claimed;
524
525 if (iface->l3_dev.dev == dev)
526 return;
527
528 interface_ip_set_enabled(&iface->config_ip, false);
529 interface_ip_flush(&iface->proto_ip);
530 device_add_user(&iface->l3_dev, dev);
531
532 if (dev) {
533 if (claimed)
534 device_claim(&iface->l3_dev);
535 interface_ip_set_enabled(&iface->config_ip, enabled);
536 }
537 }
538
539 void
540 interface_set_main_dev(struct interface *iface, struct device *dev)
541 {
542 bool set_l3 = (iface->main_dev.dev == iface->l3_dev.dev);
543 bool claimed = iface->l3_dev.claimed;
544
545 if (iface->main_dev.dev == dev)
546 return;
547
548 if (set_l3)
549 interface_set_l3_dev(iface, dev);
550
551 device_add_user(&iface->main_dev, dev);
552 if (claimed)
553 device_claim(&iface->l3_dev);
554
555 if (!iface->l3_dev.dev)
556 interface_set_l3_dev(iface, dev);
557 }
558
559 int
560 interface_remove_link(struct interface *iface, struct device *dev)
561 {
562 struct device *mdev = iface->main_dev.dev;
563
564 if (mdev && mdev->hotplug_ops)
565 return mdev->hotplug_ops->del(mdev, dev);
566
567 if (!iface->main_dev.hotplug)
568 return UBUS_STATUS_INVALID_ARGUMENT;
569
570 if (dev != iface->main_dev.dev)
571 return UBUS_STATUS_INVALID_ARGUMENT;
572
573 device_remove_user(&iface->main_dev);
574 return 0;
575 }
576
577 int
578 interface_add_link(struct interface *iface, struct device *dev)
579 {
580 struct device *mdev = iface->main_dev.dev;
581
582 if (mdev == dev)
583 return 0;
584
585 if (iface->main_dev.hotplug)
586 device_remove_user(&iface->main_dev);
587
588 if (mdev) {
589 if (mdev->hotplug_ops)
590 return mdev->hotplug_ops->add(mdev, dev);
591 else
592 return UBUS_STATUS_NOT_SUPPORTED;
593 }
594
595 interface_set_main_dev(iface, dev);
596 iface->main_dev.hotplug = true;
597 return 0;
598 }
599
600 int
601 interface_set_up(struct interface *iface)
602 {
603 int ret;
604
605 iface->autostart = true;
606
607 if (iface->state != IFS_DOWN)
608 return 0;
609
610 interface_clear_errors(iface);
611 if (!iface->available) {
612 interface_add_error(iface, "interface", "NO_DEVICE", NULL, 0);
613 return -1;
614 }
615
616 if (iface->main_dev.dev) {
617 ret = device_claim(&iface->main_dev);
618 if (ret)
619 return ret;
620 }
621
622 iface->state = IFS_SETUP;
623 ret = interface_proto_event(iface->proto, PROTO_CMD_SETUP, false);
624 if (ret) {
625 mark_interface_down(iface);
626 return ret;
627 }
628
629 return 0;
630 }
631
632 int
633 interface_set_down(struct interface *iface)
634 {
635 if (!iface) {
636 vlist_for_each_element(&interfaces, iface, node)
637 __interface_set_down(iface, false);
638 } else {
639 iface->autostart = false;
640 __interface_set_down(iface, false);
641 }
642
643 return 0;
644 }
645
646 void
647 interface_start_pending(void)
648 {
649 struct interface *iface;
650
651 vlist_for_each_element(&interfaces, iface, node) {
652 if (iface->available && iface->autostart)
653 interface_set_up(iface);
654 }
655 }
656
657 static void
658 set_config_state(struct interface *iface, enum interface_config_state s)
659 {
660 iface->config_state = s;
661 if (iface->state == IFS_DOWN)
662 interface_handle_config_change(iface);
663 else
664 __interface_set_down(iface, false);
665 }
666
667 void
668 interface_update_start(struct interface *iface)
669 {
670 interface_ip_update_start(&iface->proto_ip);
671 }
672
673 void
674 interface_update_complete(struct interface *iface)
675 {
676 interface_ip_update_complete(&iface->proto_ip);
677 }
678
679 static void
680 interface_replace_dns(struct interface_ip_settings *new, struct interface_ip_settings *old)
681 {
682 vlist_simple_replace(&new->dns_servers, &old->dns_servers);
683 vlist_simple_replace(&new->dns_search, &old->dns_search);
684 }
685
686 static void
687 interface_change_config(struct interface *if_old, struct interface *if_new)
688 {
689 struct blob_attr *old_config = if_old->config;
690 const char *old_ifname = if_old->ifname;
691 const char *old_parent_ifname = if_old->parent_ifname;
692 const struct proto_handler *proto = if_old->proto_handler;
693
694 interface_clear_errors(if_old);
695 if_old->config = if_new->config;
696 if (!if_old->config_autostart && if_new->config_autostart)
697 if_old->autostart = true;
698
699 if_old->config_autostart = if_new->config_autostart;
700 if_old->ifname = if_new->ifname;
701 if_old->parent_ifname = if_new->parent_ifname;
702 if_old->proto_handler = if_new->proto_handler;
703
704 #define FIELD_CHANGED_STR(field) \
705 ((!!if_old->field != !!old_ ## field) || \
706 (old_ ## field && \
707 strcmp(old_ ## field, if_old->field) != 0))
708
709 if (FIELD_CHANGED_STR(parent_ifname)) {
710 if (if_old->parent_iface.iface)
711 interface_remove_user(&if_old->parent_iface);
712 goto reload;
713 }
714
715 if (FIELD_CHANGED_STR(ifname) || proto != if_new->proto_handler) {
716 D(INTERFACE, "Reload interface '%s' because of ifname/proto change\n",
717 if_old->name);
718 goto reload;
719 }
720
721 if (!proto->config_params)
722 D(INTERFACE, "No config parameters for interface '%s'\n",
723 if_old->name);
724 else if (!config_check_equal(old_config, if_new->config,
725 proto->config_params)) {
726 D(INTERFACE, "Reload interface '%s because of config changes\n",
727 if_old->name);
728 goto reload;
729 }
730
731 #define UPDATE(field) ({ \
732 bool __changed = (if_old->field != if_new->field); \
733 if_old->field = if_new->field; \
734 __changed; \
735 })
736
737 if (UPDATE(metric) || UPDATE(proto_ip.no_defaultroute)) {
738 interface_ip_set_enabled(&if_old->config_ip, false);
739 interface_ip_set_enabled(&if_old->config_ip, if_new->config_ip.enabled);
740 interface_ip_set_enabled(&if_old->proto_ip, false);
741 interface_ip_set_enabled(&if_old->proto_ip, if_new->proto_ip.enabled);
742 }
743
744 UPDATE(proto_ip.no_dns);
745 interface_replace_dns(&if_old->config_ip, &if_new->config_ip);
746 interface_write_resolv_conf();
747
748 #undef UPDATE
749
750 goto out;
751
752 reload:
753 set_config_state(if_old, IFC_RELOAD);
754 out:
755 if_new->config = NULL;
756 interface_cleanup(if_new, false);
757 free(old_config);
758 free(if_new);
759 }
760
761 static void
762 interface_update(struct vlist_tree *tree, struct vlist_node *node_new,
763 struct vlist_node *node_old)
764 {
765 struct interface *if_old = container_of(node_old, struct interface, node);
766 struct interface *if_new = container_of(node_new, struct interface, node);
767
768 if (node_old && node_new) {
769 D(INTERFACE, "Update interface '%s'\n", if_new->name);
770 interface_change_config(if_old, if_new);
771 } else if (node_old) {
772 D(INTERFACE, "Remove interface '%s'\n", if_old->name);
773 set_config_state(if_old, IFC_REMOVE);
774 } else if (node_new) {
775 D(INTERFACE, "Create interface '%s'\n", if_new->name);
776 proto_init_interface(if_new, if_new->config);
777 interface_claim_device(if_new);
778 netifd_ubus_add_interface(if_new);
779 }
780 }
781
782
783 static void __init
784 interface_init_list(void)
785 {
786 vlist_init(&interfaces, avl_strcmp, interface_update);
787 interfaces.keep_old = true;
788 interfaces.no_delete = true;
789 }