p4-projects@freebsd.org
[Top] [All Lists]

PERFORCE change 127639 for review

Subject: PERFORCE change 127639 for review
From: Marko Zec
Date: Wed, 17 Oct 2007 22:58:03 GMT
http://perforce.freebsd.org/chv.cgi?CH=127639

Change 127639 by zec@zec_tpx32 on 2007/10/17 22:57:48

        Introduce a few macros for easier and more readable fetching
        of virtualized resource context from a ptr to a proc or thread.
        
        The additional benefit is that if we ever decide not to hang
        vimage / vnet etc. from struct ucred but use some other
        method instead, we won't have to change hundreds of lines of
        code, but only those few new macros...

Affected files ...

.. //depot/projects/vimage/src/sys/compat/linprocfs/linprocfs.c#13 edit
.. //depot/projects/vimage/src/sys/compat/linux/linux_ioctl.c#6 edit
.. //depot/projects/vimage/src/sys/compat/linux/linux_misc.c#11 edit
.. //depot/projects/vimage/src/sys/dev/firewire/firewire.c#9 edit
.. //depot/projects/vimage/src/sys/fs/cd9660/cd9660_rrip.c#3 edit
.. //depot/projects/vimage/src/sys/i386/i386/dump_machdep.c#4 edit
.. //depot/projects/vimage/src/sys/i386/i386/minidump_machdep.c#5 edit
.. //depot/projects/vimage/src/sys/kern/init_main.c#13 edit
.. //depot/projects/vimage/src/sys/kern/kern_clock.c#12 edit
.. //depot/projects/vimage/src/sys/kern/kern_exit.c#12 edit
.. //depot/projects/vimage/src/sys/kern/kern_fork.c#12 edit
.. //depot/projects/vimage/src/sys/kern/kern_jail.c#5 edit
.. //depot/projects/vimage/src/sys/kern/kern_linker.c#10 edit
.. //depot/projects/vimage/src/sys/kern/kern_mib.c#7 edit
.. //depot/projects/vimage/src/sys/kern/kern_prot.c#6 edit
.. //depot/projects/vimage/src/sys/kern/kern_sysctl.c#9 edit
.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#47 edit
.. //depot/projects/vimage/src/sys/kern/kern_xxx.c#4 edit
.. //depot/projects/vimage/src/sys/kern/sched_4bsd.c#16 edit
.. //depot/projects/vimage/src/sys/kern/sched_ule.c#16 edit
.. //depot/projects/vimage/src/sys/kern/tty.c#11 edit
.. //depot/projects/vimage/src/sys/kern/uipc_socket.c#13 edit
.. //depot/projects/vimage/src/sys/kern/vfs_export.c#8 edit
.. //depot/projects/vimage/src/sys/kern/vfs_lookup.c#9 edit
.. //depot/projects/vimage/src/sys/net/bpf.c#14 edit
.. //depot/projects/vimage/src/sys/net/if.c#21 edit
.. //depot/projects/vimage/src/sys/netinet6/icmp6.c#17 edit
.. //depot/projects/vimage/src/sys/netinet6/in6.c#13 edit
.. //depot/projects/vimage/src/sys/netinet6/in6_ifattach.c#14 edit
.. //depot/projects/vimage/src/sys/nfsclient/nfs_vfsops.c#8 edit
.. //depot/projects/vimage/src/sys/sys/sysctl.h#12 edit
.. //depot/projects/vimage/src/sys/sys/ucred.h#5 edit
.. //depot/projects/vimage/src/sys/sys/vimage.h#44 edit
.. //depot/projects/vimage/src/sys/vm/vm_meter.c#7 edit

Differences ...

==== //depot/projects/vimage/src/sys/compat/linprocfs/linprocfs.c#13 (text+ko) 
====

