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 EE04CC433E9 for ; Fri, 5 Mar 2021 22:22:40 +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 5631B650A8 for ; Fri, 5 Mar 2021 22:22:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5631B650A8 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]:59386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIIqE-0007AC-8p for qemu-devel@archiver.kernel.org; Fri, 05 Mar 2021 17:22:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45856) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIIpb-0006kS-E0 for qemu-devel@nongnu.org; Fri, 05 Mar 2021 17:21:59 -0500 Received: from mail-ua1-x92c.google.com ([2607:f8b0:4864:20::92c]:38127) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lIIpV-0008Pb-Dv for qemu-devel@nongnu.org; Fri, 05 Mar 2021 17:21:59 -0500 Received: by mail-ua1-x92c.google.com with SMTP id y35so1289194uad.5 for ; Fri, 05 Mar 2021 14:21:52 -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=zPe8lu2TZMlPxhIcgYxZxZ8wKfaB/yTv7p4P5ajzQF8=; b=OXoBWFpglM/KwYIKgNG1G9TSikOSREMlcCLRxjtOeMK82I5iRcR1b6qjUPeD4gHt2l xSd0BpMU0MDYxNH3W1ulyrie75e5KoW8KXsEIhFwWonSM2nspwc/Az2+qSbdKvxhsavJ 8CkV2/Hl//L0gDZvGyth7pe+XSFy8tBl4TGFxTrgWi8Wo9i9qCSgvp90xA50Ss/cWRJf q4zNEEunGuqSZXccYYYchrt2fEhs6I6U+sun5aXqUjErpuVP+YyLQSfJ7FWSrQ8k6Kyv ChpYoU/AoPMh5sGIwvX2qtXqbhO6DojA7QGiXwmydc5ZHAXyHloFTqoEkvSrsK5lIp0Q 94Vg== 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=zPe8lu2TZMlPxhIcgYxZxZ8wKfaB/yTv7p4P5ajzQF8=; b=uBBogenbkGbv19YK04ZTUXJLvaghfEZM/arrllxk1oDQ9y+oq5W0Y97OaqCZL8NRXC 36oYv29Z9jqxeGe4IsLjkoP1JY1SghGKgiOw0QrT0W1kWMRSWLc8ymxxuuvmakUx+lmh 8fgakKUK3eiSwNz3UMo9EPcvUoy+a5FMzGsj/1E5amimHLjmTAc18TU3NT8tdi8XkH3p V1VJcJX2i+Hz3fuQypleQf+x341a2M2p6IMZvEF9GVJ4TpCqc6Ei4NQvyeh9jzuAb0Ji lVAwfoOQrWpqVWVo8tDom922livnsHvvF3Zp1/DvgkDxWEfdvNniWtqoYA2XV6sHzA52 3akg== X-Gm-Message-State: AOAM532tpblawWxLq4NiPtns3/ELl/Z0YBP/BbgzWI2ONh7DGXzGAwQN ZS3fDtd2vCfF8F3OzdMRdjZRI6Wwib5PmWXH3Op4jQ== X-Google-Smtp-Source: ABdhPJwt8xJOEYx6DMCPxTJTZ0WIRsnOxU3vuLcrKQRfLHxyZH111dsgJtCuqTDTGDpPAit9SEAJj3p9X4px8xpBHfM= X-Received: by 2002:ab0:48c2:: with SMTP id y2mr8088655uac.22.1614982911166; Fri, 05 Mar 2021 14:21:51 -0800 (PST) MIME-Version: 1.0 References: <20210228213957.xkc4cceh5o6rgd5n@begin> <20210305212806.kx62ycfr7k4wxdlq@begin> In-Reply-To: From: Doug Evans Date: Fri, 5 Mar 2021 14:21:13 -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="000000000000bd8bff05bcd182af" Received-SPF: pass client-ip=2607:f8b0:4864:20::92c; envelope-from=dje@google.com; helo=mail-ua1-x92c.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=unavailable 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" --000000000000bd8bff05bcd182af Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Mar 5, 2021 at 1:51 PM Doug Evans wrote: > 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 ipv= 6 >> > tcp::10022,ipv6=3Doff - listen on default address, but only for ipv= 4 >> > >> > 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 gue= st > (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, "[::]", i= s > interpreted as listen on both IPv4 and IPv6 addresses. To listen on onl= y > 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? > For those following along, there are problems with the above help text (e.g., it's wrong to say "tcp::10022-:22" is not supported, because it obviously is! - the issue is more nuanced than that). And I'm sure there are more that I have yet to find. I'll give reviewers some time to comment on what's there now before sending an updated proposed text. --000000000000bd8bff05bcd182af Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Mar 5, 2021 at 1:51 PM Doug Evans <dje@google.com> wrote:
On Fri, Mar 5, 202= 1 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'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 "[netdev_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,
=C2=A0 =C2=A0 }= ,
#endif
SRST
``hostfwd_add``
=C2=A0 Redirect TCP or UDP connec= tions from host to guest (requires -net user).
=C2=A0 IPv6 addresses are= wrapped in square brackets, IPv4 addresses are not.

=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

=C2=A0 Empty host addresses:
=C2=A0 A= n empty address for the host, expressed as either "" or "[]&= quot;, 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 lis= ten on both IPv4 and IPv6 addresses. To listen on only
=C2=A0 IPv6 addre= sses, add ",ipv4=3Doff" to the address. E.g.,
=C2=A0 hostfwd_a= dd 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 hostfwd_add net0 tcp:= [::]:10022,ipv4=3Doff-[fe80::1:2:3:4]:22
=C2=A0 And similarly for IPv4 o= nly:
=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 assuming that the guest is= using DHCP to acquire its address.
=C2=A0 Note that Libslirp currently = only provides a "stateless" DHCPv6 server, a
=C2=A0 consequenc= e of which is that it cannot do the "addr-any" translation to the=
=C2=A0 guest address that is done for IPv4. In other words, the followi= ng is
=C2=A0 currently not supported: hostfwd_add net0 tcp::10022-:22, t= he guest
=C2=A0 address is required.
ERST
---snip---

Any corrections or suggestions?


For those following along, there are problems with the ab= ove help text
(= e.g., it's wrong to say "tcp::10022-:22" is not supported, be= cause it
obviou= sly is! - the issue is more nuanced than that).
And I'm sure there are more that I hav= e yet to find.
= I'll give reviewers some time to comment on what's there now
<= div class=3D"gmail_default" style=3D"font-size:small">before sending an upd= ated proposed text.
--000000000000bd8bff05bcd182af--