diff --git a/lib/libc/sys/socket.2 b/lib/libc/sys/socket.2 index 1e4ebdecfdc2..23c45959db4a 100644 --- a/lib/libc/sys/socket.2 +++ b/lib/libc/sys/socket.2 @@ -1,4 +1,4 @@ -.\" $NetBSD: socket.2,v 1.32 2006/06/13 20:37:24 ginsbach Exp $ +.\" $NetBSD: socket.2,v 1.33 2006/06/13 21:19:56 ginsbach Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -223,6 +223,9 @@ call fails if: .It Bq Er EACCES Permission to create a socket of the specified type and/or protocol is denied. +.It Bq Er EAFNOSUPPORT +The address family (domain) is not supported or +the specified domain is not supported by this protocol family. .It Bq Er EMFILE The per-process descriptor table is full. .It Bq Er ENFILE @@ -231,8 +234,10 @@ The system file table is full. Insufficient buffer space is available. The socket cannot be created until sufficient resources are freed. .It Bq Er EPROTONOSUPPORT -The protocol type or the specified protocol is not supported -within this domain. +The protocol family is not supported or +the specified protocol is not supported within this domain. +.It Bq Er EPROTOTYPE +The socket type is not supported by the protocol. .El .Sh SEE ALSO .Xr accept 2 , diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 28d04d47f2c2..4a4a7946674f 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.119 2006/05/25 14:27:28 yamt Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.120 2006/06/13 21:19:56 ginsbach Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.119 2006/05/25 14:27:28 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.120 2006/06/13 21:19:56 ginsbach Exp $"); #include "opt_sock_counters.h" #include "opt_sosend_loan.h" @@ -478,7 +478,16 @@ socreate(int dom, struct socket **aso, int type, int proto, struct lwp *l) prp = pffindproto(dom, proto, type); else prp = pffindtype(dom, type); - if (prp == 0 || prp->pr_usrreq == 0) + if (prp == 0) { + /* no support for domain */ + if (pffinddomain(dom) == 0) + return (EAFNOSUPPORT); + /* no support for socket type */ + if (proto == 0 && type != 0) + return (EPROTOTYPE); + return (EPROTONOSUPPORT); + } + if (prp->pr_usrreq == 0) return (EPROTONOSUPPORT); if (prp->pr_type != type) return (EPROTOTYPE);