From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nf_tables PATCH v2 3/3] netfilter: nf_tables: add new expression nft_redir
Date: Thu, 16 Oct 2014 14:05:23 +0200 [thread overview]
Message-ID: <20141016120523.GD3346@salvia> (raw)
In-Reply-To: <20141016102403.4715.34436.stgit@nfdev.cica.es>
On Thu, Oct 16, 2014 at 12:25:08PM +0200, Arturo Borrero Gonzalez wrote:
> diff --git a/net/netfilter/nft_redir.c b/net/netfilter/nft_redir.c
> new file mode 100644
> index 0000000..424cbf1
> --- /dev/null
> +++ b/net/netfilter/nft_redir.c
> @@ -0,0 +1,86 @@
> +/*
> + * Copyright (c) 2014 Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/module.h>
> +#include <linux/netlink.h>
> +#include <linux/netfilter.h>
> +#include <linux/netfilter/nf_tables.h>
> +#include <net/netfilter/nf_nat.h>
> +#include <net/netfilter/nf_tables.h>
> +#include <net/netfilter/nft_redir.h>
> +
> +const struct nla_policy nft_redir_policy[NFTA_REDIR_MAX + 1] = {
> + [NFTA_REDIR_REG_PROTO_MIN] = { .type = NLA_U32 },
> + [NFTA_REDIR_REG_PROTO_MAX] = { .type = NLA_U32 },
> + [NFTA_REDIR_FLAGS] = { .type = NLA_U16 },
> +};
> +EXPORT_SYMBOL_GPL(nft_redir_policy);
> +
> +int nft_redir_init(const struct nft_ctx *ctx,
> + const struct nft_expr *expr,
> + const struct nlattr * const tb[])
> +{
> + struct nft_redir *priv = nft_expr_priv(expr);
> + int err;
> +
> + if (tb[NFTA_REDIR_REG_PROTO_MIN]) {
> + priv->sreg_proto_min =
> + ntohl(nla_get_be32(tb[NFTA_REDIR_REG_PROTO_MIN]));
> + err = nft_validate_input_register(priv->sreg_proto_min);
> + if (err < 0)
> + return err;
Add the max handling here:
if (tb[NFTA_REDIR_REG_PROTO_MAX]) {
...
}
> + }
The idea is that NFTA_REDIR_REG_PROTO_MAX is only interpreted if
NFTA_REDIR_REG_PROTO_MIN is specified. I'll send a similar patch for
nft_nat.
Thanks Arturo.
next prev parent reply other threads:[~2014-10-16 12:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-16 10:23 [nf_tables PATCH v2 1/3] netfilter: refactor NAT redirect IPv4 to use it from nf_tables Arturo Borrero Gonzalez
2014-10-16 10:23 ` [nf_tables PATCH v2 2/3] netfilter: refactor NAT redirect IPv6 code " Arturo Borrero Gonzalez
2014-10-16 12:02 ` Pablo Neira Ayuso
2014-10-16 10:25 ` [nf_tables PATCH v2 3/3] netfilter: nf_tables: add new expression nft_redir Arturo Borrero Gonzalez
2014-10-16 12:00 ` Pablo Neira Ayuso
2014-10-16 12:05 ` Pablo Neira Ayuso [this message]
2014-10-30 16:28 ` [nf_tables PATCH v2 1/3] netfilter: refactor NAT redirect IPv4 to use it from nf_tables 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=20141016120523.GD3346@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).