MCPcopy Create free account
hub / github.com/F-Stack/f-stack / in6_ifattach_loopback

Function in6_ifattach_loopback

freebsd/netinet6/in6_ifattach.c:537–569  ·  view source on GitHub ↗

* ifp - must be IFT_LOOP */

Source from the content-addressed store, hash-verified

535 * ifp - must be IFT_LOOP
536 */
537static int
538in6_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.

Callers 1

in6_ifattachFunction · 0.85

Calls 2

in6_prepare_ifraFunction · 0.85
in6_update_ifaFunction · 0.85

Tested by

no test coverage detected