From nobody Tue Apr 05 14:17:25 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7D3B01A899E3 for ; Tue, 5 Apr 2022 14:17:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KXqTx08byz4WjP for ; Tue, 5 Apr 2022 14:17:25 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DA241140 for ; Tue, 5 Apr 2022 14:17:24 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 235EHO0N014736 for ; Tue, 5 Apr 2022 14:17:24 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 235EHO29014735 for bugs@FreeBSD.org; Tue, 5 Apr 2022 14:17:24 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 263062] tcp_inpcb leaking in VM environment Date: Tue, 05 Apr 2022 14:17:25 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.1-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: eugene@zhegan.in X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649168245; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xnDRal3VduPwrEgaoLx2DeoXJvVNsrhCY6vLkdoGQQc=; b=w/i5Hgd6uWJ+q/Dp5IZBX1j+FayTbbkaBlwEQ06YzOEtOUvVhQ/a6y5ZewsyAbF1+JE8M9 EEq+CvbXzmrJxumFMf5WvpJOn57lWdTsve0h4EdZGOLgIIOLrRdKY/0kcNOmWaiSq70fua kfwSJDdCvNoYlCwCFw/wSE5FZs3PZNhKWekp+7qxD8Zdp1O1gIZgHS66d4uW2+8nj6F2lZ SFffeQv0d/tbmvZ8TpDuAzES+9KqmjpnM5iWxDC1J7TAnjrCPYIxzfFbEZPjJBFbY/elt5 K4KAGVHf5992Re1XyGDsnj67wCEEWdSeTT2dr8jtkn3j4n3WIg9/OzBIzOFXIg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649168245; a=rsa-sha256; cv=none; b=lwObL5XQpsOdBsPWV1FozZumE3jJhkjkwtABV/L/NV7tHYVRKFOpp02/uZG9DVJoEDvza8 snkcYqmz8M7PIEX9F1TJlgRsDzWNQ0WwKf3YzY3mSxVRnLtkan+pittYOLnkzn9lCYmxNe usbcBn0SlCNTfk9pKbYStVJDBstVK3lV8BEYUZh0HlhcroDSUb9klxO5DCyPLMU76WZxKK PNyJXDh+azbWqA3vg2YzLk9rzWWjmBLgk8fuu13RWfDNAuUAoyMY1xtL9vM8A7SRG7Rweu q5thZLHhNOPqPTV1W2lnyDDjT3GU4yYzVvE2AJQlOByxys566VWN41v7OzZggg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D263062 Bug ID: 263062 Summary: tcp_inpcb leaking in VM environment Product: Base System Version: 13.1-STABLE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: eugene@zhegan.in I'm running 13.0-RELEASE or 13.1-RC1 in a virtual machine attached to the o= uter world via vtnet(4) driver. VM presumably is ran as Q35 chipset VM , definit= ely under KVM/QEMU in Hetzner cloud datacenter. VM is used as a web-server, proxying wss/grpc application via nginx with relatively long-living connections. VM has 16 Gigs of memory and is running GENERIC kernel. Nginx is servicing around 30-40K of established connections. After 2-3 hours of uptime VM is starting to show several signs of kernel structure leakage: I can see multiple dmesg errors: sonewconn: pcb 0xfffff8001ac8bd90: pru_attach() failed sonewconn: pcb 0xfffff8000ab625d0: pru_attach() failed sonewconn: pcb 0xfffff8000af999b0: pru_attach() failed sonewconn: pcb 0xfffff8000ab621f0: pru_attach() failed sonewconn: pcb 0xfffff8000ab62000: pru_attach() failed sonewconn: pcb 0xfffff8000ab625d0: pru_attach() failed sonewconn: pcb 0xfffff8000af999b0: pru_attach() failed sonewconn: pcb 0xfffff8000af999b0: pru_attach() failed sonewconn: pcb 0xfffff8000af993e0: pru_attach() failed sonewconn: pcb 0xfffff8000af999b0: pru_attach() failed sonewconn: pcb 0xfffff8000ab627c0: pru_attach() failed console is spamming errors:=20 [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached [zone: tcp_inpcb] kern.ipc.maxsockets limit reached and the network stack is basically unusable: # telnet 127.0.0.1 4080 Trying 127.0.0.1... telnet: socket: No buffer space available=20 This is definitely caused by leaking tcp_inpcb. It's count is progressing o= ver time and is never constantly diminished: (these are taken with 10 seconds interval) ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 802462, 1194, 1050344, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 803971, 1469, 1051853, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 805375, 1081, 1053257, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 806936, 1296, 1054818, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 808609, 1143, 1056491, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 810052, 1228, 1057934, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 811487, 809, 1059369, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 813068, 1260, 1060950, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 814532, 1068, 1062414, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 816036, 1084, 1063918, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 817511, 1641, 1065393, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 818988, 924, 1066870, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 820412, 1532, 1068294, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 821880, 832, 1069762, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 823399, 1345, 1071281, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 824865, 895, 1072747, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 826309, 1227, 1074191, 0, 0, = 0 ITEM SIZE LIMIT USED FREE REQ FAILSLEEP XDOMAIN tcp_inpcb: 496, 4189440, 827594, 958, 1075476, 0, 0, = 0 In the same time the kern.ipc.numopensockets is relatively low: kern.ipc.numopensockets: 34689 I also have several 12.x and 13.x running the same stack on baremetal; but = with bigger amount of RAM: 96-128 Gigs. This never happens on these. One can say that the reason is the amount of RAM, and this may seem reasonable. However: - baremetal servers serve way more connections, for instance I have the baremetal 13.0 server serving around 300K of connections: TCP connection count by state: 4 connections in CLOSED state 65 connections in LISTEN state 31 connections in SYN_SENT state 446 connections in SYN_RCVD state 292378 connections in ESTABLISHED state 5 connections in CLOSE_WAIT state 27467 connections in FIN_WAIT_1 state 266 connections in CLOSING state 6714 connections in LAST_ACK state 5114 connections in FIN_WAIT_2 state 40976 connections in TIME_WAIT state the number of ipc sockets is also way bigger: kern.ipc.numopensockets: 332907 But the tcp_inpcb is way lower: ITEM SIZE LIMIT USED FREE REQ FAIL SLEEP tcp_inpcb: 488, 4189440, 374628, 181772,27330286910, 0, 0 So I assume this leakage is specific to the situation when FreeBSD runs in a virtual environment, and is probably caused by the virtio drivers. As a workaround I have tried to tweak some of the sysctl oids: kern.maxfiles=3D4189440 kern.ipc.maxsockets=3D4189440 net.inet.tcp.tcbhashsize=3D1048576 but this measure only delayed the tcp_inpcb exhaustion. --=20 You are receiving this mail because: You are the assignee for the bug.=