netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Cc: Netfilter Development Mailing list <netfilter-devel@vger.kernel.org>
Subject: Re: [libnftnl PATCH v3] utils: fix arp family number
Date: Tue, 21 Oct 2014 11:57:41 +0200	[thread overview]
Message-ID: <20141021095741.GA5493@salvia> (raw)
In-Reply-To: <20141021095649.GA5248@salvia>

On Tue, Oct 21, 2014 at 11:56:49AM +0200, Pablo Neira Ayuso wrote:
> On Tue, Oct 21, 2014 at 10:53:19AM +0200, Arturo Borrero Gonzalez wrote:
> > On 21 October 2014 09:59, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > >
> > > BTW, it would be good to see a similar refactor in nft_verdict2str().
> > 
> > I don't see a clean way to do it, given some verdicts are negative
> > numbers (enum nft_verdicts in nf_tables.h).
> > We may end accessing a negative index, out of bounds of the array.
> 
> I see, you mean:
> 
> enum nft_verdicts {
>         NFT_CONTINUE    = -1,
>         NFT_BREAK       = -2,
>         NFT_JUMP        = -3,
>         NFT_GOTO        = -4,
>         NFT_RETURN      = -5,
> };
> 
> You can add some function to shift the values:
> 
> #define nft_verdict_index(base)     (base + 5)

BTW, instead of 5, add:

#define NFT_VERDICT_BASE        NFT_RETURN

and use it.

> 
> ... nft_verdict_array[] = {
>         [nft_verdict_index(NFT_RETURN)]     = "return",
>         ...
> };

  reply	other threads:[~2014-10-21  9:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 11:52 [libnftnl PATCH v3] utils: fix arp family number Arturo Borrero Gonzalez
2014-10-21  7:59 ` Pablo Neira Ayuso
2014-10-21  8:53   ` Arturo Borrero Gonzalez
2014-10-21  9:56     ` Pablo Neira Ayuso
2014-10-21  9:57       ` Pablo Neira Ayuso [this message]
2014-10-22 14:24         ` Arturo Borrero Gonzalez

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=20141021095741.GA5493@salvia \
    --to=pablo@netfilter.org \
    --cc=arturo.borrero.glez@gmail.com \
    --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).