Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Oct 2003 21:56:54 -0700 (PDT)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 40367 for review
Message-ID:  <200310240456.h9O4usSG026089@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=40367

Change 40367 by sam@sam_ebb on 2003/10/23 21:56:06

	import andre's latest tcp hostcache patch

Affected files ...

.. //depot/projects/hostcache/sys/conf/files#2 edit
.. //depot/projects/hostcache/sys/net/if_arcsubr.c#2 edit
.. //depot/projects/hostcache/sys/net/if_ef.c#2 edit
.. //depot/projects/hostcache/sys/net/if_ethersubr.c#2 edit
.. //depot/projects/hostcache/sys/net/if_faith.c#2 edit
.. //depot/projects/hostcache/sys/net/if_fddisubr.c#2 edit
.. //depot/projects/hostcache/sys/net/if_iso88025subr.c#2 edit
.. //depot/projects/hostcache/sys/net/if_loop.c#2 edit
.. //depot/projects/hostcache/sys/net/if_ppp.c#2 edit
.. //depot/projects/hostcache/sys/net/route.c#2 edit
.. //depot/projects/hostcache/sys/net/route.h#2 edit
.. //depot/projects/hostcache/sys/net/rtsock.c#2 edit
.. //depot/projects/hostcache/sys/netatalk/ddp_output.c#2 edit
.. //depot/projects/hostcache/sys/netinet/icmp_var.h#2 edit
.. //depot/projects/hostcache/sys/netinet/in_pcb.c#2 edit
.. //depot/projects/hostcache/sys/netinet/in_pcb.h#2 edit
.. //depot/projects/hostcache/sys/netinet/in_rmx.c#2 edit
.. //depot/projects/hostcache/sys/netinet/in_var.h#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_divert.c#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_fastforward.c#3 add
.. //depot/projects/hostcache/sys/netinet/ip_flow.c#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_flow.h#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_fw.h#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_fw2.c#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_icmp.c#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_input.c#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_output.c#2 edit
.. //depot/projects/hostcache/sys/netinet/ip_var.h#2 edit
.. //depot/projects/hostcache/sys/netinet/raw_ip.c#2 edit
.. //depot/projects/hostcache/sys/netinet/tcp.h#2 edit
.. //depot/projects/hostcache/sys/netinet/tcp_hostcache.c#3 add
.. //depot/projects/hostcache/sys/netinet/tcp_input.c#2 edit
.. //depot/projects/hostcache/sys/netinet/tcp_output.c#2 edit
.. //depot/projects/hostcache/sys/netinet/tcp_subr.c#2 edit
.. //depot/projects/hostcache/sys/netinet/tcp_syncache.c#2 edit
.. //depot/projects/hostcache/sys/netinet/tcp_timer.c#2 edit
.. //depot/projects/hostcache/sys/netinet/tcp_usrreq.c#2 edit
.. //depot/projects/hostcache/sys/netinet/tcp_var.h#2 edit
.. //depot/projects/hostcache/sys/netinet/udp_usrreq.c#2 edit
.. //depot/projects/hostcache/sys/netinet6/icmp6.c#2 edit
.. //depot/projects/hostcache/sys/netinet6/in6_pcb.c#2 edit
.. //depot/projects/hostcache/sys/netinet6/in6_rmx.c#2 edit
.. //depot/projects/hostcache/sys/netinet6/in6_src.c#3 edit
.. //depot/projects/hostcache/sys/netinet6/ip6_forward.c#2 edit
.. //depot/projects/hostcache/sys/netinet6/ip6_input.c#2 edit
.. //depot/projects/hostcache/sys/netinet6/ip6_output.c#2 edit
.. //depot/projects/hostcache/sys/netinet6/raw_ip6.c#2 edit
.. //depot/projects/hostcache/sys/netinet6/udp6_output.c#2 edit
.. //depot/projects/hostcache/sys/netipx/ipx_input.c#2 edit
.. //depot/projects/hostcache/sys/netipx/ipx_outputfl.c#2 edit
.. //depot/projects/hostcache/sys/sys/mbuf.h#2 edit

Differences ...

==== //depot/projects/hostcache/sys/conf/files#2 (text+ko) ====

@@ -1424,7 +1424,7 @@
 netinet/ip_ecn.c	optional inet6
 netinet/ip_encap.c	optional inet
 netinet/ip_encap.c	optional inet6
-netinet/ip_flow.c	optional inet
+netinet/ip_fastforward.c	optional inet
 netinet/ip_fw2.c	optional ipfirewall
 netinet/ip_icmp.c	optional inet
 netinet/ip_input.c	optional inet
@@ -1432,6 +1432,7 @@
 netinet/ip_output.c	optional inet
 netinet/raw_ip.c	optional inet
 netinet/tcp_debug.c	optional tcpdebug
+netinet/tcp_hostcache.c	optional inet
 netinet/tcp_input.c	optional inet
 netinet/tcp_output.c	optional inet
 netinet/tcp_subr.c	optional inet

==== //depot/projects/hostcache/sys/net/if_arcsubr.c#2 (text+ko) ====

@@ -543,14 +543,14 @@
 #ifdef INET
 	case ARCTYPE_IP:
 		m_adj(m, ARC_HDRNEWLEN);
