Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754489AbdHYDTv (ORCPT ); Thu, 24 Aug 2017 23:19:51 -0400 Received: from mail-pu1apc01on0108.outbound.protection.outlook.com ([104.47.126.108]:48800 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754248AbdHYDTt (ORCPT ); Thu, 24 Aug 2017 23:19:49 -0400 From: Dexuan Cui To: David Miller CC: "jhansen@vmware.com" , "stefanha@redhat.com" , "netdev@vger.kernel.org" , "mkubecek@suse.cz" , "joe@perches.com" , "olaf@aepfle.de" , Stephen Hemminger , "jasowang@redhat.com" , "KY Srinivasan" , Haiyang Zhang , "dave.scott@docker.com" , "linux-kernel@vger.kernel.org" , "apw@canonical.com" , "rolf.neugebauer@docker.com" , "gregkh@linuxfoundation.org" , "marcelo.cerri@canonical.com" , "devel@linuxdriverproject.org" , "vkuznets@redhat.com" , "georgezhang@vmware.com" , "dan.carpenter@oracle.com" , "acking@vmware.com" , "dtor@vmware.com" , "grantr@vmware.com" , "cavery@redhat.com" Subject: RE: [PATCH v2 net-next 1/1] hv_sock: implements Hyper-V transport for Virtual Sockets (AF_VSOCK) Thread-Topic: [PATCH v2 net-next 1/1] hv_sock: implements Hyper-V transport for Virtual Sockets (AF_VSOCK) Thread-Index: AdMbyrj6MaAmPGUxQ7CUdFpOZGF+LABdXryAAAB+ccA= Date: Fri, 25 Aug 2017 03:19:22 +0000 Message-ID: References: <20170824.181931.584865895464286033.davem@davemloft.net> In-Reply-To: <20170824.181931.584865895464286033.davem@davemloft.net> 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-24T20:19:20.5027642-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.0.112] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;KL1P15301MB0007;6:O9830tMJl/1ZMcOv6hzxBsIxTZkH8/VHMfNxoy+xBnwXn0Vy7dMf4FMRtJTFh0oxoblBOtao5iCIfa52H9fdINTu1iT2TbAmSo3jwNAMG4J7iqX7LSB1ctGbjafdTvhiogxCfBTOcEixtHlCnX5lIXqxW0V4TITsSgg8zu8WopCvPMd+DwDF8BP9We/rgLwqNLxI53FK+S6EZ9tg3ypIT6Z7M2auBScWPWPnvRn+7N7E3dDCd5I+3MwcMmRqFRPr/yd5hfv/QoZAGLSEUwXCmAqcWeZkCBgOK+XDXcWp47Ovwv93OGB8+4wbFIIUf40UQPUZz/CK6WYxHvnSIhRdpA==;5:CR1uLhobiglzbk544YtYTxiTJgESrGkMRWa+QlYyqpdq2A+1bWDyFfGYqRg+/oSpVGckCfCWcQUGAscsQXctLYLDn8O6lk6YveJitL3x5k3YxEC97I3esLvzdGtZAkbkogJHqF3zgw9cX900DBDhzg==;24:muAVYUrV/a6b4A23FhhG0zbuGZDsGEnLn8MEeSrYRE7ukkxh6yipAY9ukpXYOGsP+gF4gyx569IEHrU05wVCtfjCqlvcFNrfXX+p90fiEt4=;7:SioUBYZ3hVluYEHXzPg1cOK1ZmC32KuaLyocU5rjDgNQtTuFY2QCgs3m+bfyBzsesRXlQe/nqdEAsk0XgvOd5FDXDd8t/2u1I191cD2X4O8M2vwcZA896tPnf7kHEeVn8AZfaVDinShCq0gDhG3Xb1CohNh9zZ9yV4M+gZdTGncyECda0peVrwdN5+ctmgbOYlcSWtx8Uoc0hobe+JYGfZvoXjmFOtTr5qWp4O7lwlE= x-ms-office365-filtering-correlation-id: 06029e48-b6a5-4315-3e3d-08d4eb681566 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:KL1P15301MB0007; x-ms-traffictypediagnostic: KL1P15301MB0007: x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(61425038)(6040450)(2401047)(5005006)(8121501046)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6055026)(61426038)(61427038)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:KL1P15301MB0007;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:KL1P15301MB0007; x-forefront-prvs: 041032FF37 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(47760400005)(199003)(189002)(33656002)(229853002)(105586002)(97736004)(101416001)(6436002)(77096006)(305945005)(106356001)(7736002)(6506006)(54906002)(478600001)(55016002)(189998001)(53936002)(8990500004)(10290500003)(25786009)(9686003)(3660700001)(3280700002)(110136004)(2906002)(6246003)(4326008)(5005710100001)(6916009)(7696004)(2950100002)(81166006)(8936002)(68736007)(81156014)(10090500001)(8676002)(54356999)(74316002)(3846002)(102836003)(6116002)(5660300001)(2900100001)(7416002)(14454004)(66066001)(86362001)(76176999)(50986999)(86612001);DIR:OUT;SFP:1102;SCL:1;SRVR:KL1P15301MB0007;H:KL1P15301MB0008.APCP153.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX: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: 25 Aug 2017 03:19:22.5934 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1P15301MB0007 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 v7P3JvWR024530 Content-Length: 1783 Lines: 59 > From: David Miller [mailto:davem@davemloft.net] > Sent: Thursday, August 24, 2017 18:20 > > +#define VMBUS_PKT_TRAILER (sizeof(u64)) > > This is not the packet trailer, it's the size of the packet trailer. Thanks! I'll change it to VMBUS_PKT_TRAILER_SIZE. > > + /* Have we sent the zero-length packet (FIN)? */ > > + unsigned long fin_sent; > > Why does this need to be atomic? Why can't a smaller simpler It doesn't have to be. It was originally made for a quick workaround. Thanks! I should do it in the right way now. > mechanism be used to make sure hvs_shutdown() only performs > hvs_send_data() call once on the channel? I'll change "fin_sent" to bool, and avoid test_and_set_bit(). I'll add lock_sock/release_sock() in hvs_shutdown() like this: static int hvs_shutdown(struct vsock_sock *vsk, int mode) { ... lock_sock(sk); hvs = vsk->trans; if (hvs->fin_sent) goto out; send_buf = (struct hvs_send_buf *)&hdr; (void)hvs_send_data(hvs->chan, send_buf, 0); hvs->fin_sent = true; out: release_sock(sk); return 0; } > > +static inline bool is_valid_srv_id(const uuid_le *id) > > +{ > > + return !memcmp(&id->b[4], &srv_id_template.b[4], sizeof(uuid_le) - > 4); > > +} > > Do not use the inline function attribute in *.c code. Let the > compiler decide. OK. Will remove all the inline usages. > > + *((u32 *)&h->vm_srv_id) = vsk->local_addr.svm_port; > > + *((u32 *)&h->host_srv_id) = vsk->remote_addr.svm_port; > > There has to be a better way to express this. I may need to define a uinon here. Let me try it. > And if this is partially initializing vm_srv_id, at a minimum > endianness needs to be taken into account. I may need to use cpu_to_le32(). Let me check it.