From patchwork Mon May 5 12:56:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 345711 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D605E140278 for ; Mon, 5 May 2014 22:58:08 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932638AbaEEM6D (ORCPT ); Mon, 5 May 2014 08:58:03 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:47495 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932611AbaEEM6B (ORCPT ); Mon, 5 May 2014 08:58:01 -0400 Received: from [10.30.3.27] ([10.30.3.27]) (authenticated bits=0) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id s45CvsWa016088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 5 May 2014 16:57:55 +0400 (MSK) Message-ID: <53678A7C.9030701@parallels.com> Date: Mon, 05 May 2014 16:56:28 +0400 From: Vasily Averin Organization: Parallels User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: Florian Westphal , Pablo Neira Ayuso CC: netfilter-devel@vger.kernel.org, Patrick McHardy Subject: [PATCH 6/7] nf: ipv4 defragmentation users counter changes in xt_socket match References: <20140503233908.GA6297@localhost> In-Reply-To: Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Signed-off-by: Vasily Averin --- net/netfilter/xt_socket.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/net/netfilter/xt_socket.c b/net/netfilter/xt_socket.c index 1ba6793..982bd58 100644 --- a/net/netfilter/xt_socket.c +++ b/net/netfilter/xt_socket.c @@ -388,6 +388,12 @@ socket_mt6_v1_v2(const struct sk_buff *skb, struct xt_action_param *par) } #endif +static int socket_mt4_v0_check(const struct xt_mtchk_param *par) +{ + inc_br_defrag_ipv4_users_count(par->net); + return 0; +} + static int socket_mt_v1_check(const struct xt_mtchk_param *par) { const struct xt_socket_mtinfo1 *info = (struct xt_socket_mtinfo1 *) par->matchinfo; @@ -396,6 +402,8 @@ static int socket_mt_v1_check(const struct xt_mtchk_param *par) pr_info("unknown flags 0x%x\n", info->flags & ~XT_SOCKET_FLAGS_V1); return -EINVAL; } + if (par->family == NFPROTO_IPV4) + inc_br_defrag_ipv4_users_count(par->net); return 0; } @@ -407,15 +415,24 @@ static int socket_mt_v2_check(const struct xt_mtchk_param *par) pr_info("unknown flags 0x%x\n", info->flags & ~XT_SOCKET_FLAGS_V2); return -EINVAL; } + if (par->family == NFPROTO_IPV4) + inc_br_defrag_ipv4_users_count(par->net); return 0; } +static void socket_mt4_destroy(const struct xt_mtdtor_param *par) +{ + dec_br_defrag_ipv4_users_count(par->net); +} + static struct xt_match socket_mt_reg[] __read_mostly = { { .name = "socket", .revision = 0, .family = NFPROTO_IPV4, .match = socket_mt4_v0, + .checkentry = socket_mt4_v0_check, + .destroy = socket_mt4_destroy, .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN), .me = THIS_MODULE, @@ -426,6 +443,7 @@ static struct xt_match socket_mt_reg[] __read_mostly = { .family = NFPROTO_IPV4, .match = socket_mt4_v1_v2, .checkentry = socket_mt_v1_check, + .destroy = socket_mt4_destroy, .matchsize = sizeof(struct xt_socket_mtinfo1), .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN), @@ -450,6 +468,7 @@ static struct xt_match socket_mt_reg[] __read_mostly = { .family = NFPROTO_IPV4, .match = socket_mt4_v1_v2, .checkentry = socket_mt_v2_check, + .destroy = socket_mt4_destroy, .matchsize = sizeof(struct xt_socket_mtinfo1), .hooks = (1 << NF_INET_PRE_ROUTING) | (1 << NF_INET_LOCAL_IN),