Print this page
XXXX adding PID information to netstat output

@@ -121,10 +121,13 @@
         flag &= ~FCREAT;                /* paranoia */
         mutex_enter(&so->so_lock);
         so->so_count++;
         mutex_exit(&so->so_lock);
 
+        if (!(curproc->p_flag & SSYS))
+                sonode_insert_pid(so, curproc->p_pidp->pid_id);
+
         ASSERT(so->so_count != 0);      /* wraparound */
         ASSERT(vp->v_type == VSOCK);
 
         return (0);
 }

@@ -207,10 +210,26 @@
 {
         struct sonode *so = VTOSO(vp);
 
         ASSERT(vp->v_type == VSOCK);
 
+        switch (cmd) {
+        case F_ASSOCI_PID:
+                if (cr != kcred)
+                        return (EPERM);
+                if (!(curproc->p_flag & SSYS))
+                        sonode_insert_pid(so, (pid_t)arg);
+                return (0);
+
+        case F_DASSOC_PID:
+                if (cr != kcred)
+                        return (EPERM);
+                if (!(curproc->p_flag & SSYS))
+                        sonode_remove_pid(so, (pid_t)arg);
+                return (0);
+        }
+
         return (socket_ioctl(so, cmd, arg, mode, cr, rvalp));
 }
 
 /*
  * Allow any flags. Record FNDELAY and FNONBLOCK so that they can be inherited