From patchwork Mon Aug 19 15:10:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Emelyanov X-Patchwork-Id: 268251 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 6D07F2C00BF for ; Tue, 20 Aug 2013 01:10:50 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750816Ab3HSPKq (ORCPT ); Mon, 19 Aug 2013 11:10:46 -0400 Received: from relay.parallels.com ([195.214.232.42]:53516 "EHLO relay.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750740Ab3HSPKq (ORCPT ); Mon, 19 Aug 2013 11:10:46 -0400 Received: from [10.30.3.11] (helo=mail.sw.ru) by relay.parallels.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.80.1) (envelope-from ) id 1VBR6T-0005pI-5C; Mon, 19 Aug 2013 19:10:45 +0400 Received: from [10.30.16.114] (10.30.16.114) by mail.sw.ru (10.30.3.11) with Microsoft SMTP Server (TLS) id 14.2.342.3; Mon, 19 Aug 2013 19:10:44 +0400 Message-ID: <52123574.3020501@parallels.com> Date: Mon, 19 Aug 2013 19:10:44 +0400 From: Pavel Emelyanov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120605 Thunderbird/13.0 MIME-Version: 1.0 To: Linux Netdev List , David Miller Subject: [PATCH 4/4] tun: Get skfilter layout References: <52123515.3060507@parallels.com> In-Reply-To: <52123515.3060507@parallels.com> X-Originating-IP: [10.30.16.114] Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The only thing we may have from tun device is the fprog, whic contains the number of filter elements and a pointer to (user-space) memory where the elements are. The program itself may not be available if the device is persistent and detached. Signed-off-by: Pavel Emelyanov --- drivers/net/tun.c | 10 ++++++++++ include/uapi/linux/if_tun.h | 1 + 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 8bfc1ce..eb48157 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2042,6 +2042,16 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, tun_detach_filter(tun, tun->numqueues); break; + case TUNGETFILTER: + ret = -EINVAL; + if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV) + break; + ret = -EFAULT; + if (copy_to_user(argp, &tun->fprog, sizeof(tun->fprog))) + break; + ret = 0; + break; + default: ret = -EINVAL; break; diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h index cc127b2..e9502dd 100644 --- a/include/uapi/linux/if_tun.h +++ b/include/uapi/linux/if_tun.h @@ -57,6 +57,7 @@ #define TUNSETVNETHDRSZ _IOW('T', 216, int) #define TUNSETQUEUE _IOW('T', 217, int) #define TUNSETIFINDEX _IOW('T', 218, unsigned int) +#define TUNGETFILTER _IOR('T', 219, struct sock_fprog) /* TUNSETIFF ifr flags */ #define IFF_TUN 0x0001