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

Function regen_tmpaddr

freebsd/netinet6/nd6.c:1082–1147  ·  view source on GitHub ↗

* ia6 - deprecated/invalidated temporary address */

Source from the content-addressed store, hash-verified

1080 * ia6 - deprecated/invalidated temporary address
1081 */
1082static int
1083regen_tmpaddr(struct in6_ifaddr *ia6)
1084{
1085 struct ifaddr *ifa;
1086 struct ifnet *ifp;
1087 struct in6_ifaddr *public_ifa6 = NULL;
1088
1089 NET_EPOCH_ASSERT();
1090
1091 ifp = ia6->ia_ifa.ifa_ifp;
1092 CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
1093 struct in6_ifaddr *it6;
1094
1095 if (ifa->ifa_addr->sa_family != AF_INET6)
1096 continue;
1097
1098 it6 = (struct in6_ifaddr *)ifa;
1099
1100 /* ignore no autoconf addresses. */
1101 if ((it6->ia6_flags & IN6_IFF_AUTOCONF) == 0)
1102 continue;
1103
1104 /* ignore autoconf addresses with different prefixes. */
1105 if (it6->ia6_ndpr == NULL || it6->ia6_ndpr != ia6->ia6_ndpr)
1106 continue;
1107
1108 /*
1109 * Now we are looking at an autoconf address with the same
1110 * prefix as ours. If the address is temporary and is still
1111 * preferred, do not create another one. It would be rare, but
1112 * could happen, for example, when we resume a laptop PC after
1113 * a long period.
1114 */
1115 if ((it6->ia6_flags & IN6_IFF_TEMPORARY) != 0 &&
1116 !IFA6_IS_DEPRECATED(it6)) {
1117 public_ifa6 = NULL;
1118 break;
1119 }
1120
1121 /*
1122 * This is a public autoconf address that has the same prefix
1123 * as ours. If it is preferred, keep it. We can't break the
1124 * loop here, because there may be a still-preferred temporary
1125 * address with the prefix.
1126 */
1127 if (!IFA6_IS_DEPRECATED(it6))
1128 public_ifa6 = it6;
1129 }
1130 if (public_ifa6 != NULL)
1131 ifa_ref(&public_ifa6->ia_ifa);
1132
1133 if (public_ifa6 != NULL) {
1134 int e;
1135
1136 if ((e = in6_tmpifadd(public_ifa6, 0, 0)) != 0) {
1137 ifa_free(&public_ifa6->ia_ifa);
1138 log(LOG_NOTICE, "regen_tmpaddr: failed to create a new"
1139 " tmp addr,errno=%d\n", e);

Callers 1

nd6_timerFunction · 0.85

Calls 4

ifa_refFunction · 0.85
in6_tmpifaddFunction · 0.85
ifa_freeFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected