All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org, Anand Raj Manickam <anandrm@gmail.com>
Subject: Re: [RFC PATCH nft] src: add support for interface wildcard name
Date: Wed, 16 Oct 2013 12:39:49 +0200	[thread overview]
Message-ID: <20131016103949.GA10032@localhost> (raw)
In-Reply-To: <1381846993-30093-1-git-send-email-fw@strlen.de>

Hi Florian,

On Tue, Oct 15, 2013 at 04:23:13PM +0200, Florian Westphal wrote:
> Uses same syntax as iptables: itfname+.

Good you're bringing up this issue, we've been discussing this for a
while with recent Anand's patch.

> The '+' suffix is not stored on the kernel side; this approach
> is the same as the one used by iptables-nftables.

Hm, it seems current iptables-nftables seems broken by:

73ea1cc nft: convert rule into a command state structure

So let's have a look at the previous handling we had (which is the one
I guess you're refering to):

       ifname_ptr = nft_rule_expr_get(e, NFT_EXPR_CMP_DATA, &len);
       memcpy(ifname, ifname_ptr, len);
       ifname[len] = '\0';

       /* if this is zero, then assume this is a interface */
       if (if_nametoindex(ifname) == 0) {
               ifname[len] = '+';
               ifname[len+1] = '\0';
       }

That if_nametoindex handling was a bit of cheat: if the interface is
gone after adding the rule, it will attach the '+', which is wrong.

> +static void ifname_type_print(const struct expr *expr)
> +{
> +	unsigned int len = div_round_up(expr->len, BITS_PER_BYTE);
> +	char data[len];
> +
> +	mpz_export_data(data, expr->value, BYTEORDER_HOST_ENDIAN, len);
> +	printf("\"%.*s", len, data);
> +	if (len && data[len-1] != '\0')
> +		printf("+"); /* string without nul: interface wildcard match */
> +	printf("\"");
> +}

Your assumption regarding trailing nul looks similar to what I can see
in iptables, let's go that way in iptables-nftables.

> i.e. xtables-save understands 'nft .. meta oifname foo+' and vice versa.
> 
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
>  Caveats:
>   - I am not convinced '+' is a good idea -- it is ambiguous since
>   'foo+' is a legal interface name.

I think we can remove the '+' in nft, so we match exactly what we
pass for the ifname case, eg. iifname "eth".

OK with this approach?

>   Maybe we should use 'foo/' (Linux forbids / in interface names) instead?
>   - added a new 'itfname' data type since I felt uncomfortable
>     with allowing 'non-nul-terminated' strings.
>   - removes a FIXME in netlink_delinearize.  What was that about? :-}

I don't remember the reason for that case, please try to dig it out
from the history. Thanks!

  reply	other threads:[~2013-10-16 10:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 14:23 [RFC PATCH nft] src: add support for interface wildcard name Florian Westphal
2013-10-16 10:39 ` Pablo Neira Ayuso [this message]
2013-10-16 11:00   ` Florian Westphal
2013-10-16 11:02     ` Patrick McHardy
2013-10-16 12:58     ` Pablo Neira Ayuso
2013-10-16 13:01       ` Pablo Neira Ayuso
2013-10-16 13:18         ` Anand Raj Manickam
2013-10-20 11:49 ` Jan Engelhardt

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=20131016103949.GA10032@localhost \
    --to=pablo@netfilter.org \
    --cc=anandrm@gmail.com \
    --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 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.