Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 07 Mar 2002 10:41:35 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Julian Elischer <julian@elischer.org>
Cc:        Bill Fumerola <billf@mu.org>, net@freebsd.org, hackers@freebsd.org
Subject:   Re: in_pcblookup_hash() called multiple times
Message-ID:  <3C87B45F.3061AABF@mindspring.com>
References:  <Pine.BSF.4.21.0203070351020.41354-100000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------87879C4452F25813094EB958
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Julian Elischer wrote:
> what  would be even nicer is if ipfw found the cached entry and passed it
> back to ip_input so it didn't need to :-)

This is the approach I intended.

The problem is that there are cases where you want the inpcb
for additional processing (e.g. ipfw), and cases where there
is no additioanl processing.

Just because you have IP traffic doesn't mean you have an
inpcb requirement.

In addition, there are two lookup cases that are meaningful
to the upper layers of the code (wildcard and non-wildcard);
both of these are constrained to the source/source port and
dest/dest port.

The ipfw code actually does a number of lookups based on
both input and output processing.  Fixing up the input
processing is rather easy (if tedious).  The output processing
is much harder to do anything but cache.


NB: Is there a particular reason Bill's changes haven't simply
been committed?

In any case, I have a rough set of patches that adds a parameter
for the cached inpcb, and passes a pointer to the pointer to the
ipfw_chk() that it can fill out, and that will be passed to the
upper level protocol processing, if it's filled out.

I say "rough" here because I've not included the IPv6 code; don't
worry: everything still works, but the IPv6 code seems to use
varradic functions as initializers for the protosw in some cases,
and seems to be broken in a couple of other places, and I wasn't
going to go through and fix it without the IPv6 people being
involved.  The if_gif code is a particular abomination.  8-(.

I also only do the tcp_input() and udp_input() path, and leave
the ctlinput path for both for someone else (the parameter is
there, I just don't check it before the lookup, which is trivial
to do... see tcp_input).

A clever eye will note that the lookup in the ip_fw code is
non-wildcard, and the lookup in the tcp_input is wildcard.
This works because the tcp_input call to in_pcblookup_hash
wildcard case matches in both the wildcard and the non-wildcard
case.  The wildcard case is handled by doing a wildcard lookup
if the cached value is NULL.  This makes the code work in all
cases, including the case where the ipfw code is not enabled
(it just falls back to the old behaviour).

Actually, I'm not sure that the non-wildcard lookup in the ipfw
case is correct.  It seems to me that you could use this to do
filter avoidance on initial packets (e.g. T/TCP or data piggyback
on the ACK for an outbound connection setup).

Anyway, patches in unidiff format (that Julian likes) against
-stable as of yesterday's CVSup are attached (about 20k).

I'd like to see Bill F's stuff rolled in, too... obviously.

-- Terry
--------------87879C4452F25813094EB958
Content-Type: text/plain; charset=us-ascii;
 name="inp.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="inp.patch"

Index: net/bridge.c
===================================================================
RCS file: /usr/cvs/src/sys/net/bridge.c,v
retrieving revision 1.16.2.17
diff -u -r1.16.2.17 bridge.c
--- net/bridge.c	24 Nov 2001 01:48:21 -0000	1.16.2.17
+++ net/bridge.c	7 Mar 2002 18:22:36 -0000
@@ -767,7 +767,8 @@
 	 * The firewall knows this is a bridged packet as the cookie ptr
 	 * is NULL.
 	 */
-	i = ip_fw_chk_ptr(&ip, 0, NULL, NULL /* cookie */, &m0, &rule, NULL);
+	i = ip_fw_chk_ptr(&ip, 0, NULL, NULL /* cookie */, &m0, &rule,
+								NULL, NULL);
 	if ( (i & IP_FW_PORT_DENY_FLAG) || m0 == NULL) /* drop */
 	    return m0 ;
 	/*
Index: netinet/igmp.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/igmp.c,v
retrieving revision 1.29.2.1
diff -u -r1.29.2.1 igmp.c
--- netinet/igmp.c	17 Sep 2001 15:17:46 -0000	1.29.2.1
+++ netinet/igmp.c	7 Mar 2002 07:23:22 -0000
@@ -146,9 +146,10 @@
 }
 
 void
-igmp_input(m, off, proto)
+igmp_input(m, off, proto, vimp)
 	register struct mbuf *m;
 	int off, proto;
+	void *vimp;
 {
 	register int iphlen = off;
 	register struct igmp *igmp;
@@ -336,7 +337,7 @@
 	 * Pass all valid IGMP packets up to any process(es) listening
 	 * on a raw IGMP socket.
 	 */
-	rip_input(m, off, proto);
+	rip_input(m, off, proto, vimp);
 }
 
 void
