Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755146AbbGZL5r (ORCPT ); Sun, 26 Jul 2015 07:57:47 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:35680 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063AbbGZL5p (ORCPT ); Sun, 26 Jul 2015 07:57:45 -0400 Date: Sun, 26 Jul 2015 17:27:37 +0530 From: Vaishali Thakkar To: Pablo Neira Ayuso Cc: Patrick McHardy , Jozsef Kadlecsik , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org Subject: [PATCH] netfilter: xtables: Add helper macro for xt_match boilerplate Message-ID: <20150726115737.GA14070@vaishali-Ideapad-Z570> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1489 Lines: 40 For simple modules that contain a single xt_match without any additional setup code then ends up being a block of duplicated boilerplate. This patch adds a new macro, module_xt_match(), which replaces the module_init()/module_exit() registrations with template functions. Signed-off-by: Vaishali Thakkar --- include/linux/netfilter/x_tables.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 286098a..4ebf66b 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -142,6 +142,16 @@ struct xt_match { unsigned short family; }; +/** + * module_xt_match() - Helper macro for registering a netfilter driver + * @__xt_match: xt_match struct + * Helper macro for netfilter drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_xt_match(__xt_match) \ + module_driver(__xt_match, xt_register_match, xt_unregister_match) + /* Registration hooks for targets. */ struct xt_target { struct list_head list; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/