From patchwork Sat Nov 21 16:18:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 547196 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 030D21402CC for ; Sun, 22 Nov 2015 03:19:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=g5aFb5OC; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761422AbbKUQS4 (ORCPT ); Sat, 21 Nov 2015 11:18:56 -0500 Received: from mail-yk0-f181.google.com ([209.85.160.181]:33977 "EHLO mail-yk0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761186AbbKUQSy (ORCPT ); Sat, 21 Nov 2015 11:18:54 -0500 Received: by ykfs79 with SMTP id s79so198777161ykf.1; Sat, 21 Nov 2015 08:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=1+Vl0gkRc/cnNfZVTA435c1QiMGP/T+lDi/9jPe/Dqo=; b=g5aFb5OC7xIhk6Qz6dEL8vMn3MB6U1GxQX2u3Kvaoc48OcNxT0qDQlokHLIG2/w3DR h/zDrLtSrFnrvs8CxiXDD4QkTTFNeDsu2j/R4RyWv8tQ332PDYP3EqpC8uqLCUU/9Pk5 zjyrr57/I1+20rS6zYEpl2u/6vjSwUnPQwrn6cdGcepLonRUb0puWcbbwl9lZ29tkVFz Pq9n2kN5nMQS2tGg3DhQoKaVdT90a/P2i0Wrpt1epB6q7rndkmKiZtKrZRMOe0s9Y8pA bIQ+HquPYdDfYVb7Wtc99ZAqaTyHnvRJpGy3oPCB3dsuNWSKaT7mLDSa2vqBnOPDdwQx MsrA== X-Received: by 10.129.79.201 with SMTP id d192mr8936163ywb.115.1448122733484; Sat, 21 Nov 2015 08:18:53 -0800 (PST) Received: from htj.duckdns.org ([2620:10d:c091:180::1244]) by smtp.gmail.com with ESMTPSA id y18sm4284202ywd.11.2015.11.21.08.18.51 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 21 Nov 2015 08:18:53 -0800 (PST) Date: Sat, 21 Nov 2015 11:18:46 -0500 From: Tejun Heo To: davem@davemloft.net, pablo@netfilter.org, kaber@trash.net, kadlec@blackhole.kfki.hu, daniel@iogearbox.net, daniel.wagner@bmw-carit.de, nhorman@tuxdriver.com Cc: lizefan@huawei.com, hannes@cmpxchg.org, netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, ninasc@fb.com Subject: [PATCH 1/2 iptables] libxt_cgroup: prepare for multi revisions Message-ID: <20151121161846.GB3428@htj.duckdns.org> References: <1448122441-9335-1-git-send-email-tj@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1448122441-9335-1-git-send-email-tj@kernel.org> User-Agent: Mutt/1.5.23 (2015-06-09) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org libxt_cgroup will grow cgroup2 path based match. Postfix existing symbols with _v0 and prepare for multi revision registration. While at it, rename O_CGROUP to O_CLASSID and fwid to classid. Signed-off-by: Tejun Heo Cc: Daniel Borkmann Cc: Jan Engelhardt Cc: Pablo Neira Ayuso --- extensions/libxt_cgroup.c | 51 +++++++++++++++++++----------------- include/linux/netfilter/xt_cgroup.h | 2 - 2 files changed, 28 insertions(+), 25 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/extensions/libxt_cgroup.c +++ b/extensions/libxt_cgroup.c @@ -3,30 +3,30 @@ #include enum { - O_CGROUP = 0, + O_CLASSID = 0, }; -static void cgroup_help(void) +static void cgroup_help_v0(void) { printf( "cgroup match options:\n" -"[!] --cgroup fwid Match cgroup fwid\n"); +"[!] --cgroup classid Match cgroup classid\n"); } -static const struct xt_option_entry cgroup_opts[] = { +static const struct xt_option_entry cgroup_opts_v0[] = { { .name = "cgroup", - .id = O_CGROUP, + .id = O_CLASSID, .type = XTTYPE_UINT32, .flags = XTOPT_INVERT | XTOPT_MAND | XTOPT_PUT, - XTOPT_POINTER(struct xt_cgroup_info, id) + XTOPT_POINTER(struct xt_cgroup_info_v0, id) }, XTOPT_TABLEEND, }; -static void cgroup_parse(struct xt_option_call *cb) +static void cgroup_parse_v0(struct xt_option_call *cb) { - struct xt_cgroup_info *cgroupinfo = cb->data; + struct xt_cgroup_info_v0 *cgroupinfo = cb->data; xtables_option_parse(cb); if (cb->invert) @@ -34,34 +34,37 @@ static void cgroup_parse(struct xt_optio } static void -cgroup_print(const void *ip, const struct xt_entry_match *match, int numeric) +cgroup_print_v0(const void *ip, const struct xt_entry_match *match, int numeric) { - const struct xt_cgroup_info *info = (void *) match->data; + const struct xt_cgroup_info_v0 *info = (void *) match->data; printf(" cgroup %s%u", info->invert ? "! ":"", info->id); } -static void cgroup_save(const void *ip, const struct xt_entry_match *match) +static void cgroup_save_v0(const void *ip, const struct xt_entry_match *match) { - const struct xt_cgroup_info *info = (void *) match->data; + const struct xt_cgroup_info_v0 *info = (void *) match->data; printf("%s --cgroup %u", info->invert ? " !" : "", info->id); } -static struct xtables_match cgroup_match = { - .family = NFPROTO_UNSPEC, - .name = "cgroup", - .version = XTABLES_VERSION, - .size = XT_ALIGN(sizeof(struct xt_cgroup_info)), - .userspacesize = XT_ALIGN(sizeof(struct xt_cgroup_info)), - .help = cgroup_help, - .print = cgroup_print, - .save = cgroup_save, - .x6_parse = cgroup_parse, - .x6_options = cgroup_opts, +static struct xtables_match cgroup_match[] = { + { + .family = NFPROTO_UNSPEC, + .revision = 0, + .name = "cgroup", + .version = XTABLES_VERSION, + .size = XT_ALIGN(sizeof(struct xt_cgroup_info_v0)), + .userspacesize = XT_ALIGN(sizeof(struct xt_cgroup_info_v0)), + .help = cgroup_help_v0, + .print = cgroup_print_v0, + .save = cgroup_save_v0, + .x6_parse = cgroup_parse_v0, + .x6_options = cgroup_opts_v0, + }, }; void _init(void) { - xtables_register_match(&cgroup_match); + xtables_register_matches(cgroup_match, ARRAY_SIZE(cgroup_match)); } --- a/include/linux/netfilter/xt_cgroup.h +++ b/include/linux/netfilter/xt_cgroup.h @@ -3,7 +3,7 @@ #include -struct xt_cgroup_info { +struct xt_cgroup_info_v0 { __u32 id; __u32 invert; };