Index: netinet/igmp_var.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/igmp_var.h,v
retrieving revision 1.17
diff -u -r1.17 igmp_var.h
--- netinet/igmp_var.h	29 Dec 1999 04:40:59 -0000	1.17
+++ netinet/igmp_var.h	7 Mar 2002 07:23:46 -0000
@@ -86,7 +86,7 @@
 #define IGMP_AGE_THRESHOLD			540
 
 void	igmp_init __P((void));
-void	igmp_input __P((struct mbuf *, int, int));
+void	igmp_input __P((struct mbuf *, int, int, void *));
 void	igmp_joingroup __P((struct in_multi *));
 void	igmp_leavegroup __P((struct in_multi *));
 void	igmp_fasttimo __P((void));
Index: netinet/in_gif.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/in_gif.c,v
retrieving revision 1.5.2.5
diff -u -r1.5.2.5 in_gif.c
--- netinet/in_gif.c	24 Jul 2001 19:10:18 -0000	1.5.2.5
+++ netinet/in_gif.c	7 Mar 2002 07:34:19 -0000
@@ -202,10 +202,11 @@
 }
 
 void
-in_gif_input(m, off, proto)
+in_gif_input(m, off, proto, vinp)
 	struct mbuf *m;
 	int off;
 	int proto;
