Deleted Added
sdiff udiff text old ( 132780 ) new ( 133513 )
full compact
1/*
2 * Copyright (c) 1980, 1986, 1991, 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

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

22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)route.c 8.3.1.1 (Berkeley) 2/23/95
30 * $FreeBSD: head/sys/net/route.c 132780 2004-07-28 06:59:55Z kan $
31 */
32
33#include "opt_inet.h"
34#include "opt_mrouting.h"
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/malloc.h>
39#include <sys/mbuf.h>
40#include <sys/socket.h>
41#include <sys/domain.h>
42#include <sys/kernel.h>
43
44#include <net/if.h>
45#include <net/route.h>
46
47#include <netinet/in.h>
48#include <netinet/ip_mroute.h>
49
50static struct rtstat rtstat;
51struct radix_node_head *rt_tables[AF_MAX+1];
52
53static int rttrash; /* routes not in table but not freed */
54
55static void rt_maskedcopy(struct sockaddr *,
56 struct sockaddr *, struct sockaddr *);
57static void rtable_init(void **);

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

76{
77 struct domain *dom;
78 for (dom = domains; dom; dom = dom->dom_next)
79 if (dom->dom_rtattach)
80 dom->dom_rtattach(&table[dom->dom_family],
81 dom->dom_rtoffset);
82}
83
84static void
85route_init(void)
86{
87 rn_init(); /* initialize all zeroes, all ones, mask table */
88 rtable_init((void **)rt_tables);
89}
90
91/*
92 * Packet routing routines.
93 */
94void

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

287 * together.
288 */
289 Free(rt_key(rt));
290
291 /*
292 * and the rtentry itself of course
293 */
294 RT_LOCK_DESTROY(rt);
295 Free(rt);
296 return;
297 }
298done:
299 RT_UNLOCK(rt);
300}
301
302
303/*

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

733 if ((flags & RTF_GATEWAY) && !gateway)
734 panic("rtrequest: GATEWAY but no gateway");
735
736 if (info->rti_ifa == NULL && (error = rt_getifa(info)))
737 senderr(error);
738 ifa = info->rti_ifa;
739
740 makeroute:
741 R_Zalloc(rt, struct rtentry *, sizeof(*rt));
742 if (rt == NULL)
743 senderr(ENOBUFS);
744 RT_LOCK_INIT(rt);
745 rt->rt_flags = RTF_UP | flags;
746 /*
747 * Add the gateway. Possibly re-malloc-ing the storage for it
748 * also add the rt_gwroute if possible.
749 */
750 RT_LOCK(rt);
751 if ((error = rt_setgate(rt, dst, gateway)) != 0) {
752 RT_LOCK_DESTROY(rt);
753 Free(rt);
754 senderr(error);
755 }
756
757 /*
758 * point to the (possibly newly malloc'd) dest address.
759 */
760 ndst = (struct sockaddr *)rt_key(rt);
761

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

805 */
806 if (rn == NULL) {
807 if (rt->rt_gwroute)
808 RTFREE(rt->rt_gwroute);
809 if (rt->rt_ifa)
810 IFAFREE(rt->rt_ifa);
811 Free(rt_key(rt));
812 RT_LOCK_DESTROY(rt);
813 Free(rt);
814 senderr(EEXIST);
815 }
816
817 rt->rt_parent = NULL;
818
819 /*
820 * If we got here from RESOLVE, then we are cloning
821 * so clone the rest, and note that we

--- 482 unchanged lines hidden ---