Re: [nf_tables PATCH v2 3/3] netfilter: nf_tables: add new expression nft_redir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> + *
> + * 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.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux