From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C9C6A00C2; Thu, 23 Apr 2020 04:39:51 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 967211D41B; Thu, 23 Apr 2020 04:39:50 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 728CB1D40D for ; Thu, 23 Apr 2020 04:39:48 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id c21so924783plz.4 for ; Wed, 22 Apr 2020 19:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=F1O2gmVGU36xmEZekleoKRZyfDOhMYu7CDjmvHAQh70=; b=vpz2SG1VhwltSRjgMQ8wTmreh1nRsKAPoPHHdQrtCaPl4YSWxqjcY3eMLLfjDoj1oU LsA9VJkqZA8sxdaVnf6XHfNZRXRF7Zz+ANgig3p2pUdbM1SKvs2V0Io89KijOobYSBMn X8kj4zF8KizgMLRURGzETL2GSIp4DF8d9Mgsc5PuySv5ftQfdh+iKYgSGA5IcIgFU5rr 1Hh6aki5+nZkeH+FZS+N3WNMtWxj8xYMi49XBKSIkhqwNQE1fev5sP18ZrfmZLNtRhfP dUju9ijlvlAgB4P+jHVtyTBHKjkZz7AdsZoCuo2nWUwvbfSJ7s6/UFBgWCpFhfk0T/aI nMMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F1O2gmVGU36xmEZekleoKRZyfDOhMYu7CDjmvHAQh70=; b=V9z+poqn9YufM3QCu6/ihoAn0JOYYRXZgVobkodMOqbF8LgZjok+DJLome2wKRlCxl LIJq8YGWrUjQzitCefj+IxUbL9CDgGIZIgFH8Sawbfh/FqlqvVrCEEkiYHd1QlT4ENzg PInf6zZPb4NqT7RqtX1uUzHZxVRwsVOvl5hxWB0ZFUQCwU0p/4vbDRAdH1MHg/JHqM/X t8BU1AFfyJcYceqxPLD7arnLyGi+KqOAHZT9UqMYdrQ3ePHKzZEwkVWzr7qXZddcnVKB Ip5SsFoHysZu0RLy5zt9OrnsM51LA5RGUb56HD26oZ++i4lFGQLec9kMU52lYieShcPF fMfg== X-Gm-Message-State: AGi0PuYgDwVTXr4Y6OYmTz6XXIv7/TzbwKBBK5IEOC5pshyCVomJkP8h BayUS9amBD8P396jLVYahL5fIFpcqzY= X-Google-Smtp-Source: APiQypIhwnexgMjS3/8U6stxDeI//kgFBgOUKEkq49Hvijge5qYOTndWjuSPsWl4la7pbontHwVinA== X-Received: by 2002:a17:902:bd85:: with SMTP id q5mr1697439pls.269.1587609587455; Wed, 22 Apr 2020 19:39:47 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 138sm913548pfz.31.2020.04.22.19.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Apr 2020 19:39:47 -0700 (PDT) Date: Wed, 22 Apr 2020 19:39:39 -0700 From: Stephen Hemminger To: Dan Gora Cc: dev@dpdk.org, Mattias =?UTF-8?B?UsO2bm5ibG9t?= , David Marchand , Jerin Jacob Message-ID: <20200422193939.20841234@hermes.lan> In-Reply-To: <20200422234255.7066-3-dg@adax.com> References: <20200421195446.1730-1-dg@adax.com> <20200422234255.7066-1-dg@adax.com> <20200422234255.7066-3-dg@adax.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 2/2] eal: emulate glibc getentropy for initial random seed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, 22 Apr 2020 20:42:54 -0300 Dan Gora wrote: > + fd = open("/dev/urandom", O_RDONLY); > + if (fd < 0) { > + errno = ENODEV; > + return -1; > + } > + > + end = start + length; > + while (start < end) { > + bytes = read(fd, start, end - start); > + if (bytes < 0) { You are overdoing the complexity here. More error handling is not better. 1. This should only be called once at startup EINTR is not an issue then 2. The amount requested is always returned when using urandom (see man page for random(4)) The O_NONBLOCK flag has no effect when opening /dev/urandom. When calling read(2) for the device /dev/urandom, reads of up to 256 bytes will return as many bytes as are requested and will not be interrupted by a signal handler. Reads with a buffer over this limit may return less than the requested number of bytes or fail with the error EINTR, if interrupted by a signal handler.