Deleted Added
full compact
if.c (108250) if.c (109623)
1/*
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)if.c 8.5 (Berkeley) 1/9/95
1/*
2 * Copyright (c) 1980, 1986, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)if.c 8.5 (Berkeley) 1/9/95
34 * $FreeBSD: head/sys/net/if.c 108250 2002-12-24 03:03:39Z hsu $
34 * $FreeBSD: head/sys/net/if.c 109623 2003-01-21 08:56:16Z alfred $
35 */
36
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_inet.h"
40#include "opt_mac.h"
41
42#include <sys/param.h>

--- 232 unchanged lines hidden (view full) ---

275static void
276if_grow(void)
277{
278 u_int n;
279 struct ifindex_entry *e;
280
281 if_indexlim <<= 1;
282 n = if_indexlim * sizeof(*e);
35 */
36
37#include "opt_compat.h"
38#include "opt_inet6.h"
39#include "opt_inet.h"
40#include "opt_mac.h"
41
42#include <sys/param.h>

--- 232 unchanged lines hidden (view full) ---

275static void
276if_grow(void)
277{
278 u_int n;
279 struct ifindex_entry *e;
280
281 if_indexlim <<= 1;
282 n = if_indexlim * sizeof(*e);
283 e = malloc(n, M_IFADDR, M_WAITOK | M_ZERO);
283 e = malloc(n, M_IFADDR, M_ZERO);
284 if (ifindex_table != NULL) {
285 memcpy((caddr_t)e, (caddr_t)ifindex_table, n/2);
286 free((caddr_t)ifindex_table, M_IFADDR);
287 }
288 ifindex_table = e;
289}
290
291/* ARGSUSED*/

--- 132 unchanged lines hidden (view full) ---

424#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
425 masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) + namelen;
426 socksize = masklen + ifp->if_addrlen;
427#define ROUNDUP(a) (1 + (((a) - 1) | (sizeof(long) - 1)))
428 if (socksize < sizeof(*sdl))
429 socksize = sizeof(*sdl);
430 socksize = ROUNDUP(socksize);
431 ifasize = sizeof(*ifa) + 2 * socksize;
284 if (ifindex_table != NULL) {
285 memcpy((caddr_t)e, (caddr_t)ifindex_table, n/2);
286 free((caddr_t)ifindex_table, M_IFADDR);
287 }
288 ifindex_table = e;
289}
290
291/* ARGSUSED*/

--- 132 unchanged lines hidden (view full) ---