@@ -378,7 +378,7 @@
 static int
 linprocfs_dostat(PFS_FILL_ARGS)
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread));
        int i;
 
        sbuf_printf(sb, "cpu %ld %ld %ld %ld\n",
@@ -415,7 +415,7 @@
 static int
 linprocfs_douptime(PFS_FILL_ARGS)
 {
-        INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+        INIT_VPROCG(TD_TO_VPROCG(curthread));
        struct timeval tv;
 
        getmicrouptime(&tv);
@@ -502,7 +502,7 @@
 static int
 linprocfs_doloadavg(PFS_FILL_ARGS)
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread));
 
        sbuf_printf(sb,
            "%d.%02d %d.%02d %d.%02d %d/%d %d\n",
@@ -994,7 +994,7 @@
 static int
 linprocfs_donetdev(PFS_FILL_ARGS)
 {
-       INIT_VNET_NET(curthread->td_ucred->cr_vimage->v_vnet);
+       INIT_VNET_NET(TD_TO_VNET(curthread));
        char ifname[16]; /* XXX LINUX_IFNAMSIZ */
        struct ifnet *ifp;
 

==== //depot/projects/vimage/src/sys/compat/linux/linux_ioctl.c#6 (text+ko) ====

@@ -2075,7 +2075,7 @@
 static struct ifnet *
 ifname_linux_to_bsd(const char *lxname, char *bsdname)
 {
-       INIT_VNET_NET(curthread->td_ucred->cr_vimage->v_vnet);
+       INIT_VNET_NET(TD_TO_VNET(curthread));
        struct ifnet *ifp;
        int len, unit;
        char *ep;
@@ -2116,7 +2116,7 @@
 static int
 linux_ifconf(struct thread *td, struct ifconf *uifc)
 {
-       INIT_VNET_NET(td->td_ucred->cr_vimage->v_vnet);
+       INIT_VNET_NET(TD_TO_VNET(td));
 #ifdef COMPAT_LINUX32
        struct l_ifconf ifc;
 #else

==== //depot/projects/vimage/src/sys/compat/linux/linux_misc.c#11 (text+ko) ====

@@ -125,7 +125,7 @@
 int
 linux_sysinfo(struct thread *td, struct linux_sysinfo_args *args)
 {
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
        struct l_sysinfo sysinfo;
        vm_object_t object;
        int i, j;
@@ -697,7 +697,7 @@
 int
 linux_newuname(struct thread *td, struct linux_newuname_args *args)
 {
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
        struct l_new_utsname utsname;
        char osname[LINUX_MAX_UTSNAME];
        char osrelease[LINUX_MAX_UTSNAME];

==== //depot/projects/vimage/src/sys/dev/firewire/firewire.c#9 (text+ko) ====

@@ -677,7 +677,7 @@
 static void
 fw_reset_crom(struct firewire_comm *fc)
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg); /* XXX */
+       INIT_VPROCG(TD_TO_VPROCG(curthread)); /* XXX */
        struct crom_src_buf *buf;
        struct crom_src *src;
        struct crom_chunk *root;

==== //depot/projects/vimage/src/sys/fs/cd9660/cd9660_rrip.c#3 (text+ko) ====

@@ -116,7 +116,7 @@
        ISO_RRIP_SLINK  *p;
        ISO_RRIP_ANALYZE *ana;
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread));
        ISO_RRIP_SLINK_COMPONENT *pcomp;
        ISO_RRIP_SLINK_COMPONENT *pcompe;
        int len, wlen, cont;
@@ -226,7 +226,7 @@
        ISO_RRIP_ALTNAME *p;
        ISO_RRIP_ANALYZE *ana;
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread));
        char *inbuf;
        int wlen;
        int cont;

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

@@ -112,7 +112,7 @@
 mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
     uint32_t blksz)
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg); /* XXX */
+       INIT_VPROCG(TD_TO_VPROCG(curthread)); /* XXX */
 
        bzero(kdh, sizeof(*kdh));
        strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));

==== //depot/projects/vimage/src/sys/i386/i386/minidump_machdep.c#5 (text) ====

@@ -86,7 +86,7 @@
 mkdumpheader(struct kerneldumpheader *kdh, uint32_t archver, uint64_t dumplen,
     uint32_t blksz)
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread));
 
        bzero(kdh, sizeof(*kdh));
        strncpy(kdh->magic, KERNELDUMPMAGIC, sizeof(kdh->magic));

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


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

