From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 25 12:20:28 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B05C916A4DE for ; Mon, 25 Apr 2005 12:20:28 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 748AB43D53 for ; Mon, 25 Apr 2005 12:20:27 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j3PCKRKd075683 for ; Mon, 25 Apr 2005 12:20:27 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j3PCKRr5075682; Mon, 25 Apr 2005 12:20:27 GMT (envelope-from gnats) Resent-Date: Mon, 25 Apr 2005 12:20:27 GMT Resent-Message-Id: <200504251220.j3PCKRr5075682@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jan Srzednicki Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9E6AC16A4CE for ; Mon, 25 Apr 2005 12:16:57 +0000 (GMT) Received: from miranda.expro.pl (miranda.expro.pl [193.25.166.12]) by mx1.FreeBSD.org (Postfix) with ESMTP id B7E2643D5C for ; Mon, 25 Apr 2005 12:16:56 +0000 (GMT) (envelope-from winfried@miranda.expro.pl) Received: by miranda.expro.pl (Postfix, from userid 1001) id 68D6E153CA; Mon, 25 Apr 2005 14:16:50 +0200 (CEST) Message-Id: <20050425121650.68D6E153CA@miranda.expro.pl> Date: Mon, 25 Apr 2005 14:16:50 +0200 (CEST) From: Jan Srzednicki To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/80322: TCP socket support broken on a busy port X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Apr 2005 12:20:29 -0000 >Number: 80322 >Category: kern >Synopsis: TCP socket support broken on a busy port >Confidential: no >Severity: serious >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 25 12:20:26 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Jan Srzednicki >Release: FreeBSD 4.10-RELEASE i386 >Organization: Expro >Environment: System: FreeBSD miranda 4.10-RELEASE FreeBSD 4.10-RELEASE #19: Tue Jan 4 12:11:01 CET 2005 >Description: There appears to be a rather weird problem with TCP sockets implementation. After a server daemon listening on a very busy unprivileged (>1024) port dies (I'm not able to repeat that with a low-usage port), the port is closed as it should, sockstat doesn't show anything listening on it, everything looks fine. But an attempt to bind to that port with UID != 0 results in failure -- EADDRINUSE. Here is a strace snap from a netcat process trying to bind to that port (UID!=0): socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 setsockopt(3, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0 bind(3, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use) But, when I swich to root everything is fine: socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 setsockopt(3, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0 bind(3, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("0.0.0.0")}, 16) = 0 listen(3, 1) = 0 (I can repeat that subsequently, once for root, once for user; it's not a timeout issue of any kind) There are no ipfw nor ipf rules on that host. There's no apparent reason why the 3306 port is treated in a different way, provided that in the begining the server daemon started succesfully. So, it appears that the dead server daemon leaves the port in some weird state. Maybe it's some socket cleaning issue. I haven't found any way to fix this behaviour except rebooting that machine. I have checked the CVS tree for RELENG_4, but I haven't found any relevant changes since 4.10-RELEASE in that area. >How-To-Repeat: 1. Get a quite busy machine with a very busy port (SQL port is a good example) 2. Kill the server. Don't let it shutdown cleanly. 3. Try binding to that port first with UID!=0, then with UID==0. >Fix: >Release-Note: >Audit-Trail: >Unformatted: