From owner-freebsd-net Fri Jan 19 16:38:43 2001 Delivered-To: freebsd-net@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 97B6537B401 for ; Fri, 19 Jan 2001 16:38:25 -0800 (PST) Received: by bazooka.unixfreak.org (Postfix, from userid 1000) id 5FD213E02; Fri, 19 Jan 2001 16:38:25 -0800 (PST) Received: from unixfreak.org (localhost [127.0.0.1]) by bazooka.unixfreak.org (Postfix) with ESMTP id 5E3E43C10A; Fri, 19 Jan 2001 16:38:25 -0800 (PST) To: Garrett Wollman Cc: Wes Peters , freebsd-net@FreeBSD.ORG Subject: Re: manual page review: connect(2) EAGAIN error In-Reply-To: Message from Garrett Wollman of "Fri, 19 Jan 2001 12:36:27 EST." <200101191736.MAA10929@khavrinen.lcs.mit.edu> Date: Fri, 19 Jan 2001 16:38:20 -0800 From: Dima Dorfman Message-Id: <20010120003825.5FD213E02@bazooka.unixfreak.org> Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > < said: > > > If the code implements what? Returning EAGAIN when no ephemeral ports are > > available? That is all the above really says, and then provides a hint > > as to how to fix it. The description is a little simplistic, as it misses > > the lowfirst-lowlast and highfirst-highlast ranges. > > If no ports are available, the correct (Standard) error is > [EADDRNOTAVAIL], regardless of whether the socket is in blocking or > non-blocking mode. The code does indeed seem to implement this. The patch below is a possible remedy. I only tested some very simple cases, but it does seem to work. Also, judging from the comments above the changed lines (not in the diff), it looks like this is the right place. As far as I can tell, function changed, in_pcbbind, is called on blocking and non-blocking sockets alike. My tests also show that EAGAIN was being returned on blocking sockets when all ports were in use (just wanted to clear that up; the patch seems to just use non-blocking sockets as an example, anyway). Dima Dorfman dima@unixfreak.org Index: in_pcb.c =================================================================== RCS file: /st/src/FreeBSD/src/sys/netinet/in_pcb.c,v retrieving revision 1.71 diff -u -r1.71 in_pcb.c --- in_pcb.c 2000/12/27 03:02:29 1.71 +++ in_pcb.c 2001/01/20 00:31:27 @@ -313,7 +313,7 @@ * occurred above. */ inp->inp_laddr.s_addr = INADDR_ANY; - return (EAGAIN); + return (EADDRNOTAVAIL); } --*lastport; if (*lastport > first || *lastport < last) @@ -334,7 +334,7 @@ * occurred above. */ inp->inp_laddr.s_addr = INADDR_ANY; - return (EAGAIN); + return (EADDRNOTAVAIL); } ++*lastport; if (*lastport < first || *lastport > last) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message