All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: "Ahelenia Ziemiańska" <nabijaczleweli@nabijaczleweli.xyz>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] conntrack: -L doesn't take a value, so don't discard one (same for -IUDGEFA)
Date: Wed, 25 Sep 2024 16:53:49 +0200	[thread overview]
Message-ID: <ZvQj_TOKcN7A9kmz@calendula> (raw)
In-Reply-To: <bymeee6fsub6oz64xtykfru25aq6xx4k2agjbeabekzfobu4jd@tarta.nabijaczleweli.xyz>

On Tue, Sep 03, 2024 at 04:53:46PM +0200, Ahelenia Ziemiańska wrote:
> On Tue, Sep 03, 2024 at 10:22:09AM +0200, Pablo Neira Ayuso wrote:
> > On Tue, Sep 03, 2024 at 04:16:21AM +0200, Ahelenia Ziemiańska wrote:
> > > The manual says
> > >    COMMANDS
> > >        These options specify the particular operation to perform.
> > >        Only one of them can be specified at any given time.
> > > 
> > >        -L --dump
> > >               List connection tracking or expectation table
> > > 
> > > So, naturally, "conntrack -Lo extended" should work,
> > > but it doesn't, it's equivalent to "conntrack -L",
> > > and you need "conntrack -L -o extended".
> > > This violates user expectations (borne of the Utility Syntax Guidelines)
> > > and contradicts the manual.
> > > 
> > > optarg is unused, anyway. Unclear why any of these were :: at all?
> > Because this supports:
> >         -L
> >         -L conntrack
> >         -L expect
> Well that's not what :: does, though; we realise this, right?
> 
> "L::" means that getopt() will return
>   "-L", "conntrack" -> 'L',optarg=NULL
>   "-Lconntrack"     -> 'L',optarg="conntrack"
> and the parser for -L (&c.) doesn't... use optarg.

Are you sure it does not use optarg?

static unsigned int check_type(int argc, char *argv[])
{
        const char *table = get_optional_arg(argc, argv);

and get_optional_arg() uses optarg.

> You don't parse the filter (table name? idk.) with getopt at all;
> you can test this /right now/ by running precisely the thing you outlined:
>   # conntrack -L > /dev/null
>   conntrack v1.4.7 (conntrack-tools): 137 flow entries have been shown.
>   # conntrack -L expect > /dev/null
>   conntrack v1.4.7 (conntrack-tools): 0 expectations have been shown.
>   # conntrack -Lexpect > /dev/null
>   conntrack v1.4.7 (conntrack-tools): 152 flow entries have been shown.
> and getopt returns, respectively
>   'L',optarg=NULL
>   'L',optarg=NULL; argv[optind]="expect"
>   'L',optarg="expect"
> ...and once again you discard the optarg for 'L' &c.

  parent reply	other threads:[~2024-09-25 14:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-03  2:16 [PATCH] conntrack: -L doesn't take a value, so don't discard one (same for -IUDGEFA) Ahelenia Ziemiańska
2024-09-03  8:22 ` Pablo Neira Ayuso
2024-09-03 14:53   ` Ahelenia Ziemiańska
2024-09-15 21:38     ` Pablo Neira Ayuso
2024-09-25 14:53     ` Pablo Neira Ayuso [this message]
2024-09-25 15:11       ` Ahelenia Ziemiańska
2024-09-25 20:32         ` Pablo Neira Ayuso
2024-09-26  8:28           ` наб
2024-09-26 10:32             ` Pablo Neira Ayuso
2024-09-26 10:38               ` Pablo Neira Ayuso
2024-09-26 11:05                 ` наб

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=ZvQj_TOKcN7A9kmz@calendula \
    --to=pablo@netfilter.org \
    --cc=nabijaczleweli@nabijaczleweli.xyz \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.