+	void *vinp;
 {
 	struct ifnet *gifp = NULL;
 	struct ip *ip;
Index: netinet/in_gif.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/in_gif.h,v
retrieving revision 1.3.2.2
diff -u -r1.3.2.2 in_gif.h
--- netinet/in_gif.h	24 Jul 2001 19:10:18 -0000	1.3.2.2
+++ netinet/in_gif.h	7 Mar 2002 07:34:41 -0000
@@ -37,7 +37,7 @@
 
 extern int ip_gif_ttl;
 
-void in_gif_input __P((struct mbuf *, int off, int proto));
+void in_gif_input __P((struct mbuf *, int off, int proto, void *));
 int in_gif_output __P((struct ifnet *, int, struct mbuf *, struct rtentry *));
 int gif_encapcheck4 __P((const struct mbuf *, int, int, void *));
 
Index: netinet/ip_divert.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_divert.c,v
retrieving revision 1.42.2.4
diff -u -r1.42.2.4 ip_divert.c
--- netinet/ip_divert.c	29 Jul 2001 19:32:40 -0000	1.42.2.4
+++ netinet/ip_divert.c	7 Mar 2002 07:44:31 -0000
@@ -129,7 +129,7 @@
  * with that protocol number to enter the system from the outside.
  */
 void
-div_input(struct mbuf *m, int off, int proto)
+div_input(struct mbuf *m, int off, int proto, void *vinp)
 {
 	ipstat.ips_noproto++;
 	m_freem(m);
Index: netinet/ip_encap.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_encap.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 ip_encap.c
--- netinet/ip_encap.c	3 Jul 2001 11:01:46 -0000	1.1.2.2
+++ netinet/ip_encap.c	7 Mar 2002 17:59:44 -0000
@@ -211,7 +211,7 @@
 		psw = (const struct ipprotosw *)match->psw;
 		if (psw && psw->pr_input) {
 			encap_fillarg(m, match);
-			(*psw->pr_input)(m, off, proto);
+			(*psw->pr_input)(m, off, proto, NULL);
 		} else
 			m_freem(m);
 		return;
@@ -230,16 +230,17 @@
 #endif
 
 	/* last resort: inject to raw socket */
-	rip_input(m, off, proto);
+	rip_input(m, off, proto, NULL);
 }
 #endif
 
 #ifdef INET6
 int
-encap6_input(mp, offp, proto)
+encap6_input(mp, offp, proto, vinp)
 	struct mbuf **mp;
 	int *offp;
 	int proto;
+	void *vinp;
 {
 	struct mbuf *m = *mp;
 	struct ip6_hdr *ip6;
Index: netinet/ip_encap.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_encap.h,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 ip_encap.h
--- netinet/ip_encap.h	15 Jul 2000 07:14:30 -0000	1.1.2.1
+++ netinet/ip_encap.h	7 Mar 2002 07:41:34 -0000
@@ -50,7 +50,7 @@
 
 void	encap_init __P((void));
 void	encap4_input __P((struct mbuf *, ...));
-int	encap6_input __P((struct mbuf **, int *, int));
+int	encap6_input __P((struct mbuf **, int *, int, void *));
 const struct encaptab *encap_attach __P((int, int, const struct sockaddr *,
 	const struct sockaddr *, const struct sockaddr *,
 	const struct sockaddr *, const struct protosw *, void *));
Index: netinet/ip_fw.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_fw.c,v
retrieving revision 1.131.2.30
diff -u -r1.131.2.30 ip_fw.c
--- netinet/ip_fw.c	7 Jan 2002 22:40:22 -0000	1.131.2.30
+++ netinet/ip_fw.c	7 Mar 2002 18:27:30 -0000
@@ -227,7 +227,7 @@
 static int	ip_fw_chk (struct ip **pip, int hlen,
 			struct ifnet *oif, u_int16_t *cookie, struct mbuf **m,
 			struct ip_fw **flow_id,
-			struct sockaddr_in **next_hop);
+			struct sockaddr_in **next_hop, struct inpcb **inpp);
 static int	ip_fw_ctl (struct sockopt *sopt);
 
 ip_dn_ruledel_t *ip_dn_ruledel_ptr = NULL;
@@ -1059,7 +1059,7 @@
 ip_fw_chk(struct ip **pip, int hlen,
 	struct ifnet *oif, u_int16_t *cookie, struct mbuf **m,
 	struct ip_fw **flow_id,
-        struct sockaddr_in **next_hop)
+        struct sockaddr_in **next_hop, struct inpcb **inpp)
 {
 	struct ip_fw *f = NULL;		/* matching rule */
 	struct ip *ip = *pip;
@@ -1298,10 +1298,13 @@
 				P = in_pcblookup_hash(&tcbinfo, dst_ip,
 				   dst_port, src_ip, src_port, 0,
 				   oif);
-			    else
+			    else {
 				P = in_pcblookup_hash(&tcbinfo, src_ip,
 				   src_port, dst_ip, dst_port, 0,
 				   NULL);
+				if( inpp)
+					*inpp = P;
+			    }
 
 			    if (P && P->inp_socket) {
 				if (f->fw_flg & IP_FW_F_UID) {
@@ -1327,10 +1330,13 @@
 				P = in_pcblookup_hash(&udbinfo, dst_ip,
 				   dst_port, src_ip, src_port, 1,
 				   oif);
-			    else
+			    else {
 				P = in_pcblookup_hash(&udbinfo, src_ip,
 				   src_port, dst_ip, dst_port, 1,
 				   NULL);
+				if( inpp)
+					*inpp = P;
+			    }
 
 			    if (P && P->inp_socket) {
 				if (f->fw_flg & IP_FW_F_UID) {
Index: netinet/ip_fw.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_fw.h,v
retrieving revision 1.47.2.10
diff -u -r1.47.2.10 ip_fw.h
--- netinet/ip_fw.h	3 Nov 2001 00:36:09 -0000	1.47.2.10
+++ netinet/ip_fw.h	7 Mar 2002 18:15:01 -0000
@@ -335,7 +335,7 @@
 struct ip;
 struct sockopt;
 typedef int ip_fw_chk_t (struct ip **, int, struct ifnet *, u_int16_t *,
-    struct mbuf **, struct ip_fw **, struct sockaddr_in **);
+    struct mbuf **, struct ip_fw **, struct sockaddr_in **, struct inpcb **);
 typedef int ip_fw_ctl_t (struct sockopt *);
 extern ip_fw_chk_t *ip_fw_chk_ptr;
 extern ip_fw_ctl_t *ip_fw_ctl_ptr;
Index: netinet/ip_icmp.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_icmp.c,v
retrieving revision 1.39.2.14
diff -u -r1.39.2.14 ip_icmp.c
--- netinet/ip_icmp.c	14 Jan 2002 07:54:35 -0000	1.39.2.14
+++ netinet/ip_icmp.c	7 Mar 2002 07:25:59 -0000
@@ -237,9 +237,10 @@
  * Process a received ICMP message.
  */
 void
-icmp_input(m, off, proto)
+icmp_input(m, off, proto, vinp)
 	register struct mbuf *m;
 	int off, proto;
+	void *vinp;
 {
 	int hlen = off;
 	register struct icmp *icp;
@@ -584,7 +585,7 @@
 	}
 
 raw:
-	rip_input(m, off, proto);
+	rip_input(m, off, proto, vinp);
 	return;
 
 freeit:
Index: netinet/ip_icmp.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_icmp.h,v
retrieving revision 1.16
diff -u -r1.16 ip_icmp.h
--- netinet/ip_icmp.h	29 Dec 1999 04:41:01 -0000	1.16
+++ netinet/ip_icmp.h	7 Mar 2002 07:26:21 -0000
@@ -186,7 +186,7 @@
 
 #ifdef _KERNEL
 void	icmp_error __P((struct mbuf *, int, int, n_long, struct ifnet *));
-void	icmp_input __P((struct mbuf *, int, int));
+void	icmp_input __P((struct mbuf *, int, int, void *));
 #endif
 
 #endif
Index: netinet/ip_input.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_input.c,v
retrieving revision 1.130.2.31
diff -u -r1.130.2.31 ip_input.c
--- netinet/ip_input.c	15 Dec 2001 01:06:27 -0000	1.130.2.31
+++ netinet/ip_input.c	7 Mar 2002 18:09:49 -0000
@@ -282,6 +282,7 @@
 	u_int32_t divert_info = 0;		/* packet divert/tee info */
 #endif
 	struct ip_fw *rule = NULL;
+	struct inpcb *inp = NULL;		/* pre-cache inpcb, if any */
 
 #ifdef IPDIVERT
 	/* Get and reset firewall cookie */
@@ -434,7 +435,8 @@
 		 * produced by the firewall.
 		 */
 		i = ip_fw_chk_ptr(&ip,
-		    hlen, NULL, &divert_cookie, &m, &rule, &ip_fw_fwd_addr);
+		    hlen, NULL, &divert_cookie, &m, &rule, &ip_fw_fwd_addr,
+		    &inp);
 		if ( (i & IP_FW_PORT_DENY_FLAG) || m == NULL) { /* drop */
                         if (m)
                                 m_freem(m);
@@ -812,7 +814,7 @@
     {
 	int off = hlen, nh = ip->ip_p;
 
-	(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off, nh);
+	(*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off, nh, inp);
 #ifdef	IPFIREWALL_FORWARD
 	ip_fw_fwd_addr = NULL;	/* tcp needed it */
 #endif
Index: netinet/ip_mroute.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_mroute.c,v
retrieving revision 1.56.2.3
diff -u -r1.56.2.3 ip_mroute.c
--- netinet/ip_mroute.c	7 Dec 2001 09:23:11 -0000	1.56.2.3
+++ netinet/ip_mroute.c	7 Mar 2002 07:32:49 -0000
@@ -118,10 +118,11 @@
 int (*mrt_ioctl)(int, caddr_t, struct proc *) = _mrt_ioctl;
 
 void
-rsvp_input(m, off, proto)		/* XXX must fixup manually */
+rsvp_input(m, off, proto, vinp)		/* XXX must fixup manually */
 	struct mbuf *m;
 	int off;
 	int proto;
+	void *vinp;
 {
     /* Can still get packets with rsvp_on = 0 if there is a local member
      * of the group to which the RSVP packet is addressed.  But in this
@@ -135,15 +136,17 @@
     if (ip_rsvpd != NULL) {
 	if (rsvpdebug)
 	    printf("rsvp_input: Sending packet up old-style socket\n");
-	rip_input(m, off, proto);
+	rip_input(m, off, proto, vinp);
 	return;
     }
     /* Drop the packet */
     m_freem(m);
 }
 
-void ipip_input(struct mbuf *m, int off, int proto) { /* XXX must fixup manually */
-	rip_input(m, off, proto);
+/* XXX must fixup manually */
+void ipip_input(struct mbuf *m, int off, int proto, void *vinp)
+{
+	rip_input(m, off, proto, vinp);
 }
 
 int (*legal_vif_num)(int) = 0;
@@ -1615,13 +1618,14 @@
  */
 void
 #ifdef MROUTE_LKM
-X_ipip_input(m, off, proto)
+X_ipip_input(m, off, proto, vinp)
 #else
-ipip_input(m, off, proto)
+ipip_input(m, off, proto, vinp)
 #endif
 	register struct mbuf *m;
 	int off;
 	int proto;
+	void *vinp;
 {
     struct ifnet *ifp = m->m_pkthdr.rcvif;
     register struct ip *ip = mtod(m, struct ip *);
@@ -1631,7 +1635,7 @@
     register struct vif *vifp;
 
     if (!have_encap_tunnel) {
-	    rip_input(m, off, proto);
+	    rip_input(m, off, proto, vinp);
 	    return;
     }
     /*
@@ -2125,10 +2129,11 @@
 }
 
 void
-rsvp_input(m, off, proto)
+rsvp_input(m, off, proto, vinp)
 	struct mbuf *m;
 	int off;
 	int proto;
+	void *vinp;
 {
     int vifi;
     register struct ip *ip = mtod(m, struct ip *);
@@ -2173,7 +2178,7 @@
 	if (ip_rsvpd != NULL) {
 	    if (rsvpdebug)
 		printf("rsvp_input: Sending packet up old-style socket\n");
-	    rip_input(m, off, proto);  /* xxx */
+	    rip_input(m, off, proto, vinp);  /* xxx */
 	} else {
 	    if (rsvpdebug && vifi == numvifs)
 		printf("rsvp_input: Can't find vif for packet.\n");
Index: netinet/ip_output.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_output.c,v
retrieving revision 1.99.2.24
diff -u -r1.99.2.24 ip_output.c
--- netinet/ip_output.c	28 Dec 2001 10:08:33 -0000	1.99.2.24
+++ netinet/ip_output.c	7 Mar 2002 18:15:33 -0000
@@ -577,7 +577,7 @@
 		struct sockaddr_in *old = dst;
 
 		off = ip_fw_chk_ptr(&ip,
-		    hlen, ifp, &divert_cookie, &m, &rule, &dst);
+		    hlen, ifp, &divert_cookie, &m, &rule, &dst, NULL);
                 /*
                  * On return we must do the following:
                  * IP_FW_PORT_DENY_FLAG		-> drop the pkt (XXX new)
Index: netinet/ip_var.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.50.2.5
diff -u -r1.50.2.5 ip_var.h
--- netinet/ip_var.h	7 Dec 2001 09:23:14 -0000	1.50.2.5
+++ netinet/ip_var.h	7 Mar 2002 07:45:04 -0000
@@ -176,12 +176,12 @@
 	 ip_randomid __P((void));
 #endif
 int	 rip_ctloutput __P((struct socket *, struct sockopt *));
-void	 rip_ctlinput __P((int, struct sockaddr *, void *));
+void	 rip_ctlinput __P((int, struct sockaddr *, void *, void *));
 void	 rip_init __P((void));
-void	 rip_input __P((struct mbuf *, int, int));
+void	 rip_input __P((struct mbuf *, int, int, void *));
 int	 rip_output __P((struct mbuf *, struct socket *, u_long));
-void	ipip_input __P((struct mbuf *, int, int));
-void	rsvp_input __P((struct mbuf *, int, int));
+void	ipip_input __P((struct mbuf *, int, int, void *));
+void	rsvp_input __P((struct mbuf *, int, int, void *));
 int	ip_rsvp_init __P((struct socket *));
 int	ip_rsvp_done __P((void));
 int	ip_rsvp_vif_init __P((struct socket *, struct sockopt *));
@@ -190,7 +190,7 @@
 
 #ifdef IPDIVERT
 void	div_init __P((void));
-void	div_input __P((struct mbuf *, int, int));
+void	div_input __P((struct mbuf *, int, int, void *));
 void	divert_packet __P((struct mbuf *, int, int));
 extern struct pr_usrreqs div_usrreqs;
 extern u_int16_t ip_divert_cookie;
Index: netinet/ipprotosw.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/ipprotosw.h,v
retrieving revision 1.1
diff -u -r1.1 ipprotosw.h
--- netinet/ipprotosw.h	22 Dec 1999 19:13:23 -0000	1.1
+++ netinet/ipprotosw.h	7 Mar 2002 04:31:56 -0000
@@ -79,11 +79,11 @@
 	short	pr_protocol;		/* protocol number */
 	short	pr_flags;		/* see below */
 /* protocol-protocol hooks */
-	void	(*pr_input) __P((struct mbuf *, int off, int proto));
+	void	(*pr_input) __P((struct mbuf *, int off, int proto, void *));
 					/* input to protocol (from below) */
 	int	(*pr_output)	__P((struct mbuf *m, struct socket *so));
 					/* output to protocol (from above) */
-	void	(*pr_ctlinput)__P((int, struct sockaddr *, void *));
+	void	(*pr_ctlinput)__P((int, struct sockaddr *, void *, void *));
 					/* control input (from below) */
 	int	(*pr_ctloutput)__P((struct socket *, struct sockopt *));
 					/* control output (from above) */
Index: netinet/raw_ip.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/raw_ip.c,v
retrieving revision 1.64.2.10
diff -u -r1.64.2.10 raw_ip.c
--- netinet/raw_ip.c	26 Nov 2001 10:07:57 -0000	1.64.2.10
+++ netinet/raw_ip.c	7 Mar 2002 07:32:20 -0000
@@ -113,9 +113,10 @@
  * mbuf chain.
  */
 void
-rip_input(m, off, proto)
+rip_input(m, off, proto, vimp)
 	struct mbuf *m;
 	int off, proto;
+	void *vimp;
 {
 	register struct ip *ip = mtod(m, struct ip *);
 	register struct inpcb *inp;
@@ -396,10 +397,11 @@
  * interface routes.
  */
 void
-rip_ctlinput(cmd, sa, vip)
+rip_ctlinput(cmd, sa, vip, vinp)
 	int cmd;
 	struct sockaddr *sa;
 	void *vip;
+	void *vinp;
 {
 	struct in_ifaddr *ia;
 	struct ifnet *ifp;
Index: netinet/tcp_input.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/tcp_input.c,v
retrieving revision 1.107.2.20
diff -u -r1.107.2.20 tcp_input.c
--- netinet/tcp_input.c	14 Dec 2001 20:21:12 -0000	1.107.2.20
+++ netinet/tcp_input.c	7 Mar 2002 18:34:55 -0000
@@ -321,15 +321,16 @@
 		return IPPROTO_DONE;
 	}
 
-	tcp_input(m, *offp, proto);
+	tcp_input(m, *offp, proto, NULL);
 	return IPPROTO_DONE;
 }
 #endif
 
 void
-tcp_input(m, off0, proto)
+tcp_input(m, off0, proto, vinp)
 	register struct mbuf *m;
 	int off0, proto;
+	void *vinp;
 {
 	register struct tcphdr *th;
 	register struct ip *ip = NULL;
@@ -544,8 +545,11 @@
 					 m->m_pkthdr.rcvif);
 	else
 #endif /* INET6 */
-	inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
-	    ip->ip_dst, th->th_dport, 1, m->m_pkthdr.rcvif);
+	if( vinp != NULL)
+		inp = vinp;	/* use cached value */
+	else
+		inp = in_pcblookup_hash(&tcbinfo, ip->ip_src, th->th_sport,
+		    ip->ip_dst, th->th_dport, 1, m->m_pkthdr.rcvif);
       }
 
 #ifdef IPSEC
Index: netinet/tcp_subr.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/tcp_subr.c,v
retrieving revision 1.73.2.23
diff -u -r1.73.2.23 tcp_subr.c
--- netinet/tcp_subr.c	14 Dec 2001 20:21:12 -0000	1.73.2.23
+++ netinet/tcp_subr.c	7 Mar 2002 05:05:03 -0000
@@ -972,10 +972,11 @@
 
 
 void
-tcp_ctlinput(cmd, sa, vip)
+tcp_ctlinput(cmd, sa, vip, vinp)
 	int cmd;
 	struct sockaddr *sa;
 	void *vip;
+	void *vinp;
 {
 	struct ip *ip = vip;
 	struct tcphdr *th;
Index: netinet/tcp_var.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/tcp_var.h,v
retrieving revision 1.56.2.10
diff -u -r1.56.2.10 tcp_var.h
--- netinet/tcp_var.h	14 Dec 2001 20:21:12 -0000	1.56.2.10
+++ netinet/tcp_var.h	7 Mar 2002 05:17:04 -0000
@@ -437,7 +437,7 @@
 void	 tcp_canceltimers __P((struct tcpcb *));
 struct tcpcb *
 	 tcp_close __P((struct tcpcb *));
-void	 tcp_ctlinput __P((int, struct sockaddr *, void *));
+void	 tcp_ctlinput __P((int, struct sockaddr *, void *, void *));
 int	 tcp_ctloutput __P((struct socket *, struct sockopt *));
 struct tcpcb *
 	 tcp_drop __P((struct tcpcb *, int));
@@ -446,7 +446,7 @@
 struct rmxp_tao *
 	 tcp_gettaocache __P((struct in_conninfo *));
 void	 tcp_init __P((void));
-void	 tcp_input __P((struct mbuf *, int, int));
+void	 tcp_input __P((struct mbuf *, int, int, void *));
 void	 tcp_mss __P((struct tcpcb *, int));
 int	 tcp_mssopt __P((struct tcpcb *));
 void	 tcp_drop_syn_sent __P((struct inpcb *, int));
Index: netinet/udp_usrreq.c
===================================================================
RCS file: /usr/cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.64.2.15
diff -u -r1.64.2.15 udp_usrreq.c
--- netinet/udp_usrreq.c	29 Oct 2001 19:28:43 -0000	1.64.2.15
+++ netinet/udp_usrreq.c	7 Mar 2002 18:35:08 -0000
@@ -148,9 +148,10 @@
 }
 
 void
-udp_input(m, off, proto)
+udp_input(m, off, proto, vinp)
 	register struct mbuf *m;
 	int off, proto;
+	void *vinp;
 {
 	int iphlen = off;
 	register struct ip *ip;
@@ -339,8 +340,11 @@
 	/*
 	 * Locate pcb for datagram.
 	 */
-	inp = in_pcblookup_hash(&udbinfo, ip->ip_src, uh->uh_sport,
-	    ip->ip_dst, uh->uh_dport, 1, m->m_pkthdr.rcvif);
+	if (vinp != NULL)
+		inp = vinp;	/* use cached value */
+	else
+		inp = in_pcblookup_hash(&udbinfo, ip->ip_src, uh->uh_sport,
+		    ip->ip_dst, uh->uh_dport, 1, m->m_pkthdr.rcvif);
 	if (inp == NULL) {
 		if (log_in_vain) {
 			char buf[4*sizeof "123"];
@@ -502,10 +506,11 @@
 }
 
 void
-udp_ctlinput(cmd, sa, vip)
+udp_ctlinput(cmd, sa, vip, vinp)
 	int cmd;
 	struct sockaddr *sa;
 	void *vip;
+	void *vinp;
 {
 	struct ip *ip = vip;
 	struct udphdr *uh;
Index: netinet/udp_var.h
===================================================================
RCS file: /usr/cvs/src/sys/netinet/udp_var.h,v
retrieving revision 1.22.2.1
diff -u -r1.22.2.1 udp_var.h
--- netinet/udp_var.h	18 Feb 2001 07:12:25 -0000	1.22.2.1
+++ netinet/udp_var.h	7 Mar 2002 05:17:48 -0000
@@ -103,9 +103,9 @@
 extern struct	udpstat udpstat;
 extern int	log_in_vain;
 
-void	udp_ctlinput __P((int, struct sockaddr *, void *));
+void	udp_ctlinput __P((int, struct sockaddr *, void *, void *));
 void	udp_init __P((void));
-void	udp_input __P((struct mbuf *, int, int));
+void	udp_input __P((struct mbuf *, int, int, void *));
 
 void	udp_notify __P((struct inpcb *inp, int errno));
 int	udp_shutdown __P((struct socket *so));

--------------87879C4452F25813094EB958--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C87B45F.3061AABF>