* ifp - must be IFT_LOOP */
| 535 | * ifp - must be IFT_LOOP |
| 536 | */ |
| 537 | static int |
| 538 | in6_ifattach_loopback(struct ifnet *ifp) |
| 539 | { |
| 540 | struct in6_aliasreq ifra; |
| 541 | int error; |
| 542 | |
| 543 | in6_prepare_ifra(&ifra, &in6addr_loopback, &in6mask128); |
| 544 | |
| 545 | /* |
| 546 | * Always initialize ia_dstaddr (= broadcast address) to loopback |
| 547 | * address. Follows IPv4 practice - see in_ifinit(). |
| 548 | */ |
| 549 | ifra.ifra_dstaddr.sin6_len = sizeof(struct sockaddr_in6); |
| 550 | ifra.ifra_dstaddr.sin6_family = AF_INET6; |
| 551 | ifra.ifra_dstaddr.sin6_addr = in6addr_loopback; |
| 552 | |
| 553 | /* the loopback address should NEVER expire. */ |
| 554 | ifra.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; |
| 555 | ifra.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; |
| 556 | |
| 557 | /* |
| 558 | * We are sure that this is a newly assigned address, so we can set |
| 559 | * NULL to the 3rd arg. |
| 560 | */ |
| 561 | if ((error = in6_update_ifa(ifp, &ifra, NULL, 0)) != 0) { |
| 562 | nd6log((LOG_ERR, "in6_ifattach_loopback: failed to configure " |
| 563 | "the loopback address on %s (errno=%d)\n", |
| 564 | if_name(ifp), error)); |
| 565 | return (-1); |
| 566 | } |
| 567 | |
| 568 | return 0; |
| 569 | } |
| 570 | |
| 571 | /* |
| 572 | * compute NI group address, based on the current hostname setting. |
no test coverage detected