-		if (ipflow_fastforward(m))
+		if (ip_fastforward(m))
 			return;
 		isr = NETISR_IP;
 		break;
 
 	case ARCTYPE_IP_OLD:
 		m_adj(m, ARC_HDRLEN);
-		if (ipflow_fastforward(m))
+		if (ip_fastforward(m))
 			return;
 		isr = NETISR_IP;
 		break;

==== //depot/projects/hostcache/sys/net/if_ef.c#2 (text+ko) ====

@@ -252,8 +252,8 @@
 #endif
 #ifdef INET
 	case ETHERTYPE_IP:
-		if (ipflow_fastforward(m))
-			return (0);
+		if (ip_fastforward(m))
+			return;
 		isr = NETISR_IP;
 		break;
 

==== //depot/projects/hostcache/sys/net/if_ethersubr.c#2 (text+ko) ====

@@ -717,7 +717,7 @@
 	switch (ether_type) {
 #ifdef INET
 	case ETHERTYPE_IP:
-		if (ipflow_fastforward(m))
+		if (ip_fastforward(m))
 			return;
 		isr = NETISR_IP;
 		break;

==== //depot/projects/hostcache/sys/net/if_faith.c#2 (text+ko) ====

@@ -271,17 +271,8 @@
 	struct rt_addrinfo *info;
 {
 	RT_LOCK_ASSERT(rt);
-
-	if (rt) {
-		rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; /* for ISO */
-		/*
-		 * For optimal performance, the send and receive buffers
-		 * should be at least twice the MTU plus a little more for
-		 * overhead.
-		 */
-		rt->rt_rmx.rmx_recvpipe =
-			rt->rt_rmx.rmx_sendpipe = 3 * FAITHMTU;
-	}
+	if (rt)
+		rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu;
 }
 
 /*

==== //depot/projects/hostcache/sys/net/if_fddisubr.c#2 (text+ko) ====

@@ -471,7 +471,7 @@
 		switch (type) {
 #ifdef INET
 		case ETHERTYPE_IP:
-			if (ipflow_fastforward(m))
+			if (ip_fastforward(m))
 				return;
 			isr = NETISR_IP;
 			break;

==== //depot/projects/hostcache/sys/net/if_iso88025subr.c#2 (text+ko) ====

@@ -556,7 +556,7 @@
 #ifdef INET
 		case ETHERTYPE_IP:
 			th->iso88025_shost[0] &= ~(TR_RII); 
-			if (ipflow_fastforward(m))
+			if (ip_fastforward(m))
 				return;
 			isr = NETISR_IP;
 			break;

==== //depot/projects/hostcache/sys/net/if_loop.c#2 (text+ko) ====

@@ -357,17 +357,8 @@
 	struct rt_addrinfo *info;
 {
 	RT_LOCK_ASSERT(rt);
-
-	if (rt) {
-		rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu; /* for ISO */
-		/*
-		 * For optimal performance, the send and receive buffers
-		 * should be at least twice the MTU plus a little more for
-		 * overhead.
-		 */
-		rt->rt_rmx.rmx_recvpipe =
-			rt->rt_rmx.rmx_sendpipe = 3 * LOMTU;
-	}
+	if (rt)
+		rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu;
 }
 
 /*

==== //depot/projects/hostcache/sys/net/if_ppp.c#2 (text+ko) ====

@@ -1538,8 +1538,8 @@
 	m->m_pkthdr.len -= PPP_HDRLEN;
 	m->m_data += PPP_HDRLEN;
 	m->m_len -= PPP_HDRLEN;
-	if (ipflow_fastforward(m))
-	    return;
+	if (ip_fastforward(m))
+		return;
 	isr = NETISR_IP;
 	break;
 #endif

==== //depot/projects/hostcache/sys/net/route.c#2 (text+ko) ====

@@ -139,7 +139,7 @@
 		 */
 		newrt = rt = (struct rtentry *)rn;
 		nflags = rt->rt_flags & ~ignflags;
