Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172AbdHRWYW (ORCPT ); Fri, 18 Aug 2017 18:24:22 -0400 Received: from mail-pu1apc01on0131.outbound.protection.outlook.com ([104.47.126.131]:20448 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750969AbdHRWYR (ORCPT ); Fri, 18 Aug 2017 18:24:17 -0400 From: Dexuan Cui To: Stefan Hajnoczi CC: "davem@davemloft.net" , "netdev@vger.kernel.org" , "devel@linuxdriverproject.org" , KY Srinivasan , "Haiyang Zhang" , Stephen Hemminger , George Zhang , Jorgen Hansen , Michal Kubecek , Vitaly Kuznetsov , Cathy Avery , "jasowang@redhat.com" , Rolf Neugebauer , Dave Scott , Marcelo Cerri , "apw@canonical.com" , "olaf@aepfle.de" , "joe@perches.com" , "linux-kernel@vger.kernel.org" , Dan Carpenter Subject: RE: [PATCH net-next 3/3] hv_sock: implements Hyper-V transport for Virtual Sockets (AF_VSOCK) Thread-Topic: [PATCH net-next 3/3] hv_sock: implements Hyper-V transport for Virtual Sockets (AF_VSOCK) Thread-Index: AdMWFGQ8Y3X/Q87vRRyut4fx304pkwBVIa6AAEEmG8A= Date: Fri, 18 Aug 2017 22:23:54 +0000 Message-ID: References: <20170817145551.GI5539@stefanha-x1.localdomain> In-Reply-To: <20170817145551.GI5539@stefanha-x1.localdomain> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Ref=https://api.informationprotection.azure.com/api/72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=decui@microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2017-08-18T15:23:52.5803834-07:00; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic; Sensitivity=General authentication-results: spf=none (sender IP is ) smtp.mailfrom=decui@microsoft.com; x-originating-ip: [167.220.1.87] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;KL1P15301MB0053;6:whec0ciTDBE2WPP2t3iVirX0rVb+Wz6Tfvgp7tNjxOEhhLG9OUnFmiDppe9hn5b6oKm1p1KrdmUqzcLRsPp9wUHgAOxLxZgbt4qf9NtpKK48hGwVnxVZiiJpw8TNLyoRYnpkZIzWd4WNKwAYuj5fepJ1lrscDxRdfQcRS22GAQAAto1IYBq/v61ieYdjwdLRDrzYbJsY3MA6EGFpadByW6eQzG18epZS0l6Gh7HstgDUK1Uv3eU3YzOp5eIJj5v235XHNloNOMPeJ8hgfug8AJsCvQO7M2xQHfvlV+zEoOKN0MpQtz5NGF14+9z7ueNSkXIJbBIbNKjLS2IFp7tftA==;5:s7jVH0/ooatnps6bDuRjUKTbT62j2cJ+3Jkx12Gg74HcIea/A+XYco3Hxu+5czmodFE7ieW3msJbFIGqUNZt8A7eXPJNR4NeZqK4wJlS2CcFSUT27QNB7wT1ftyv0EZDUR2LxDaOibHTrxo84p/6tQ==;24:w3GPIH3mW30+qkx92D4GpX1FJgLDnsAVllFjoSZwWMdf+Zg7iuVZUygDxcQ0ZCUcrp2ozJ6Pco2XBeBhB7x/HgYTf4kT7J7GTUbf8pDUpc4=;7:lSD5+wDpvJ/DH0prMsfgpa592pHH47DsyJH0R6jxWWJi/L9hFi/NieQZI5mOfR7Tqv01+6eKS00Wrxp6UiLSS6quu9HArl6zZXnEKzVgRv75O8vElvJa3q8MqKZB2QdfSzPHP8S5DHxRksDsKKFpoOE3gAhukrlnKr0cOHDwj/3+TIaLr6GCFy6frwDFjfki/KcBqz8NCbZeQ8YyJGRsh0ResVcXpG5e6Eu4+zsxo3I= x-ms-office365-filtering-correlation-id: 1ea7e00b-874e-4a85-606b-08d4e687d010 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:KL1P15301MB0053; x-ms-traffictypediagnostic: KL1P15301MB0053: x-exchange-antispam-report-test: UriScan:(89211679590171)(21532816269658); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(61426038)(61427038)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1P15301MB0053;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1P15301MB0053; x-forefront-prvs: 040359335D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(47760400005)(189002)(199003)(24454002)(55016002)(9686003)(478600001)(54906002)(189998001)(77096006)(7416002)(6506006)(101416001)(68736007)(53936002)(229853002)(74316002)(25786009)(7696004)(110136004)(6246003)(6436002)(106356001)(5660300001)(105586002)(2900100001)(10290500003)(66066001)(86362001)(53546010)(4326008)(8676002)(8990500004)(33656002)(5005710100001)(3846002)(102836003)(86612001)(10090500001)(3280700002)(2950100002)(97736004)(14454004)(76176999)(54356999)(6916009)(6116002)(81166006)(81156014)(2906002)(50986999)(8936002)(7736002)(3660700001)(305945005);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1P15301MB0053;H:KL1P15301MB0008.APCP153.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Aug 2017 22:23:54.5524 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0053 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7IMOTZK002033 Content-Length: 1860 Lines: 54 > From: Stefan Hajnoczi [mailto:stefanha@redhat.com] > Sent: Thursday, August 17, 2017 07:56 > To: Dexuan Cui > On Tue, Aug 15, 2017 at 10:18:41PM +0000, Dexuan Cui wrote: > > +static u32 hvs_get_local_cid(void) > > +{ > > + return VMADDR_CID_ANY; > > +} > > Interesting concept: the guest never knows its CID. This is nice from a > live migration perspective. Currently VMCI and virtio adjust listen > socket local CIDs after migration. > > > +static bool hvs_stream_allow(u32 cid, u32 port) > > +{ > > + static const u32 valid_cids[] = { > > + VMADDR_CID_ANY, > > Is this for loopback? No, we don't support lookback in Linux VM, at least for now. In our Linux implementation, Linux VM can only connect to the host, and here when Linux VM calls connect(), I treat VMADDR_CID_ANY the same as VMADDR_CID_HOST. > > + VMADDR_CID_HOST, > > + }; > > + int i; > > + > > + /* The host's port range [MIN_HOST_EPHEMERAL_PORT, 0xFFFFFFFF) > is > > + * reserved as ephemeral ports, which are used as the host's ports > > + * when the host initiates connections. > > + */ > > + if (port > MAX_HOST_LISTEN_PORT) > > + return false; > > Without this if statement the guest will attempt to connect. I guess > there will be no listen sockets above MAX_HOST_LISTEN_PORT, so the > connection attempt will fail. You're correct. To use the vsock common infrastructure, we have to map Hyper-V's GUID to int , and hence we must limit the port range we can listen() on to [0, MAX_LISTEN_PORT], i.e. we can only use half of the whole 32-bit port space for listen(). This is detailed in the long comments starting at about Line 100. > ...but hardcode this knowledge into the guest driver? I'd like the guest's connect() to fail immediately here. IMO this is better than a connect timeout. :-) Thanks, -- Dexuan