From patchwork Thu Aug 21 02:52:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhouyi Zhou X-Patchwork-Id: 381851 X-Patchwork-Delegate: pablo@netfilter.org 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 80F8A14008C for ; Thu, 21 Aug 2014 12:53:57 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753362AbaHUCxa (ORCPT ); Wed, 20 Aug 2014 22:53:30 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:39228 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753081AbaHUCxR (ORCPT ); Wed, 20 Aug 2014 22:53:17 -0400 Received: by mail-pa0-f50.google.com with SMTP id et14so13213858pad.37 for ; Wed, 20 Aug 2014 19:53:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=xlWO2c5++ryHiAZTbblAmp+JiTKUddibCT19xmJnsC4=; b=golGX3e1kY1QbU4x7xgeKLZH/1Ixld7w4e82snDQf08CZ3/8jvEltMBCBFJpACnrsK 5duuqYrn7Fqw1iG7sdgzJRI9dZMAqonAmktEXNkqcmOsGpOKTwZ2OZGkNV3AVFL5ESfF I++piSCQZqq45HCWnAKMuNf9nKWrThym3m2XKJDF1Wpy1lMkhGfB3K5/eK9RhaRUZUlL 1XOCvnp/KPNuFXaTfhRYBVXSkS3Phhe/dJUXyIiUqsw52+mdP5upmeLIfOiU959X1G9l oTvsWvlCsKXX9iLDqt/meN6s6bVDnmEcFAT1zbfP3XLvJTzdW0euCxgo+APJoeE0ZzhG kfzw== X-Received: by 10.70.55.103 with SMTP id r7mr26840046pdp.169.1408589596587; Wed, 20 Aug 2014 19:53:16 -0700 (PDT) Received: from localhost.localdomain ([159.226.43.96]) by mx.google.com with ESMTPSA id f12sm85942683pat.23.2014.08.20.19.53.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Aug 2014 19:53:16 -0700 (PDT) From: Zhouyi Zhou X-Google-Original-From: Zhouyi Zhou To: , , , , , , , , Cc: Zhouyi Zhou Subject: [PATCH 1/1] netfilter/jump_label: use HAVE_JUMP_LABEL? Date: Thu, 21 Aug 2014 10:52:48 +0800 Message-Id: <1408589568-27046-1-git-send-email-yizhouzhou@ict.ac.cn> X-Mailer: git-send-email 1.7.10.4 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org CONFIG_JUMP_LABEL doesn't ensure HAVE_JUMP_LABEL, if it is not the case use maintainers's own mutex to guard the modification of global values. Signed-off-by: Zhouyi Zhou --- include/linux/netfilter.h | 5 +++-- net/netfilter/core.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index 2077489..83a1952 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #ifdef CONFIG_NETFILTER static inline int NF_DROP_GETERR(int verdict) @@ -99,8 +100,8 @@ void nf_unregister_sockopt(struct nf_sockopt_ops *reg); extern struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS]; -#if defined(CONFIG_JUMP_LABEL) -#include +#ifdef HAVE_JUMP_LABEL + extern struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS]; static inline bool nf_hooks_active(u_int8_t pf, unsigned int hook) { diff --git a/net/netfilter/core.c b/net/netfilter/core.c index a93c97f..024a2e2 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c @@ -54,7 +54,7 @@ EXPORT_SYMBOL_GPL(nf_unregister_afinfo); struct list_head nf_hooks[NFPROTO_NUMPROTO][NF_MAX_HOOKS] __read_mostly; EXPORT_SYMBOL(nf_hooks); -#if defined(CONFIG_JUMP_LABEL) +#ifdef HAVE_JUMP_LABEL struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS]; EXPORT_SYMBOL(nf_hooks_needed); #endif @@ -72,7 +72,7 @@ int nf_register_hook(struct nf_hook_ops *reg) } list_add_rcu(®->list, elem->list.prev); mutex_unlock(&nf_hook_mutex); -#if defined(CONFIG_JUMP_LABEL) +#ifdef HAVE_JUMP_LABEL static_key_slow_inc(&nf_hooks_needed[reg->pf][reg->hooknum]); #endif return 0; @@ -84,7 +84,7 @@ void nf_unregister_hook(struct nf_hook_ops *reg) mutex_lock(&nf_hook_mutex); list_del_rcu(®->list); mutex_unlock(&nf_hook_mutex); -#if defined(CONFIG_JUMP_LABEL) +#ifdef HAVE_JUMP_LABEL static_key_slow_dec(&nf_hooks_needed[reg->pf][reg->hooknum]); #endif synchronize_net();