424#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
425 masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) + namelen;
426 socksize = masklen + ifp->if_addrlen;
427#define ROUNDUP(a) (1 + (((a) - 1) | (sizeof(long) - 1)))
428 if (socksize < sizeof(*sdl))
429 socksize = sizeof(*sdl);
430 socksize = ROUNDUP(socksize);
431 ifasize = sizeof(*ifa) + 2 * socksize;
432 ifa = (struct ifaddr *)malloc(ifasize, M_IFADDR, M_WAITOK | M_ZERO);
432 ifa = (struct ifaddr *)malloc(ifasize, M_IFADDR, M_ZERO);
433 if (ifa) {
434 IFA_LOCK_INIT(ifa);
435 sdl = (struct sockaddr_dl *)(ifa + 1);
436 sdl->sdl_len = socksize;
437 sdl->sdl_family = AF_LINK;
438 bcopy(workbuf, sdl->sdl_data, namelen);
439 sdl->sdl_nlen = namelen;
440 sdl->sdl_index = ifp->if_index;

--- 329 unchanged lines hidden (view full) ---

770 ifc->ifc_maxunit + 1));
771 /*
772 * Compute bitmap size and allocate it.
773 */
774 maxclone = ifc->ifc_maxunit + 1;
775 len = maxclone >> 3;
776 if ((len << 3) < maxclone)
777 len++;
433 if (ifa) {
434 IFA_LOCK_INIT(ifa);
435 sdl = (struct sockaddr_dl *)(ifa + 1);
436 sdl->sdl_len = socksize;
437 sdl->sdl_family = AF_LINK;
438 bcopy(workbuf, sdl->sdl_data, namelen);
439 sdl->sdl_nlen = namelen;
440 sdl->sdl_index = ifp->if_index;

--- 329 unchanged lines hidden (view full) ---

770 ifc->ifc_maxunit + 1));
771 /*
772 * Compute bitmap size and allocate it.
773 */
774 maxclone = ifc->ifc_maxunit + 1;
775 len = maxclone >> 3;
776 if ((len << 3) < maxclone)
777 len++;
778 ifc->ifc_units = malloc(len, M_CLONE, M_WAITOK | M_ZERO);
778 ifc->ifc_units = malloc(len, M_CLONE, M_ZERO);
779 ifc->ifc_bmlen = len;
780
781 LIST_INSERT_HEAD(&if_cloners, ifc, ifc_list);
782 if_cloners_count++;
783
784 for (unit = 0; unit < ifc->ifc_minifs; unit++) {
785 err = (*ifc->ifc_create)(ifc, unit);
786 KASSERT(err == 0,

--- 1005 unchanged lines hidden (view full) ---

1792 */
1793 if (ifp->if_resolvemulti) {
1794 error = ifp->if_resolvemulti(ifp, &llsa, sa);
1795 if (error) return error;
1796 } else {
1797 llsa = 0;
1798 }
1799
779 ifc->ifc_bmlen = len;
780
781 LIST_INSERT_HEAD(&if_cloners, ifc, ifc_list);
782 if_cloners_count++;
783
784 for (unit = 0; unit < ifc->ifc_minifs; unit++) {
785 err = (*ifc->ifc_create)(ifc, unit);
786 KASSERT(err == 0,

--- 1005 unchanged lines hidden (view full) ---

1792 */
1793 if (ifp->if_resolvemulti) {
1794 error = ifp->if_resolvemulti(ifp, &llsa, sa);
1795 if (error) return error;
1796 } else {
1797 llsa = 0;
1798 }
1799
1800 MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, M_IFMADDR, M_WAITOK);
1801 MALLOC(dupsa, struct sockaddr *, sa->sa_len, M_IFMADDR, M_WAITOK);
1800 MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma, M_IFMADDR, 0);
1801 MALLOC(dupsa, struct sockaddr *, sa->sa_len, M_IFMADDR, 0);
1802 bcopy(sa, dupsa, sa->sa_len);
1803
1804 ifma->ifma_addr = dupsa;
1805 ifma->ifma_lladdr = llsa;
1806 ifma->ifma_ifp = ifp;
1807 ifma->ifma_refcount = 1;
1808 ifma->ifma_protospec = 0;
1809 rt_newmaddrmsg(RTM_NEWMADDR, ifma);

--- 12 unchanged lines hidden (view full) ---

1822 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
1823 if (equal(ifma->ifma_addr, llsa))
1824 break;
1825 }
1826 if (ifma) {
1827 ifma->ifma_refcount++;
1828 } else {
1829 MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma,
1802 bcopy(sa, dupsa, sa->sa_len);
1803
1804 ifma->ifma_addr = dupsa;
1805 ifma->ifma_lladdr = llsa;
1806 ifma->ifma_ifp = ifp;
1807 ifma->ifma_refcount = 1;
1808 ifma->ifma_protospec = 0;
1809 rt_newmaddrmsg(RTM_NEWMADDR, ifma);

--- 12 unchanged lines hidden (view full) ---

1822 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
1823 if (equal(ifma->ifma_addr, llsa))
1824 break;
1825 }
1826 if (ifma) {
1827 ifma->ifma_refcount++;
1828 } else {
1829 MALLOC(ifma, struct ifmultiaddr *, sizeof *ifma,
1830 M_IFMADDR, M_WAITOK);
1830 M_IFMADDR, 0);
1831 MALLOC(dupsa, struct sockaddr *, llsa->sa_len,
1831 MALLOC(dupsa, struct sockaddr *, llsa->sa_len,
1832 M_IFMADDR, M_WAITOK);
1832 M_IFMADDR, 0);
1833 bcopy(llsa, dupsa, llsa->sa_len);
1834 ifma->ifma_addr = dupsa;
1835 ifma->ifma_ifp = ifp;
1836 ifma->ifma_refcount = 1;
1837 s = splimp();
1838 TAILQ_INSERT_HEAD(&ifp->if_multiaddrs, ifma, ifma_link);
1839 splx(s);
1840 }

--- 175 unchanged lines hidden ---
1833 bcopy(llsa, dupsa, llsa->sa_len);
1834 ifma->ifma_addr = dupsa;
1835 ifma->ifma_ifp = ifp;
1836 ifma->ifma_refcount = 1;
1837 s = splimp();
1838 TAILQ_INSERT_HEAD(&ifp->if_multiaddrs, ifma, ifma_link);
1839 splx(s);
1840 }

--- 175 unchanged lines hidden ---