From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B658AA00C4; Fri, 29 Jul 2022 19:08:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5C5FA4069C; Fri, 29 Jul 2022 19:08:44 +0200 (CEST) Received: from office2.cesnet.cz (office2.cesnet.cz [195.113.144.244]) by mails.dpdk.org (Postfix) with ESMTP id 6CFFF40151 for ; Fri, 29 Jul 2022 19:08:42 +0200 (CEST) Received: from [IPV6:2a01:c846:1282:6700:b822:3860:b95f:29c6] (unknown [IPv6:2a01:c846:1282:6700:b822:3860:b95f:29c6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by office2.cesnet.cz (Postfix) with ESMTPSA id A3D3A40006E; Fri, 29 Jul 2022 19:08:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cesnet.cz; s=office2-2020; t=1659114522; bh=w8Q2hpHdDF7nOKUVAPoQ/t3f9GvTfS6nS5dI35IzCNo=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=GnDrdUKIqxnRI529siegYPAQLoESlR+7IVbQybve79/zj943EC8qWGjZQsjIt4sWn V6cds8uT6MWO+LNbgEAIdqCw+0Dg19mG+k8U+ISphfqGMgqgwBjQNV/gvIyS2f2otx nlmu8cuYbfbHpBfwQr81j8MHNuMu0N4XnYra6q+xZFJCadur6t4f/N322Mr1g85tEv JUXyK82Fe8+IPqYijBYs3vMoWDHO8kv1PkTZzX9e7BIRXi9btz8I8Uy98W7Ng9sUQ1 4wqBwsjpcpt8vx5XVJLqPAMn7ytsCqAv0sJwAK/SrlZCMzB2mfZqpY+fdXEiOHjRPK gicct/JfMV7QQ== Message-ID: Date: Fri, 29 Jul 2022 19:08:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 2/2] pcapng: check if writev() returns a partial write Content-Language: sk-SK To: Stephen Hemminger Cc: dev@dpdk.org, mdr@ashroe.eu, reshma.pattan@intel.com References: <20220725152811.409447-1-kuka@cesnet.cz> <20220729071841.18198-1-kuka@cesnet.cz> <20220729071841.18198-3-kuka@cesnet.cz> <20220729090028.25674943@hermes.local> From: =?UTF-8?Q?M=c3=a1rio_Kuka?= In-Reply-To: <20220729090028.25674943@hermes.local> Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="------------ms080905070102070802070800" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This is a cryptographically signed message in MIME format. --------------ms080905070102070802070800 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit > Since this is being written to a file, handling partial writes makes little > sense. The only case where partial write would happen would be if filesystem > was full. Retrying just adds unnecessary complexity. > > If you really want to track this, then add a dropped counter. But the file descriptor doesn't have to refer to just a regular file, what if it's a socket or a pipe or some device? The pcapng documentation doesn't say anything about any restrictions, so the implementation should be fully generic. What's the point of a function to write packets to a file descriptor where there's a risk that it won't write all the packets or that the file will by corrupted due to a partial write and still not even let me know about it? On 29/07/2022 18:00, Stephen Hemminger wrote: > On Fri, 29 Jul 2022 09:18:41 +0200 > Mário Kuka wrote: > >> +pcapng_writev(int fd, struct iovec *iov, const int count) >> +{ >> + size_t total = 0; >> + int at = 0; >> + >> + while (at < count) { >> + /* >> + * Note: writev() can return the following on a write request: >> + * Complete: >> + * written = [sum of all iov.iov_len] >> + * Partial: >> + * written < [sum of all iov.iov_len] >> + * Deferred: >> + * written = -1, errno = [EAGAIN] >> + * >> + * Partial and deferred writes are only possible with O_NONBLOCK set. >> + * >> + * If we get a partial result, we have to call the writev() again on any ivo buffers >> + * that have not been fully written. >> + */ >> + ssize_t written = writev(fd, &iov[at], count - at); >> + if (unlikely(written < 0)) >> + return written; >> + >> + total += written; >> + at += pcapng_update_iov(&iov[at], count - at, written); >> + } >> + >> + return total; > Since this is being written to a file, handling partial writes makes little > sense. The only case where partial write would happen would be if filesystem > was full. Retrying just adds unnecessary complexity. > > If you really want to track this, then add a dropped counter. --------------ms080905070102070802070800 Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwEAAKCC DU4wggZgMIIESKADAgECAhEAnTCbnaNwi54ahsTjQqFVbTANBgkqhkiG9w0BAQwFADBGMQsw CQYDVQQGEwJOTDEZMBcGA1UEChMQR0VBTlQgVmVyZW5pZ2luZzEcMBoGA1UEAxMTR0VBTlQg UGVyc29uYWwgQ0EgNDAeFw0yMTA0MjUwMDAwMDBaFw0yNDA0MjQyMzU5NTlaMIHbMQ8wDQYD VQQREwYxNjAgMDAxODA2BgNVBAoML0NFU05FVCwgesOham1vdsOpIHNkcnXFvmVuw60gcHLD oXZuaWNrw71jaCBvc29iMRYwFAYDVQQJEw0xOTAzLzQgWmlrb3ZhMR4wHAYDVQQIDBVQcmFo YSwgSGxhdm7DrSBtxJtzdG8xDjAMBgNVBAcTBVByYWhhMQswCQYDVQQGEwJDWjEUMBIGA1UE AwwLTcOhcmlvIEt1a2ExIzAhBgkqhkiG9w0BCQEWFG1hcmlvLmt1a2FAY2VzbmV0LmN6MIIB IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsf8rfNlSMXsoruJ2DkRtAGXBvekIfYKu HfaRR7BzICsgHgjwxDZl1bIqTMuwiadre+QI2EN4h7DqAI8+ws7s+RUtSD9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