netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Davidson <davidson.brian@gmail.com>
To: Kerin Millar <kfm@plushkava.net>
Cc: netfilter@vger.kernel.org
Subject: Re: meta time/hour questions
Date: Thu, 16 Nov 2023 17:58:40 -0500	[thread overview]
Message-ID: <CAOoaxdFjedx6N5kVG_7SuQ20kg8MtiYqt8Sr_Vxg0X34pgdVrw@mail.gmail.com> (raw)
In-Reply-To: <20231116211417.6e4d438986bebed9b8cf3fb8@plushkava.net>

On Thu, Nov 16, 2023 at 4:14 PM Kerin Millar <kfm@plushkava.net> wrote:
>
> On Wed, 15 Nov 2023 13:33:05 -0500
> Brian Davidson <davidson.brian@gmail.com> wrote:
>
> > The man page states that meta time and meta hour optionally accept
> > seconds, but I get errors on v1.0.6 or v1.0.8. meta time doesn't even
> > like the dash date separator.
> >
> > # nft -c add rule inet t c meta hour "17:00:01" drop
> > Error: syntax error, unexpected colon, expecting end of file or
> > newline or semicolon
> > add rule inet t c meta hour 17:00:01 drop
> >                                  ^
>
> 17:00:01 is only accepted if double quoted, implying that the parser otherwise considers it to be something other than a string. This may or may not be a defect.
>
> Note that the double quotes given to your shell accomplished nothing. Instead, compare the following two commands, the first of which is equivalent to the command that you attempted.
>
> # nft -c 'add rule inet t c meta hour 17:00:01 drop'
> # nft -c 'add rule inet t c meta hour "17:00:01" drop'
>
> > # nft -c add rule inet t c meta time "2023-12-24 17:00:01" drop
> > Error: syntax error, unexpected -, expecting end of file or newline or semicolon
> > add rule inet t c meta time 2023-12-24 17:00:01 drop
> >                                    ^

Ah, of course! I usually only think of single quoting the rule when
braces or semi-colons are involved. Escaping the quotes also works for
me:

# nft -c add rule inet t c meta hour \"17:00:01\" drop

> Similarly, the timestamp needs to be double quoted at the point that nft encounters it.
>
> # nft -c 'add rule inet t c meta time "2023-12-24 17:00:01" drop'
>
> In this instance, such a requirement is easier to fathom. Presumably, 2023-12-24 and 17:00:01 are otherwise considered as two tokens that are not connected with one another.
>
> In both cases, I would describe the error reporting as being poor.
>
> --
> Kerin Millar

      reply	other threads:[~2023-11-16 22:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-15 18:33 meta time/hour questions Brian Davidson
2023-11-16 21:14 ` Kerin Millar
2023-11-16 22:58   ` Brian Davidson [this message]

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=CAOoaxdFjedx6N5kVG_7SuQ20kg8MtiYqt8Sr_Vxg0X34pgdVrw@mail.gmail.com \
    --to=davidson.brian@gmail.com \
    --cc=kfm@plushkava.net \
    --cc=netfilter@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 read-only IMAP folder(s) and NNTP newsgroup(s).