@@ -94,7 +94,7 @@
 static int
 sysctl_kern_cp_time(SYSCTL_HANDLER_ARGS)
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread));
 
        int error;
 #ifdef SCTL_MASK32
@@ -421,8 +421,8 @@
        td = curthread;
        p = td->td_proc;
 #ifdef VIMAGE
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
-       INIT_VCPU(td->td_ucred->cr_vimage->v_cpu);
+       INIT_VPROCG(TD_TO_VPROCG(td));
+       INIT_VCPU(TD_TO_VCPU(td));
        struct vprocg *vprocg_iter;
 #endif
 

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


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


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


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

@@ -857,12 +857,12 @@
                return (error);
 
 #ifdef VIMAGE
-       if (!IS_DEFAULT_VIMAGE(td->td_ucred->cr_vimage))
+       if (!IS_DEFAULT_VIMAGE(TD_TO_VIMAGE(td)))
                return (EPERM);
+
+       CURVNET_SET(TD_TO_VNET(td));
 #endif
 
-       CURVNET_SET(td->td_ucred->cr_vimage->v_vnet);
-
        /*
         * If file does not contain a qualified name or any dot in it
         * (kldname.ko, or kldname.ver.ko) treat it as an interface
@@ -929,9 +929,9 @@
                return (error);
 
        /* XXX should suser catch this for us? */
-       VNET_ASSERT(IS_DEFAULT_VIMAGE(td->td_ucred->cr_vimage));
+       VNET_ASSERT(IS_DEFAULT_VIMAGE(TD_TO_VIMAGE(td)));
 
-       CURVNET_SET(td->td_ucred->cr_vimage->v_vnet);
+       CURVNET_SET(TD_TO_VNET(td));
 
        KLD_LOCK();
        lf = linker_find_file_by_id(fileid);
