From nobody Sun May 5 20:50:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148805842905217.698531133782012; Sat, 25 Feb 2017 13:33:49 -0800 (PST) Received: from localhost ([::1]:44316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chjyN-0001lp-4Y for importer@patchew.org; Sat, 25 Feb 2017 16:33:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chjwv-00019t-Ag for qemu-devel@nongnu.org; Sat, 25 Feb 2017 16:32:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chjwq-0001Pl-Tl for qemu-devel@nongnu.org; Sat, 25 Feb 2017 16:32:16 -0500 Received: from bart.luffy.cx ([78.47.78.131]:41932) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1chjwq-0001Mf-GT for qemu-devel@nongnu.org; Sat, 25 Feb 2017 16:32:12 -0500 Received: from bart.luffy.cx (localhost [127.0.0.1]) by bart.luffy.cx (Postfix) with ESMTP id 7B58115243; Sat, 25 Feb 2017 22:32:09 +0100 (CET) Received: from neo.luffy.cx (102.116.105.92.dynamic.wline.res.cust.swisscom.ch [92.105.116.102]) by bart.luffy.cx (Postfix) with ESMTPS id 5823715139; Sat, 25 Feb 2017 22:32:09 +0100 (CET) Received: by neo.luffy.cx (Postfix, from userid 500) id 05AF15C3; Sat, 25 Feb 2017 22:32:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bernat.im; h=from:to:cc :subject:date:message-id; s=postfix; bh=8ma76bl8LcWDYooMdHBTqySh HQQ=; b=Pc/IU5EaipfybVtNKEC+PFFauKOFhb5IUAJJ2q3U3iRuzfnlm454hO0v 9xFg7m9LVX4UE/ZI9RlzDShA967LTCpzyLXS4g3SruJwB/NLWOwk0Jil+jpEriBZ NfcHgeWen4JBOhZo2FlVqw8154+ZUC/CZNjCx6Si+IBshMllmG8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bernat.im; h=from:to:cc :subject:date:message-id; q=dns; s=postfix; b=pSFfn+XmcMb7czXtHF VzMC+dw8iFbnEP9WSlMBxwJhN9CndsW/heTk9KzMxQMFxJjFOlG6ovrpfloDF3cW iK2wwhEXHCg2dp/YBqRJhGZF9yADFvIPMgQfj0XCNTjgb6qCzv+1p14+lO0l8PNp NECWRx+A5g9xF4OUhCekjx8fY= From: Vincent Bernat To: qemu-devel@nongnu.org Date: Sat, 25 Feb 2017 22:31:58 +0100 Message-Id: <20170225213158.32452-1-vincent@bernat.im> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 78.47.78.131 Subject: [Qemu-devel] [PATCH] slirp: allow host port 0 for hostfwd X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Bernat Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The OS will allocate automatically a free port. This is useful if you want to be sure to not get any port conflict. You still have to figure out which port you got, for example with "lsof" (this could be exposed in the monitor if needed). Example of use: $ qemu-system-x86_64 -net user,hostfwd=3D127.0.0.1:0-:22 ... Then, get your port with: $ lsof -np 1474 | grep LISTEN qemu-syst 31777 bernat 12u IPv4 [...] TCP 127.0.0.1:35145 (LISTEN) Signed-off-by: Vincent Bernat --- net/slirp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/slirp.c b/net/slirp.c index f97ec233454e..11b2dd249a79 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -487,7 +487,7 @@ static int slirp_hostfwd(SlirpState *s, const char *red= ir_str, goto fail_syntax; } host_port =3D strtol(buf, &end, 0); - if (*end !=3D '\0' || host_port < 1 || host_port > 65535) { + if (*end !=3D '\0' || host_port < 0 || host_port > 65535) { goto fail_syntax; } =20 --=20 2.11.0