When moving ifnets from one vnet to another, and the ifnet

has ifaddresses of AF_LINK type which thus have an embedded
if_index "backpointer", we must update that if_index backpointer
to reflect the new if_index that our ifnet just got assigned.

This change affects only options VIMAGE builds.

Submitted by:	bz
Reviewed by:	bz
Approved by:	re (rwatson), julian (mentor)
This commit is contained in:
Marko Zec 2009-08-24 10:14:09 +00:00
parent 0348c661d1
commit 52db6805ea
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=196504

View File

@ -589,6 +589,21 @@ if_attach_internal(struct ifnet *ifp, int vmove)
/* Reliably crash if used uninitialized. */
ifp->if_broadcastaddr = NULL;
}
#ifdef VIMAGE
else {
/*
* Update the interface index in the link layer address
* of the interface.
*/
for (ifa = ifp->if_addr; ifa != NULL;
ifa = TAILQ_NEXT(ifa, ifa_link)) {
if (ifa->ifa_addr->sa_family == AF_LINK) {
sdl = (struct sockaddr_dl *)ifa->ifa_addr;
sdl->sdl_index = ifp->if_index;
}
}
}
#endif
IFNET_WLOCK();
TAILQ_INSERT_TAIL(&V_ifnet, ifp, if_link);