@@ -1176,7 +1176,7 @@
                }
 #ifdef VIMAGE
                if (lf == NULL) {
-                       CURVNET_SET(td->td_ucred->cr_vimage->v_vnet);
+                       CURVNET_SET(TD_TO_VNET(td));
                        error = vi_symlookup(&lookup, symstr);
                        CURVNET_RESTORE();
                        if (error == 0) {

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

@@ -211,7 +211,7 @@
 static int
 sysctl_hostname(SYSCTL_HANDLER_ARGS)
 {
-       INIT_VPROCG(req->td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(req->td));
        struct prison *pr;
        char tmphostname[MAXHOSTNAMELEN];
        int error;

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

@@ -1723,7 +1723,7 @@
        KASSERT(td == curthread, ("%s: td not curthread", __func__));
        PROC_LOCK_ASSERT(p, MA_OWNED);
 #ifdef VIMAGE
-       if (!vi_child_of(td->td_ucred->cr_vimage, p->p_ucred->cr_vimage))
+       if (!vi_child_of(TD_TO_VIMAGE(td), P_TO_VIMAGE(p)))
 #endif
        if ((error = prison_check(td->td_ucred, p->p_ucred)))
                return (error);

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

@@ -1503,8 +1503,7 @@
        req.lock = REQ_LOCKED;
 
        SYSCTL_LOCK();
-       CURVNET_SET(curthread->td_ucred->cr_vimage->v_vnet);
-       VNET_ASSERT(td == curthread);
+       CURVNET_SET(TD_TO_VNET(curthread));
 
        do {
                req.oldidx = 0;

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

@@ -450,7 +450,7 @@
        struct thread *td;
 {
        int error;
-       struct vimage *vip = td->td_ucred->cr_vimage;
+       struct vimage *vip = TD_TO_VIMAGE(td);
        struct vimage *vip_r = NULL;
        struct vimage *tvip;
 
@@ -533,7 +533,7 @@
                        PROC_UNLOCK(p);
                        sx_xlock(&allproc_lock);
                        oldcred->cr_vimage->v_procg->nprocs--;
-                       p->p_ucred->cr_vimage->v_procg->nprocs++;
+                       P_TO_VPROCG(p)->nprocs++;
                        sched_load_reassign(oldcred->cr_vimage->v_procg,
                            newcred->cr_vimage->v_procg);
                        sx_xunlock(&allproc_lock);

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

@@ -247,7 +247,7 @@
         struct thread *td;
         struct getdomainname_args *uap;
 {
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
        int domainnamelen;
        int error;
 
@@ -272,7 +272,7 @@
         struct thread *td;
         struct setdomainname_args *uap;
 {
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
         int error, domainnamelen;
 
        error = priv_check(td, PRIV_SETDOMAINNAME);

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

@@ -236,7 +236,7 @@
 static __inline void
 sched_load_add(struct thread *td)
 {
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
 
        V_sched_tdcnt++;
        CTR1(KTR_SCHED, "global load: %d", V_sched_tdcnt);
@@ -245,7 +245,7 @@
 static __inline void
 sched_load_rem(struct thread *td)
 {
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
 
        V_sched_tdcnt--;
        CTR1(KTR_SCHED, "global load: %d", V_sched_tdcnt);
@@ -405,7 +405,7 @@
                PROC_SLOCK(p);
 #ifdef VIMAGE
                if (p->p_ucred != NULL) {
-                       INIT_VPROCG(p->p_ucred->cr_vimage->v_procg);
+                       INIT_VPROCG(P_TO_VPROCG(p));
                        loadfac = loadfactor(V_averunnable.ldavg[0]);
                } else
                        loadfac = 0;
@@ -516,7 +516,7 @@
 static void
 updatepri(struct thread *td)
 {
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
        struct td_sched *ts;
        fixpt_t loadfac;
        unsigned int newcpu;

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

@@ -1356,7 +1356,7 @@
 #ifndef VIMAGE
        tdq_load_add(tdq, &td_sched0);
 #else
-       tdq_load_add(tdq, &td_sched0, thread0.td_ucred->cr_vimage->v_procg);
+       tdq_load_add(tdq, &td_sched0, TD_TO_VPROCG(&thread0));
 #endif
        TDQ_UNLOCK(tdq);
 }
@@ -1893,7 +1893,7 @@
 #ifndef VIMAGE
                tdq_load_rem(tdq, ts);
 #else
-               tdq_load_rem(tdq, ts, td->td_ucred->cr_vimage->v_procg);
+               tdq_load_rem(tdq, ts, TD_TO_VPROCG(td));
 #endif
                srqflag = (flags & SW_PREEMPT) ?
                    SRQ_OURSELF|SRQ_YIELDING|SRQ_PREEMPTED :
@@ -1909,7 +1909,7 @@
 #ifndef VIMAGE
                tdq_load_rem(tdq, ts);
 #else
-               tdq_load_rem(tdq, ts, td->td_ucred->cr_vimage->v_procg);
+               tdq_load_rem(tdq, ts, TD_TO_VPROCG(td));
 #endif
        }
        /*
@@ -2417,7 +2417,7 @@
 #ifndef VIMAGE
        tdq_load_add(tdq, ts);
 #else
-       tdq_load_add(tdq, ts, td->td_ucred->cr_vimage->v_procg);
+       tdq_load_add(tdq, ts, TD_TO_VPROCG(td));
 #endif
 }
 
@@ -2501,7 +2501,7 @@
 #ifndef VIMAGE
        tdq_load_rem(tdq, ts);
 #else
-       tdq_load_rem(tdq, ts, td->td_ucred->cr_vimage->v_procg);
+       tdq_load_rem(tdq, ts, TD_TO_VPROCG(td));
 #endif
        TD_SET_CAN_RUN(td);
 }
@@ -2690,8 +2690,7 @@
 #ifndef VIMAGE
                tdq_load_rem(tdq, td->td_sched);
 #else
-               tdq_load_rem(tdq, td->td_sched,
-                   td->td_ucred->cr_vimage->v_procg);
+               tdq_load_rem(tdq, td->td_sched, TD_TO_VPROCG(td));
 #endif
        }
        KASSERT(curthread->td_md.md_spinlock_count == 1, ("invalid count"));

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

@@ -1143,7 +1143,7 @@
                if (t == tp->t_line)
                        return (0);
                s = spltty();
-               CURVNET_SET(curthread->td_ucred->cr_vimage->v_vnet);
+               CURVNET_SET(TD_TO_VNET(curthread));
                ttyld_close(tp, flag);
                tp->t_line = t;
                /* XXX: we should use the correct cdev here */
@@ -2534,7 +2534,7 @@
 void
 ttyinfo(struct tty *tp)
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread));
        struct timeval utime, stime;
        struct proc *p, *pick;
        struct thread *td, *picktd;
@@ -3203,7 +3203,7 @@
                        goto out;
                goto open_top;
        }
-       CURVNET_SET(curthread->td_ucred->cr_vimage->v_vnet);
+       CURVNET_SET(TD_TO_VNET(curthread));
        error = ttyld_open(tp, dev);
        CURVNET_RESTORE();
        ttyldoptim(tp);
@@ -3222,7 +3222,7 @@
        struct tty *tp;
 
        tp = dev->si_tty;
-       CURVNET_SET(curthread->td_ucred->cr_vimage->v_vnet);
+       CURVNET_SET(TD_TO_VNET(curthread));
        ttyld_close(tp, flag);
        CURVNET_RESTORE();
        ttyldoptim(tp);

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

@@ -364,7 +364,7 @@
        if (prp->pr_type != type)
                return (EPROTOTYPE);
 #ifdef VIMAGE
-       so = soalloc(td->td_ucred->cr_vimage->v_vnet);
+       so = soalloc(TD_TO_VNET(td));
 #else
        so = soalloc(NULL);
 #endif

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

@@ -138,7 +138,7 @@
        }
 #endif
 
-       CURVNET_SET(curthread->td_ucred->cr_vimage->v_vnet); /* XXX MARKO */
+       CURVNET_SET(TD_TO_VNET(curthread)); /* XXX MARKO */
        i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen;
        np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK | M_ZERO);
        saddr = (struct sockaddr *) (np + 1);

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

@@ -141,7 +141,7 @@
        struct proc *p = td->td_proc;
        int vfslocked;
 #ifdef IMUNES_SYMLINK_HACK
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
 #endif
 
        KASSERT((cnp->cn_flags & MPSAFE) != 0 || mtx_owned(&Giant) != 0,
@@ -301,7 +301,7 @@
 #ifdef IMUNES_SYMLINK_HACK
                if (V_morphing_symlinks) {
                        char *sp = strchr(cp, '@');
-                       int vnamelen = strlen(td->td_ucred->cr_vimage->vi_name);
+                       int vnamelen = strlen(TD_TO_VIMAGE(td)->vi_name);
 
                        if (sp) {
                                if (vnamelen >= auio.uio_resid) {
@@ -312,8 +312,7 @@
                                }
                                bcopy(sp + 1, sp + vnamelen,
                                    linklen - (sp - cp));
-                               bcopy(td->td_ucred->cr_vimage->vi_name, sp,
-                                   vnamelen);
+                               bcopy(TD_TO_VIMAGE(td)->vi_name, sp, vnamelen);
                                linklen += (vnamelen - 1);
                        }
                }

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

@@ -767,7 +767,7 @@
                        return (EPERM);
                }
        }
-       CURVNET_SET(td->td_ucred->cr_vimage->v_vnet);
+       CURVNET_SET(TD_TO_VNET(td));
        switch (cmd) {
 
        default:

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

@@ -1987,7 +1987,7 @@
                error = suser(td);
                if (error == 0)
                        error = vi_if_move((struct vi_req *) data, NULL,
-                                          td->td_ucred->cr_vimage);
+                           TD_TO_VIMAGE(td));
                return (error);
 
        /*

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


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

@@ -799,8 +799,7 @@
     struct in6_ifaddr *ia, int flags)
 {
        INIT_VNET_INET6(ifp->if_vnet);
-       /* XXX this bellow is WRONG - MARKO */
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread)); /* XXX V_hostname needs this */
        int error = 0, hostIsNew = 0, plen = -1;
        struct in6_ifaddr *oia;
        struct sockaddr_in6 dst6;

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

