PERFORCE change 111198 for review

Marko Zec zec at FreeBSD.org
Wed Dec 6 07:31:29 PST 2006


http://perforce.freebsd.org/chv.cgi?CH=111198

Change 111198 by zec at zec_tpx32 on 2006/12/06 15:31:22

	Store a pointer back to the owner vnet in struct inpcbinfo,
	so that whenever an inpcb is directly or indirectly available
	as an argument to a function, the function-local vnet ptr can
	be fetched from there, and not via the curvnetb macro.

Affected files ...

.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#6 edit
.. //depot/projects/vimage/src/sys/net/bpf.c#4 edit
.. //depot/projects/vimage/src/sys/net/if.c#6 edit
.. //depot/projects/vimage/src/sys/net/if_loop.c#5 edit
.. //depot/projects/vimage/src/sys/net/if_stf.c#4 edit
.. //depot/projects/vimage/src/sys/net/if_var.h#4 edit
.. //depot/projects/vimage/src/sys/net/rtsock.c#5 edit
.. //depot/projects/vimage/src/sys/netgraph/ng_ether.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/if_ether.c#5 edit
.. //depot/projects/vimage/src/sys/netinet/igmp.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/in.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/in_pcb.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/in_pcb.h#2 edit
.. //depot/projects/vimage/src/sys/netinet/ip_fastfwd.c#3 edit
.. //depot/projects/vimage/src/sys/netinet/ip_input.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/ip_output.c#3 edit
.. //depot/projects/vimage/src/sys/netinet/raw_ip.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_input.c#3 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_output.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_sack.c#3 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_subr.c#3 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_syncache.c#3 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_timer.c#3 edit
.. //depot/projects/vimage/src/sys/netinet/tcp_usrreq.c#4 edit
.. //depot/projects/vimage/src/sys/netinet/udp_usrreq.c#4 edit
.. //depot/projects/vimage/src/sys/netinet6/in6_ifattach.c#4 edit
.. //depot/projects/vimage/src/sys/netinet6/in6_pcb.c#4 edit
.. //depot/projects/vimage/src/sys/netinet6/ip6_input.c#3 edit
.. //depot/projects/vimage/src/sys/netinet6/nd6.c#5 edit
.. //depot/projects/vimage/src/sys/netinet6/raw_ip6.c#4 edit
.. //depot/projects/vimage/src/sys/netinet6/scope6.c#4 edit
.. //depot/projects/vimage/src/sys/netinet6/udp6_output.c#3 edit
.. //depot/projects/vimage/src/sys/netinet6/udp6_usrreq.c#4 edit
.. //depot/projects/vimage/src/sys/sys/vimage.h#5 edit

Differences ...

==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#6 (text+ko) ====


==== //depot/projects/vimage/src/sys/net/bpf.c#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/net/if.c#6 (text+ko) ====


==== //depot/projects/vimage/src/sys/net/if_loop.c#5 (text+ko) ====


==== //depot/projects/vimage/src/sys/net/if_stf.c#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/net/if_var.h#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/net/rtsock.c#5 (text+ko) ====


==== //depot/projects/vimage/src/sys/netgraph/ng_ether.c#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/netinet/if_ether.c#5 (text+ko) ====


==== //depot/projects/vimage/src/sys/netinet/igmp.c#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/netinet/in.c#4 (text+ko) ====

@@ -230,7 +230,7 @@
 	register struct ifnet *ifp;
 	struct thread *td;
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(curvnetb);	/* so and ifp can be 0 ! */
 	register struct ifreq *ifr = (struct ifreq *)data;
 	register struct in_ifaddr *ia = 0, *iap;
 	register struct ifaddr *ifa;

==== //depot/projects/vimage/src/sys/netinet/in_pcb.c#4 (text+ko) ====

@@ -270,6 +270,7 @@
 in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
     u_short *lportp, struct ucred *cred)
 {
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct socket *so = inp->inp_socket;
 	unsigned short *lastport;
 	struct sockaddr_in *sin;
@@ -279,7 +280,6 @@
 	int wild = 0, reuseport = (so->so_options & SO_REUSEPORT);
 	int error, prison = 0;
 	int dorandom;
-	INIT_VNET_INET(so->so_vnetb);
 
 	INP_INFO_WLOCK_ASSERT(pcbinfo);
 	INP_LOCK_ASSERT(inp);
@@ -561,7 +561,7 @@
     in_addr_t *laddrp, u_short *lportp, in_addr_t *faddrp, u_short *fportp,
     struct inpcb **oinpp, struct ucred *cred)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct sockaddr_in *sin = (struct sockaddr_in *)nam;
 	struct in_ifaddr *ia;
 	struct sockaddr_in sa;

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

