From patchwork Sat Nov 7 19:59:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 541363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 0B7981402C6 for ; Sun, 8 Nov 2015 07:00:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=nicira_com.20150623.gappssmtp.com header.i=@nicira_com.20150623.gappssmtp.com header.b=RQrkFbmm; dkim-atps=neutral Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 19CB110A0F; Sat, 7 Nov 2015 12:00:22 -0800 (PST) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 80B1D109F6 for ; Sat, 7 Nov 2015 12:00:20 -0800 (PST) Received: from bar3.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id 08F13162F83 for ; Sat, 7 Nov 2015 13:00:20 -0700 (MST) X-ASG-Debug-ID: 1446926419-03dd7b490d1f0e0001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar3.cudamail.com with ESMTP id EtzDn1vVv4CVykgZ (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 07 Nov 2015 13:00:19 -0700 (MST) X-Barracuda-Envelope-From: joestringer@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO mail-pa0-f46.google.com) (209.85.220.46) by mx3-pf2.cudamail.com with ESMTPS (RC4-SHA encrypted); 7 Nov 2015 20:00:19 -0000 Received-SPF: unknown (mx3-pf2.cudamail.com: Multiple SPF records returned) X-Barracuda-Apparent-Source-IP: 209.85.220.46 X-Barracuda-RBL-IP: 209.85.220.46 Received: by pacdm15 with SMTP id dm15so132296792pac.3 for ; Sat, 07 Nov 2015 12:00:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nicira_com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=7cYgBhb+GwNRvoL2n7XA1/pKf7flJLkIOTyNBSGgUng=; b=RQrkFbmm3dqOOjxsRXnKqKmu6mvtirumc2PEzG49XdD8OJz7gJl8mGKOxKaKI+/MQH Uo3OAIO2SCiq9mwUEcVaRsoInZb70n4T+G0EkONVVW2e/ZK1fbmou5Ej0MOdolUPji3F 6Q7zPxnLmNIsP8XKCgXwbvHT7nOpzoDyBwmVUeVIb15scQYNYE7gl0kFSMv/8cfM7nJo xxC39xrysVdVz3O3fvLQp7oUFe2sb5Qix5wShQL4v6EMVS16D+USwRIXXu6Qc96BbeWP meP5x1hLjqFgfc/rkgajXvz8IirzIjCpuxv2epVhSIH4mIDkXY62yd+3x+tdNV7wKOMN 7AUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=7cYgBhb+GwNRvoL2n7XA1/pKf7flJLkIOTyNBSGgUng=; b=JdTgsP1dEyNdssaJi3CQsEN275HyQYG4R3qnRDGU3qyFIebJe2OCVnFVj5R7s8+RLM fdtcJz8n0Eom7WwHwb1ePnbtbh94spYxY/1MIAA17xWxQdidB/PQrKGVMGmW88UH8s2c pMNElnAhvb+Iv7wmdjT2wnHrUhY8m3RrkoAwnLWGtCd0K07czy9mbDwMQ7+2D+jbVgBr BD9kfZlFdsdugKIXc4iOP0Oiz6cC7BlOFfadO1IWySMJM1i1HQFQyE5NWdd3G4nrNg0t 7ybjl2l+UiCl3ZaPMJCcdgnGi7SZwD6MBRhn5TZCoodiVDNVPPWT4ZnTvTDDew4h973M /fNw== X-Gm-Message-State: ALoCoQmrGRi1yepe1GUhdVcnM3UK9Dw080jvAmTqqaLW+oN/MkQGDzIrxXn5ZUX5pcrfMt4WxTgi X-Received: by 10.66.66.166 with SMTP id g6mr27206364pat.152.1446926419081; Sat, 07 Nov 2015 12:00:19 -0800 (PST) Received: from localhost.localdomain ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id nu5sm7312219pbb.65.2015.11.07.12.00.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 07 Nov 2015 12:00:18 -0800 (PST) X-CudaMail-Envelope-Sender: joestringer@nicira.com From: Joe Stringer To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V2-1106015414 X-CudaMail-DTE: 110715 X-CudaMail-Originating-IP: 209.85.220.46 Date: Sat, 7 Nov 2015 11:59:43 -0800 X-ASG-Orig-Subj: [##CM-V2-1106015414##][PATCH 05/23] compat: Backport prandom_u32_max(). Message-Id: <1446926401-55723-6-git-send-email-joestringer@nicira.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446926401-55723-1-git-send-email-joestringer@nicira.com> References: <1446926401-55723-1-git-send-email-joestringer@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1446926419 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 05/23] compat: Backport prandom_u32_max(). X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: Joe Stringer --- acinclude.m4 | 1 + datapath/linux/compat/include/linux/random.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/acinclude.m4 b/acinclude.m4 index 9465adb1daab..cb3326227f82 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -375,6 +375,7 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [ [OVS_DEFINE([HAVE_NF_HOOKFN_ARG_OPS])]) OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32]) + OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32_max]) OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [get_link_net]) OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [name_assign_type]) diff --git a/datapath/linux/compat/include/linux/random.h b/datapath/linux/compat/include/linux/random.h index f2a6d6aa1468..5c088a2d860b 100644 --- a/datapath/linux/compat/include/linux/random.h +++ b/datapath/linux/compat/include/linux/random.h @@ -7,4 +7,11 @@ #define prandom_u32() random32() #endif +#ifndef HAVE_PRANDOM_U32_MAX +static inline u32 prandom_u32_max(u32 ep_ro) +{ + return (u32)(((u64) prandom_u32() * ep_ro) >> 32); +} +#endif + #endif