netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH] netfilter: xt_time: add support to ignore day transition
Date: Mon, 24 Sep 2012 14:35:59 +0200	[thread overview]
Message-ID: <20120924123559.GA30314@1984> (raw)
In-Reply-To: <1347877389-15728-2-git-send-email-fw@strlen.de>

On Mon, Sep 17, 2012 at 12:23:09PM +0200, Florian Westphal wrote:
> Currently, if you want to do something like:
> "match Monday, starting 23:00, for two hours"
> You need two rules, one for Mon 23:00 to 0:00 and one for Tue 0:00-1:00.
> The rule
> --weekdays Mo --timestart 23:00  --timestop 01:00
> looks correct, but it will first match on monday from midnight to 1 a.m.
> and then again for another hour from 23:00 onwards.
> 
> This permits userspace to explicitly ignore the day transition and
> match for a single, continuous time period instead.

Applied with one minor glitch.

> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
>  include/linux/netfilter/xt_time.h |    7 +++++++
>  net/netfilter/xt_time.c           |   24 +++++++++++++++++++++++-
>  2 files changed, 30 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/netfilter/xt_time.h b/include/linux/netfilter/xt_time.h
> index 7c37fac..39cc3c4 100644
> --- a/include/linux/netfilter/xt_time.h
> +++ b/include/linux/netfilter/xt_time.h
> @@ -17,6 +17,9 @@ enum {
>  	/* Match against local time (instead of UTC) */
>  	XT_TIME_LOCAL_TZ = 1 << 0,
>  
> +	/* treat timestart > timestop (e.g. 23:00-01:00) as single period */
> +	XT_TIME_CONTIGUOUS = 1 << 1,
> +
>  	/* Shortcuts */
>  	XT_TIME_ALL_MONTHDAYS = 0xFFFFFFFE,
>  	XT_TIME_ALL_WEEKDAYS  = 0xFE,
> @@ -24,4 +27,8 @@ enum {
>  	XT_TIME_MAX_DAYTIME   = 24 * 60 * 60 - 1,
>  };
>  
> +#ifdef __KERNEL__
> +#define XT_TIME_ALL_FLAGS (XT_TIME_LOCAL_TZ|XT_TIME_CONTIGUOUS)
> +#endif

I've removed this conditional definition. IMO that ifdef is too much
for just hidding one mask from user-space. Moreover it uses two flags
that are exposed to user-space.

There's is still one rare case we may use it, which is adding one rule
with recent iptables using the contiguous thing and dumping the
rule-set with one old iptables binary. But that's really rare.

Well, this is just to avoid a bit the ifdef pollution we have all
around our code.

  parent reply	other threads:[~2012-09-24 12:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-17 10:23 [PATCH] libxt_time: add support to ignore day transition Florian Westphal
2012-09-17 10:23 ` [PATCH] netfilter: xt_time: " Florian Westphal
2012-09-17 10:32   ` Jan Engelhardt
2012-09-17 11:02     ` Florian Westphal
2012-09-24 12:35   ` Pablo Neira Ayuso [this message]
2012-09-24 12:40 ` [PATCH] libxt_time: " Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120924123559.GA30314@1984 \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).