Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/nd6_rtr.c
| Show First 20 Lines • Show All 1,140 Lines • ▼ Show 20 Lines | restart: | ||||
| V_nd6_list_genid++; | V_nd6_list_genid++; | ||||
| ND6_WUNLOCK(); | ND6_WUNLOCK(); | ||||
| defrouter_select_fib(new->ifp->if_fib); | defrouter_select_fib(new->ifp->if_fib); | ||||
| return (n); | return (n); | ||||
| } | } | ||||
| static int | static void | ||||
| in6_init_prefix_ltimes(struct nd_prefix *ndpr) | in6_init_prefix_ltimes(struct nd_prefix *ndpr) | ||||
| { | { | ||||
| if (ndpr->ndpr_pltime == ND6_INFINITE_LIFETIME) | ndpr->ndpr_preferred = in6_expire_time(ndpr->ndpr_pltime); | ||||
| ndpr->ndpr_preferred = 0; | ndpr->ndpr_expire = in6_expire_time(ndpr->ndpr_vltime); | ||||
| else | |||||
| ndpr->ndpr_preferred = time_uptime + ndpr->ndpr_pltime; | |||||
| if (ndpr->ndpr_vltime == ND6_INFINITE_LIFETIME) | |||||
| ndpr->ndpr_expire = 0; | |||||
| else | |||||
| ndpr->ndpr_expire = time_uptime + ndpr->ndpr_vltime; | |||||
| return 0; | |||||
| } | } | ||||
| static void | static void | ||||
| in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6) | in6_init_address_ltimes(struct nd_prefix *new, struct in6_addrlifetime *lt6) | ||||
| { | { | ||||
| /* init ia6t_expire */ | lt6->ia6t_preferred = in6_expire_time(lt6->ia6t_pltime); | ||||
| if (lt6->ia6t_vltime == ND6_INFINITE_LIFETIME) | lt6->ia6t_expire = in6_expire_time(lt6->ia6t_vltime); | ||||
| lt6->ia6t_expire = 0; | |||||
| else { | |||||
| lt6->ia6t_expire = time_uptime; | |||||
| lt6->ia6t_expire += lt6->ia6t_vltime; | |||||
| } | } | ||||
| /* init ia6t_preferred */ | |||||
| if (lt6->ia6t_pltime == ND6_INFINITE_LIFETIME) | |||||
| lt6->ia6t_preferred = 0; | |||||
| else { | |||||
| lt6->ia6t_preferred = time_uptime; | |||||
| lt6->ia6t_preferred += lt6->ia6t_pltime; | |||||
| } | |||||
| } | |||||
| static struct in6_ifaddr * | static struct in6_ifaddr * | ||||
| in6_ifadd(struct nd_prefixctl *pr, int mcast) | in6_ifadd(struct nd_prefixctl *pr, int mcast) | ||||
| { | { | ||||
| struct ifnet *ifp = pr->ndpr_ifp; | struct ifnet *ifp = pr->ndpr_ifp; | ||||
| struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
| struct in6_aliasreq ifra; | struct in6_aliasreq ifra; | ||||
| struct in6_ifaddr *ia = NULL, *ib = NULL; | struct in6_ifaddr *ia = NULL, *ib = NULL; | ||||
| int error, plen0; | int error, plen0; | ||||
| ▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | 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_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) { | |||||
| free(new, M_IP6NDP); | |||||
| return (error); | |||||
| } | |||||
| new->ndpr_lastupdate = time_uptime; | new->ndpr_lastupdate = time_uptime; | ||||
| in6_init_prefix_ltimes(new); | |||||
| /* initialization */ | /* initialization */ | ||||
| LIST_INIT(&new->ndpr_advrtrs); | LIST_INIT(&new->ndpr_advrtrs); | ||||
| in6_prefixlen2mask(&new->ndpr_mask, new->ndpr_plen); | in6_prefixlen2mask(&new->ndpr_mask, new->ndpr_plen); | ||||
| /* make prefix in the canonical form */ | /* make prefix in the canonical form */ | ||||
| IN6_MASK_ADDR(&new->ndpr_prefix.sin6_addr, &new->ndpr_mask); | IN6_MASK_ADDR(&new->ndpr_prefix.sin6_addr, &new->ndpr_mask); | ||||
| ND6_WLOCK(); | ND6_WLOCK(); | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | if ((pr = nd6_prefix_lookup(new)) != NULL) { | ||||
| */ | */ | ||||
| if (new->ndpr_raf_onlink == 1) | if (new->ndpr_raf_onlink == 1) | ||||
| pr->ndpr_raf_onlink = 1; | pr->ndpr_raf_onlink = 1; | ||||
| if (new->ndpr_raf_auto == 1) | if (new->ndpr_raf_auto == 1) | ||||
| pr->ndpr_raf_auto = 1; | pr->ndpr_raf_auto = 1; | ||||
| if (new->ndpr_raf_onlink) { | if (new->ndpr_raf_onlink) { | ||||
| pr->ndpr_vltime = new->ndpr_vltime; | pr->ndpr_vltime = new->ndpr_vltime; | ||||
| pr->ndpr_pltime = new->ndpr_pltime; | pr->ndpr_pltime = new->ndpr_pltime; | ||||
| (void)in6_init_prefix_ltimes(pr); /* XXX error case? */ | in6_init_prefix_ltimes(pr); | ||||
| pr->ndpr_lastupdate = time_uptime; | pr->ndpr_lastupdate = time_uptime; | ||||
| } | } | ||||
| if (new->ndpr_raf_onlink && | if (new->ndpr_raf_onlink && | ||||
| (pr->ndpr_stateflags & NDPRF_ONLINK) == 0) { | (pr->ndpr_stateflags & NDPRF_ONLINK) == 0) { | ||||
| ND6_ONLINK_LOCK(); | ND6_ONLINK_LOCK(); | ||||
| if ((error = nd6_prefix_onlink(pr)) != 0) { | if ((error = nd6_prefix_onlink(pr)) != 0) { | ||||
| nd6log((LOG_ERR, | nd6log((LOG_ERR, | ||||
| ▲ Show 20 Lines • Show All 1,115 Lines • Show Last 20 Lines | |||||