Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/nd6_rtr.c
Show First 20 Lines • Show All 1,343 Lines • ▼ Show 20 Lines | nd6_prelist_add(struct nd_prefixctl *pr, struct nd_defrouter *dr, | ||||
struct nd_prefix *new; | struct nd_prefix *new; | ||||
char ip6buf[INET6_ADDRSTRLEN]; | char ip6buf[INET6_ADDRSTRLEN]; | ||||
int error; | int error; | ||||
new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO); | new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO); | ||||
if (new == NULL) | if (new == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
refcount_init(&new->ndpr_refcnt, newp != NULL ? 2 : 1); | refcount_init(&new->ndpr_refcnt, newp != NULL ? 2 : 1); | ||||
new->ndpr_num_autoconf_addrs = 0; | |||||
melifaro: Is this needed given `M_ZERO` above? | |||||
new->ndpr_ifp = pr->ndpr_ifp; | new->ndpr_ifp = pr->ndpr_ifp; | ||||
new->ndpr_prefix = pr->ndpr_prefix; | new->ndpr_prefix = pr->ndpr_prefix; | ||||
new->ndpr_plen = pr->ndpr_plen; | new->ndpr_plen = pr->ndpr_plen; | ||||
new->ndpr_vltime = pr->ndpr_vltime; | new->ndpr_vltime = pr->ndpr_vltime; | ||||
new->ndpr_pltime = pr->ndpr_pltime; | new->ndpr_pltime = pr->ndpr_pltime; | ||||
new->ndpr_flags = pr->ndpr_flags; | new->ndpr_flags = pr->ndpr_flags; | ||||
if ((error = in6_init_prefix_ltimes(new)) != 0) { | if ((error = in6_init_prefix_ltimes(new)) != 0) { | ||||
free(new, M_IP6NDP); | free(new, M_IP6NDP); | ||||
▲ Show 20 Lines • Show All 376 Lines • ▼ Show 20 Lines | if (ifidlen + pr->ndpr_plen != 128) { | ||||
goto end; | goto end; | ||||
} | } | ||||
if ((ia6 = in6_ifadd(new, mcast)) != NULL) { | if ((ia6 = in6_ifadd(new, mcast)) != NULL) { | ||||
/* | /* | ||||
* note that we should use pr (not new) for reference. | * note that we should use pr (not new) for reference. | ||||
*/ | */ | ||||
pr->ndpr_addrcnt++; | pr->ndpr_addrcnt++; | ||||
if (ia6->ia6_flags & IN6_IFF_AUTOCONF) | |||||
pr->ndpr_num_autoconf_addrs++; | |||||
ia6->ia6_ndpr = pr; | ia6->ia6_ndpr = pr; | ||||
/* | /* | ||||
* RFC 3041 3.3 (2). | * RFC 3041 3.3 (2). | ||||
* When a new public address is created as described | * When a new public address is created as described | ||||
* in RFC2462, also create a new temporary address. | * in RFC2462, also create a new temporary address. | ||||
* | * | ||||
* RFC 3041 3.5. | * RFC 3041 3.5. | ||||
▲ Show 20 Lines • Show All 621 Lines • ▼ Show 20 Lines | in6_tmpifadd(const struct in6_ifaddr *ia0, int forcegen, int delay) | ||||
if (newia == NULL) { /* XXX: can it happen? */ | if (newia == NULL) { /* XXX: can it happen? */ | ||||
nd6log((LOG_ERR, | nd6log((LOG_ERR, | ||||
"%s: ifa update succeeded, but we got no ifaddr\n", | "%s: ifa update succeeded, but we got no ifaddr\n", | ||||
__func__)); | __func__)); | ||||
return (EINVAL); /* XXX */ | return (EINVAL); /* XXX */ | ||||
} | } | ||||
newia->ia6_ndpr = ia0->ia6_ndpr; | newia->ia6_ndpr = ia0->ia6_ndpr; | ||||
newia->ia6_ndpr->ndpr_addrcnt++; | newia->ia6_ndpr->ndpr_addrcnt++; | ||||
if (ifra.ifra_flags & IN6_IFF_AUTOCONF) | |||||
markjUnsubmitted Not Done Inline ActionsThe if-statement condition is always true here. markj: The if-statement condition is always true here. | |||||
newia->ia6_ndpr->ndpr_num_autoconf_addrs++; | |||||
ifa_free(&newia->ia_ifa); | ifa_free(&newia->ia_ifa); | ||||
/* | /* | ||||
* A newly added address might affect the status of other addresses. | * A newly added address might affect the status of other addresses. | ||||
* XXX: when the temporary address is generated with a new public | * XXX: when the temporary address is generated with a new public | ||||
* address, the onlink check is redundant. However, it would be safe | * address, the onlink check is redundant. However, it would be safe | ||||
* to do the check explicitly everywhere a new address is generated, | * to do the check explicitly everywhere a new address is generated, | ||||
* and, in fact, we surely need the check when we create a new | * and, in fact, we surely need the check when we create a new | ||||
▲ Show 20 Lines • Show All 213 Lines • Show Last 20 Lines |
Is this needed given M_ZERO above?