From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E57ADC433DB for ; Fri, 5 Mar 2021 21:53:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4A9E6650A8 for ; Fri, 5 Mar 2021 21:53:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4A9E6650A8 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIINc-0000UO-7w for qemu-devel@archiver.kernel.org; Fri, 05 Mar 2021 16:53:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIIMg-0008Ri-9E for qemu-devel@nongnu.org; Fri, 05 Mar 2021 16:52:06 -0500 Received: from mail-vs1-xe32.google.com ([2607:f8b0:4864:20::e32]:46704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lIIMe-0003aM-7m for qemu-devel@nongnu.org; Fri, 05 Mar 2021 16:52:05 -0500 Received: by mail-vs1-xe32.google.com with SMTP id p24so1731302vsj.13 for ; Fri, 05 Mar 2021 13:52:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HmmEsGzH2HFVqFZK3mrhn3Opfk9dthLeJa8b9LgsjNw=; b=JIudGWHJjg0tSMZz/zyzfVbbwhl8v1UAvSkUqz/vA5rI6zIlgAfIbQlgpyPfWWTZOb UQuyZ+pdFhrind9/jkHYyLfjqmXlCoBpiMQpbPUkYS/V/qFkUAwMFXc2ZXFq3Z4Aar4N dz5E9XS5zf8RYFIrqs676TjUjHoOO5bnUMHF4+gqdzYtPtX6eil2UzOpsT85c7SZZITS ITwyqaT4JtKhtac/bZIZFuiRstSIOotIPlc69qkOuWSZCy6l3hc740aU4OcdYHj/xvRO Lu/b6AffhtY105Q4Y2olMW3xviubD/glq2XKXYItC/G8qhaOViEtdeyFU+lGqyg2uHr6 5y1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HmmEsGzH2HFVqFZK3mrhn3Opfk9dthLeJa8b9LgsjNw=; b=Kqbq4N596uxQK8k06OB6Pn/npJSc6czC7pxngunFq0Rr9E6OUUDpsxVfipzUvlCuJP xLzb0Z87Vn261wtaSurEFv5smPtsrWc6/TKaVwu+kRS5j2QCCDP+LAKuRpOHesVzMlcZ ZQtA1IP6pOBt9M1zVH6SYClcnBghu3u29gbpd0umYThhRLYc2s9tZA+ghD+GRCf/KA+x pYo+dQXflZXD4XMekHeBXQBtd2WDdnK8VDc5jLf9RTedhWtlgF7JhguHTOkd5mPWWgfz fk3mqejHH+EM7M75GyZjWWq4M6G64ScORTuoDSdBiIzSFtu4dn7LFiwR3pKUE89DVmlp QPGw== X-Gm-Message-State: AOAM530PGZbU1Y6ebFWvF+VhMB4ubHZ24vDa0quEDfIrY9euXYbTaGcP NkAt6lz2gOmhkwZDprdGJho/Sa3sYXekR9vtAKXBTA== X-Google-Smtp-Source: ABdhPJylzZ/e0bSaRgUNmGRucaglJZC4542rDPYH9JwXKZDCQZDWBTF+tklyZij+070rS4HWSBDwhZ1QWvufffva3X4= X-Received: by 2002:a05:6102:b11:: with SMTP id b17mr7986316vst.43.1614981122656; Fri, 05 Mar 2021 13:52:02 -0800 (PST) MIME-Version: 1.0 References: <20210228213957.xkc4cceh5o6rgd5n@begin> <20210305212806.kx62ycfr7k4wxdlq@begin> In-Reply-To: <20210305212806.kx62ycfr7k4wxdlq@begin> From: Doug Evans Date: Fri, 5 Mar 2021 13:51:25 -0800 Message-ID: Subject: Re: [PATCH v4 2/4] util/qemu-sockets.c: Split host:port parsing out of inet_parse To: Samuel Thibault Cc: =?UTF-8?Q?Daniel_P=2E_Berrang=C3=A9?= , Markus Armbruster , QEMU Developers , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Content-Type: multipart/alternative; boundary="0000000000002327e505bcd11889" Received-SPF: pass client-ip=2607:f8b0:4864:20::e32; envelope-from=dje@google.com; helo=mail-vs1-xe32.google.com X-Spam_score_int: -175 X-Spam_score: -17.6 X-Spam_bar: ----------------- X-Spam_report: (-17.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000002327e505bcd11889 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 5, 2021 at 1:28 PM Samuel Thibault wrote: > Daniel P. Berrang=C3=A9, le mer. 03 mars 2021 18:11:41 +0000, a ecrit: > > On Wed, Mar 03, 2021 at 10:06:50AM -0800, Doug Evans wrote: > > > On Sun, Feb 28, 2021 at 1:40 PM Samuel Thibault < > samuel.thibault@gnu.org> > > > wrote: > > > > > > > > + Examples: > > > > > + hostfwd_add net0 tcp:127.0.0.1:10022-:22 > > > > > + hostfwd_add net0 tcp:[::1]:10022-[fe80::1:2:3:4]:22 > > > > > > > > Yep, that looks good to me. > > > > > > Daniel, you wanted me to use inet_parse(). > > > Is the above syntax ok with you? > > > You must have had some expectation that at least some of > > > the various flags that inet_parse() recognizes would be needed here. > > > > It feels like the ,ipv4=3Don|off,ipv6=3Don|off flags are relevant here, > > especially in the empty address case. eg > > > > tcp::10022 - attempt to listen on both ipv4 + ipv6 > > tcp::10022,ipv4=3Doff - listen on default address, but only for ipv6 > > tcp::10022,ipv6=3Doff - listen on default address, but only for ipv4 > > > > Basically this ends up bringing the hostfwd stuff into alignment with > > the way other backends deal with this > > I'm fine with this yes, better have a coherent user interface. > Cool. Here's the current help text I have: ---snip--- #ifdef CONFIG_SLIRP { .name =3D "hostfwd_add", .args_type =3D "arg1:s,arg2:s?", .params =3D "[netdev_id] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport", .help =3D "redirect TCP or UDP connections from host to guest (requires -net user)", .cmd =3D hmp_hostfwd_add, }, #endif SRST ``hostfwd_add`` Redirect TCP or UDP connections from host to guest (requires -net user). IPv6 addresses are wrapped in square brackets, IPv4 addresses are not. Examples: hostfwd_add net0 tcp:127.0.0.1:10022-:22 hostfwd_add net0 tcp:[::1]:10022-[fe80::1:2:3:4]:22 Empty host addresses: An empty address for the host, expressed as either "" or "[]", is interpreted as listen at any address for both IPv4 and IPv6. To listen on only IPv4 one can use "0.0.0.0". The equivalent IPv6 address, "[::]", is interpreted as listen on both IPv4 and IPv6 addresses. To listen on only IPv6 addresses, add ",ipv4=3Doff" to the address. E.g., hostfwd_add net0 tcp::10022,ipv4=3Doff-[fe80::1:2:3:4]:22 hostfwd_add net0 tcp:[]:10022,ipv4=3Doff-[fe80::1:2:3:4]:22 hostfwd_add net0 tcp:[::]:10022,ipv4=3Doff-[fe80::1:2:3:4]:22 And similarly for IPv4 only: hostfwd_add net0 tcp::10022,ipv6=3Doff-[fe80::1:2:3:4]:22 hostfwd_add net0 tcp:[]:10022,ipv6=3Doff-[fe80::1:2:3:4]:22 Empty guest addresses: An empty guest address for IPv4 is translated to the guest's address, assuming that the guest is using DHCP to acquire its address. Note that Libslirp currently only provides a "stateless" DHCPv6 server, a consequence of which is that it cannot do the "addr-any" translation to the guest address that is done for IPv4. In other words, the following is currently not supported: hostfwd_add net0 tcp::10022-:22, the guest address is required. ERST ---snip--- Any corrections or suggestions? --0000000000002327e505bcd11889 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Mar 5, 2021 at 1:28 PM Samuel Thibault <samuel.thibault@gnu.org> wrote:
=
Daniel P. Berrang=C3=A9, le mer. 03 mars 2021 18:11:41 +0000,= a ecrit:
> On Wed, Mar 03, 2021 at 10:06:50AM -0800, Doug Evans wrote:
> > On Sun, Feb 28, 2021 at 1:40 PM Samuel Thibault <samuel.thibault@gnu.org= >
> > wrote:
> >
> > > > +=C2=A0 Examples:
> > > > +=C2=A0 hostfwd_add net0 tcp:127.0.0.1:10022-:22
> > > > +=C2=A0 hostfwd_add net0 tcp:[::1]:10022-[fe80::1:2:3:4= ]:22
> > >
> > > Yep, that looks good to me.
> >
> > Daniel, you wanted me to use inet_parse().
> > Is the above syntax ok with you?
> > You must have had some expectation that at least some of
> > the various flags that inet_parse() recognizes would be needed he= re.
>
> It feels like the ,ipv4=3Don|off,ipv6=3Don|off flags are relevant here= ,
> especially in the empty address case. eg
>
>=C2=A0 =C2=A0 tcp::10022=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 - attempt to= listen on both ipv4 + ipv6
>=C2=A0 =C2=A0 tcp::10022,ipv4=3Doff - listen on default address, but on= ly for ipv6
>=C2=A0 =C2=A0 tcp::10022,ipv6=3Doff - listen on default address, but on= ly for ipv4
>
> Basically this ends up bringing the hostfwd stuff into alignment with<= br> > the way other backends deal with this

I'm fine with this yes, better have a coherent user interface.

Cool. Here&= #39;s the current help text I have:

---snip---
#ifdef CONFIG_SLIRP
=C2=A0 =C2=A0 {
=C2=A0= =C2=A0 =C2=A0 =C2=A0 .name =C2=A0 =C2=A0 =C2=A0 =3D "hostfwd_add"= ;,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .args_type =C2=A0=3D "arg1:s,arg2:s?= ",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 .params =C2=A0 =C2=A0 =3D "[net= dev_id] [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport",
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 .help =C2=A0 =C2=A0 =C2=A0 =3D "redirect TCP = or UDP connections from host to guest (requires -net user)",
=C2=A0= =C2=A0 =C2=A0 =C2=A0 .cmd =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D hmp_hostfwd_add,<= br>=C2=A0 =C2=A0 },
#endif
SRST
``hostfwd_add``
=C2=A0 Redirect= TCP or UDP connections from host to guest (requires -net user).
=C2=A0 = IPv6 addresses are wrapped in square brackets, IPv4 addresses are not.

=C2=A0 Ex= amples:
=C2=A0 hostfwd_add net0 tcp:127.0.0.1:10022-:22
=C2=A0 hostfw= d_add net0 tcp:[::1]:10022-[fe80::1:2:3:4]:22

=C2=A0 Empty host addr= esses:
=C2=A0 An empty address for the host, expressed as either "&= quot; or "[]", is
=C2=A0 interpreted as listen at any address = for both IPv4 and IPv6. To listen on
=C2=A0 only IPv4 one can use "= 0.0.0.0". The equivalent IPv6 address, "[::]", is
=C2=A0 = interpreted as listen on both IPv4 and IPv6 addresses. To listen on only=C2=A0 IPv6 addresses, add ",ipv4=3Doff" to the address. E.g.,=C2=A0 hostfwd_add net0 tcp::10022,ipv4=3Doff-[fe80::1:2:3:4]:22
=C2= =A0 hostfwd_add net0 tcp:[]:10022,ipv4=3Doff-[fe80::1:2:3:4]:22
=C2=A0 h= ostfwd_add net0 tcp:[::]:10022,ipv4=3Doff-[fe80::1:2:3:4]:22
=C2=A0 And = similarly for IPv4 only:
=C2=A0 hostfwd_add net0 tcp::10022,ipv6=3Doff-[= fe80::1:2:3:4]:22
=C2=A0 hostfwd_add net0 tcp:[]:10022,ipv6=3Doff-[fe80:= :1:2:3:4]:22

=C2=A0 Empty guest addresses:
=C2=A0 An empty guest = address for IPv4 is translated to the guest's address,
=C2=A0 assumi= ng that the guest is using DHCP to acquire its address.
=C2=A0 Note that= Libslirp currently only provides a "stateless" DHCPv6 server, a<= br>=C2=A0 consequence of which is that it cannot do the "addr-any"= ; translation to the
=C2=A0 guest address that is done for IPv4. In othe= r words, the following is
=C2=A0 currently not supported: hostfwd_add ne= t0 tcp::10022-:22, the guest
=C2=A0 address is required.
ERST
---snip---

Any corrections or suggestions?
<= /div>
--0000000000002327e505bcd11889--