Subject: Re: accept(2) behaviour.
To: None <thorpej@nas.nasa.gov>
From: Darren Reed <darrenr@reed.wattle.id.au>
List: tech-net
Date: 06/29/1999 10:50:37
ok, how does the below patch look ?
Darren
*** /sys/kern/uipc_syscalls.c.dist Sat Jun 26 16:01:29 1999
--- /sys/kern/uipc_syscalls.c Tue Jun 29 10:42:46 1999
***************
*** 67,72 ****
--- 67,75 ----
#include <sys/mount.h>
#include <sys/syscallargs.h>
+ #include <vm/vm.h>
+ #include <uvm/uvm_extern.h>
+
/*
* System call interface to the socket abstraction.
*/
***************
*** 171,181 ****
--- 174,192 ----
if (SCARG(uap, name) && (error = copyin((caddr_t)SCARG(uap, anamelen),
(caddr_t)&namelen, sizeof(namelen))))
return (error);
+ if (SCARG(uap, name) != NULL &&
+ uvm_useracc((caddr_t)SCARG(uap, name), sizeof(struct sockaddr),
+ B_WRITE) == FALSE)
+ return (EFAULT);
if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
return (error);
s = splsoftnet();
so = (struct socket *)fp->f_data;
+ if (!(so->so_proto->pr_flags & PR_LISTEN)) {
+ splx(s);
+ return (EOPNOTSUPP);
+ }
if ((so->so_options & SO_ACCEPTCONN) == 0) {
splx(s);
return (EINVAL);
***************
*** 227,232 ****
--- 238,245 ----
error = copyout((caddr_t)&namelen,
(caddr_t)SCARG(uap, anamelen),
sizeof(*SCARG(uap, anamelen)));
+ if (error != 0)
+ (void) closef(fp, p);
}
m_freem(nam);
splx(s);
*** /sys/sys/protosw.h.dist Wed Jun 3 06:55:53 1998
--- /sys/sys/protosw.h Tue Jun 29 09:59:47 1999
***************
*** 115,120 ****
--- 115,121 ----
#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
#define PR_RIGHTS 0x10 /* passes capabilities */
+ #define PR_LISTEN 0x20 /* supports listen(2) and accept(2) */
/*
* The arguments to usrreq are:
*** /sys/netccitt/ccitt_proto.c.dist Thu Jan 14 12:21:52 1999
--- /sys/netccitt/ccitt_proto.c Tue Jun 29 10:33:44 1999
***************
*** 87,93 ****
hd_init, 0, hd_timer, 0,
},
#endif
! { SOCK_STREAM, DOMAIN, CCITTPROTO_X25, PR_CONNREQUIRED|PR_ATOMIC|PR_WANTRCVD,
pk_input, 0, pk_ctlinput, pk_ctloutput,
pk_usrreq,
pk_init, 0, pk_timer, 0,
--- 87,93 ----
hd_init, 0, hd_timer, 0,
},
#endif
! { SOCK_STREAM, DOMAIN, CCITTPROTO_X25, PR_CONNREQUIRED|PR_ATOMIC|PR_WANTRCVD|PR_LISTEN,
pk_input, 0, pk_ctlinput, pk_ctloutput,
pk_usrreq,
pk_init, 0, pk_timer, 0,
*** /sys/netinet/in_proto.c.dist Fri Apr 30 00:44:48 1999
--- /sys/netinet/in_proto.c Tue Jun 29 10:31:14 1999
***************
*** 107,113 ****
udp_usrreq,
udp_init, 0, 0, 0, udp_sysctl
},
! { SOCK_STREAM, &inetdomain, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD,
tcp_input, 0, tcp_ctlinput, tcp_ctloutput,
tcp_usrreq,
tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain, tcp_sysctl
--- 107,113 ----
udp_usrreq,
udp_init, 0, 0, 0, udp_sysctl
},
! { SOCK_STREAM, &inetdomain, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN,
tcp_input, 0, tcp_ctlinput, tcp_ctloutput,
tcp_usrreq,
tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain, tcp_sysctl
***************
*** 147,153 ****
igmp_init, igmp_fasttimo, igmp_slowtimo, 0,
},
#ifdef TPIP
! { SOCK_SEQPACKET,&inetdomain, IPPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD,
tpip_input, 0, tpip_ctlinput, tp_ctloutput,
tp_usrreq,
tp_init, 0, tp_slowtimo, tp_drain,
--- 147,153 ----
igmp_init, igmp_fasttimo, igmp_slowtimo, 0,
},
#ifdef TPIP
! { SOCK_SEQPACKET,&inetdomain, IPPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD|PR_LISTEN,
tpip_input, 0, tpip_ctlinput, tp_ctloutput,
tp_usrreq,
tp_init, 0, tp_slowtimo, tp_drain,
*** /sys/netiso/iso_proto.c.dist Thu Jan 14 12:22:43 1999
--- /sys/netiso/iso_proto.c Tue Jun 29 10:35:24 1999
***************
*** 147,153 ****
},
/* ISOPROTO_TP */
! {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP, PR_CONNREQUIRED | PR_WANTRCVD,
tpclnp_input, 0, tpclnp_ctlinput, tp_ctloutput,
tp_usrreq,
tp_init, tp_fasttimo, tp_slowtimo, tp_drain,
--- 147,153 ----
},
/* ISOPROTO_TP */
! {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP, PR_CONNREQUIRED | PR_WANTRCVD | PR_LISTEN,
tpclnp_input, 0, tpclnp_ctlinput, tp_ctloutput,
tp_usrreq,
tp_init, tp_fasttimo, tp_slowtimo, tp_drain,
***************
*** 155,161 ****
#ifdef TPCONS
/* ISOPROTO_TP */
! {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP0, PR_CONNREQUIRED | PR_WANTRCVD,
tpcons_input, 0, 0, tp_ctloutput,
tp_usrreq,
cons_init, 0, 0, 0,
--- 155,161 ----
#ifdef TPCONS
/* ISOPROTO_TP */
! {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP0, PR_CONNREQUIRED | PR_WANTRCVD | PR_LISTEN,
tpcons_input, 0, 0, tp_ctloutput,
tp_usrreq,
cons_init, 0, 0, 0,
*** /sys/netns/ns_proto.c.dist Tue Jun 29 10:32:14 1999
--- /sys/netns/ns_proto.c Tue Jun 29 10:31:59 1999
***************
*** 78,84 ****
spp_usrreq,
spp_init, spp_fasttimo, spp_slowtimo, 0,
},
! { SOCK_SEQPACKET,&nsdomain, NSPROTO_SPP, PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC,
spp_input, 0, spp_ctlinput, spp_ctloutput,
spp_usrreq_sp,
0, 0, 0, 0,
--- 78,84 ----
spp_usrreq,
spp_init, spp_fasttimo, spp_slowtimo, 0,
},
! { SOCK_SEQPACKET,&nsdomain, NSPROTO_SPP, PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC|PR_LISTEN,
spp_input, 0, spp_ctlinput, spp_ctloutput,
spp_usrreq_sp,
0, 0, 0, 0,