Received: by 10.192.165.148 with SMTP id m20csp425575imm; Fri, 20 Apr 2018 08:58:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/nKAFektbGbtpSk1ReljD+5hYA5tvOBZWGDRy+UA3l/n8RRFWoPKZkm+/UM2haegIIrhY6 X-Received: by 10.98.0.194 with SMTP id 185mr6496409pfa.238.1524239922568; Fri, 20 Apr 2018 08:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524239922; cv=none; d=google.com; s=arc-20160816; b=akygpkVXHH/jrHhUeItrcD0xsT4cgW27CmeettpynSvLGmkKDg9X4CWoDP1qFRUXbt ZCEM+szX+1cl/u9fXbUjCLSVtAXOLNgCbgmSzS0jSwED088VNoxwe0PXdgliERVm2JWU 05RvMvVBxol0vGkjDh0B7bJ50qlQ/BYzPpazSSdg8XKPKWKAcmPjKqqtBDLCDbj8HTds y/r+Wf9xJsYikQYoJ9qHvUhzbeSabUoN55p6u4NuzvLh9jSKYH245FHpKfEsdV2MAi9y FG3YiGPIpnyvBQGCZ7u/yJN5tT5DQ7thKyzDqiQmqAwi7ktIBuVOpyu5hpwpzoiHE16t b/hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=SmUW3gO+zwyIw5Ba1sHZNZfzoWhEGhuEpuB2ZbtNXOI=; b=Gb+JL418ZYpSZ57DBNY4K3PsEYkBbGyEbCou3tgcoKXtzziwL6lPYo6YrrRZnpimgm Cv34AaAXxDN61Yk9U+xrtaHk3fWE7Vn5a2N+JdICYOmjXJdx2mih6wkDLbkliYkGUpFM M/YQTxYFAH/CD3SvDL8aer7PO6cgGo2hSNndvEzsn3q+wu5A6xuBrxjne9C2f+qncqh/ y/ejpOrMzvtPF1+OQioFeuw8jpwPdKC0W5gZ6ttCze8us5oS2jp1PdjXhDZ/6zpt/HVh w/t2tXc98182b1pUxSJdUGPnntBywm/m957Cg9dq6J+/WVULJomS8PTOu/CaCQHp6uFO 4P8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BqBrnh4w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l22si2748262pgn.74.2018.04.20.08.58.27; Fri, 20 Apr 2018 08:58:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BqBrnh4w; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755957AbeDTP4o (ORCPT + 99 others); Fri, 20 Apr 2018 11:56:44 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:42764 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755318AbeDTPzw (ORCPT ); Fri, 20 Apr 2018 11:55:52 -0400 Received: by mail-pg0-f66.google.com with SMTP id e12so4211581pgn.9 for ; Fri, 20 Apr 2018 08:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SmUW3gO+zwyIw5Ba1sHZNZfzoWhEGhuEpuB2ZbtNXOI=; b=BqBrnh4w60AIitky8wuG2KU7fHtxhCNo+geCQNkObG3n6E8jlmpspzLGhJTgPUrJW4 4F/cz7chOcZQRgOgpnBk4plTJJClDTM8Oh6SUf7IrYbO8IN5WiIMy1pUs8vTb0I5QwuR Pz7antl7INNvdLePEvOwy7wzr2ev1ONgSFAE+guJtsit23KrR4gRiDvuXX/BKTmkY1mn ODFwvJFH7BrwBmhH3s4nB/qrBATEX6vGYXtIeI5GFg0/p9dKUS1OG3lVYPeya/aWxg1X N0yVr0/Tnj8P7jhE5OshwmigUmAWUq5l/fEXHVtd08tLGBNTkGOYSqyThBnuATZ6UKqs mLyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SmUW3gO+zwyIw5Ba1sHZNZfzoWhEGhuEpuB2ZbtNXOI=; b=Cefje5w6AxQ1C5/XC3SdzdEtvI1K/VjML+TJPtYqvnpyG2RotIOxmyqWHsLW8W1TbX mVL5QcD5WXGT7KHH6ezB5eGJR0D3W33CTGUzhK5RjzBaRhOQy7+lvD5ZqPbU/7siPnJr /dv/aI/Hp4PSBnfDY47R4illDNMzvTSKyxXlv75R8zkCpXYpSWsFnoT/d6f1JZooOfyw qXHZfJjsCa5K6F6f/gFTVgxDkqf8FZ8jsBvDpr7OT6ZapFyT162x+9s9l7ENu6enjRes mRYAqB0gLUQl0uNZkfKfBe1ZLWZTsHwyEPYgFt7Qjkq7/lbhz9YUDSI0JIPhCTZEJ9Hs YlZw== X-Gm-Message-State: ALQs6tDf7+og4XBLEdcdGBvl9MDRbUrMrfTGG9XKlUeDLVOaJgyrbDmP EwnAuDK8HpxOag5veu7JV0NClg== X-Received: by 10.99.113.84 with SMTP id b20mr9202459pgn.426.1524239750901; Fri, 20 Apr 2018 08:55:50 -0700 (PDT) Received: from localhost ([2620:15c:2c4:1:7e6f:1e60:1805:893c]) by smtp.gmail.com with ESMTPSA id l10sm9349424pgp.35.2018.04.20.08.55.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Apr 2018 08:55:49 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" Cc: netdev , linux-kernel , Soheil Hassas Yeganeh , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next 2/4] net: implement sock_mmap_hook() Date: Fri, 20 Apr 2018 08:55:40 -0700 Message-Id: <20180420155542.122183-3-edumazet@google.com> X-Mailer: git-send-email 2.17.0.484.g0c8726318c-goog In-Reply-To: <20180420155542.122183-1-edumazet@google.com> References: <20180420155542.122183-1-edumazet@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sock_mmap_hook() is the mmap_hook handler provided for socket_file_ops Following patch will provide tcp_mmap_hook() for TCP protocol. Signed-off-by: Eric Dumazet --- include/linux/net.h | 1 + net/socket.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/linux/net.h b/include/linux/net.h index 6554d3ba4396b3df49acac934ad16eeb71a695f4..5192bf502b11e42c3d9eb342ce67361916149bfa 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -181,6 +181,7 @@ struct proto_ops { size_t total_len, int flags); int (*mmap) (struct file *file, struct socket *sock, struct vm_area_struct * vma); + int (*mmap_hook) (struct socket *sock, enum mmap_hook); ssize_t (*sendpage) (struct socket *sock, struct page *page, int offset, size_t size, int flags); ssize_t (*splice_read)(struct socket *sock, loff_t *ppos, diff --git a/net/socket.c b/net/socket.c index f10f1d947c78c193b49379b0ec641d81367fb4cf..75a5c2ebe57e0621dae17c6c9e1a796ee818b107 100644 --- a/net/socket.c +++ b/net/socket.c @@ -131,6 +131,14 @@ static ssize_t sock_splice_read(struct file *file, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags); +static int sock_mmap_hook(struct file *file, enum mmap_hook mode) +{ + struct socket *sock = file->private_data; + + if (!sock->ops->mmap_hook) + return 0; + return sock->ops->mmap_hook(sock, mode); +} /* * Socket files have a set of 'special' operations as well as the generic file ones. These don't appear * in the operation structures but are done directly via the socketcall() multiplexor. @@ -147,6 +155,7 @@ static const struct file_operations socket_file_ops = { .compat_ioctl = compat_sock_ioctl, #endif .mmap = sock_mmap, + .mmap_hook = sock_mmap_hook, .release = sock_close, .fasync = sock_fasync, .sendpage = sock_sendpage, -- 2.17.0.484.g0c8726318c-goog