summaryrefslogtreecommitdiffstats
path: root/src/conntrack/grp_setter.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2012-01-04 11:50:28 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2012-01-04 12:08:22 +0100
commit00c2c9dca32eb8eb8687b42fc6d135f35eaa5ff8 (patch)
tree165dc4759be70221168fe401c8c7b8114ea3039e /src/conntrack/grp_setter.c
parentac39464a7619955adf9b317c829a0de0379d7c04 (diff)
src: put nf_expect and nf_conntrack into diet
Now, struct nf_expect takes only 192 bytes, instead of 1KB. struct nf_conntrack takes 296 bytes instead of 328 bytes. The size of the nf_expect structure has been reduced by rearranging the layout of the nf_conntrack structure. For the nf_conntrack case, this removes the allocation of room for attributes that the master tuple does not use (more specifically, the NATseq bytes). This patch modifies the binary layout of struct nf_conntrack. This should not be a problem since the definition of this object is opaque (it can be only accessed via get/set API). Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/conntrack/grp_setter.c')
-rw-r--r--src/conntrack/grp_setter.c64
1 files changed, 32 insertions, 32 deletions
diff --git a/src/conntrack/grp_setter.c b/src/conntrack/grp_setter.c
index 324aa4c..0492a84 100644
--- a/src/conntrack/grp_setter.c
+++ b/src/conntrack/grp_setter.c
@@ -40,47 +40,47 @@ static const u_int8_t invmap_icmpv6[] = {
static void set_attr_grp_orig_ipv4(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_ipv4 *this = value;
- ct->tuple[__DIR_ORIG].src.v4 = this->src;
- ct->tuple[__DIR_ORIG].dst.v4 = this->dst;
- ct->tuple[__DIR_ORIG].l3protonum = AF_INET;
+ ct->head.orig.src.v4 = this->src;
+ ct->head.orig.dst.v4 = this->dst;
+ ct->head.orig.l3protonum = AF_INET;
}
static void set_attr_grp_repl_ipv4(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_ipv4 *this = value;
- ct->tuple[__DIR_REPL].src.v4 = this->src;
- ct->tuple[__DIR_REPL].dst.v4 = this->dst;
- ct->tuple[__DIR_REPL].l3protonum = AF_INET;
+ ct->repl.src.v4 = this->src;
+ ct->repl.dst.v4 = this->dst;
+ ct->repl.l3protonum = AF_INET;
}
static void set_attr_grp_orig_ipv6(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_ipv6 *this = value;
- memcpy(&ct->tuple[__DIR_ORIG].src.v6, this->src, sizeof(u_int32_t)*4);
- memcpy(&ct->tuple[__DIR_ORIG].dst.v6, this->dst, sizeof(u_int32_t)*4);
- ct->tuple[__DIR_ORIG].l3protonum = AF_INET6;
+ memcpy(&ct->head.orig.src.v6, this->src, sizeof(u_int32_t)*4);
+ memcpy(&ct->head.orig.dst.v6, this->dst, sizeof(u_int32_t)*4);
+ ct->head.orig.l3protonum = AF_INET6;
}
static void set_attr_grp_repl_ipv6(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_ipv6 *this = value;
- memcpy(&ct->tuple[__DIR_REPL].src.v6, this->src, sizeof(u_int32_t)*4);
- memcpy(&ct->tuple[__DIR_REPL].dst.v6, this->dst, sizeof(u_int32_t)*4);
- ct->tuple[__DIR_REPL].l3protonum = AF_INET6;
+ memcpy(&ct->repl.src.v6, this->src, sizeof(u_int32_t)*4);
+ memcpy(&ct->repl.dst.v6, this->dst, sizeof(u_int32_t)*4);
+ ct->repl.l3protonum = AF_INET6;
}
static void set_attr_grp_orig_port(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_port *this = value;
- ct->tuple[__DIR_ORIG].l4src.all = this->sport;
- ct->tuple[__DIR_ORIG].l4dst.all = this->dport;
+ ct->head.orig.l4src.all = this->sport;
+ ct->head.orig.l4dst.all = this->dport;
}
static void set_attr_grp_repl_port(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_port *this = value;
- ct->tuple[__DIR_REPL].l4src.all = this->sport;
- ct->tuple[__DIR_REPL].l4dst.all = this->dport;
+ ct->repl.l4src.all = this->sport;
+ ct->repl.l4dst.all = this->dport;
}
static void set_attr_grp_icmp(struct nf_conntrack *ct, const void *value)
@@ -88,9 +88,9 @@ static void set_attr_grp_icmp(struct nf_conntrack *ct, const void *value)
u_int8_t rtype;
const struct nfct_attr_grp_icmp *this = value;
- ct->tuple[__DIR_ORIG].l4dst.icmp.type = this->type;
+ ct->head.orig.l4dst.icmp.type = this->type;
- switch(ct->tuple[__DIR_ORIG].l3protonum) {
+ switch(ct->head.orig.l3protonum) {
case AF_INET:
rtype = invmap_icmp[this->type];
break;
@@ -104,38 +104,38 @@ static void set_attr_grp_icmp(struct nf_conntrack *ct, const void *value)
}
if (rtype)
- ct->tuple[__DIR_REPL].l4dst.icmp.type = rtype - 1;
+ ct->repl.l4dst.icmp.type = rtype - 1;
else
- ct->tuple[__DIR_REPL].l4dst.icmp.type = 255; /* -EINVAL */
+ ct->repl.l4dst.icmp.type = 255; /* -EINVAL */
- ct->tuple[__DIR_ORIG].l4dst.icmp.code = this->code;
- ct->tuple[__DIR_REPL].l4dst.icmp.code = this->code;
+ ct->head.orig.l4dst.icmp.code = this->code;
+ ct->repl.l4dst.icmp.code = this->code;
- ct->tuple[__DIR_ORIG].l4src.icmp.id = this->id;
- ct->tuple[__DIR_REPL].l4src.icmp.id = this->id;
+ ct->head.orig.l4src.icmp.id = this->id;
+ ct->repl.l4src.icmp.id = this->id;
}
static void set_attr_grp_master_ipv4(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_ipv4 *this = value;
- ct->tuple[__DIR_MASTER].src.v4 = this->src;
- ct->tuple[__DIR_MASTER].dst.v4 = this->dst;
- ct->tuple[__DIR_MASTER].l3protonum = AF_INET;
+ ct->master.src.v4 = this->src;
+ ct->master.dst.v4 = this->dst;
+ ct->master.l3protonum = AF_INET;
}
static void set_attr_grp_master_ipv6(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_ipv6 *this = value;
- memcpy(&ct->tuple[__DIR_MASTER].src.v6, this->src, sizeof(u_int32_t)*4);
- memcpy(&ct->tuple[__DIR_MASTER].dst.v6, this->dst, sizeof(u_int32_t)*4);
- ct->tuple[__DIR_MASTER].l3protonum = AF_INET6;
+ memcpy(&ct->master.src.v6, this->src, sizeof(u_int32_t)*4);
+ memcpy(&ct->master.dst.v6, this->dst, sizeof(u_int32_t)*4);
+ ct->master.l3protonum = AF_INET6;
}
static void set_attr_grp_master_port(struct nf_conntrack *ct, const void *value)
{
const struct nfct_attr_grp_port *this = value;
- ct->tuple[__DIR_MASTER].l4src.all = this->sport;
- ct->tuple[__DIR_MASTER].l4dst.all = this->dport;
+ ct->master.l4src.all = this->sport;
+ ct->master.l4dst.all = this->dport;
}
static void set_attr_grp_do_nothing(struct nf_conntrack *ct, const void *value)