-/* $OpenBSD: if.c,v 1.288 2014/05/13 14:33:25 claudio Exp $ */
+/* $OpenBSD: if.c,v 1.289 2014/05/16 08:21:54 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
if (socksize < sizeof(*sdl))
socksize = sizeof(*sdl);
socksize = ROUNDUP(socksize);
- ifasize = sizeof(*ifa) + 2 * socksize;
+ ifasize = sizeof(*ifa) + socksize;
ifa = malloc(ifasize, M_IFADDR, M_WAITOK|M_ZERO);
sdl = (struct sockaddr_dl *)(ifa + 1);
sdl->sdl_len = socksize;
ifa->ifa_rtrequest = link_rtrequest;
ifa->ifa_addr = (struct sockaddr *)sdl;
ifp->if_sadl = sdl;
- sdl = (struct sockaddr_dl *)(socksize + (caddr_t)sdl);
- ifa->ifa_netmask = (struct sockaddr *)sdl;
- sdl->sdl_len = masklen;
- while (namelen != 0)
- sdl->sdl_data[--namelen] = 0xff;
- ifa_add(ifp, ifa);
+ ifa->ifa_netmask = NULL;
}
/*
s = splnet();
rt_ifa_del(ifa, 0, ifa->ifa_addr);
- ifa_del(ifp, ifa);
ifafree(ifp->if_lladdr);
ifp->if_lladdr = NULL;
ifp->if_sadl = NULL;
struct ifgroupreq *ifgr;
char ifdescrbuf[IFDESCRSIZE];
char ifrtlabelbuf[RTLABEL_LEN];
- int s, error = 0, needsadd;
+ int s, error = 0;
size_t bytesdone;
short oif_flags;
const char *label;
/* remove all routing entries when switching domains */
/* XXX hell this is ugly */
- needsadd = 0;
if (ifr->ifr_rdomainid != ifp->if_rdomain) {
s = splnet();
if (ifp->if_flags & IFF_UP)
#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);
- needsadd = 1;
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 */
- if (needsadd)
- ifa_add(ifp, ifp->if_lladdr);
break;
case SIOCAIFGROUP:
void
ifa_add(struct ifnet *ifp, struct ifaddr *ifa)
{
- if (ifa->ifa_addr->sa_family == AF_LINK)
- TAILQ_INSERT_HEAD(&ifp->if_addrlist, ifa, ifa_list);
- else
- TAILQ_INSERT_TAIL(&ifp->if_addrlist, ifa, ifa_list);
+ TAILQ_INSERT_TAIL(&ifp->if_addrlist, ifa, ifa_list);
ifa_item_insert(ifa->ifa_addr, ifa, ifp);
if (ifp->if_flags & IFF_BROADCAST && ifa->ifa_broadaddr)
ifa_item_insert(ifa->ifa_broadaddr, ifa, ifp);
-/* $OpenBSD: rtsock.c,v 1.143 2014/04/25 10:41:09 mpi Exp $ */
+/* $OpenBSD: rtsock.c,v 1.144 2014/05/16 08:21:54 mpi Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
}
info.rti_info[RTAX_IFP] = NULL;
TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) {
- if (ifa->ifa_addr->sa_family == AF_LINK)
- continue;
+ KASSERT(ifa->ifa_addr->sa_family != AF_LINK);
if (af && af != ifa->ifa_addr->sa_family)
continue;
info.rti_info[RTAX_IFA] = ifa->ifa_addr;