-		if (report && (nflags & (RTF_CLONING | RTF_PRCLONING))) {
+		if (report && (nflags & RTF_CLONING)) {
 			/*
 			 * We are apparently adding (report = 0 in delete).
 			 * If it requires that it be cloned, do so.
@@ -548,7 +548,7 @@
 	 */
 	if (flags & RTF_HOST) {
 		netmask = 0;
-		flags &= ~(RTF_CLONING | RTF_PRCLONING);
+		flags &= ~RTF_CLONING;
 	}
 	switch (req) {
 	case RTM_DELETE:
@@ -570,7 +570,7 @@
 		 * Now search what's left of the subtree for any cloned
 		 * routes which might have been formed from this node.
 		 */
-		if ((rt->rt_flags & (RTF_CLONING | RTF_PRCLONING)) &&
+		if ((rt->rt_flags & RTF_CLONING) &&
 		    rt_mask(rt)) {
 			rnh->rnh_walktree_from(rnh, dst, rt_mask(rt),
 					       rt_fixdelete, rt);
@@ -617,7 +617,7 @@
 		ifa = rt->rt_ifa;
 		/* XXX locking? */
 		flags = rt->rt_flags &
-		    ~(RTF_CLONING | RTF_PRCLONING | RTF_STATIC);
+		    ~(RTF_CLONING | RTF_STATIC);
 		flags |= RTF_WASCLONED;
 		gateway = rt->rt_gateway;
 		if ((netmask = rt->rt_genmask) == 0)
@@ -678,11 +678,11 @@
 			/*
 			 * Uh-oh, we already have one of these in the tree.
 			 * We do a special hack: if the route that's already
-			 * there was generated by the protocol-cloning
-			 * mechanism, then we just blow it away and retry
-			 * the insertion of the new one.
+			 * there was generated by the cloning mechanism
+			 * then we just blow it away and retry the insertion
+			 * of the new one.
 			 */
-			rt2 = rtalloc1(dst, 0, RTF_PRCLONING);
+			rt2 = rtalloc1(dst, 0, 0);
 			if (rt2 && rt2->rt_parent) {
 				rtrequest(RTM_DELETE,
 					  rt_key(rt2),
@@ -724,7 +724,7 @@
 				("no route to clone from"));
 			rt->rt_rmx = (*ret_nrt)->rt_rmx; /* copy metrics */
 			rt->rt_rmx.rmx_pksent = 0; /* reset packet counter */
-			if ((*ret_nrt)->rt_flags & (RTF_CLONING | RTF_PRCLONING)) {
+			if ((*ret_nrt)->rt_flags & RTF_CLONING) {
 				/*
 				 * NB: We do not bump the refcnt on the parent
 				 * entry under the assumption that it will
@@ -800,7 +800,7 @@
 	struct rtentry *rt0 = vp;
 
 	if (rt->rt_parent == rt0 &&
-	    !(rt->rt_flags & (RTF_PINNED | RTF_CLONING | RTF_PRCLONING))) {
+	    !(rt->rt_flags & (RTF_PINNED | RTF_CLONING))) {
 		return rtrequest(RTM_DELETE, rt_key(rt),
 				 (struct sockaddr *)0, rt_mask(rt),
 				 rt->rt_flags, (struct rtentry **)0);
@@ -841,7 +841,7 @@
 #endif
 
 	if (!rt->rt_parent ||
-	    (rt->rt_flags & (RTF_PINNED | RTF_CLONING | RTF_PRCLONING))) {
+	    (rt->rt_flags & (RTF_PINNED | RTF_CLONING))) {
 #ifdef DEBUG
 		if(rtfcdebug) printf("no parent, pinned or cloning\n");
 #endif
@@ -992,9 +992,10 @@
 	 * correct choice anyway), and avoid the resulting reference loops
 	 * by disallowing any route to run through itself as a gateway.
 	 * This is obviously mandatory when we get rt->rt_output().
+	 * XXX: After removal of PRCLONING this probably not needed anymore.
 	 */
 	if (rt->rt_flags & RTF_GATEWAY) {
-		rt->rt_gwroute = rtalloc1(gate, 1, RTF_PRCLONING);
+		rt->rt_gwroute = rtalloc1(gate, 1, 0);
 		if (rt->rt_gwroute == rt) {
 			RTFREE_LOCKED(rt->rt_gwroute);
 			rt->rt_gwroute = 0;

==== //depot/projects/hostcache/sys/net/route.h#2 (text+ko) ====

@@ -58,6 +58,12 @@
  * These numbers are used by reliable protocols for determining
  * retransmission behavior and are included in the routing structure.
  */
+struct rt_metrics_lite {
+	u_long	rmx_mtu;	/* MTU for this path */
+	u_long	rmx_expire;	/* lifetime for route, e.g. redirect */
+	u_long	rmx_pksent;	/* packets sent using this route */
+};
+
 struct rt_metrics {
 	u_long	rmx_locks;	/* Kernel must leave these values alone */
 	u_long	rmx_mtu;	/* MTU for this path */
@@ -104,10 +110,10 @@
 	long	rt_refcnt;		/* # held references */
 	u_long	rt_flags;		/* up/down?, host/net */
 	struct	ifnet *rt_ifp;		/* the answer: interface to use */
-	struct	ifaddr *rt_ifa;		/* the answer: interface to use */
+	struct	ifaddr *rt_ifa;		/* the answer: interface address to use */
 	struct	sockaddr *rt_genmask;	/* for generation of cloned routes */
 	caddr_t	rt_llinfo;		/* pointer to link level info cache */
-	struct	rt_metrics rt_rmx;	/* metrics used by rx'ing protocols */
+	struct	rt_metrics_lite rt_rmx;	/* metrics used by rx'ing protocols */
 	struct	rtentry *rt_gwroute;	/* implied entry for gatewayed routes */
 	int	(*rt_output)(struct ifnet *, struct mbuf *, struct sockaddr *,
 		    struct rtentry *);
@@ -151,7 +157,7 @@
 #define RTF_PROTO2	0x4000		/* protocol specific routing flag */
 #define RTF_PROTO1	0x8000		/* protocol specific routing flag */
 
-#define RTF_PRCLONING	0x10000		/* protocol requires cloning */
+/*			0x10000		   unused */
 #define RTF_WASCLONED	0x20000		/* route generated through cloning */
 #define RTF_PROTO3	0x40000		/* protocol specific routing flag */
 /*			0x80000		   unused */

==== //depot/projects/hostcache/sys/net/rtsock.c#2 (text+ko) ====

@@ -86,7 +86,8 @@
 static int	sysctl_dumpentry(struct radix_node *rn, void *vw);
 static int	sysctl_iflist(int af, struct walkarg *w);
 static int	route_output(struct mbuf *, struct socket *);
-static void	rt_setmetrics(u_long, struct rt_metrics *, struct rt_metrics *);
+static void	rt_setmetrics(u_long, struct rt_metrics *, struct rt_metrics_lite *);
+static void	rt_getmetrics(struct rt_metrics_lite *, struct rt_metrics *);
 static void	rt_dispatch(struct mbuf *, struct sockaddr *);
 
 /*
@@ -354,9 +355,6 @@
 			RT_LOCK(saved_nrt);
 			rt_setmetrics(rtm->rtm_inits,
 				&rtm->rtm_rmx, &saved_nrt->rt_rmx);
-			saved_nrt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits);
-			saved_nrt->rt_rmx.rmx_locks |=
-				(rtm->rtm_inits & rtm->rtm_rmx.rmx_locks);
 			saved_nrt->rt_refcnt--;
 			saved_nrt->rt_genmask = info.rti_info[RTAX_GENMASK];
 			RT_UNLOCK(saved_nrt);
@@ -427,7 +425,7 @@
 			(void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm,
 				(struct walkarg *)0);
 			rtm->rtm_flags = rt->rt_flags;
-			rtm->rtm_rmx = rt->rt_rmx;
+			rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx);
 			rtm->rtm_addrs = info.rti_addrs;
 			break;
 
@@ -477,9 +475,7 @@
 				rt->rt_genmask = info.rti_info[RTAX_GENMASK];
 			/* FALLTHROUGH */
 		case RTM_LOCK:
-			rt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits);
-			rt->rt_rmx.rmx_locks |=
-				(rtm->rtm_inits & rtm->rtm_rmx.rmx_locks);
+			/* We don't support locks anymore */
 			break;
 		}
 		RT_UNLOCK(rt);
@@ -541,20 +537,28 @@
 }
 
 static void
-rt_setmetrics(u_long which, struct rt_metrics *in, struct rt_metrics *out)
+rt_setmetrics(u_long which, struct rt_metrics *in, struct rt_metrics_lite *out)
 {
 #define metric(f, e) if (which & (f)) out->e = in->e;
-	metric(RTV_RPIPE, rmx_recvpipe);
-	metric(RTV_SPIPE, rmx_sendpipe);
-	metric(RTV_SSTHRESH, rmx_ssthresh);
-	metric(RTV_RTT, rmx_rtt);
-	metric(RTV_RTTVAR, rmx_rttvar);
-	metric(RTV_HOPCOUNT, rmx_hopcount);
+	/*
+	 * Only these are stored in the routing entry since introduction
+	 * of tcp hostcache. The rest is ignored.
+	 */
 	metric(RTV_MTU, rmx_mtu);
 	metric(RTV_EXPIRE, rmx_expire);
 #undef metric
 }
 
+static void
+rt_getmetrics(struct rt_metrics_lite *in, struct rt_metrics *out)
+{
+#define metric(e) out->e = in->e;
+	bzero(out, sizeof(*out));
+	metric(rmx_mtu);
+	metric(rmx_expire);
+#undef metric
+}
+
 #define ROUNDUP(a) \
 	((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
 
@@ -944,8 +948,8 @@
 		struct rt_msghdr *rtm = (struct rt_msghdr *)w->w_tmem;
 
 		rtm->rtm_flags = rt->rt_flags;
-		rtm->rtm_use = rt->rt_use;
-		rtm->rtm_rmx = rt->rt_rmx;
+		rtm->rtm_use = rt->rt_rmx.rmx_pksent;
+		rt_getmetrics(&rt->rt_rmx, &rtm->rtm_rmx);
 		rtm->rtm_index = rt->rt_ifp->if_index;
 		rtm->rtm_errno = rtm->rtm_pid = rtm->rtm_seq = 0;
 		rtm->rtm_addrs = info.rti_addrs;

==== //depot/projects/hostcache/sys/netatalk/ddp_output.c#2 (text+ko) ====

@@ -217,7 +217,7 @@
 	elh->el_type = ELAP_DDPEXTEND;
 	elh->el_dnode = gate.sat_addr.s_node;
     }
-    ro->ro_rt->rt_use++;
+    ro->ro_rt->rt_rmx.rmx_pksent++;
 
 #ifdef NETATALK_DEBUG
     printf ("ddp_route: from %d.%d to %d.%d, via %d.%d (%s%d)\n",

==== //depot/projects/hostcache/sys/netinet/icmp_var.h#2 (text+ko) ====

@@ -81,11 +81,12 @@
 extern int badport_bandlim(int);
 #define BANDLIM_UNLIMITED -1
 #define BANDLIM_ICMP_UNREACH 0
-#define BANDLIM_ICMP_ECHO 1
-#define BANDLIM_ICMP_TSTAMP 2
-#define BANDLIM_RST_CLOSEDPORT 3 /* No connection, and no listeners */
-#define BANDLIM_RST_OPENPORT 4   /* No connection, listener */
-#define BANDLIM_MAX 4
+#define BANDLIM_ICMP_UNREACH_HOST 1
+#define BANDLIM_ICMP_ECHO 2
+#define BANDLIM_ICMP_TSTAMP 3
+#define BANDLIM_RST_CLOSEDPORT 4	/* No connection, and no listeners */
+#define BANDLIM_RST_OPENPORT 5		/* No connection, listener */
+#define BANDLIM_MAX 5
 #endif
 
 #endif

==== //depot/projects/hostcache/sys/netinet/in_pcb.c#2 (text+ko) ====

@@ -536,7 +536,6 @@
 		if (error)
 			return (error);
 	}
-
 	if (!TAILQ_EMPTY(&in_ifaddrhead)) {
 		/*
 		 * If the destination address is INADDR_ANY,
@@ -554,7 +553,8 @@
 			    &in_ifaddrhead)->ia_broadaddr)->sin_addr;
 	}
 	if (laddr.s_addr == INADDR_ANY) {
-		register struct route *ro;
+		struct route *ro;
+		struct route sro;
 
 		ia = (struct in_ifaddr *)0;
 		/*
@@ -563,19 +563,10 @@
 		 * Note that we should check the address family of the cached
 		 * destination, in case of sharing the cache with IPv6.
 		 */
-		ro = &inp->inp_route;
-		if (ro->ro_rt &&
-		    (ro->ro_dst.sa_family != AF_INET ||
-		     satosin(&ro->ro_dst)->sin_addr.s_addr != faddr.s_addr ||
-		     inp->inp_socket->so_options & SO_DONTROUTE)) {
-			RTFREE(ro->ro_rt);
-			ro->ro_rt = (struct rtentry *)0;
-		}
-		if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0 && /*XXX*/
-		    (ro->ro_rt == (struct rtentry *)0 ||
-		    ro->ro_rt->rt_ifp == (struct ifnet *)0)) {
-			/* No route yet, so try to acquire one */
-			bzero(&ro->ro_dst, sizeof(struct sockaddr_in));
+		ro = &sro;
+		bzero(ro, sizeof(*ro));
+		if ((inp->inp_socket->so_options & SO_DONTROUTE) == 0) {
+			/* Find out route to destination */
 			ro->ro_dst.sa_family = AF_INET;
 			ro->ro_dst.sa_len = sizeof(struct sockaddr_in);
 			((struct sockaddr_in *)&ro->ro_dst)->sin_addr = faddr;
@@ -589,6 +580,8 @@
 		 */
 		if (ro->ro_rt && !(ro->ro_rt->rt_ifp->if_flags & IFF_LOOPBACK))
 			ia = ifatoia(ro->ro_rt->rt_ifa);
+		if (ro->ro_rt)
+			RTFREE(ro->ro_rt);
 		if (ia == 0) {
 			bzero(&sa, sizeof(sa));
 			sa.sin_addr = faddr;
@@ -675,8 +668,6 @@
 	}
 	if (inp->inp_options)
 		(void)m_free(inp->inp_options);
-	if (inp->inp_route.ro_rt)
-		RTFREE(inp->inp_route.ro_rt);
 	ip_freemoptions(inp->inp_moptions);
 	inp->inp_vflag = 0;
 	INP_LOCK_DESTROY(inp);
@@ -850,60 +841,6 @@
 }
 
 /*
- * Check for alternatives when higher level complains
- * about service problems.  For now, invalidate cached
- * routing information.  If the route was created dynamically
- * (by a redirect), time to try a default gateway again.
- */
-void
-in_losing(inp)
-	struct inpcb *inp;
-{
-	register struct rtentry *rt;
-	struct rt_addrinfo info;
-
-	if ((rt = inp->inp_route.ro_rt)) {
-		RT_LOCK(rt);
-		inp->inp_route.ro_rt = NULL;
-		bzero((caddr_t)&info, sizeof(info));
-		info.rti_flags = rt->rt_flags;
-		info.rti_info[RTAX_DST] = rt_key(rt);
-		info.rti_info[RTAX_GATEWAY] = rt->rt_gateway;
-		info.rti_info[RTAX_NETMASK] = rt_mask(rt);
-		rt_missmsg(RTM_LOSING, &info, rt->rt_flags, 0);
-		if (rt->rt_flags & RTF_DYNAMIC) {
-			RT_UNLOCK(rt);		/* XXX refcnt? */
-			(void) rtrequest1(RTM_DELETE, &info, NULL);
-		} else
-			rtfree(rt);
-		/*
-		 * A new route can be allocated
-		 * the next time output is attempted.
-		 */
-	}
-}
-
-/*
- * After a routing change, flush old routing
- * and allocate a (hopefully) better one.
- */
-struct inpcb *
-in_rtchange(inp, errno)
-	register struct inpcb *inp;
-	int errno;
-{
-	if (inp->inp_route.ro_rt) {
-		RTFREE(inp->inp_route.ro_rt);
-		inp->inp_route.ro_rt = 0;
-		/*
-		 * A new route can be allocated the next time
-		 * output is attempted.
-		 */
-	}
-	return inp;
-}
-
-/*
  * Lookup a PCB based on the local address and port.
  */
 struct inpcb *

==== //depot/projects/hostcache/sys/netinet/in_pcb.h#2 (text+ko) ====

@@ -94,31 +94,22 @@
 
 /*
  * XXX
- * At some point struct route should possibly change to:
- *   struct rtentry *rt
- *   struct in_endpoints *ie; 
+ * the defines for inc_* are hacks and should be changed to direct references
  */
 struct in_conninfo {
 	u_int8_t	inc_flags;
 	u_int8_t	inc_len;
 	u_int16_t	inc_pad;	/* XXX alignment for in_endpoints */
-	/* protocol dependent part; cached route */
+	/* protocol dependent part */
 	struct	in_endpoints inc_ie;
-	union {
-		/* placeholder for routing entry */
-		struct	route inc4_route;
-		struct	route_in6 inc6_route;
-	} inc_dependroute;
 };
 #define inc_isipv6	inc_flags	/* temp compatability */
 #define	inc_fport	inc_ie.ie_fport
 #define	inc_lport	inc_ie.ie_lport
 #define	inc_faddr	inc_ie.ie_faddr
 #define	inc_laddr	inc_ie.ie_laddr
-#define	inc_route	inc_dependroute.inc4_route
 #define	inc6_faddr	inc_ie.ie6_faddr
 #define	inc6_laddr	inc_ie.ie6_laddr
-#define	inc6_route	inc_dependroute.inc6_route
 
 struct	icmp6_filter;
 
@@ -156,7 +147,6 @@
 #define inp_lport	inp_inc.inc_lport
 #define	inp_faddr	inp_inc.inc_faddr
 #define	inp_laddr	inp_inc.inc_laddr
-#define	inp_route	inp_inc.inc_route
 #define	inp_ip_tos	inp_depend4.inp4_ip_tos
 #define	inp_options	inp_depend4.inp4_options
 #define	inp_moptions	inp_depend4.inp4_moptions
@@ -182,7 +172,6 @@
 
 #define	in6p_faddr	inp_inc.inc6_faddr
 #define	in6p_laddr	inp_inc.inc6_laddr
-#define	in6p_route	inp_inc.inc6_route
 #define	in6p_ip6_hlim	inp_depend6.inp6_hlim
 #define	in6p_hops	inp_depend6.inp6_hops	/* default hop limit */
 #define	in6p_ip6_nxt	inp_ip_p
@@ -327,9 +316,6 @@
 extern int	ipport_hilastauto;
 
 void	in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
-void	in_losing(struct inpcb *);
-struct inpcb *
-	in_rtchange(struct inpcb *, int);
 int	in_pcballoc(struct socket *, struct inpcbinfo *, struct thread *);
 int	in_pcbbind(struct inpcb *, struct sockaddr *, struct thread *);
 int	in_pcbbind_setup(struct inpcb *, struct sockaddr *, in_addr_t *,

==== //depot/projects/hostcache/sys/netinet/in_rmx.c#2 (text+ko) ====

@@ -73,15 +73,6 @@
 	struct radix_node *ret;
 
 	/*
-	 * For IP, all unicast non-host routes are automatically cloning.
-	 */
-	if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
-		rt->rt_flags |= RTF_MULTICAST;
-
-	if (!(rt->rt_flags & (RTF_HOST | RTF_CLONING | RTF_MULTICAST)))
-		rt->rt_flags |= RTF_PRCLONING;
-
-	/*
 	 * A little bit of help for both IP output and input:
 	 *   For host routes, we make sure that RTF_BROADCAST
 	 *   is set for anything that looks like a broadcast address.
@@ -94,8 +85,7 @@
 	 *
 	 * We also mark routes to multicast addresses as such, because
 	 * it's easy to do and might be useful (but this is much more
-	 * dubious since it's so easy to inspect the address).  (This
-	 * is done above.)
+	 * dubious since it's so easy to inspect the address).
 	 */
 	if (rt->rt_flags & RTF_HOST) {
 		if (in_broadcast(sin->sin_addr, rt->rt_ifp)) {
@@ -105,9 +95,10 @@
 			rt->rt_flags |= RTF_LOCAL;
 		}
 	}
+	if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
+		rt->rt_flags |= RTF_MULTICAST;
 
-	if (!rt->rt_rmx.rmx_mtu && !(rt->rt_rmx.rmx_locks & RTV_MTU) &&
-	    rt->rt_ifp)
+	if (!rt->rt_rmx.rmx_mtu && rt->rt_ifp)
 		rt->rt_rmx.rmx_mtu = rt->rt_ifp->if_mtu;
 
 	ret = rn_addroute(v_arg, n_arg, head, treenodes);
@@ -118,8 +109,7 @@
 		 * Find out if it is because of an
 		 * ARP entry and delete it if so.
 		 */
-		rt2 = rtalloc1((struct sockaddr *)sin, 0,
-				RTF_CLONING | RTF_PRCLONING);
+		rt2 = rtalloc1((struct sockaddr *)sin, 0, RTF_CLONING);
 		if (rt2) {
 			if (rt2->rt_flags & RTF_LLINFO &&
 			    rt2->rt_flags & RTF_HOST &&
@@ -138,14 +128,6 @@
 			RTFREE_LOCKED(rt2);
 		}
 	}
-
-	/*
-	 * If the new route created successfully, and we are forwarding,
-	 * flush any cached routes to avoid using a stale value.
-	 */
-	if (ret != NULL && ipforwarding)
-		ip_forward_cacheinval();
-
 	return ret;
 }
 
@@ -398,7 +380,7 @@
 		 * so that behavior is not needed there.
 		 */
 		RT_LOCK(rt);
-		rt->rt_flags &= ~(RTF_CLONING | RTF_PRCLONING);
+		rt->rt_flags &= ~RTF_CLONING;
 		RT_UNLOCK(rt);
 		err = rtrequest(RTM_DELETE, (struct sockaddr *)rt_key(rt),
 				rt->rt_gateway, rt_mask(rt), rt->rt_flags, 0);

==== //depot/projects/hostcache/sys/netinet/in_var.h#2 (text+ko) ====

@@ -230,9 +230,7 @@
 void	ip_input(struct mbuf *);
 int	in_ifadown(struct ifaddr *ifa, int);
 void	in_ifscrub(struct ifnet *, struct in_ifaddr *);
-int	ipflow_fastforward(struct mbuf *);
-void	ipflow_create(const struct route *, struct mbuf *);
-void	ipflow_slowtimo(void);
+int	ip_fastforward(struct mbuf *);
 
 #endif /* _KERNEL */
 

==== //depot/projects/hostcache/sys/netinet/ip_divert.c#2 (text+ko) ====

@@ -333,7 +333,7 @@
 		/* Send packet to output processing */
 		ipstat.ips_rawout++;			/* XXX */
 		error = ip_output((struct mbuf *)&divert_tag,
-			    inp->inp_options, &inp->inp_route,
+			    inp->inp_options, NULL,
 			    (so->so_options & SO_DONTROUTE) |
 			    IP_ALLOWBROADCAST | IP_RAWOUTPUT,
 			    inp->inp_moptions, NULL);

==== //depot/projects/hostcache/sys/netinet/ip_flow.c#2 (text+ko) ====

@@ -1,377 +1,1 @@
-/*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by the 3am Software Foundry ("3am").  It was developed by Matt Thomas.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the NetBSD
- *	Foundation, Inc. and its contributors.
- * 4. Neither the name of The NetBSD Foundation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/sys/netinet/ip_flow.c,v 1.15 2003/10/04 03:44:49 sam Exp $
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mbuf.h>
-#include <sys/mutex.h>
-#include <sys/protosw.h>
-#include <sys/socket.h>
-#include <sys/kernel.h>
-
-#include <sys/sysctl.h>
-
-#include <net/if.h>
-#include <net/route.h>
-
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
-#include <netinet/in_var.h>
-#include <netinet/ip_var.h>
-#include <netinet/ip_flow.h>
-
-#define	IPFLOW_TIMER		(5 * PR_SLOWHZ)
-#define IPFLOW_HASHBITS		6	/* should not be a multiple of 8 */
-#define	IPFLOW_HASHSIZE		(1 << IPFLOW_HASHBITS)
-#if IPFLOW_HASHSIZE > 255
-#error "make ipf_hash larger"
-#endif
-static struct ipflow_head ipflows[IPFLOW_HASHSIZE];
-static int ipflow_inuse;
-#define	IPFLOW_MAX		256
-
-/*
- * Each flow list has a lock that guards updates to the list and to
- * all entries on the list.  Flow entries hold the hash index for
- * finding the head of the list so the lock can be found quickly.
- *
- * ipflow_inuse holds a count of the number of flow entries present.
- * This is used to bound the size of the table.  When IPFLOW_MAX entries
- * are present and an additional entry is needed one is chosen for
- * replacement.  We could use atomic ops for this counter but having it
- * inconsistent doesn't appear to be a problem.
- */
-#define	IPFLOW_HEAD_LOCK(_ipfh)		mtx_lock(&(_ipfh)->ipfh_mtx)
-#define	IPFLOW_HEAD_UNLOCK(_ipfh)	mtx_unlock(&(_ipfh)->ipfh_mtx)
-#define	IPFLOW_LOCK(_ipf) \
-	IPFLOW_HEAD_LOCK(&ipflows[(_ipf)->ipf_hash])
-#define	IPFLOW_UNLOCK(_ipf) \
-	IPFLOW_HEAD_UNLOCK(&ipflows[(_ipf)->ipf_hash])
-
-static int ipflow_active = 0;
-SYSCTL_INT(_net_inet_ip, IPCTL_FASTFORWARDING, fastforwarding, CTLFLAG_RW,
-    &ipflow_active, 0, "Enable flow-based IP forwarding");
-
-static MALLOC_DEFINE(M_IPFLOW, "ip_flow", "IP flow");
-
-static unsigned
-ipflow_hash(struct in_addr dst, struct in_addr src, unsigned tos)
-{
-	unsigned hash = tos;
-	int idx;
-	for (idx = 0; idx < 32; idx += IPFLOW_HASHBITS)
-		hash += (dst.s_addr >> (32 - idx)) + (src.s_addr >> idx);
-	return hash & (IPFLOW_HASHSIZE-1);
-}
-
-static struct ipflow *
-ipflow_lookup(const struct ip *ip)
-{
-	unsigned hash;
-	struct ipflow_head *head;
-	struct ipflow *ipf;
-
-	hash = ipflow_hash(ip->ip_dst, ip->ip_src, ip->ip_tos);
-	head = &ipflows[hash];
-
-	IPFLOW_HEAD_LOCK(head);
-	LIST_FOREACH(ipf, &head->ipfh_head, ipf_next) {
-		if (ip->ip_dst.s_addr == ipf->ipf_dst.s_addr
-		    && ip->ip_src.s_addr == ipf->ipf_src.s_addr
-		    && ip->ip_tos == ipf->ipf_tos) {
-			/* NB: return head locked */
-			return ipf;
-		}
-	}
-	IPFLOW_HEAD_UNLOCK(head);
-	return NULL;
-}
-
-int
-ipflow_fastforward(struct mbuf *m)
-{
-	struct ip *ip;
-	struct ipflow *ipf;
-	struct rtentry *rt;
-	struct sockaddr *dst;
-	int error;
-
-	/*
-	 * Are we forwarding packets?  Big enough for an IP packet?
-	 */
-	if (!ipforwarding || !ipflow_active || m->m_len < sizeof(struct ip))
-		return 0;
-	/*
-	 * IP header with no option and valid version and length
-	 */
-	ip = mtod(m, struct ip *);
-	if (ip->ip_v != IPVERSION || ip->ip_hl != (sizeof(struct ip) >> 2)
-	    || ntohs(ip->ip_len) > m->m_pkthdr.len)
-		return 0;
-	/*
-	 * Find a flow.
-	 */
-	if ((ipf = ipflow_lookup(ip)) == NULL)
-		return 0;
-
-	/*
-	 * Route and interface still up?
-	 */
-	rt = ipf->ipf_ro.ro_rt;
-	if ((rt->rt_flags & RTF_UP) == 0 || (rt->rt_ifp->if_flags & IFF_UP) == 0) {
-		IPFLOW_UNLOCK(ipf);
-		return 0;
-	}
-
-	/*
-	 * Packet size OK?  TTL?
-	 */
-	if (m->m_pkthdr.len > rt->rt_ifp->if_mtu || ip->ip_ttl <= IPTTLDEC) {
-		IPFLOW_UNLOCK(ipf);
-		return 0;
-	}
-
-	/*
-	 * Everything checks out and so we can forward this packet.
-	 * Modify the TTL and incrementally change the checksum.
-	 */
-	ip->ip_ttl -= IPTTLDEC;
-	if (ip->ip_sum >= htons(0xffff - (IPTTLDEC << 8))) {
-		ip->ip_sum += htons(IPTTLDEC << 8) + 1;
-	} else {
-		ip->ip_sum += htons(IPTTLDEC << 8);
-	}
-
-	/*
-	 * Send the packet on its way.  All we can get back is ENOBUFS
-	 */
-	ipf->ipf_uses++;
-	ipf->ipf_timer = IPFLOW_TIMER;
-
-	if (rt->rt_flags & RTF_GATEWAY)
-		dst = rt->rt_gateway;
-	else
-		dst = &ipf->ipf_ro.ro_dst;
-	if ((error = (*rt->rt_ifp->if_output)(rt->rt_ifp, m, dst, rt)) != 0) {
-		if (error == ENOBUFS)
-			ipf->ipf_dropped++;
-		else
-			ipf->ipf_errors++;
-	}
-	IPFLOW_UNLOCK(ipf);
-	return 1;
-}
-
-static void
-ipflow_addstats(struct ipflow *ipf)
-{
-	ipf->ipf_ro.ro_rt->rt_use += ipf->ipf_uses;
-	ipstat.ips_cantforward += ipf->ipf_errors + ipf->ipf_dropped;
-	ipstat.ips_forward += ipf->ipf_uses;
-	ipstat.ips_fastforward += ipf->ipf_uses;
-}
-
-/*
- * XXX the locking here makes reaping an entry very expensive...
- */
-static struct ipflow *
-ipflow_reap(void)
-{
-	struct ipflow *victim = NULL;
-	struct ipflow *ipf;
-	int idx;
-
-	for (idx = 0; idx < IPFLOW_HASHSIZE; idx++) {
-		struct ipflow_head *head = &ipflows[idx];
-
-		IPFLOW_HEAD_LOCK(head);
-		LIST_FOREACH(ipf, &head->ipfh_head, ipf_next) {
-			/*
-			 * If this no longer points to a valid route
-			 * reclaim it.
-			 */
-			if ((ipf->ipf_ro.ro_rt->rt_flags & RTF_UP) == 0)
-				goto done;
-			/*
-			 * choose the one that's been least recently used
-			 * or has had the least uses in the last 1.5 
-			 * intervals.
-			 */
-			if (victim == NULL)
-				victim = ipf;
-			else if (ipf->ipf_timer < victim->ipf_timer
-			    || (ipf->ipf_timer == victim->ipf_timer
-				&& ipf->ipf_last_uses + ipf->ipf_uses <
-				    victim->ipf_last_uses + victim->ipf_uses)) {

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200310240456.h9O4usSG026089>