From fbc9d5cd12dcc1ff564e70face6aff3cef21fbdc Mon Sep 17 00:00:00 2001 From: Jun-ichiro itojun Hagino Date: Fri, 25 May 2001 22:08:26 +0000 Subject: recover old acecept(2) behavior (no ECONNABORTED) for unix domain socket. it is to be friendly with postfix daemon-to-daemon communication (not 100% sure if which behavior is correct, specwise). patch similar to netbsd. --- sys/kern/uipc_socket.c | 5 +++-- sys/netccitt/ccitt_proto.c | 4 ++-- sys/netinet/in_proto.c | 6 +++--- sys/netinet6/in6_proto.c | 12 ++++++------ sys/netipx/ipx_proto.c | 6 +++--- sys/netiso/iso_proto.c | 8 ++++---- sys/netns/ns_proto.c | 6 +++--- sys/sys/protosw.h | 4 +++- 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 854d804f124..42c4c4a1a0d 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.33 2001/03/06 19:42:43 provos Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.34 2001/05/25 22:08:23 itojun Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -266,7 +266,8 @@ soaccept(so, nam) if ((so->so_state & SS_NOFDREF) == 0) panic("soaccept: !NOFDREF"); so->so_state &= ~SS_NOFDREF; - if ((so->so_state & SS_ISDISCONNECTED) == 0) + if ((so->so_state & SS_ISDISCONNECTED) == 0 || + (so->so_proto->pr_flags & PR_ABRTACPTDIS) == 0) error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT, NULL, nam, NULL); else diff --git a/sys/netccitt/ccitt_proto.c b/sys/netccitt/ccitt_proto.c index 275a3ea3d0a..43a4937958e 100644 --- a/sys/netccitt/ccitt_proto.c +++ b/sys/netccitt/ccitt_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ccitt_proto.c,v 1.2 1996/03/04 07:36:20 niklas Exp $ */ +/* $OpenBSD: ccitt_proto.c,v 1.3 2001/05/25 22:08:23 itojun Exp $ */ /* $NetBSD: ccitt_proto.c,v 1.6 1996/02/13 22:04:21 christos Exp $ */ /* @@ -85,7 +85,7 @@ struct protosw ccittsw[] = { hd_init, 0, hd_timer, 0, }, #endif -{ SOCK_STREAM, DOMAIN, CCITTPROTO_X25, PR_CONNREQUIRED|PR_ATOMIC|PR_WANTRCVD, +{ SOCK_STREAM, DOMAIN, CCITTPROTO_X25, PR_CONNREQUIRED|PR_ATOMIC|PR_WANTRCVD|PR_ABRTACPTDIS, pk_input, 0, pk_ctlinput, pk_ctloutput, pk_usrreq, pk_init, 0, pk_timer, 0, diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index ca30664e986..ed39157dddc 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_proto.c,v 1.25 2000/01/27 08:09:08 angelos Exp $ */ +/* $OpenBSD: in_proto.c,v 1.26 2001/05/25 22:08:23 itojun Exp $ */ /* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */ /* @@ -178,7 +178,7 @@ struct protosw inetsw[] = { udp_usrreq, udp_init, 0, 0, 0, udp_sysctl }, -{ SOCK_STREAM, &inetdomain, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD, +{ SOCK_STREAM, &inetdomain, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS, tcp_input, 0, tcp_ctlinput, tcp_ctloutput, tcp_usrreq, tcp_init, tcp_fasttimo, tcp_slowtimo, tcp_drain, tcp_sysctl @@ -226,7 +226,7 @@ struct protosw inetsw[] = { igmp_init, igmp_fasttimo, igmp_slowtimo, 0, }, #ifdef TPIP -{ SOCK_SEQPACKET,&inetdomain, IPPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD, +{ SOCK_SEQPACKET,&inetdomain, IPPROTO_TP, PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS, tpip_input, 0, tpip_ctlinput, tp_ctloutput, tp_usrreq, tp_init, 0, tp_slowtimo, tp_drain, diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c index 4b324026561..cb703e7952a 100644 --- a/sys/netinet6/in6_proto.c +++ b/sys/netinet6/in6_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_proto.c,v 1.27 2001/04/06 04:42:09 csapuntz Exp $ */ +/* $OpenBSD: in6_proto.c,v 1.28 2001/05/25 22:08:24 itojun Exp $ */ /* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */ /* @@ -122,13 +122,13 @@ struct ip6protosw inet6sw[] = { ip6_init, 0, frag6_slowtimo, frag6_drain, ip6_sysctl, }, -{ SOCK_DGRAM, &inet6domain, IPPROTO_UDP, PR_ATOMIC | PR_ADDR, +{ SOCK_DGRAM, &inet6domain, IPPROTO_UDP, PR_ATOMIC|PR_ADDR, udp6_input, 0, udp6_ctlinput, ip6_ctloutput, udp6_usrreq, 0, 0, 0, 0, udp_sysctl, }, -{ SOCK_STREAM, &inet6domain, IPPROTO_TCP, PR_CONNREQUIRED | PR_WANTRCVD, +{ SOCK_STREAM, &inet6domain, IPPROTO_TCP, PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS, tcp6_input, 0, tcp6_ctlinput, tcp_ctloutput, tcp6_usrreq, #ifdef INET /* don't call initialization and timeout routines twice */ @@ -138,12 +138,12 @@ struct ip6protosw inet6sw[] = { #endif tcp_sysctl, }, -{ SOCK_RAW, &inet6domain, IPPROTO_RAW, PR_ATOMIC | PR_ADDR, +{ SOCK_RAW, &inet6domain, IPPROTO_RAW, PR_ATOMIC|PR_ADDR, rip6_input, rip6_output, rip6_ctlinput, rip6_ctloutput, rip6_usrreq, 0, 0, 0, 0, }, -{ SOCK_RAW, &inet6domain, IPPROTO_ICMPV6, PR_ATOMIC | PR_ADDR, +{ SOCK_RAW, &inet6domain, IPPROTO_ICMPV6, PR_ATOMIC|PR_ADDR, icmp6_input, rip6_output, 0, rip6_ctloutput, rip6_usrreq, icmp6_init, icmp6_fasttimo, 0, 0, @@ -219,7 +219,7 @@ struct ip6protosw inet6sw[] = { 0, 0, 0, 0, }, /* raw wildcard */ -{ SOCK_RAW, &inet6domain, 0, PR_ATOMIC | PR_ADDR, +{ SOCK_RAW, &inet6domain, 0, PR_ATOMIC|PR_ADDR, rip6_input, rip6_output, 0, rip6_ctloutput, rip6_usrreq, rip6_init, 0, 0, 0, diff --git a/sys/netipx/ipx_proto.c b/sys/netipx/ipx_proto.c index 400391544bd..7038d3b5d48 100644 --- a/sys/netipx/ipx_proto.c +++ b/sys/netipx/ipx_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipx_proto.c,v 1.4 2000/01/13 06:48:21 fgsch Exp $ */ +/* $OpenBSD: ipx_proto.c,v 1.5 2001/05/25 22:08:24 itojun Exp $ */ /*- * @@ -67,12 +67,12 @@ struct protosw ipxsw[] = { ipx_usrreq, 0, 0, 0, 0, ipx_sysctl }, -{ SOCK_STREAM, &ipxdomain, IPXPROTO_SPX, PR_CONNREQUIRED|PR_WANTRCVD, +{ SOCK_STREAM, &ipxdomain, IPXPROTO_SPX, PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS, spx_input, 0, spx_ctlinput, spx_ctloutput, spx_usrreq, spx_init, spx_fasttimo, spx_slowtimo, 0, spx_sysctl }, -{ SOCK_SEQPACKET,&ipxdomain, IPXPROTO_SPX, PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC, +{ SOCK_SEQPACKET,&ipxdomain, IPXPROTO_SPX, PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC|PR_ABRTACPTDIS, spx_input, 0, spx_ctlinput, spx_ctloutput, spx_usrreq_sp, 0, 0, 0, 0, spx_sysctl diff --git a/sys/netiso/iso_proto.c b/sys/netiso/iso_proto.c index b0caaf21eea..5ccd3ba1dee 100644 --- a/sys/netiso/iso_proto.c +++ b/sys/netiso/iso_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iso_proto.c,v 1.2 1996/03/04 10:35:38 mickey Exp $ */ +/* $OpenBSD: iso_proto.c,v 1.3 2001/05/25 22:08:25 itojun Exp $ */ /* $NetBSD: iso_proto.c,v 1.6 1996/02/13 22:10:21 christos Exp $ */ /*- @@ -149,14 +149,14 @@ struct protosw isosw[] = { }, /* ISOPROTO_TP */ - {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP, PR_CONNREQUIRED | PR_WANTRCVD, + {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP, PR_CONNREQUIRED | PR_WANTRCVD | PR_ABRTACPTDIS, tpclnp_input, 0, tpclnp_ctlinput, tp_ctloutput, tp_usrreq, tp_init, tp_fasttimo, tp_slowtimo, tp_drain, }, #ifdef TUBA - {SOCK_STREAM, &isodomain, ISOPROTO_TCP, PR_CONNREQUIRED | PR_WANTRCVD, + {SOCK_STREAM, &isodomain, ISOPROTO_TCP, PR_CONNREQUIRED | PR_WANTRCVD | PR_ABRTACPTDIS, tuba_tcpinput, 0, 0, tuba_ctloutput, tuba_usrreq, tuba_init, tuba_fasttimo, tuba_fasttimo, 0 @@ -165,7 +165,7 @@ struct protosw isosw[] = { #ifdef TPCONS /* ISOPROTO_TP */ - {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP0, PR_CONNREQUIRED | PR_WANTRCVD, + {SOCK_SEQPACKET, &isodomain, ISOPROTO_TP0, PR_CONNREQUIRED | PR_WANTRCVD | PR_ABRTACPTDIS, tpcons_input, 0, 0, tp_ctloutput, tp_usrreq, cons_init, 0, 0, 0, diff --git a/sys/netns/ns_proto.c b/sys/netns/ns_proto.c index db1f67f76b8..2d60231e405 100644 --- a/sys/netns/ns_proto.c +++ b/sys/netns/ns_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ns_proto.c,v 1.2 1996/03/04 08:20:31 niklas Exp $ */ +/* $OpenBSD: ns_proto.c,v 1.3 2001/05/25 22:08:25 itojun Exp $ */ /* $NetBSD: ns_proto.c,v 1.6 1996/02/13 22:14:08 christos Exp $ */ /* @@ -74,12 +74,12 @@ struct protosw nssw[] = { idp_usrreq, 0, 0, 0, 0, }, -{ SOCK_STREAM, &nsdomain, NSPROTO_SPP, PR_CONNREQUIRED|PR_WANTRCVD, +{ SOCK_STREAM, &nsdomain, NSPROTO_SPP, PR_CONNREQUIRED|PR_WANTRCVD|PR_ABRTACPTDIS, spp_input, 0, spp_ctlinput, spp_ctloutput, spp_usrreq, spp_init, spp_fasttimo, spp_slowtimo, 0, }, -{ SOCK_SEQPACKET,&nsdomain, NSPROTO_SPP, PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC, +{ SOCK_SEQPACKET,&nsdomain, NSPROTO_SPP, PR_CONNREQUIRED|PR_WANTRCVD|PR_ATOMIC|PR_ABRTACPTDIS, spp_input, 0, spp_ctlinput, spp_ctloutput, spp_usrreq_sp, 0, 0, 0, 0, diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index ebf4cfcfd08..d0615fe6b2d 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.4 2000/09/25 09:41:02 provos Exp $ */ +/* $OpenBSD: protosw.h,v 1.5 2001/05/25 22:08:22 itojun Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -112,6 +112,8 @@ struct protosw { #define PR_CONNREQUIRED 0x04 /* connection required by protocol */ #define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */ #define PR_RIGHTS 0x10 /* passes capabilities */ +#define PR_ABRTACPTDIS 0x20 /* abort on accept(2) to disconnected + socket */ /* * The arguments to usrreq are: -- cgit v1.2.3