From 00c2c9dca32eb8eb8687b42fc6d135f35eaa5ff8 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 4 Jan 2012 11:50:28 +0100 Subject: 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 --- src/expect/build.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/expect/build.c') diff --git a/src/expect/build.c b/src/expect/build.c index 175698a..7fefd5f 100644 --- a/src/expect/build.c +++ b/src/expect/build.c @@ -45,9 +45,9 @@ int __build_expect(struct nfnl_subsys_handle *ssh, u_int8_t l3num; if (test_bit(ATTR_ORIG_L3PROTO, exp->master.set)) - l3num = exp->master.tuple[__DIR_ORIG].l3protonum; + l3num = exp->master.orig.l3protonum; else if (test_bit(ATTR_ORIG_L3PROTO, exp->expected.set)) - l3num = exp->expected.tuple[__DIR_ORIG].l3protonum; + l3num = exp->expected.orig.l3protonum; else return -1; @@ -56,24 +56,15 @@ int __build_expect(struct nfnl_subsys_handle *ssh, nfnl_fill_hdr(ssh, &req->nlh, 0, l3num, 0, type, flags); if (test_bit(ATTR_EXP_EXPECTED, exp->set)) { - __build_tuple(req, - size, - &exp->expected.tuple[__DIR_ORIG], - CTA_EXPECT_TUPLE); + __build_tuple(req, size, &exp->expected.orig, CTA_EXPECT_TUPLE); } if (test_bit(ATTR_EXP_MASTER, exp->set)) { - __build_tuple(req, - size, - &exp->master.tuple[__DIR_ORIG], - CTA_EXPECT_MASTER); + __build_tuple(req, size, &exp->master.orig, CTA_EXPECT_MASTER); } if (test_bit(ATTR_EXP_MASK, exp->set)) { - __build_tuple(req, - size, - &exp->mask.tuple[__DIR_ORIG], - CTA_EXPECT_MASK); + __build_tuple(req, size, &exp->mask.orig, CTA_EXPECT_MASK); } if (test_bit(ATTR_EXP_TIMEOUT, exp->set)) -- cgit v1.2.3