diff --git a/sys/net/agr/if_agr.c b/sys/net/agr/if_agr.c index 01ab5e14f5c0..4c39c6a42b10 100644 --- a/sys/net/agr/if_agr.c +++ b/sys/net/agr/if_agr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_agr.c,v 1.15 2007/08/30 02:17:36 dyoung Exp $ */ +/* $NetBSD: if_agr.c,v 1.16 2007/09/02 19:42:21 dyoung Exp $ */ /*- * Copyright (c)2005 YAMAMOTO Takashi, @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.15 2007/08/30 02:17:36 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.16 2007/09/02 19:42:21 dyoung Exp $"); #include "bpfilter.h" #include "opt_inet.h" @@ -689,19 +689,19 @@ agrport_cleanup(struct agr_softc *sc, struct agr_port *port) error = (*ifp_port->if_init)(ifp_port); } #else - struct sockaddr *sa; + union { + struct sockaddr sa; + struct sockaddr_dl sdl; + struct sockaddr_storage ss; + } u; struct ifaddr ifa; - sa = sockaddr_dl_alloc(0, ifp_port->if_type, NULL, 0, - port->port_origlladdr, ifp_port->if_addrlen, M_WAITOK); - if (sa == NULL) - error = ENOMEM; - else { - memset(&ifa, 0, sizeof(ifa)); - ifa.ifa_addr = sa; - error = agrport_ioctl(port, SIOCSIFADDR, &ifa); - sockaddr_free(sa); - } + sockaddr_dl_init(&u.sdl, sizeof(u.ss), + 0, ifp_port->if_type, NULL, 0, + port->port_origlladdr, ifp_port->if_addrlen); + memset(&ifa, 0, sizeof(ifa)); + ifa.ifa_addr = &u.sa; + error = agrport_ioctl(port, SIOCSIFADDR, &ifa); #endif if (error) { printf("%s: if_init error %d\n", __func__, error); diff --git a/sys/netinet/if_arp.c b/sys/netinet/if_arp.c index 426bf943a62a..b5610cba3424 100644 --- a/sys/netinet/if_arp.c +++ b/sys/netinet/if_arp.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_arp.c,v 1.127 2007/08/30 02:17:36 dyoung Exp $ */ +/* $NetBSD: if_arp.c,v 1.128 2007/09/02 19:42:22 dyoung Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -75,7 +75,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.127 2007/08/30 02:17:36 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_arp.c,v 1.128 2007/09/02 19:42:22 dyoung Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -405,15 +405,18 @@ arp_setgate(struct rtentry *rt, struct sockaddr *gate, satocsin(netmask)->sin_addr.s_addr != 0xffffffff) rt->rt_flags |= RTF_CLONING; if (rt->rt_flags & RTF_CLONING) { - struct sockaddr *sa; + union { + struct sockaddr sa; + struct sockaddr_storage ss; + struct sockaddr_dl sdl; + } u; /* * Case 1: This route should come from a route to iface. */ - sa = sockaddr_dl_alloc(ifp->if_index, ifp->if_type, - NULL, namelen, NULL, addrlen, M_WAITOK); - rt_setgate(rt, sa); + sockaddr_dl_init(&u.sdl, sizeof(u.ss), + ifp->if_index, ifp->if_type, NULL, namelen, NULL, addrlen); + rt_setgate(rt, &u.sa); gate = rt->rt_gateway; - sockaddr_free(sa); } return gate; } diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 416a586b9b41..32f622f36e37 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $NetBSD: nd6.c,v 1.119 2007/08/30 02:17:38 dyoung Exp $ */ +/* $NetBSD: nd6.c,v 1.120 2007/09/02 19:42:22 dyoung Exp $ */ /* $KAME: nd6.c,v 1.279 2002/06/08 11:16:51 itojun Exp $ */ /* @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.119 2007/08/30 02:17:38 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nd6.c,v 1.120 2007/09/02 19:42:22 dyoung Exp $"); #include "opt_ipsec.h" @@ -1175,17 +1175,21 @@ nd6_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) */ if ((rt->rt_flags & RTF_CLONING) || ((rt->rt_flags & RTF_LLINFO) && !ln)) { - struct sockaddr *sa; + union { + struct sockaddr sa; + struct sockaddr_dl sdl; + struct sockaddr_storage ss; + } u; /* * Case 1: This route should come from a route to * interface (RTF_CLONING case) or the route should be * treated as on-link but is currently not * (RTF_LLINFO && !ln case). */ - sa = sockaddr_dl_alloc(ifp->if_index, ifp->if_type, - NULL, namelen, NULL, addrlen, M_WAITOK); - rt_setgate(rt, sa); - sockaddr_free(sa); + sockaddr_dl_init(&u.sdl, sizeof(u.ss), + ifp->if_index, ifp->if_type, + NULL, namelen, NULL, addrlen); + rt_setgate(rt, &u.sa); gate = rt->rt_gateway; RT_DPRINTF("%s l.%d: rt->_rt_key = %p\n", __func__, __LINE__, (void *)rt->_rt_key); diff --git a/sys/netiso/iso_snpac.c b/sys/netiso/iso_snpac.c index 7672aee435d0..c69755f0c7ae 100644 --- a/sys/netiso/iso_snpac.c +++ b/sys/netiso/iso_snpac.c @@ -1,4 +1,4 @@ -/* $NetBSD: iso_snpac.c,v 1.46 2007/08/30 02:17:39 dyoung Exp $ */ +/* $NetBSD: iso_snpac.c,v 1.47 2007/09/02 19:42:22 dyoung Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -59,7 +59,7 @@ SOFTWARE. */ #include -__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.46 2007/08/30 02:17:39 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: iso_snpac.c,v 1.47 2007/09/02 19:42:22 dyoung Exp $"); #include "opt_iso.h" #ifdef ISO @@ -201,14 +201,18 @@ llc_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) * or from a default route. */ if (rt->rt_flags & RTF_CLONING) { - struct sockaddr *sa; + union { + struct sockaddr sa; + struct sockaddr_dl sdl; + struct sockaddr_storage ss; + } u; iso_setmcasts(ifp, req); - sa = sockaddr_dl_alloc(ifp->if_index, - ifp->if_type, NULL, strlen(ifp->if_xname), - NULL, ifp->if_addrlen, M_WAITOK); - rt_setgate(rt, sa); - sockaddr_free(sa); + sockaddr_dl_init(&u.sdl, sizeof(u.ss), + ifp->if_index, ifp->if_type, + NULL, strlen(ifp->if_xname), + NULL, ifp->if_addrlen); + rt_setgate(rt, &u.sa); return; } if (lc != 0)