@@ -119,6 +119,7 @@
 
 	void	*inp_ppcb;		/* pointer to per-protocol pcb */
 	struct	inpcbinfo *inp_pcbinfo;	/* PCB list info */
+#define inp_vnetb inp_pcbinfo->vnetb
 	struct	socket *inp_socket;	/* back pointer to socket */
 					/* list for this PCB's local port */
 	struct	label *inp_label;	/* MAC label */
@@ -235,6 +236,7 @@
 	u_int	ipi_count;	/* number of pcbs in this list */
 	u_quad_t ipi_gencnt;	/* current generation count */
 	struct	mtx ipi_mtx;
+	struct	vnet_base *vnetb;
 };
 
 /*

==== //depot/projects/vimage/src/sys/netinet/ip_fastfwd.c#3 (text+ko) ====

@@ -115,7 +115,7 @@
 static struct sockaddr_in *
 ip_findroute(struct route *ro, struct in_addr dest, struct mbuf *m)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(curvnetb); /* XXX perhaps ro->...so_vnetb ? revisit */
 	struct sockaddr_in *dst;
 	struct rtentry *rt;
 

==== //depot/projects/vimage/src/sys/netinet/ip_input.c#4 (text+ko) ====

@@ -1501,7 +1501,7 @@
 	register struct ip *ip;
 	register struct mbuf *m;
 {
-	INIT_VNET_NET(curvnetb);
+	INIT_VNET_NET(inp->inp_vnetb);
 
 	if (inp->inp_socket->so_options & (SO_BINTIME | SO_TIMESTAMP)) {
 		struct bintime bt;

==== //depot/projects/vimage/src/sys/netinet/ip_output.c#3 (text+ko) ====

@@ -1536,7 +1536,7 @@
 static int
 ip_getmoptions(struct inpcb *inp, struct sockopt *sopt)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct ip_moptions *imo;
 	struct in_addr addr;
 	struct in_ifaddr *ia;

==== //depot/projects/vimage/src/sys/netinet/raw_ip.c#4 (text+ko) ====

@@ -158,8 +158,10 @@
 	V_ripcbinfo.hashbase = hashinit(1, M_PCB, &V_ripcbinfo.hashmask);
 	V_ripcbinfo.porthashbase =
 	    hashinit(1, M_PCB, &V_ripcbinfo.porthashmask);
+/* XXX Marko we don't need a full zone for each stack - revisit this! */
 	V_ripcbinfo.ipi_zone = uma_zcreate("ripcb", sizeof(struct inpcb),
 	    NULL, NULL, rip_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
+	V_ripcbinfo.vnetb = curvnetb;
 	uma_zone_set_max(V_ripcbinfo.ipi_zone, maxsockets);
 	EVENTHANDLER_REGISTER(maxsockets_change, rip_zone_change,
 		NULL, EVENTHANDLER_PRI_ANY);

==== //depot/projects/vimage/src/sys/netinet/tcp_input.c#3 (text+ko) ====

@@ -240,7 +240,7 @@
 	int *tlenp;
 	struct mbuf *m;
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 	struct tseg_qent *q;
 	struct tseg_qent *p = NULL;
 	struct tseg_qent *nq;
@@ -2762,7 +2762,7 @@
 	register struct tcpcb *tp;
 	int rtt;
 {
-	INIT_VNET_INET(curvnetb); /* XXX should be tp->pcb->so->so_vnetb */
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 	register int delta;
 
 	INP_LOCK_ASSERT(tp->t_inpcb);
@@ -2871,7 +2871,7 @@
 	struct tcpcb *tp;
 	int offer;
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 	int rtt, mss;
 	u_long bufsize;
 	u_long maxmtu;
@@ -3200,7 +3200,7 @@
 	struct mbuf *m;
 	int tlen;
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct tcptw *tw;
 	int thflags;
 	tcp_seq seq;

==== //depot/projects/vimage/src/sys/netinet/tcp_output.c#4 (text+ko) ====

@@ -120,8 +120,8 @@
 int
 tcp_output(struct tcpcb *tp)
 {
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 	struct socket *so = tp->t_inpcb->inp_socket;
-	INIT_VNET_INET(so->so_vnetb);
 	long len, recwin, sendwin;
 	int off, flags, error;
 #ifdef TCP_SIGNATURE

==== //depot/projects/vimage/src/sys/netinet/tcp_sack.c#3 (text+ko) ====

@@ -282,7 +282,7 @@
 static struct sackhole *
 tcp_sackhole_alloc(struct tcpcb *tp, tcp_seq start, tcp_seq end)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 	struct sackhole *hole;
 
 	if (tp->snd_numholes >= tcp_sack_maxholes ||

==== //depot/projects/vimage/src/sys/netinet/tcp_subr.c#3 (text+ko) ====

@@ -374,6 +374,7 @@
 	V_tcbinfo.porthashbase = hashinit(hashsize, M_PCB,
 					&V_tcbinfo.porthashmask);
 	V_tcbinfo.ipi_zone = tcp_ipi_zone;
+	V_tcbinfo.vnetb = curvnetb;
 #ifdef INET6
 #define TCP_MINPROTOHDR (sizeof(struct ip6_hdr) + sizeof(struct tcphdr))
 #else /* INET6 */
@@ -734,7 +735,7 @@
 struct tcpcb *
 tcp_drop(struct tcpcb *tp, int errno)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 	struct socket *so = tp->t_inpcb->inp_socket;
 
 	INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
@@ -853,7 +854,7 @@
 struct tcpcb *
 tcp_close(struct tcpcb *tp)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 	struct inpcb *inp = tp->t_inpcb;
 	struct socket *so;
 
@@ -930,7 +931,7 @@
 static struct inpcb *
 tcp_notify(struct inpcb *inp, int error)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct tcpcb *tp;
 
 	INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
@@ -1536,7 +1537,7 @@
 struct inpcb *
 tcp_drop_syn_sent(struct inpcb *inp, int errno)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct tcpcb *tp;
 
 	INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
@@ -1566,7 +1567,7 @@
 struct inpcb *
 tcp_mtudisc(struct inpcb *inp, int errno)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct tcpcb *tp;
 	struct socket *so = inp->inp_socket;
 	u_int maxmtu;
@@ -1793,7 +1794,7 @@
 void
 tcp_twstart(struct tcpcb *tp)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 	struct tcptw *tw;
 	struct inpcb *inp = tp->t_inpcb;
 	int acknow;
@@ -1923,7 +1924,7 @@
 void
 tcp_twclose(struct tcptw *tw, int reuse)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tw->tw_inpcb->inp_vnetb);
 	struct socket *so;
 	struct inpcb *inp;
 
@@ -1991,7 +1992,7 @@
 int
 tcp_twrespond(struct tcptw *tw, int flags)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tw->tw_inpcb->inp_vnetb);
 	struct inpcb *inp = tw->tw_inpcb;
 	struct tcphdr *th;
 	struct mbuf *m;

==== //depot/projects/vimage/src/sys/netinet/tcp_syncache.c#3 (text+ko) ====

@@ -374,7 +374,7 @@
 static void
 syncache_timer(void *xsch)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(curvnetb);	/* XXX this can't work !!! */
 	struct syncache_head *sch = (struct syncache_head *)xsch;
 	struct syncache *sc, *nsc;
 	int tick = ticks;
@@ -553,7 +553,7 @@
 static struct socket *
 syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(lso->so_vnetb);
 	struct inpcb *inp = NULL;
 	struct socket *so;
 	struct tcpcb *tp;
@@ -851,7 +851,7 @@
 syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
     struct inpcb *inp, struct socket **lsop, struct mbuf *m)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct tcpcb *tp;
 	struct socket *so;
 	struct syncache *sc = NULL;

==== //depot/projects/vimage/src/sys/netinet/tcp_timer.c#3 (text+ko) ====

@@ -146,7 +146,7 @@
 	struct tcpcb *tp = xtp;
 	struct inpcb *inp;
 	CURVNETB_SET(vnetb_tbl[tp->vnet_id]);
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(vnetb_tbl[tp->vnet_id]);
 
 	INP_INFO_RLOCK(&V_tcbinfo);
 	inp = tp->t_inpcb;
@@ -188,7 +188,7 @@
 	struct tcpcb *tp = xtp;
 	struct inpcb *inp;
 	CURVNETB_SET(vnetb_tbl[tp->vnet_id]);
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(vnetb_tbl[tp->vnet_id]);
 #ifdef TCPDEBUG
 	int ostate;
 
@@ -268,7 +268,7 @@
 void
 tcp_timer_2msl_reset(struct tcptw *tw, int rearm)
 {
-	INIT_VNET_INET(curvnetb);	/* XXX Is this safe? */
+	INIT_VNET_INET(tw->tw_inpcb->inp_vnetb);
 
 	INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
 	INP_LOCK_ASSERT(tw->tw_inpcb);
@@ -281,7 +281,7 @@
 void
 tcp_timer_2msl_stop(struct tcptw *tw)
 {
-	INIT_VNET_INET(curvnetb);	/* XXX is this safe? */
+	INIT_VNET_INET(tw->tw_inpcb->inp_vnetb);
 
 	INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
 	TAILQ_REMOVE(&V_twq_2msl, tw, tw_2msl);
@@ -314,7 +314,7 @@
 	struct tcptemp *t_template;
 	struct inpcb *inp;
 	CURVNETB_SET(vnetb_tbl[tp->vnet_id]);
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(vnetb_tbl[tp->vnet_id]);
 #ifdef TCPDEBUG
 	int ostate;
 
@@ -412,7 +412,7 @@
 	struct tcpcb *tp = xtp;
 	struct inpcb *inp;
 	CURVNETB_SET(vnetb_tbl[tp->vnet_id]);
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(vnetb_tbl[tp->vnet_id]);
 #ifdef TCPDEBUG
 	int ostate;
 
@@ -487,7 +487,7 @@
 	int headlocked;
 	struct inpcb *inp;
 	CURVNETB_SET(vnetb_tbl[tp->vnet_id]);
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(vnetb_tbl[tp->vnet_id]);
 #ifdef TCPDEBUG
 	int ostate;
 

==== //depot/projects/vimage/src/sys/netinet/tcp_usrreq.c#4 (text+ko) ====

@@ -1556,7 +1556,7 @@
 tcp_usrclosed(tp)
 	register struct tcpcb *tp;
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(tp->t_inpcb->inp_vnetb);
 
 	INP_INFO_WLOCK_ASSERT(&V_tcbinfo);
 	INP_LOCK_ASSERT(tp->t_inpcb);

==== //depot/projects/vimage/src/sys/netinet/udp_usrreq.c#4 (text+ko) ====

@@ -180,6 +180,7 @@
 	V_udbinfo.porthashbase = hashinit(UDBHASHSIZE, M_PCB,
 					&V_udbinfo.porthashmask);
 	V_udbinfo.ipi_zone = udp_ipi_zone;
+	V_udbinfo.vnetb = curvnetb;
 }
 
 void
@@ -476,7 +477,7 @@
 	int off;
 	struct sockaddr_in *udp_in;
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	struct sockaddr *append_sa;
 	struct socket *so;
 	struct mbuf *opts = 0;
@@ -749,7 +750,7 @@
 	struct mbuf *control;
 	struct thread *td;
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(inp->inp_vnetb);
 	register struct udpiphdr *ui;
 	register int len = m->m_pkthdr.len;
 	struct in_addr faddr, laddr;

==== //depot/projects/vimage/src/sys/netinet6/in6_ifattach.c#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/netinet6/in6_pcb.c#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/netinet6/ip6_input.c#3 (text+ko) ====

@@ -190,9 +190,7 @@
         }
         curvnetb->mod_data[vnet_inet6_modinfo.id] = vnet_inet6;
         vnet_inet6->parent_vnetb = curvnetb;
-#endif
 
-#ifdef VIMAGE
 	/*
 	 * Skip global initialization stuff 
 	 * for non-default instances.

==== //depot/projects/vimage/src/sys/netinet6/nd6.c#5 (text+ko) ====


==== //depot/projects/vimage/src/sys/netinet6/raw_ip6.c#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/netinet6/scope6.c#4 (text+ko) ====


==== //depot/projects/vimage/src/sys/netinet6/udp6_output.c#3 (text+ko) ====

@@ -126,7 +126,7 @@
 	struct sockaddr *addr6;
 	struct thread *td;
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(in6p->inp_vnetb);
 	u_int32_t ulen = m->m_pkthdr.len;
 	u_int32_t plen = sizeof(struct udphdr) + ulen;
 	struct ip6_hdr *ip6;

==== //depot/projects/vimage/src/sys/netinet6/udp6_usrreq.c#4 (text+ko) ====

@@ -128,7 +128,7 @@
 udp6_append(struct inpcb *in6p, struct mbuf *n, int off,
     struct sockaddr_in6 *fromsa)
 {
-	INIT_VNET_INET(curvnetb);
+	INIT_VNET_INET(in6p->inp_vnetb);
 	struct socket *so;
 	struct mbuf *opts;
 

==== //depot/projects/vimage/src/sys/sys/vimage.h#5 (text+ko) ====



More information about the p4-projects mailing list