Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet6/in6_ifattach.c
Show First 20 Lines • Show All 669 Lines • ▼ Show 20 Lines | |||||
* XXX multiple link-local address case | * XXX multiple link-local address case | ||||
* | * | ||||
* altifp - secondary EUI64 source | * altifp - secondary EUI64 source | ||||
*/ | */ | ||||
void | void | ||||
in6_ifattach(struct ifnet *ifp, struct ifnet *altifp) | in6_ifattach(struct ifnet *ifp, struct ifnet *altifp) | ||||
{ | { | ||||
struct in6_ifaddr *ia; | struct in6_ifaddr *ia; | ||||
struct nd_ifinfo *ndi; | |||||
if (ifp->if_afdata[AF_INET6] == NULL) | if ((ndi = nd6_ifinfo(ifp)) == NULL) | ||||
return; | return; | ||||
/* | /* | ||||
* quirks based on interface type | * quirks based on interface type | ||||
*/ | */ | ||||
switch (ifp->if_type) { | switch (ifp->if_type) { | ||||
case IFT_STF: | case IFT_STF: | ||||
/* | /* | ||||
* 6to4 interface is a very special kind of beast. | * 6to4 interface is a very special kind of beast. | ||||
* no multicast, no linklocal. RFC2529 specifies how to make | * no multicast, no linklocal. RFC2529 specifies how to make | ||||
* linklocals for 6to4 interface, but there's no use and | * linklocals for 6to4 interface, but there's no use and | ||||
* it is rather harmful to have one. | * it is rather harmful to have one. | ||||
*/ | */ | ||||
ND_IFINFO(ifp)->flags &= ~ND6_IFF_AUTO_LINKLOCAL; | ndi->flags &= ~ND6_IFF_AUTO_LINKLOCAL; | ||||
ND_IFINFO(ifp)->flags |= ND6_IFF_NO_DAD; | ndi->flags |= ND6_IFF_NO_DAD; | ||||
break; | break; | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
/* | /* | ||||
* usually, we require multicast capability to the interface | * usually, we require multicast capability to the interface | ||||
*/ | */ | ||||
Show All 14 Lines | if ((ifp->if_flags & IFF_LOOPBACK) != 0) { | ||||
ia = in6ifa_ifwithaddr(&in6addr_loopback, 0, false); | ia = in6ifa_ifwithaddr(&in6addr_loopback, 0, false); | ||||
if (ia == NULL) | if (ia == NULL) | ||||
in6_ifattach_loopback(ifp); | in6_ifattach_loopback(ifp); | ||||
} | } | ||||
/* | /* | ||||
* assign a link-local address, if there's none. | * assign a link-local address, if there's none. | ||||
*/ | */ | ||||
if (!(ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) && | if ((ndi->flags & ND6_IFF_IFDISABLED) == 0 && | ||||
ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) { | (ndi->flags & ND6_IFF_AUTO_LINKLOCAL) != 0) { | ||||
struct epoch_tracker et; | struct epoch_tracker et; | ||||
NET_EPOCH_ENTER(et); | NET_EPOCH_ENTER(et); | ||||
ia = in6ifa_ifpforlinklocal(ifp, 0); | ia = in6ifa_ifpforlinklocal(ifp, 0); | ||||
NET_EPOCH_EXIT(et); | NET_EPOCH_EXIT(et); | ||||
if (ia == NULL) | if (ia == NULL) | ||||
in6_ifattach_linklocal(ifp, altifp); | in6_ifattach_linklocal(ifp, altifp); | ||||
else | else | ||||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | in6_ifdetach_destroy(struct ifnet *ifp) | ||||
_in6_ifdetach(ifp, 0); | _in6_ifdetach(ifp, 0); | ||||
} | } | ||||
int | int | ||||
in6_get_tmpifid(struct ifnet *ifp, u_int8_t *retbuf, | in6_get_tmpifid(struct ifnet *ifp, u_int8_t *retbuf, | ||||
const u_int8_t *baseid, int generate) | const u_int8_t *baseid, int generate) | ||||
{ | { | ||||
struct nd_ifinfo *ndi = nd6_ifinfo(ifp); | |||||
u_int8_t nullbuf[8]; | u_int8_t nullbuf[8]; | ||||
struct nd_ifinfo *ndi = ND_IFINFO(ifp); | |||||
if (ndi == NULL) | |||||
return (ENXIO); | |||||
bzero(nullbuf, sizeof(nullbuf)); | bzero(nullbuf, sizeof(nullbuf)); | ||||
if (bcmp(ndi->randomid, nullbuf, sizeof(nullbuf)) == 0) { | if (bcmp(ndi->randomid, nullbuf, sizeof(nullbuf)) == 0) { | ||||
/* we've never created a random ID. Create a new one. */ | /* we've never created a random ID. Create a new one. */ | ||||
generate = 1; | generate = 1; | ||||
} | } | ||||
if (generate) { | if (generate) { | ||||
bcopy(baseid, ndi->randomseed1, sizeof(ndi->randomseed1)); | bcopy(baseid, ndi->randomseed1, sizeof(ndi->randomseed1)); | ||||
Show All 18 Lines | in6_tmpaddrtimer(void *arg) | ||||
callout_reset(&V_in6_tmpaddrtimer_ch, | callout_reset(&V_in6_tmpaddrtimer_ch, | ||||
(V_ip6_temp_preferred_lifetime - V_ip6_desync_factor - | (V_ip6_temp_preferred_lifetime - V_ip6_desync_factor - | ||||
V_ip6_temp_regen_advance) * hz, in6_tmpaddrtimer, curvnet); | V_ip6_temp_regen_advance) * hz, in6_tmpaddrtimer, curvnet); | ||||
bzero(nullbuf, sizeof(nullbuf)); | bzero(nullbuf, sizeof(nullbuf)); | ||||
NET_EPOCH_ENTER(et); | NET_EPOCH_ENTER(et); | ||||
CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { | CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { | ||||
if (ifp->if_afdata[AF_INET6] == NULL) | if ((ndi = nd6_ifinfo(ifp)) == NULL) | ||||
continue; | continue; | ||||
ndi = ND_IFINFO(ifp); | |||||
if (bcmp(ndi->randomid, nullbuf, sizeof(nullbuf)) != 0) { | if (bcmp(ndi->randomid, nullbuf, sizeof(nullbuf)) != 0) { | ||||
/* | /* | ||||
* We've been generating a random ID on this interface. | * We've been generating a random ID on this interface. | ||||
* Create a new one. | * Create a new one. | ||||
*/ | */ | ||||
(void)generate_tmp_ifid(ndi->randomseed0, | (void)generate_tmp_ifid(ndi->randomseed0, | ||||
ndi->randomseed1, ndi->randomid); | ndi->randomseed1, ndi->randomid); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines |