From patchwork Fri Mar 26 22:35:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brandon Black X-Patchwork-Id: 48731 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id BED65B7C09 for ; Sat, 27 Mar 2010 09:36:04 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754274Ab0CZWfj (ORCPT ); Fri, 26 Mar 2010 18:35:39 -0400 Received: from mail-yx0-f191.google.com ([209.85.210.191]:35460 "EHLO mail-yx0-f191.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753883Ab0CZWfi (ORCPT ); Fri, 26 Mar 2010 18:35:38 -0400 Received: by yxe29 with SMTP id 29so972760yxe.4 for ; Fri, 26 Mar 2010 15:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=xyx0hZ2JIF4p3pRkVx9cSUfwgZhvzLS3Y/nh+p7b7B8=; b=dViR9Fj6AE3I2EvzWq4opsQIdUW0v59aP46wiN/dTq0dLVba5AA7Z5c07RsRKe6ejU t5hT5+Ux7+tmE1zqg1Hkbe0+mn60WE7ZVDH5pjeN3y2DsLVKkx3Xai6ZS9VwXwRuNpvA KkFSns6SuRta23JShWjvRsUVpzdpC+VazPh+c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=d/ZiHqUJ0ANhq2SKus8EZ53nRyZGGJLNDKQN28NAKMHjaBzKLO1LJRa7/70AtxW9zw m+iYnUIfC/hbIpFbISKMfD7Qfh8eGqdiSB1CGYPbXdBq47jvAjUjcoKCqB9HVUtrz6nj Rypw8rbH5xgcJgjcJblwrgUHzx2cz7BfmDJcI= Received: by 10.101.175.38 with SMTP id c38mr2664148anp.40.1269642937038; Fri, 26 Mar 2010 15:35:37 -0700 (PDT) Received: from xpc.home (pool-96-228-70-134.hstntx.fios.verizon.net [96.228.70.134]) by mx.google.com with ESMTPS id a1sm1158348ibs.6.2010.03.26.15.35.35 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 26 Mar 2010 15:35:36 -0700 (PDT) Date: Fri, 26 Mar 2010 17:35:30 -0500 From: Brandon L Black To: netdev@vger.kernel.org Cc: "David S. Miller" , Arnaldo Carvalho de Melo , Ulrich Drepper , linux-kernel@vger.kernel.org Subject: [PATCH] Add MSG_WAITFORONE flag to recvmmsg Message-ID: <20100326223530.GA11817@xpc.home> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Brandon L Black Add new flag MSG_WAITFORONE for the recvmmsg() syscall. When this flag is specified for a blocking socket, recvmmsg() will only block until at least 1 packet is available. The default behavior is to block until all vlen packets are available. This flag has no effect on non-blocking sockets or when used in combination with MSG_DONTWAIT. Signed-off-by: Brandon L Black --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/socket.h b/include/linux/socket.h index 7b3aae2..354cc56 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -255,6 +255,7 @@ struct ucred { #define MSG_ERRQUEUE 0x2000 /* Fetch message from error queue */ #define MSG_NOSIGNAL 0x4000 /* Do not generate SIGPIPE */ #define MSG_MORE 0x8000 /* Sender will send more */ +#define MSG_WAITFORONE 0x10000 /* recvmmsg(): block until 1+ packets avail */ #define MSG_EOF MSG_FIN diff --git a/net/socket.c b/net/socket.c index 769c386..33304d1 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2133,7 +2133,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen, if (err) break; - ++datagrams; + + /* MSG_WAITFORONE turns on MSG_DONTWAIT after one packet */ + if (!datagrams++ && (flags & MSG_WAITFORONE)) + flags |= MSG_DONTWAIT; if (timeout) { ktime_get_ts(timeout);