Skip to content

Commit

Permalink
netfilter: xt_CT: add alias flag
Browse files Browse the repository at this point in the history
This patch adds the alias flag to support full NOTRACK target
aliasing.

Based on initial patch from Jozsef Kadlecsik.

Acked-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hi>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Pablo Neira Ayuso committed Feb 5, 2013
1 parent d52ed43 commit 5474f57
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
6 changes: 5 additions & 1 deletion include/uapi/linux/netfilter/xt_CT.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

#include <linux/types.h>

#define XT_CT_NOTRACK 0x1
enum {
XT_CT_NOTRACK = 1 << 0,
XT_CT_NOTRACK_ALIAS = 1 << 1,
XT_CT_MASK = XT_CT_NOTRACK | XT_CT_NOTRACK_ALIAS,
};

struct xt_ct_target_info {
__u16 flags;
Expand Down
32 changes: 29 additions & 3 deletions net/netfilter/xt_CT.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
struct nf_conn *ct;
int ret = -EOPNOTSUPP;

if (info->flags & ~XT_CT_NOTRACK)
return -EINVAL;

if (info->flags & XT_CT_NOTRACK) {
ct = nf_ct_untracked_get();
atomic_inc(&ct->ct_general.use);
Expand Down Expand Up @@ -256,6 +253,9 @@ static int xt_ct_tg_check_v0(const struct xt_tgchk_param *par)
};
int ret;

if (info->flags & ~XT_CT_NOTRACK)
return -EINVAL;

memcpy(info_v1.helper, info->helper, sizeof(info->helper));

ret = xt_ct_tg_check(par, &info_v1);
Expand All @@ -269,6 +269,21 @@ static int xt_ct_tg_check_v0(const struct xt_tgchk_param *par)

static int xt_ct_tg_check_v1(const struct xt_tgchk_param *par)
{
struct xt_ct_target_info_v1 *info = par->targinfo;

if (info->flags & ~XT_CT_NOTRACK)
return -EINVAL;

return xt_ct_tg_check(par, par->targinfo);
}

static int xt_ct_tg_check_v2(const struct xt_tgchk_param *par)
{
struct xt_ct_target_info_v1 *info = par->targinfo;

if (info->flags & ~XT_CT_MASK)
return -EINVAL;

return xt_ct_tg_check(par, par->targinfo);
}

Expand Down Expand Up @@ -350,6 +365,17 @@ static struct xt_target xt_ct_tg_reg[] __read_mostly = {
.table = "raw",
.me = THIS_MODULE,
},
{
.name = "CT",
.family = NFPROTO_UNSPEC,
.revision = 2,
.targetsize = sizeof(struct xt_ct_target_info_v1),
.checkentry = xt_ct_tg_check_v2,
.destroy = xt_ct_tg_destroy_v1,
.target = xt_ct_target_v1,
.table = "raw",
.me = THIS_MODULE,
},
};

static unsigned int
Expand Down

0 comments on commit 5474f57

Please sign in to comment.