RB lookup tree because the rdomain id is part of the lookup key.
Without this the RB tree gets corrupted and in the worst case a use after
free can happen when the interface is destroyed.
Why the sadl addresses are added to the tree in the first place is something
to reconsider.
OK henning@, mpi@, sthen@
-/* $OpenBSD: if.c,v 1.284 2014/04/19 12:27:59 henning Exp $ */
+/* $OpenBSD: if.c,v 1.285 2014/04/20 11:25:18 claudio Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
#ifdef INET
in_ifdetach(ifp);
#endif
+ /*
+ * Remove sadl from ifa RB tree because rdomain is part
+ * of the lookup key and re-add it after the switch.
+ */
+ ifa_del(ifp, ifp->if_lladdr);
splx(s);
}
/* Add interface to the specified rdomain */
ifp->if_rdomain = ifr->ifr_rdomainid;
+
+ /* re-add sadl to the ifa RB tree in new rdomain */
+ ifa_add(ifp, ifp->if_lladdr);
break;
case SIOCAIFGROUP: