[BACK]Return to uipc_socket.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/kern/uipc_socket.c between version 1.134.2.2 and 1.134.2.3

version 1.134.2.2, 2007/04/10 13:26:42 version 1.134.2.3, 2007/06/08 14:17:27
Line 461  socreate(int dom, struct socket **aso, i
Line 461  socreate(int dom, struct socket **aso, i
         error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_SOCKET,          error = kauth_authorize_network(l->l_cred, KAUTH_NETWORK_SOCKET,
             KAUTH_REQ_NETWORK_SOCKET_OPEN, KAUTH_ARG(dom), KAUTH_ARG(type),              KAUTH_REQ_NETWORK_SOCKET_OPEN, KAUTH_ARG(dom), KAUTH_ARG(type),
             KAUTH_ARG(proto));              KAUTH_ARG(proto));
         if (error)          if (error != 0)
                 return (error);                  return error;
   
         if (proto)          if (proto)
                 prp = pffindproto(dom, proto, type);                  prp = pffindproto(dom, proto, type);
         else          else
                 prp = pffindtype(dom, type);                  prp = pffindtype(dom, type);
         if (prp == 0) {          if (prp == NULL) {
                 /* no support for domain */                  /* no support for domain */
                 if (pffinddomain(dom) == 0)                  if (pffinddomain(dom) == 0)
                         return (EAFNOSUPPORT);                          return EAFNOSUPPORT;
                 /* no support for socket type */                  /* no support for socket type */
                 if (proto == 0 && type != 0)                  if (proto == 0 && type != 0)
                         return (EPROTOTYPE);                          return EPROTOTYPE;
                 return (EPROTONOSUPPORT);                  return EPROTONOSUPPORT;
         }          }
         if (prp->pr_usrreq == 0)          if (prp->pr_usrreq == NULL)
                 return (EPROTONOSUPPORT);                  return EPROTONOSUPPORT;
         if (prp->pr_type != type)          if (prp->pr_type != type)
                 return (EPROTOTYPE);                  return EPROTOTYPE;
         s = splsoftnet();          s = splsoftnet();
         so = pool_get(&socket_pool, PR_WAITOK);          so = pool_get(&socket_pool, PR_WAITOK);
         memset((void *)so, 0, sizeof(*so));          memset(so, 0, sizeof(*so));
         TAILQ_INIT(&so->so_q0);          TAILQ_INIT(&so->so_q0);
         TAILQ_INIT(&so->so_q);          TAILQ_INIT(&so->so_q);
         so->so_type = type;          so->so_type = type;
Line 497  socreate(int dom, struct socket **aso, i
Line 497  socreate(int dom, struct socket **aso, i
 #endif  #endif
         uid = kauth_cred_geteuid(l->l_cred);          uid = kauth_cred_geteuid(l->l_cred);
         so->so_uidinfo = uid_find(uid);          so->so_uidinfo = uid_find(uid);
         error = (*prp->pr_usrreq)(so, PRU_ATTACH, (struct mbuf *)0,          error = (*prp->pr_usrreq)(so, PRU_ATTACH, NULL,
             (struct mbuf *)(long)proto, (struct mbuf *)0, l);              (struct mbuf *)(long)proto, NULL, l);
         if (error) {          if (error != 0) {
                 so->so_state |= SS_NOFDREF;                  so->so_state |= SS_NOFDREF;
                 sofree(so);                  sofree(so);
                 splx(s);                  splx(s);
                 return (error);                  return error;
         }          }
         splx(s);          splx(s);
         *aso = so;          *aso = so;
         return (0);          return 0;
 }  }
   
 int  int
Line 516  sobind(struct socket *so, struct mbuf *n
Line 516  sobind(struct socket *so, struct mbuf *n
         int     s, error;          int     s, error;
   
         s = splsoftnet();          s = splsoftnet();
         error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, (struct mbuf *)0,          error = (*so->so_proto->pr_usrreq)(so, PRU_BIND, NULL, nam, NULL, l);
             nam, (struct mbuf *)0, l);  
         splx(s);          splx(s);
         return (error);          return error;
 }  }
   
 int  int
Line 528  solisten(struct socket *so, int backlog)
Line 527  solisten(struct socket *so, int backlog)
         int     s, error;          int     s, error;
   
         s = splsoftnet();          s = splsoftnet();
         error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, (struct mbuf *)0,          error = (*so->so_proto->pr_usrreq)(so, PRU_LISTEN, NULL,
             (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);              NULL, NULL, NULL);
         if (error) {          if (error != 0) {
                 splx(s);                  splx(s);
                 return (error);                  return error;
         }          }
         if (TAILQ_EMPTY(&so->so_q))          if (TAILQ_EMPTY(&so->so_q))
                 so->so_options |= SO_ACCEPTCONN;                  so->so_options |= SO_ACCEPTCONN;
Line 540  solisten(struct socket *so, int backlog)
Line 539  solisten(struct socket *so, int backlog)
                 backlog = 0;                  backlog = 0;
         so->so_qlimit = min(backlog, somaxconn);          so->so_qlimit = min(backlog, somaxconn);
         splx(s);          splx(s);
         return (0);          return 0;
 }  }
   
 void  void
Line 616  soclose(struct socket *so)
Line 615  soclose(struct socket *so)
  drop:   drop:
         if (so->so_pcb) {          if (so->so_pcb) {
                 int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH,                  int error2 = (*so->so_proto->pr_usrreq)(so, PRU_DETACH,
                     (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0,                      NULL, NULL, NULL, NULL);
                     (struct lwp *)0);  
                 if (error == 0)                  if (error == 0)
                         error = error2;                          error = error2;
         }          }
Line 636  soclose(struct socket *so)
Line 634  soclose(struct socket *so)
 int  int
 soabort(struct socket *so)  soabort(struct socket *so)
 {  {
           int error;
   
         return (*so->so_proto->pr_usrreq)(so, PRU_ABORT, (struct mbuf *)0,          KASSERT(so->so_head == NULL);
             (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);          error = (*so->so_proto->pr_usrreq)(so, PRU_ABORT, NULL,
               NULL, NULL, NULL);
           if (error) {
                   sofree(so);
           }
           return error;
 }  }
   
 int  int
Line 654  soaccept(struct socket *so, struct mbuf 
Line 658  soaccept(struct socket *so, struct mbuf 
         if ((so->so_state & SS_ISDISCONNECTED) == 0 ||          if ((so->so_state & SS_ISDISCONNECTED) == 0 ||
             (so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0)              (so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0)
                 error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT,                  error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT,
                     (struct mbuf *)0, nam, (struct mbuf *)0, (struct lwp *)0);                      NULL, nam, NULL, NULL);
         else          else
                 error = ECONNABORTED;                  error = ECONNABORTED;
   
Line 682  soconnect(struct socket *so, struct mbuf
Line 686  soconnect(struct socket *so, struct mbuf
                 error = EISCONN;                  error = EISCONN;
         else          else
                 error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT,                  error = (*so->so_proto->pr_usrreq)(so, PRU_CONNECT,
                     (struct mbuf *)0, nam, (struct mbuf *)0, l);                      NULL, nam, NULL, l);
         splx(s);          splx(s);
         return (error);          return (error);
 }  }
Line 694  soconnect2(struct socket *so1, struct so
Line 698  soconnect2(struct socket *so1, struct so
   
         s = splsoftnet();          s = splsoftnet();
         error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2,          error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2,
             (struct mbuf *)0, (struct mbuf *)so2, (struct mbuf *)0,              NULL, (struct mbuf *)so2, NULL, NULL);
             (struct lwp *)0);  
         splx(s);          splx(s);
         return (error);          return (error);
 }  }
Line 715  sodisconnect(struct socket *so)
Line 718  sodisconnect(struct socket *so)
                 goto bad;                  goto bad;
         }          }
         error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT,          error = (*so->so_proto->pr_usrreq)(so, PRU_DISCONNECT,
             (struct mbuf *)0, (struct mbuf *)0, (struct mbuf *)0,              NULL, NULL, NULL, NULL);
             (struct lwp *)0);  
  bad:   bad:
         splx(s);          splx(s);
         sodopendfree();          sodopendfree();
Line 833  sosend(struct socket *so, struct mbuf *a
Line 835  sosend(struct socket *so, struct mbuf *a
                                         m = m_gethdr(M_WAIT, MT_DATA);                                          m = m_gethdr(M_WAIT, MT_DATA);
                                         mlen = MHLEN;                                          mlen = MHLEN;
                                         m->m_pkthdr.len = 0;                                          m->m_pkthdr.len = 0;
                                         m->m_pkthdr.rcvif = (struct ifnet *)0;                                          m->m_pkthdr.rcvif = NULL;
                                 } else {                                  } else {
                                         m = m_get(M_WAIT, MT_DATA);                                          m = m_get(M_WAIT, MT_DATA);
                                         mlen = MLEN;                                          mlen = MLEN;
Line 974  soreceive(struct socket *so, struct mbuf
Line 976  soreceive(struct socket *so, struct mbuf
         if (flags & MSG_OOB) {          if (flags & MSG_OOB) {
                 m = m_get(M_WAIT, MT_DATA);                  m = m_get(M_WAIT, MT_DATA);
                 error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m,                  error = (*pr->pr_usrreq)(so, PRU_RCVOOB, m,
                     (struct mbuf *)(long)(flags & MSG_PEEK),                      (struct mbuf *)(long)(flags & MSG_PEEK), NULL, l);
                     (struct mbuf *)0, l);  
                 if (error)                  if (error)
                         goto bad;                          goto bad;
                 do {                  do {
Line 989  soreceive(struct socket *so, struct mbuf
Line 990  soreceive(struct socket *so, struct mbuf
                 return (error);                  return (error);
         }          }
         if (mp)          if (mp)
                 *mp = (struct mbuf *)0;                  *mp = NULL;
         if (so->so_state & SS_ISCONFIRMING && uio->uio_resid)          if (so->so_state & SS_ISCONFIRMING && uio->uio_resid)
                 (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,                  (*pr->pr_usrreq)(so, PRU_RCVD, NULL, NULL, NULL, l);
                     (struct mbuf *)0, (struct mbuf *)0, l);  
   
  restart:   restart:
         if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0)          if ((error = sblock(&so->so_rcv, SBLOCKWAIT(flags))) != 0)
Line 1228  soreceive(struct socket *so, struct mbuf
Line 1228  soreceive(struct socket *so, struct mbuf
                                         *mp = m;                                          *mp = m;
                                         mp = &m->m_next;                                          mp = &m->m_next;
                                         so->so_rcv.sb_mb = m = m->m_next;                                          so->so_rcv.sb_mb = m = m->m_next;
                                         *mp = (struct mbuf *)0;                                          *mp = NULL;
                                 } else {                                  } else {
                                         MFREE(m, so->so_rcv.sb_mb);                                          MFREE(m, so->so_rcv.sb_mb);
                                         m = so->so_rcv.sb_mb;                                          m = so->so_rcv.sb_mb;
Line 1299  soreceive(struct socket *so, struct mbuf
Line 1299  soreceive(struct socket *so, struct mbuf
                          */                           */
                         if ((pr->pr_flags & PR_WANTRCVD) && so->so_pcb)                          if ((pr->pr_flags & PR_WANTRCVD) && so->so_pcb)
                                 (*pr->pr_usrreq)(so, PRU_RCVD,                                  (*pr->pr_usrreq)(so, PRU_RCVD,
                                     (struct mbuf *)0,                                      NULL, (struct mbuf *)(long)flags, NULL, l);
                                     (struct mbuf *)(long)flags,  
                                     (struct mbuf *)0, l);  
                         SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2");                          SBLASTRECORDCHK(&so->so_rcv, "soreceive sbwait 2");
                         SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");                          SBLASTMBUFCHK(&so->so_rcv, "soreceive sbwait 2");
                         error = sbwait(&so->so_rcv);                          error = sbwait(&so->so_rcv);
Line 1337  soreceive(struct socket *so, struct mbuf
Line 1335  soreceive(struct socket *so, struct mbuf
                 SBLASTRECORDCHK(&so->so_rcv, "soreceive 4");                  SBLASTRECORDCHK(&so->so_rcv, "soreceive 4");
                 SBLASTMBUFCHK(&so->so_rcv, "soreceive 4");                  SBLASTMBUFCHK(&so->so_rcv, "soreceive 4");
                 if (pr->pr_flags & PR_WANTRCVD && so->so_pcb)                  if (pr->pr_flags & PR_WANTRCVD && so->so_pcb)
                         (*pr->pr_usrreq)(so, PRU_RCVD, (struct mbuf *)0,                          (*pr->pr_usrreq)(so, PRU_RCVD, NULL,
                             (struct mbuf *)(long)flags, (struct mbuf *)0, l);                              (struct mbuf *)(long)flags, NULL, l);
         }          }
         if (orig_resid == uio->uio_resid && orig_resid &&          if (orig_resid == uio->uio_resid && orig_resid &&
             (flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {              (flags & MSG_EOR) == 0 && (so->so_state & SS_CANTRCVMORE) == 0) {
Line 1367  soshutdown(struct socket *so, int how)
Line 1365  soshutdown(struct socket *so, int how)
         if (how == SHUT_RD || how == SHUT_RDWR)          if (how == SHUT_RD || how == SHUT_RDWR)
                 sorflush(so);                  sorflush(so);
         if (how == SHUT_WR || how == SHUT_RDWR)          if (how == SHUT_WR || how == SHUT_RDWR)
                 return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, (struct mbuf *)0,                  return (*pr->pr_usrreq)(so, PRU_SHUTDOWN, NULL,
                     (struct mbuf *)0, (struct mbuf *)0, (struct lwp *)0);                      NULL, NULL, NULL);
         return (0);          return (0);
 }  }
   

Legend:
Removed from v.1.134.2.2  
changed lines
  Added in v.1.134.2.3

CVSweb <webmaster@jp.NetBSD.org>