From patchwork Sun Apr 21 09:55:48 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Pervushin X-Patchwork-Id: 16280 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-bk0-f69.google.com (mail-bk0-f69.google.com [209.85.214.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 88FBE20F45 for ; Sun, 21 Apr 2013 09:57:00 +0000 (UTC) Received: by mail-bk0-f69.google.com with SMTP id i18sf6962182bkv.8 for ; Sun, 21 Apr 2013 02:56:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=xL0DWbVuTDf7WkUEQdZnMsNmszGep37ect38I6Kyf7Q=; b=EwM9b3bKt99iy7OFMWSV3BuY+z52c2dXRJA3F9G82bHGa/U9BfGJ2yhf6jF2qU2yTi RZ+/s1CamD3fnNiOheplNMVHXxRHactv2uPcCppA/MAF1CqPAA0kd6zO0ol08/nGIVsp kX/TVG6ZmYGT/Mi64LIvNchXFfYNXeJW7ahGYUTMg01F8bZ2VN/zBNKv6yfhnHC6n9FQ RiIIrgBu60F48lxpvv5b2T568VJs0+vzmH3c3mfOt0r/9km48Si/TTT9DC57Vp7r4Rqi 1HcXv+xf0UZU8brMzinxxEfTGSrql99aWeTxSb8Mp2ci00OJ0QJbUhjbL4PiwVxE+YWZ DC3w== X-Received: by 10.180.20.105 with SMTP id m9mr14051700wie.5.1366538175978; Sun, 21 Apr 2013 02:56:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.20.111 with SMTP id m15ls619215wie.38.gmail; Sun, 21 Apr 2013 02:56:15 -0700 (PDT) X-Received: by 10.181.11.196 with SMTP id ek4mr40954345wid.30.1366538175752; Sun, 21 Apr 2013 02:56:15 -0700 (PDT) Received: from mail-ve0-x22f.google.com (mail-ve0-x22f.google.com [2607:f8b0:400c:c01::22f]) by mx.google.com with ESMTPS id ic5si7750594wjb.120.2013.04.21.02.56.15 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Apr 2013 02:56:15 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22f; Received: by mail-ve0-f175.google.com with SMTP id m1so331070ves.34 for ; Sun, 21 Apr 2013 02:56:14 -0700 (PDT) X-Received: by 10.220.189.9 with SMTP id dc9mr2844183vcb.8.1366538174571; Sun, 21 Apr 2013 02:56:14 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp36494veb; Sun, 21 Apr 2013 02:56:14 -0700 (PDT) X-Received: by 10.194.83.33 with SMTP id n1mr41716182wjy.7.1366538173654; Sun, 21 Apr 2013 02:56:13 -0700 (PDT) Received: from mail-wi0-x22b.google.com (mail-wi0-x22b.google.com [2a00:1450:400c:c05::22b]) by mx.google.com with ESMTPS id ce4si3351514wib.39.2013.04.21.02.56.13 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Apr 2013 02:56:13 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::22b is neither permitted nor denied by best guess record for domain of dmitry.pervushin@linaro.org) client-ip=2a00:1450:400c:c05::22b; Received: by mail-wi0-f171.google.com with SMTP id l13so2823372wie.16 for ; Sun, 21 Apr 2013 02:56:13 -0700 (PDT) X-Received: by 10.180.93.134 with SMTP id cu6mr40544629wib.8.1366538172778; Sun, 21 Apr 2013 02:56:12 -0700 (PDT) Received: from localhost.localdomain (ANice-652-1-369-36.w83-201.abo.wanadoo.fr. [83.201.204.36]) by mx.google.com with ESMTPS id k5sm14712467wiy.5.2013.04.21.02.56.10 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Apr 2013 02:56:11 -0700 (PDT) From: dmitry pervushin To: netfilter-devel@vger.kernel.org Cc: patches@linaro.org, dmitry pervushin , Ashish Sharma , JP Abgrall , John Stultz , dmitry pervushin Subject: [PATCH 2/2] netfilter: idletimers, add v1 structures Date: Sun, 21 Apr 2013 11:55:48 +0200 Message-Id: <1366538148-19759-3-git-send-email-dmitry.pervushin@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366538148-19759-1-git-send-email-dmitry.pervushin@linaro.org> References: <1366538148-19759-1-git-send-email-dmitry.pervushin@linaro.org> X-Gm-Message-State: ALoCoQlfMoAarzogNzoY0PRMI4FcmCfmYsIYi03SS3+X93agKPO+JNq93LQ0/2mSZT1DNb42DLUa X-Original-Sender: dmitry.pervushin@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22f is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add command-line options to handle --send-nl-msg Cc: Ashish Sharma Cc: JP Abgrall Signed-off-by: John Stultz Signed-off-by: dmitry pervushin --- extensions/libxt_IDLETIMER.c | 44 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/extensions/libxt_IDLETIMER.c b/extensions/libxt_IDLETIMER.c index 21004a4..4ef7f36 100644 --- a/extensions/libxt_IDLETIMER.c +++ b/extensions/libxt_IDLETIMER.c @@ -27,14 +27,17 @@ enum { O_TIMEOUT = 0, O_LABEL, + O_SEND_NLMSG, }; -#define s struct idletimer_tg_info +#define s struct idletimer_tg_info_v1 static const struct xt_option_entry idletimer_tg_opts[] = { {.name = "timeout", .id = O_TIMEOUT, .type = XTTYPE_UINT32, .flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, timeout)}, {.name = "label", .id = O_LABEL, .type = XTTYPE_STRING, .flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, label)}, + {.name = "send_nl_msg", .id = O_SEND_NLMSG, .type = XTTYPE_UINT8, + .flags = XTOPT_PUT, XTOPT_POINTER(s, send_nl_msg), .min = 0, .max = 1, }, XTOPT_TABLEEND, }; #undef s @@ -45,6 +48,7 @@ static void idletimer_tg_help(void) "IDLETIMER target options:\n" " --timeout time Timeout until the notification is sent (in seconds)\n" " --label string Unique rule identifier\n" +" --send_nl_msg 0|1 Send netlink message when timer expires\n" "\n"); } @@ -57,6 +61,11 @@ static void idletimer_tg_print(const void *ip, printf(" timeout:%u", info->timeout); printf(" label:%s", info->label); + if (target->u.user.revision > 0) { + struct idletimer_tg_info_v1 *info_v1 = + (struct idletimer_tg_info_v1 *) target->data; + printf(" send_nl_msg:%d", info_v1->send_nl_msg ? 1 : 0); + } } static void idletimer_tg_save(const void *ip, @@ -67,9 +76,23 @@ static void idletimer_tg_save(const void *ip, printf(" --timeout %u", info->timeout); printf(" --label %s", info->label); + if (target->u.user.revision > 0) { + struct idletimer_tg_info_v1 *info_v1 = + (struct idletimer_tg_info_v1 *) target->data; + printf(" --send_nl_msg %d", info_v1->send_nl_msg ? 1 : 0); + } } -static struct xtables_target idletimer_tg_reg = { +static void idletimer_tg_init_v1(struct xt_entry_target *target) +{ + struct idletimer_tg_info_v1 *info = + (struct idletimer_tg_info_v1 *)target->data; + + info->send_nl_msg = 0; +} + +static struct xtables_target idletimer_tg_reg[] = { +{ .family = NFPROTO_UNSPEC, .name = "IDLETIMER", .version = XTABLES_VERSION, @@ -81,9 +104,24 @@ static struct xtables_target idletimer_tg_reg = { .print = idletimer_tg_print, .save = idletimer_tg_save, .x6_options = idletimer_tg_opts, +}, +{ + .family = NFPROTO_UNSPEC, + .name = "IDLETIMER", + .version = XTABLES_VERSION, + .revision = 1, + .size = XT_ALIGN(sizeof(struct idletimer_tg_info_v1)), + .userspacesize = offsetof(struct idletimer_tg_info_v1, timer), + .help = idletimer_tg_help, + .x6_parse = xtables_option_parse, + .print = idletimer_tg_print, + .save = idletimer_tg_save, + .x6_options = idletimer_tg_opts, + .init = idletimer_tg_init_v1, +} }; void _init(void) { - xtables_register_target(&idletimer_tg_reg); + xtables_register_targets(idletimer_tg_reg, ARRAY_SIZE(idletimer_tg_reg)); }