@@ -102,8 +102,7 @@
 static int
 get_rand_ifid(struct ifnet *ifp, struct in6_addr *in6)
 {
-       /* XXX this bellow is WRONG - MARKO */
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread)); /* XXX V_hostname needs this */
        MD5_CTX ctxt;
        u_int8_t digest[16];
        int hostnamelen = strlen(V_hostname);

==== //depot/projects/vimage/src/sys/nfsclient/nfs_vfsops.c#8 (text+ko) ====

@@ -401,7 +401,7 @@
 int
 nfs_mountroot(struct mount *mp, struct thread *td)
 {
-       INIT_VPROCG(td->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(td));
        struct nfsv3_diskless *nd = &nfsv3_diskless;
        struct socket *so;
        struct vnode *vp;
@@ -411,7 +411,7 @@
        char buf[128];
        char *cp;
 
-       CURVNET_SET(td->td_ucred->cr_vimage->v_vnet);
+       CURVNET_SET(TD_TO_VNET(td));
 #if defined(BOOTP_NFSROOT) && defined(BOOTP)
        bootpc_init();          /* use bootp to get nfs_diskless filled in */
 #elif defined(NFS_ROOT)

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

@@ -412,15 +412,15 @@
        void *ptr;                                                      \
        switch (subs) {                                                 \
        case V_NET:                                                     \
-               ptr = curthread->td_ucred->cr_vimage->v_vnet->mod_data[mod]; \
+               ptr = TD_TO_VNET(curthread)->mod_data[mod];             \
                arg1 = (void *) ((int) ptr + (int) arg1);               \
                break;                                                  \
        case V_PROCG:                                                   \
-               ptr = curthread->td_ucred->cr_vimage->v_procg;          \
+               ptr = TD_TO_VPROCG(curthread);                          \
                arg1 = (void *) ((int) ptr + (int) arg1);               \
                break;                                                  \
        case V_CPU:                                                     \
-               ptr = curthread->td_ucred->cr_vimage->v_cpu;            \
+               ptr = TD_TO_VCPU(curthread);                            \
                arg1 = (void *) ((int) ptr + (int) arg1);               \
                break;                                                  \
        default:                                                        \

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


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

@@ -275,6 +275,15 @@
 
 #define INIT_VCPU(arg)         struct vcpu *vcpu = (arg);
 
+#define TD_TO_VIMAGE(td)       (td)->td_ucred->cr_vimage
+#define TD_TO_VNET(td)         (td)->td_ucred->cr_vimage->v_vnet
+#define TD_TO_VPROCG(td)       (td)->td_ucred->cr_vimage->v_procg
+#define TD_TO_VCPU(td)         (td)->td_ucred->cr_vimage->v_cpu
+#define P_TO_VIMAGE(p)         (p)->p_ucred->cr_vimage
+#define P_TO_VNET(p)           (p)->p_ucred->cr_vimage->v_vnet
+#define P_TO_VPROCG(p)         (p)->p_ucred->cr_vimage->v_procg
+#define P_TO_VCPU(p)           (p)->p_ucred->cr_vimage->v_cpu
+
 #else /* !VIMAGE */
 
 /* Non-VIMAGE null-macros */
@@ -294,6 +303,14 @@
 #define VPROCG_ITERLOOP_BEGIN()
 #define VPROCG_ITERLOOP_END()
 #define INIT_VCPU(arg)
+#define TD_TO_VIMAGE(td)
+#define TD_TO_VNET(td)
+#define TD_TO_VPROCG(td)
+#define TD_TO_VCPU(td)
+#define P_TO_VIMAGE(p)
+#define P_TO_VNET(p)
+#define P_TO_VPROCG(p)
+#define P_TO_VCPU(p)
 
 #endif /* !VIMAGE */
 

==== //depot/projects/vimage/src/sys/vm/vm_meter.c#7 (text+ko) ====

@@ -79,7 +79,7 @@
 static int
 sysctl_vm_loadavg(SYSCTL_HANDLER_ARGS)
 {
-       INIT_VPROCG(curthread->td_ucred->cr_vimage->v_procg);
+       INIT_VPROCG(TD_TO_VPROCG(curthread));
        
 #ifdef SCTL_MASK32
        u_int32_t la[4];
_______________________________________________
p4-projects@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "p4-projects-unsubscribe@xxxxxxxxxxx"

<Prev in Thread] Current Thread [Next in Thread>