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 #include <sys/types.h> 18 #include <sys/wait.h> 19 20 #include "netifd.h" 21 #include "device.h" 22 #include "interface.h" 23 #include "interface-ip.h" 24 #include "proto.h" 25 #include "ubus.h" 26 #include "config.h" 27 #include "system.h" 28 #include "wireless.h" 29 30 struct vlist_tree interfaces; 31 static LIST_HEAD(iface_all_users); 32 33 enum { 34 IFACE_ATTR_DEVICE, 35 IFACE_ATTR_IFNAME, /* Backward compatibility */ 36 IFACE_ATTR_PROTO, 37 IFACE_ATTR_AUTO, 38 IFACE_ATTR_ZONE, 39 IFACE_ATTR_JAIL, 40 IFACE_ATTR_JAIL_DEVICE, 41 IFACE_ATTR_JAIL_IFNAME, 42 IFACE_ATTR_HOST_DEVICE, 43 IFACE_ATTR_DEFAULTROUTE, 44 IFACE_ATTR_PEERDNS, 45 IFACE_ATTR_DNS, 46 IFACE_ATTR_DNS_SEARCH, 47 IFACE_ATTR_DNS_METRIC, 48 IFACE_ATTR_METRIC, 49 IFACE_ATTR_INTERFACE, 50 IFACE_ATTR_IP6ASSIGN, 51 IFACE_ATTR_IP6HINT, 52 IFACE_ATTR_IP4TABLE, 53 IFACE_ATTR_IP6TABLE, 54 IFACE_ATTR_IP6CLASS, 55 IFACE_ATTR_DELEGATE, 56 IFACE_ATTR_IP6IFACEID, 57 IFACE_ATTR_FORCE_LINK, 58 IFACE_ATTR_IP6WEIGHT, 59 IFACE_ATTR_MAX 60 }; 61 62 static const struct blobmsg_policy iface_attrs[IFACE_ATTR_MAX] = { 63 [IFACE_ATTR_DEVICE] = { .name = "device", .type = BLOBMSG_TYPE_STRING }, 64 [IFACE_ATTR_PROTO] = { .name = "proto", .type = BLOBMSG_TYPE_STRING }, 65 [IFACE_ATTR_IFNAME] = { .name = "ifname", .type = BLOBMSG_TYPE_STRING }, 66 [IFACE_ATTR_AUTO] = { .name = "auto", .type = BLOBMSG_TYPE_BOOL }, 67 [IFACE_ATTR_ZONE] = { .name = "zone", .type = BLOBMSG_TYPE_STRING }, 68 [IFACE_ATTR_JAIL] = { .name = "jail", .type = BLOBMSG_TYPE_STRING }, 69 [IFACE_ATTR_JAIL_DEVICE] = { .name = "jail_device", .type = BLOBMSG_TYPE_STRING }, 70 [IFACE_ATTR_JAIL_IFNAME] = { .name = "jail_ifname", .type = BLOBMSG_TYPE_STRING }, 71 [IFACE_ATTR_HOST_DEVICE] = { .name = "host_device", .type = BLOBMSG_TYPE_STRING }, 72 [IFACE_ATTR_DEFAULTROUTE] = { .name = "defaultroute", .type = BLOBMSG_TYPE_BOOL }, 73 [IFACE_ATTR_PEERDNS] = { .name = "peerdns", .type = BLOBMSG_TYPE_BOOL }, 74 [IFACE_ATTR_METRIC] = { .name = "metric", .type = BLOBMSG_TYPE_INT32 }, 75 [IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY }, 76 [IFACE_ATTR_DNS_SEARCH] = { .name = "dns_search", .type = BLOBMSG_TYPE_ARRAY }, 77 [IFACE_ATTR_DNS_METRIC] = { .name = "dns_metric", .type = BLOBMSG_TYPE_INT32 }, 78 [IFACE_ATTR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING }, 79 [IFACE_ATTR_IP6ASSIGN] = { .name = "ip6assign", .type = BLOBMSG_TYPE_INT32 }, 80 [IFACE_ATTR_IP6HINT] = { .name = "ip6hint", .type = BLOBMSG_TYPE_STRING }, 81 [IFACE_ATTR_IP4TABLE] = { .name = "ip4table", .type = BLOBMSG_TYPE_STRING }, 82 [IFACE_ATTR_IP6TABLE] = { .name = "ip6table", .type = BLOBMSG_TYPE_STRING }, 83 [IFACE_ATTR_IP6CLASS] = { .name = "ip6class", .type = BLOBMSG_TYPE_ARRAY }, 84 [IFACE_ATTR_DELEGATE] = { .name = "delegate", .type = BLOBMSG_TYPE_BOOL }, 85 [IFACE_ATTR_IP6IFACEID] = { .name = "ip6ifaceid", .type = BLOBMSG_TYPE_STRING }, 86 [IFACE_ATTR_FORCE_LINK] = { .name = "force_link", .type = BLOBMSG_TYPE_BOOL }, 87 [IFACE_ATTR_IP6WEIGHT] = { .name = "ip6weight", .type = BLOBMSG_TYPE_INT32 }, 88 }; 89 90 const struct uci_blob_param_list interface_attr_list = { 91 .n_params = IFACE_ATTR_MAX, 92 .params = iface_attrs, 93 }; 94 95 static void 96 interface_set_main_dev(struct interface *iface, struct device *dev); 97 static void 98 interface_event(struct interface *iface, enum interface_event ev); 99 100 static void 101 interface_error_flush(struct interface *iface) 102 { 103 struct interface_error *error, *tmp; 104 105 list_for_each_entry_safe(error, tmp, &iface->errors, list) { 106 list_del(&error->list); 107 free(error); 108 } 109 } 110 111 static bool 112 interface_force_link(struct interface *iface) 113 { 114 struct device *dev = iface->main_dev.dev; 115 116 if (dev && dev->settings.auth) 117 return false; 118 119 return iface->force_link; 120 } 121 122 static void 123 interface_clear_errors(struct interface *iface) 124 { 125 /* don't flush the errors in case the configured protocol handler matches the 126 running protocol handler and is having the last error capability */ 127 if (!(iface->proto && 128 (iface->proto->handler->flags & PROTO_FLAG_LASTERROR) && 129 (iface->proto->handler->name == iface->proto_handler->name))) 130 interface_error_flush(iface); 131 } 132 133 void interface_add_error(struct interface *iface, const char *subsystem, 134 const char *code, const char **data, int n_data) 135 { 136 struct interface_error *error; 137 int i, len = 0; 138 int *datalen = NULL; 139 char *dest, *d_subsys, *d_code; 140 141 /* if the configured protocol handler has the last error support capability, 142 errors should only be added if the running protocol handler matches the 143 configured one */ 144 if (iface->proto && 145 (iface->proto->handler->flags & PROTO_FLAG_LASTERROR) && 146 (iface->proto->handler->name != iface->proto_handler->name)) 147 return; 148 149 if (n_data) { 150 len = n_data * sizeof(char *); 151 datalen = alloca(len); 152 for (i = 0; i < n_data; i++) { 153 datalen[i] = strlen(data[i]) + 1; 154 len += datalen[i]; 155 } 156 } 157 158 error = calloc_a(sizeof(*error) + sizeof(char *) + len, 159 &d_subsys, subsystem ? strlen(subsystem) + 1 : 0, 160 &d_code, code ? strlen(code) + 1 : 0); 161 if (!error) 162 return; 163 164 /* Only keep the last flagged error, prevent this list grows unlimitted in case the 165 protocol can't be established (e.g auth failure) */ 166 if (iface->proto_handler->flags & PROTO_FLAG_LASTERROR) 167 interface_error_flush(iface); 168 169 list_add_tail(&error->list, &iface->errors); 170 171 dest = (char *) &error->data[n_data + 1]; 172 for (i = 0; i < n_data; i++) { 173 error->data[i] = dest; 174 memcpy(dest, data[i], datalen[i]); 175 dest += datalen[i]; 176 } 177 error->data[n_data] = NULL; 178 179 if (subsystem) 180 error->subsystem = strcpy(d_subsys, subsystem); 181 182 if (code) 183 error->code = strcpy(d_code, code); 184 } 185 186 static void 187 interface_data_del(struct interface *iface, struct interface_data *data) 188 { 189 avl_delete(&iface->data, &data->node); 190 free(data); 191 } 192 193 static void 194 interface_data_flush(struct interface *iface) 195 { 196 struct interface_data *d, *tmp; 197 198 avl_for_each_element_safe(&iface->data, d, node, tmp) 199 interface_data_del(iface, d); 200 } 201 202 int 203 interface_add_data(struct interface *iface, const struct blob_attr *data) 204 { 205 struct interface_data *n, *o; 206 207 if (!blobmsg_check_attr(data, true)) 208 return UBUS_STATUS_INVALID_ARGUMENT; 209 210 const char *name = blobmsg_name(data); 211 unsigned len = blob_pad_len(data); 212 213 o = avl_find_element(&iface->data, name, o, node); 214 if (o) { 215 if (blob_pad_len(o->data) == len && !memcmp(o->data, data, len)) 216 return 0; 217 218 interface_data_del(iface, o); 219 } 220 221 n = calloc(1, sizeof(*n) + len); 222 if (!n) 223 return UBUS_STATUS_UNKNOWN_ERROR; 224 225 memcpy(n->data, data, len); 226 n->node.key = blobmsg_name(n->data); 227 avl_insert(&iface->data, &n->node); 228 229 iface->updated |= IUF_DATA; 230 return 0; 231 } 232 233 int interface_parse_data(struct interface *iface, const struct blob_attr *attr) 234 { 235 struct blob_attr *cur; 236 size_t rem; 237 int ret; 238 239 iface->updated = 0; 240 241 blob_for_each_attr(cur, attr, rem) { 242 ret = interface_add_data(iface, cur); 243 if (ret) 244 return ret; 245 } 246 247 if (iface->updated && iface->state == IFS_UP) 248 interface_event(iface, IFEV_UPDATE); 249 250 return 0; 251 } 252 253 static void 254 interface_event(struct interface *iface, enum interface_event ev) 255 { 256 struct interface_user *dep, *tmp; 257 struct device *adev = NULL; 258 259 list_for_each_entry_safe(dep, tmp, &iface->users, list) 260 dep->cb(dep, iface, ev); 261 262 list_for_each_entry_safe(dep, tmp, &iface_all_users, list) 263 dep->cb(dep, iface, ev); 264 265 switch (ev) { 266 case IFEV_UP: 267 interface_error_flush(iface); 268 adev = iface->l3_dev.dev; 269 fallthrough; 270 case IFEV_DOWN: 271 case IFEV_UP_FAILED: 272 alias_notify_device(iface->name, adev); 273 break; 274 default: 275 break; 276 } 277 } 278 279 static void 280 interface_flush_state(struct interface *iface) 281 { 282 if (iface->l3_dev.dev) 283 device_release(&iface->l3_dev); 284 interface_data_flush(iface); 285 } 286 287 static void 288 mark_interface_down(struct interface *iface) 289 { 290 enum interface_state state = iface->state; 291 292 if (state == IFS_DOWN) 293 return; 294 295 iface->link_up_event = false; 296 iface->state = IFS_DOWN; 297 switch (state) { 298 case IFS_UP: 299 case IFS_TEARDOWN: 300 interface_event(iface, IFEV_DOWN); 301 break; 302 case IFS_SETUP: 303 interface_event(iface, IFEV_UP_FAILED); 304 break; 305 default: 306 break; 307 } 308 interface_ip_set_enabled(&iface->config_ip, false); 309 interface_ip_set_enabled(&iface->proto_ip, false); 310 interface_ip_flush(&iface->proto_ip); 311 interface_flush_state(iface); 312 system_flush_routes(); 313 } 314 315 static inline void 316 __set_config_state(struct interface *iface, enum interface_config_state s) 317 { 318 iface->config_state = s; 319 } 320 321 static void 322 __interface_set_down(struct interface *iface, bool force) 323 { 324 enum interface_state state = iface->state; 325 switch (state) { 326 case IFS_UP: 327 case IFS_SETUP: 328 iface->state = IFS_TEARDOWN; 329 if (iface->dynamic) 330 __set_config_state(iface, IFC_REMOVE); 331 332 if (state == IFS_UP) 333 interface_event(iface, IFEV_DOWN); 334 335 interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force); 336 if (force) 337 interface_flush_state(iface); 338 break; 339 340 case IFS_DOWN: 341 if (iface->main_dev.dev) 342 device_release(&iface->main_dev); 343 break; 344 case IFS_TEARDOWN: 345 default: 346 break; 347 } 348 } 349 350 static int 351 __interface_set_up(struct interface *iface) 352 { 353 int ret; 354 355 netifd_log_message(L_NOTICE, "Interface '%s' is setting up now\n", iface->name); 356 357 iface->state = IFS_SETUP; 358 ret = interface_proto_event(iface->proto, PROTO_CMD_SETUP, false); 359 if (ret) 360 mark_interface_down(iface); 361 362 return ret; 363 } 364 365 static void 366 interface_check_state(struct interface *iface) 367 { 368 bool link_state = iface->link_state || interface_force_link(iface); 369 370 switch (iface->state) { 371 case IFS_UP: 372 case IFS_SETUP: 373 if (!iface->enabled || !link_state) { 374 iface->state = IFS_TEARDOWN; 375 if (iface->dynamic) 376 __set_config_state(iface, IFC_REMOVE); 377 378 interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false); 379 } 380 break; 381 case IFS_DOWN: 382 if (!iface->available) 383 return; 384 385 if (iface->autostart && iface->enabled && link_state && !config_init) 386 __interface_set_up(iface); 387 break; 388 default: 389 break; 390 } 391 } 392 393 static void 394 interface_set_enabled(struct interface *iface, bool new_state) 395 { 396 if (iface->enabled == new_state) 397 return; 398 399 netifd_log_message(L_NOTICE, "Interface '%s' is %s\n", iface->name, new_state ? "enabled" : "disabled"); 400 iface->enabled = new_state; 401 interface_check_state(iface); 402 } 403 404 static void 405 interface_set_link_state(struct interface *iface, bool new_state) 406 { 407 if (iface->link_state == new_state) 408 return; 409 410 netifd_log_message(L_NOTICE, "Interface '%s' has link connectivity %s\n", iface->name, new_state ? "" : "loss"); 411 iface->link_state = new_state; 412 interface_check_state(iface); 413 414 if (new_state && interface_force_link(iface) && 415 iface->state == IFS_UP && !iface->link_up_event) { 416 interface_event(iface, IFEV_LINK_UP); 417 iface->link_up_event = true; 418 } 419 } 420 421 static void 422 interface_ext_dev_cb(struct device_user *dep, enum device_event ev) 423 { 424 if (ev == DEV_EVENT_REMOVE) 425 device_remove_user(dep); 426 } 427 428 static void 429 interface_main_dev_cb(struct device_user *dep, enum device_event ev) 430 { 431 struct interface *iface; 432 433 iface = container_of(dep, struct interface, main_dev); 434 switch (ev) { 435 case DEV_EVENT_ADD: 436 interface_set_available(iface, true); 437 break; 438 case DEV_EVENT_REMOVE: 439 interface_set_available(iface, false); 440 if (dep->dev && dep->dev->external && !dep->dev->sys_present) 441 interface_set_main_dev(iface, NULL); 442 break; 443 case DEV_EVENT_UP: 444 interface_set_enabled(iface, true); 445 break; 446 case DEV_EVENT_DOWN: 447 interface_set_enabled(iface, false); 448 break; 449 case DEV_EVENT_AUTH_UP: 450 case DEV_EVENT_LINK_UP: 451 case DEV_EVENT_LINK_DOWN: 452 interface_set_link_state(iface, device_link_active(dep->dev)); 453 break; 454 case DEV_EVENT_TOPO_CHANGE: 455 interface_proto_event(iface->proto, PROTO_CMD_RENEW, false); 456 return; 457 default: 458 break; 459 } 460 } 461 462 static void 463 interface_l3_dev_cb(struct device_user *dep, enum device_event ev) 464 { 465 struct interface *iface; 466 467 iface = container_of(dep, struct interface, l3_dev); 468 if (iface->l3_dev.dev == iface->main_dev.dev) 469 return; 470 471 switch (ev) { 472 case DEV_EVENT_LINK_DOWN: 473 if (iface->proto_handler->flags & PROTO_FLAG_TEARDOWN_ON_L3_LINK_DOWN) 474 interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, false); 475 break; 476 default: 477 break; 478 } 479 } 480 481 void 482 interface_set_available(struct interface *iface, bool new_state) 483 { 484 if (iface->available == new_state) 485 return; 486 487 D(INTERFACE, "Interface '%s', available=%d", iface->name, new_state); 488 iface->available = new_state; 489 490 if (new_state) { 491 if (iface->autostart && !config_init) 492 interface_set_up(iface); 493 } else 494 __interface_set_down(iface, true); 495 } 496 497 void 498 interface_add_user(struct interface_user *dep, struct interface *iface) 499 { 500 if (!iface) { 501 list_add(&dep->list, &iface_all_users); 502 return; 503 } 504 505 dep->iface = iface; 506 list_add(&dep->list, &iface->users); 507 if (iface->state == IFS_UP) 508 dep->cb(dep, iface, IFEV_UP); 509 } 510 511 void 512 interface_remove_user(struct interface_user *dep) 513 { 514 list_del_init(&dep->list); 515 dep->iface = NULL; 516 } 517 518 static void 519 interface_add_assignment_classes(struct interface *iface, struct blob_attr *list) 520 { 521 struct blob_attr *cur; 522 size_t rem; 523 524 blobmsg_for_each_attr(cur, list, rem) { 525 if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING) 526 continue; 527 528 if (!blobmsg_check_attr(cur, false)) 529 continue; 530 531 struct interface_assignment_class *c = malloc(sizeof(*c) + blobmsg_data_len(cur)); 532 memcpy(c->name, blobmsg_data(cur), blobmsg_data_len(cur)); 533 list_add(&c->head, &iface->assignment_classes); 534 } 535 } 536 537 static void 538 interface_clear_assignment_classes(struct interface *iface) 539 { 540 while (!list_empty(&iface->assignment_classes)) { 541 struct interface_assignment_class *c = list_first_entry(&iface->assignment_classes, 542 struct interface_assignment_class, head); 543 list_del(&c->head); 544 free(c); 545 } 546 } 547 548 static void 549 interface_merge_assignment_data(struct interface *old, struct interface *new) 550 { 551 bool changed = (old->assignment_hint != new->assignment_hint || 552 old->assignment_length != new->assignment_length || 553 old->assignment_iface_id_selection != new->assignment_iface_id_selection || 554 old->assignment_weight != new->assignment_weight || 555 (old->assignment_iface_id_selection == IFID_FIXED && 556 memcmp(&old->assignment_fixed_iface_id, &new->assignment_fixed_iface_id, 557 sizeof(old->assignment_fixed_iface_id))) || 558 list_empty(&old->assignment_classes) != list_empty(&new->assignment_classes)); 559 560 struct interface_assignment_class *c; 561 list_for_each_entry(c, &new->assignment_classes, head) { 562 /* Compare list entries one-by-one to see if there was a change */ 563 if (list_empty(&old->assignment_classes)) /* The new list is longer */ 564 changed = true; 565 566 if (changed) 567 break; 568 569 struct interface_assignment_class *c_old = list_first_entry(&old->assignment_classes, 570 struct interface_assignment_class, head); 571 572 if (strcmp(c_old->name, c->name)) /* An entry didn't match */ 573 break; 574 575 list_del(&c_old->head); 576 free(c_old); 577 } 578 579 /* The old list was longer than the new one or the last entry didn't match */ 580 if (!list_empty(&old->assignment_classes)) { 581 interface_clear_assignment_classes(old); 582 changed = true; 583 } 584 585 list_splice_init(&new->assignment_classes, &old->assignment_classes); 586 587 if (changed) { 588 old->assignment_hint = new->assignment_hint; 589 old->assignment_length = new->assignment_length; 590 old->assignment_iface_id_selection = new->assignment_iface_id_selection; 591 old->assignment_fixed_iface_id = new->assignment_fixed_iface_id; 592 old->assignment_weight = new->assignment_weight; 593 interface_refresh_assignments(true); 594 } 595 } 596 597 static void 598 interface_alias_cb(struct interface_user *dep, struct interface *iface, enum interface_event ev) 599 { 600 struct interface *alias = container_of(dep, struct interface, parent_iface); 601 struct device *dev = iface->l3_dev.dev; 602 603 switch (ev) { 604 case IFEV_UP: 605 if (!dev) 606 return; 607 608 interface_set_main_dev(alias, dev); 609 interface_set_available(alias, true); 610 break; 611 case IFEV_DOWN: 612 case IFEV_UP_FAILED: 613 interface_set_available(alias, false); 614 interface_set_main_dev(alias, NULL); 615 break; 616 case IFEV_FREE: 617 interface_remove_user(dep); 618 break; 619 default: 620 break; 621 } 622 } 623 624 static void 625 interface_set_device_config(struct interface *iface, struct device *dev) 626 { 627 if (!dev || !dev->default_config) 628 return; 629 630 if (!iface->device_config && 631 (!dev->iface_config || dev->config_iface != iface)) 632 return; 633 634 dev->config_iface = iface; 635 dev->iface_config = iface->device_config; 636 device_apply_config(dev, dev->type, iface->config); 637 } 638 639 static void 640 interface_claim_device(struct interface *iface) 641 { 642 struct interface *parent; 643 struct device *dev = NULL; 644 645 if (iface->parent_iface.iface) 646 interface_remove_user(&iface->parent_iface); 647 648 if (iface->parent_ifname) { 649 parent = vlist_find(&interfaces, iface->parent_ifname, parent, node); 650 iface->parent_iface.cb = interface_alias_cb; 651 interface_add_user(&iface->parent_iface, parent); 652 } else if (iface->device && 653 !(iface->proto_handler->flags & PROTO_FLAG_NODEV)) { 654 dev = device_get(iface->device, true); 655 interface_set_device_config(iface, dev); 656 } else { 657 dev = iface->ext_dev.dev; 658 } 659 660 if (dev) 661 interface_set_main_dev(iface, dev); 662 663 if (iface->proto_handler->flags & PROTO_FLAG_INIT_AVAILABLE) 664 interface_set_available(iface, true); 665 } 666 667 static void 668 interface_cleanup_state(struct interface *iface) 669 { 670 interface_set_available(iface, false); 671 672 interface_flush_state(iface); 673 interface_clear_errors(iface); 674 interface_set_proto_state(iface, NULL); 675 676 interface_set_main_dev(iface, NULL); 677 interface_set_l3_dev(iface, NULL); 678 } 679 680 static void 681 interface_cleanup(struct interface *iface) 682 { 683 struct interface_user *dep, *tmp; 684 685 uloop_timeout_cancel(&iface->remove_timer); 686 device_remove_user(&iface->ext_dev); 687 688 if (iface->parent_iface.iface) 689 interface_remove_user(&iface->parent_iface); 690 691 list_for_each_entry_safe(dep, tmp, &iface->users, list) 692 interface_remove_user(dep); 693 694 interface_clear_assignment_classes(iface); 695 interface_ip_flush(&iface->config_ip); 696 interface_cleanup_state(iface); 697 } 698 699 static void 700 interface_do_free(struct interface *iface) 701 { 702 interface_event(iface, IFEV_FREE); 703 interface_cleanup(iface); 704 free(iface->config); 705 netifd_ubus_remove_interface(iface); 706 avl_delete(&interfaces.avl, &iface->node.avl); 707 if (iface->jail) 708 free(iface->jail); 709 if (iface->jail_device) 710 free(iface->jail_device); 711 if (iface->host_device) 712 free(iface->host_device); 713 714 free(iface); 715 } 716 717 static void 718 interface_do_reload(struct interface *iface) 719 { 720 interface_event(iface, IFEV_RELOAD); 721 interface_cleanup_state(iface); 722 proto_init_interface(iface, iface->config); 723 interface_claim_device(iface); 724 } 725 726 static void 727 interface_handle_config_change(struct interface *iface) 728 { 729 enum interface_config_state state = iface->config_state; 730 731 iface->config_state = IFC_NORMAL; 732 switch(state) { 733 case IFC_NORMAL: 734 break; 735 case IFC_RELOAD: 736 interface_do_reload(iface); 737 break; 738 case IFC_REMOVE: 739 interface_do_free(iface); 740 return; 741 } 742 if (iface->autostart) 743 interface_set_up(iface); 744 } 745 746 static void 747 interface_proto_event_cb(struct interface_proto_state *state, enum interface_proto_event ev) 748 { 749 struct interface *iface = state->iface; 750 751 switch (ev) { 752 case IFPEV_UP: 753 if (iface->state != IFS_SETUP) { 754 if (iface->state == IFS_UP && iface->updated) 755 interface_event(iface, IFEV_UPDATE); 756 return; 757 } 758 759 if (!iface->l3_dev.dev) 760 interface_set_l3_dev(iface, iface->main_dev.dev); 761 762 interface_ip_set_enabled(&iface->config_ip, true); 763 interface_ip_set_enabled(&iface->proto_ip, true); 764 system_flush_routes(); 765 iface->state = IFS_UP; 766 iface->start_time = system_get_rtime(); 767 interface_event(iface, IFEV_UP); 768 netifd_log_message(L_NOTICE, "Interface '%s' is now up\n", iface->name); 769 break; 770 case IFPEV_DOWN: 771 if (iface->state == IFS_DOWN) 772 return; 773 774 netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name); 775 mark_interface_down(iface); 776 interface_write_resolv_conf(iface->jail); 777 if (iface->main_dev.dev && !(iface->config_state == IFC_NORMAL && iface->autostart && iface->available)) 778 device_release(&iface->main_dev); 779 if (iface->l3_dev.dev) 780 device_remove_user(&iface->l3_dev); 781 interface_handle_config_change(iface); 782 return; 783 case IFPEV_LINK_LOST: 784 if (iface->state != IFS_UP) 785 return; 786 787 netifd_log_message(L_NOTICE, "Interface '%s' has lost the connection\n", iface->name); 788 mark_interface_down(iface); 789 iface->state = IFS_SETUP; 790 break; 791 default: 792 return; 793 } 794 795 interface_write_resolv_conf(iface->jail); 796 } 797 798 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state) 799 { 800 if (iface->proto) { 801 iface->proto->free(iface->proto); 802 iface->proto = NULL; 803 } 804 iface->state = IFS_DOWN; 805 iface->proto = state; 806 if (!state) 807 return; 808 809 state->proto_event = interface_proto_event_cb; 810 state->iface = iface; 811 } 812 813 struct interface * 814 interface_alloc(const char *name, struct blob_attr *config, bool dynamic) 815 { 816 struct interface *iface; 817 struct blob_attr *tb[IFACE_ATTR_MAX]; 818 struct blob_attr *cur; 819 const char *proto_name = NULL; 820 char *iface_name; 821 bool force_link = false; 822 823 iface = calloc_a(sizeof(*iface), &iface_name, strlen(name) + 1); 824 iface->name = strcpy(iface_name, name); 825 INIT_LIST_HEAD(&iface->errors); 826 INIT_LIST_HEAD(&iface->users); 827 INIT_LIST_HEAD(&iface->hotplug_list); 828 INIT_LIST_HEAD(&iface->assignment_classes); 829 interface_ip_init(iface); 830 avl_init(&iface->data, avl_strcmp, false, NULL); 831 iface->config_ip.enabled = false; 832 833 iface->main_dev.cb = interface_main_dev_cb; 834 iface->l3_dev.cb = interface_l3_dev_cb; 835 iface->ext_dev.cb = interface_ext_dev_cb; 836 837 blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, 838 blob_data(config), blob_len(config)); 839 840 iface->zone = NULL; 841 if ((cur = tb[IFACE_ATTR_ZONE])) 842 iface->zone = strdup(blobmsg_get_string(cur)); 843 844 if ((cur = tb[IFACE_ATTR_PROTO])) 845 proto_name = blobmsg_data(cur); 846 847 proto_attach_interface(iface, proto_name); 848 if (iface->proto_handler->flags & PROTO_FLAG_FORCE_LINK_DEFAULT) 849 force_link = true; 850 851 iface->autostart = blobmsg_get_bool_default(tb[IFACE_ATTR_AUTO], true); 852 iface->force_link = blobmsg_get_bool_default(tb[IFACE_ATTR_FORCE_LINK], force_link); 853 iface->dynamic = dynamic; 854 iface->proto_ip.no_defaultroute = 855 !blobmsg_get_bool_default(tb[IFACE_ATTR_DEFAULTROUTE], true); 856 iface->proto_ip.no_dns = 857 !blobmsg_get_bool_default(tb[IFACE_ATTR_PEERDNS], true); 858 859 if ((cur = tb[IFACE_ATTR_DNS])) 860 interface_add_dns_server_list(&iface->config_ip, cur); 861 862 if ((cur = tb[IFACE_ATTR_DNS_SEARCH])) 863 interface_add_dns_search_list(&iface->config_ip, cur); 864 865 if ((cur = tb[IFACE_ATTR_DNS_METRIC])) 866 iface->dns_metric = blobmsg_get_u32(cur); 867 868 if ((cur = tb[IFACE_ATTR_METRIC])) 869 iface->metric = blobmsg_get_u32(cur); 870 871 if ((cur = tb[IFACE_ATTR_IP6ASSIGN])) 872 iface->assignment_length = blobmsg_get_u32(cur); 873 874 /* defaults */ 875 iface->assignment_iface_id_selection = IFID_FIXED; 876 iface->assignment_fixed_iface_id = in6addr_any; 877 iface->assignment_fixed_iface_id.s6_addr[15] = 1; 878 879 if ((cur = tb[IFACE_ATTR_IP6IFACEID])) { 880 const char *ifaceid = blobmsg_data(cur); 881 if (!strcmp(ifaceid, "random")) { 882 iface->assignment_iface_id_selection = IFID_RANDOM; 883 } 884 else if (!strcmp(ifaceid, "eui64")) { 885 iface->assignment_iface_id_selection = IFID_EUI64; 886 } 887 else { 888 /* we expect an IPv6 address with network id zero here -> fixed iface id 889 if we cannot parse -> revert to iface id 1 */ 890 if (inet_pton(AF_INET6,ifaceid,&iface->assignment_fixed_iface_id) != 1 || 891 iface->assignment_fixed_iface_id.s6_addr32[0] != 0 || 892 iface->assignment_fixed_iface_id.s6_addr32[1] != 0) { 893 iface->assignment_fixed_iface_id = in6addr_any; 894 iface->assignment_fixed_iface_id.s6_addr[15] = 1; 895 netifd_log_message(L_WARNING, "Failed to parse ip6ifaceid for interface '%s', \ 896 falling back to iface id 1.\n", iface->name); 897 } 898 } 899 } 900 901 iface->assignment_hint = -1; 902 if ((cur = tb[IFACE_ATTR_IP6HINT])) 903 iface->assignment_hint = strtol(blobmsg_get_string(cur), NULL, 16) & 904 ~((1 << (64 - iface->assignment_length)) - 1); 905 906 if ((cur = tb[IFACE_ATTR_IP6CLASS])) 907 interface_add_assignment_classes(iface, cur); 908 909 if ((cur = tb[IFACE_ATTR_IP6WEIGHT])) 910 iface->assignment_weight = blobmsg_get_u32(cur); 911 912 if ((cur = tb[IFACE_ATTR_IP4TABLE])) { 913 if (!system_resolve_rt_table(blobmsg_data(cur), &iface->ip4table)) 914 D(INTERFACE, "Failed to resolve routing table: %s", (char *) blobmsg_data(cur)); 915 } 916 917 if ((cur = tb[IFACE_ATTR_IP6TABLE])) { 918 if (!system_resolve_rt_table(blobmsg_data(cur), &iface->ip6table)) 919 D(INTERFACE, "Failed to resolve routing table: %s", (char *) blobmsg_data(cur)); 920 } 921 922 iface->proto_ip.no_delegation = !blobmsg_get_bool_default(tb[IFACE_ATTR_DELEGATE], true); 923 924 iface->config_autostart = iface->autostart; 925 iface->jail = NULL; 926 927 if ((cur = tb[IFACE_ATTR_JAIL])) { 928 iface->jail = strdup(blobmsg_get_string(cur)); 929 iface->autostart = false; 930 } 931 932 iface->jail_device = NULL; 933 if ((cur = tb[IFACE_ATTR_JAIL_DEVICE])) 934 iface->jail_device = strdup(blobmsg_get_string(cur)); 935 else if ((cur = tb[IFACE_ATTR_JAIL_IFNAME])) 936 iface->jail_device = strdup(blobmsg_get_string(cur)); 937 938 iface->host_device = NULL; 939 if ((cur = tb[IFACE_ATTR_HOST_DEVICE])) 940 iface->host_device = strdup(blobmsg_get_string(cur)); 941 942 return iface; 943 } 944 945 static bool __interface_add(struct interface *iface, struct blob_attr *config, bool alias) 946 { 947 struct blob_attr *tb[IFACE_ATTR_MAX]; 948 struct blob_attr *cur; 949 char *name = NULL; 950 951 blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, 952 blob_data(config), blob_len(config)); 953 954 if (alias) { 955 if ((cur = tb[IFACE_ATTR_INTERFACE])) 956 iface->parent_ifname = blobmsg_data(cur); 957 958 if (!iface->parent_ifname) 959 return false; 960 } else { 961 cur = tb[IFACE_ATTR_DEVICE]; 962 if (!cur) 963 cur = tb[IFACE_ATTR_IFNAME]; 964 if (cur) 965 iface->device = blobmsg_data(cur); 966 } 967 968 if (iface->dynamic) { 969 name = strdup(iface->name); 970 971 if (!name) 972 return false; 973 } 974 975 iface->config = config; 976 vlist_add(&interfaces, &iface->node, iface->name); 977 978 if (name) { 979 iface = vlist_find(&interfaces, name, iface, node); 980 free(name); 981 982 /* Don't delete dynamic interface on reload */ 983 if (iface) 984 iface->node.version = -1; 985 } 986 987 return true; 988 } 989 990 bool 991 interface_add(struct interface *iface, struct blob_attr *config) 992 { 993 return __interface_add(iface, config, false); 994 } 995 996 bool 997 interface_add_alias(struct interface *iface, struct blob_attr *config) 998 { 999 if (iface->proto_handler->flags & PROTO_FLAG_NODEV) 1000 return false; 1001 1002 return __interface_add(iface, config, true); 1003 } 1004 1005 void 1006 interface_set_l3_dev(struct interface *iface, struct device *dev) 1007 { 1008 bool enabled = iface->config_ip.enabled; 1009 bool claimed = iface->l3_dev.claimed; 1010 1011 if (iface->l3_dev.dev == dev) 1012 return; 1013 1014 interface_ip_set_enabled(&iface->config_ip, false); 1015 interface_ip_set_enabled(&iface->proto_ip, false); 1016 interface_ip_flush(&iface->proto_ip); 1017 device_add_user(&iface->l3_dev, dev); 1018 1019 if (dev) { 1020 if (claimed) { 1021 if (device_claim(&iface->l3_dev) < 0) 1022 return; 1023 } 1024 interface_ip_set_enabled(&iface->config_ip, enabled); 1025 interface_ip_set_enabled(&iface->proto_ip, enabled); 1026 } 1027 } 1028 1029 static void 1030 interface_set_main_dev(struct interface *iface, struct device *dev) 1031 { 1032 bool claimed = iface->l3_dev.claimed; 1033 1034 if (iface->main_dev.dev == dev) 1035 return; 1036 1037 interface_set_available(iface, false); 1038 device_add_user(&iface->main_dev, dev); 1039 if (!dev) { 1040 interface_set_link_state(iface, false); 1041 return; 1042 } 1043 1044 if (claimed) { 1045 if (device_claim(&iface->l3_dev) < 0) 1046 return; 1047 } 1048 1049 if (!iface->l3_dev.dev) 1050 interface_set_l3_dev(iface, dev); 1051 } 1052 1053 static int 1054 interface_remove_link(struct interface *iface, struct device *dev, 1055 struct blob_attr *vlan) 1056 { 1057 struct device *mdev = iface->main_dev.dev; 1058 1059 if (mdev && mdev->hotplug_ops) 1060 return mdev->hotplug_ops->del(mdev, dev, vlan); 1061 1062 if (dev == iface->ext_dev.dev) 1063 device_remove_user(&iface->ext_dev); 1064 1065 if (!iface->main_dev.hotplug) 1066 return UBUS_STATUS_INVALID_ARGUMENT; 1067 1068 if (dev != iface->main_dev.dev) 1069 return UBUS_STATUS_INVALID_ARGUMENT; 1070 1071 interface_set_main_dev(iface, NULL); 1072 return 0; 1073 } 1074 1075 static int 1076 interface_add_link(struct interface *iface, struct device *dev, 1077 struct blob_attr *vlan, bool link_ext) 1078 { 1079 struct device *mdev = iface->main_dev.dev; 1080 1081 if (mdev == dev) 1082 return 0; 1083 1084 if (iface->main_dev.hotplug) 1085 device_remove_user(&iface->main_dev); 1086 1087 if (mdev) { 1088 if (mdev->hotplug_ops) 1089 return mdev->hotplug_ops->add(mdev, dev, vlan); 1090 else 1091 return UBUS_STATUS_NOT_SUPPORTED; 1092 } 1093 1094 if (link_ext) 1095 device_add_user(&iface->ext_dev, dev); 1096 1097 interface_set_main_dev(iface, dev); 1098 iface->main_dev.hotplug = true; 1099 return 0; 1100 } 1101 1102 int 1103 interface_handle_link(struct interface *iface, const char *name, 1104 struct blob_attr *vlan, bool add, bool link_ext) 1105 { 1106 struct device *dev; 1107 1108 dev = device_get(name, add ? (link_ext ? 2 : 1) : 0); 1109 if (!dev) 1110 return UBUS_STATUS_NOT_FOUND; 1111 1112 if (!add) 1113 return interface_remove_link(iface, dev, vlan); 1114 1115 interface_set_device_config(iface, dev); 1116 if (!link_ext) 1117 device_set_present(dev, true); 1118 1119 return interface_add_link(iface, dev, vlan, link_ext); 1120 } 1121 1122 void 1123 interface_set_up(struct interface *iface) 1124 { 1125 int ret; 1126 const char *error = NULL; 1127 1128 iface->autostart = true; 1129 wireless_check_network_enabled(); 1130 1131 if (iface->state != IFS_DOWN) 1132 return; 1133 1134 interface_clear_errors(iface); 1135 if (iface->available) { 1136 if (iface->main_dev.dev) { 1137 ret = device_claim(&iface->main_dev); 1138 if (!ret) 1139 interface_check_state(iface); 1140 else 1141 error = "DEVICE_CLAIM_FAILED"; 1142 } else { 1143 ret = __interface_set_up(iface); 1144 if (ret) 1145 error = "SETUP_FAILED"; 1146 } 1147 } else 1148 error = "NO_DEVICE"; 1149 1150 if (error) 1151 interface_add_error(iface, "interface", error, NULL, 0); 1152 } 1153 1154 void 1155 interface_set_down(struct interface *iface) 1156 { 1157 if (!iface) { 1158 vlist_for_each_element(&interfaces, iface, node) 1159 __interface_set_down(iface, false); 1160 } else { 1161 iface->autostart = false; 1162 wireless_check_network_enabled(); 1163 __interface_set_down(iface, false); 1164 } 1165 } 1166 1167 int 1168 interface_renew(struct interface *iface) 1169 { 1170 if (iface->state == IFS_TEARDOWN || iface->state == IFS_DOWN) 1171 return -1; 1172 1173 return interface_proto_event(iface->proto, PROTO_CMD_RENEW, false); 1174 } 1175 1176 void 1177 interface_start_pending(void) 1178 { 1179 struct interface *iface; 1180 1181 vlist_for_each_element(&interfaces, iface, node) { 1182 if (iface->autostart) 1183 interface_set_up(iface); 1184 } 1185 } 1186 1187 void 1188 interface_start_jail(int netns_fd, const char *jail) 1189 { 1190 struct interface *iface; 1191 1192 vlist_for_each_element(&interfaces, iface, node) { 1193 if (!iface->jail || strcmp(iface->jail, jail)) 1194 continue; 1195 1196 system_link_netns_move(iface->main_dev.dev, netns_fd, iface->jail_device); 1197 } 1198 } 1199 1200 void 1201 interface_stop_jail(int netns_fd) 1202 { 1203 struct interface *iface; 1204 char *orig_ifname; 1205 1206 vlist_for_each_element(&interfaces, iface, node) { 1207 orig_ifname = iface->host_device; 1208 interface_set_down(iface); 1209 system_link_netns_move(iface->main_dev.dev, netns_fd, orig_ifname); 1210 } 1211 } 1212 1213 static void 1214 set_config_state(struct interface *iface, enum interface_config_state s) 1215 { 1216 __set_config_state(iface, s); 1217 if (iface->state == IFS_DOWN) 1218 interface_handle_config_change(iface); 1219 else 1220 __interface_set_down(iface, false); 1221 } 1222 1223 void 1224 interface_update_start(struct interface *iface, const bool keep_old) 1225 { 1226 iface->updated = 0; 1227 1228 if (!keep_old) 1229 interface_ip_update_start(&iface->proto_ip); 1230 } 1231 1232 void 1233 interface_update_complete(struct interface *iface) 1234 { 1235 interface_ip_update_complete(&iface->proto_ip); 1236 } 1237 1238 static void 1239 interface_replace_dns(struct interface_ip_settings *new, struct interface_ip_settings *old) 1240 { 1241 vlist_simple_replace(&new->dns_servers, &old->dns_servers); 1242 vlist_simple_replace(&new->dns_search, &old->dns_search); 1243 } 1244 1245 static bool 1246 interface_device_config_changed(struct interface *if_old, struct interface *if_new) 1247 { 1248 struct blob_attr *ntb[__DEV_ATTR_MAX]; 1249 struct blob_attr *otb[__DEV_ATTR_MAX]; 1250 struct device *dev = if_old->main_dev.dev; 1251 unsigned long diff[2] = {}; 1252 1253 BUILD_BUG_ON(sizeof(diff) < __DEV_ATTR_MAX / 8); 1254 1255 if (!dev) 1256 return false; 1257 1258 if (if_old->device_config != if_new->device_config) 1259 return true; 1260 1261 if (!if_new->device_config) 1262 return false; 1263 1264 blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, otb, 1265 blob_data(if_old->config), blob_len(if_old->config)); 1266 1267 blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, ntb, 1268 blob_data(if_new->config), blob_len(if_new->config)); 1269 1270 uci_blob_diff(ntb, otb, &device_attr_list, diff); 1271 1272 return diff[0] | diff[1]; 1273 } 1274 1275 static void 1276 interface_change_config(struct interface *if_old, struct interface *if_new) 1277 { 1278 struct blob_attr *old_config = if_old->config; 1279 bool reload = false, reload_ip = false, update_prefix_delegation = false; 1280 1281 #define FIELD_CHANGED_STR(field) \ 1282 ((!!if_old->field != !!if_new->field) || \ 1283 (if_old->field && \ 1284 strcmp(if_old->field, if_new->field) != 0)) 1285 1286 if (FIELD_CHANGED_STR(parent_ifname)) { 1287 if (if_old->parent_iface.iface) 1288 interface_remove_user(&if_old->parent_iface); 1289 reload = true; 1290 } 1291 1292 if (!reload && interface_device_config_changed(if_old, if_new)) 1293 reload = true; 1294 1295 if (FIELD_CHANGED_STR(device) || 1296 if_old->proto_handler != if_new->proto_handler) 1297 reload = true; 1298 1299 if (!if_old->proto_handler->config_params) 1300 D(INTERFACE, "No config parameters for interface '%s'", 1301 if_old->name); 1302 else if (!uci_blob_check_equal(if_old->config, if_new->config, 1303 if_old->proto_handler->config_params)) 1304 reload = true; 1305 1306 #define UPDATE(field, __var) ({ \ 1307 bool __changed = (if_old->field != if_new->field); \ 1308 if_old->field = if_new->field; \ 1309 __var |= __changed; \ 1310 }) 1311 1312 if_old->config = if_new->config; 1313 if (if_old->config_autostart != if_new->config_autostart) { 1314 if (if_old->config_autostart) 1315 reload = true; 1316 1317 if_old->autostart = if_new->config_autostart; 1318 } 1319 1320 if_old->device_config = if_new->device_config; 1321 if_old->config_autostart = if_new->config_autostart; 1322 if (if_old->jail) 1323 free(if_old->jail); 1324 1325 if_old->jail = if_new->jail; 1326 if (if_old->jail) 1327 if_old->autostart = false; 1328 1329 if (if_old->jail_device) 1330 free(if_old->jail_device); 1331 1332 if_old->jail_device = if_new->jail_device; 1333 1334 if (if_old->host_device) 1335 free(if_old->host_device); 1336 1337 if_old->host_device = if_new->host_device; 1338 1339 if_old->device = if_new->device; 1340 if_old->parent_ifname = if_new->parent_ifname; 1341 if_old->dynamic = if_new->dynamic; 1342 if_old->proto_handler = if_new->proto_handler; 1343 if_old->force_link = if_new->force_link; 1344 if_old->dns_metric = if_new->dns_metric; 1345 1346 if (if_old->proto_ip.no_delegation != if_new->proto_ip.no_delegation) { 1347 if_old->proto_ip.no_delegation = if_new->proto_ip.no_delegation; 1348 update_prefix_delegation = true; 1349 } 1350 1351 if_old->proto_ip.no_dns = if_new->proto_ip.no_dns; 1352 interface_replace_dns(&if_old->config_ip, &if_new->config_ip); 1353 1354 UPDATE(metric, reload_ip); 1355 UPDATE(proto_ip.no_defaultroute, reload_ip); 1356 UPDATE(ip4table, reload_ip); 1357 UPDATE(ip6table, reload_ip); 1358 interface_merge_assignment_data(if_old, if_new); 1359 1360 #undef UPDATE 1361 1362 if (reload) { 1363 D(INTERFACE, "Reload interface '%s' because of config changes", 1364 if_old->name); 1365 interface_clear_errors(if_old); 1366 set_config_state(if_old, IFC_RELOAD); 1367 goto out; 1368 } 1369 1370 if (reload_ip) { 1371 bool config_ip_enabled = if_old->config_ip.enabled; 1372 bool proto_ip_enabled = if_old->proto_ip.enabled; 1373 1374 interface_ip_set_enabled(&if_old->config_ip, false); 1375 interface_ip_set_enabled(&if_old->proto_ip, false); 1376 interface_ip_set_enabled(&if_old->proto_ip, proto_ip_enabled); 1377 interface_ip_set_enabled(&if_old->config_ip, config_ip_enabled); 1378 } 1379 1380 if (update_prefix_delegation) 1381 interface_update_prefix_delegation(&if_old->proto_ip); 1382 1383 interface_write_resolv_conf(if_old->jail); 1384 if (if_old->main_dev.dev) 1385 interface_check_state(if_old); 1386 1387 out: 1388 if_new->config = NULL; 1389 interface_cleanup(if_new); 1390 free(old_config); 1391 free(if_new); 1392 } 1393 1394 static void 1395 interface_update(struct vlist_tree *tree, struct vlist_node *node_new, 1396 struct vlist_node *node_old) 1397 { 1398 struct interface *if_old = container_of(node_old, struct interface, node); 1399 struct interface *if_new = container_of(node_new, struct interface, node); 1400 1401 if (node_old && node_new) { 1402 D(INTERFACE, "Update interface '%s'", if_new->name); 1403 interface_change_config(if_old, if_new); 1404 } else if (node_old) { 1405 D(INTERFACE, "Remove interface '%s'", if_old->name); 1406 set_config_state(if_old, IFC_REMOVE); 1407 } else if (node_new) { 1408 D(INTERFACE, "Create interface '%s'", if_new->name); 1409 interface_event(if_new, IFEV_CREATE); 1410 proto_init_interface(if_new, if_new->config); 1411 interface_claim_device(if_new); 1412 netifd_ubus_add_interface(if_new); 1413 } 1414 } 1415 1416 1417 static void __init 1418 interface_init_list(void) 1419 { 1420 vlist_init(&interfaces, avl_strcmp, interface_update); 1421 interfaces.keep_old = true; 1422 interfaces.no_delete = true; 1423 } 1424
This page was automatically generated by LXR 0.3.1. • OpenWrt