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/snprintf_default.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/expect/snprintf_default.c') diff --git a/src/expect/snprintf_default.c b/src/expect/snprintf_default.c index 7af9d15..77f9c3b 100644 --- a/src/expect/snprintf_default.c +++ b/src/expect/snprintf_default.c @@ -24,7 +24,7 @@ static int __snprintf_expect_proto(char *buf, const struct nf_expect *exp) { return(snprintf(buf, len, "proto=%d ", - exp->expected.tuple[__DIR_ORIG].protonum)); + exp->expected.orig.protonum)); } int __snprintf_expect_default(char *buf, @@ -58,30 +58,27 @@ int __snprintf_expect_default(char *buf, ret = __snprintf_expect_proto(buf+offset, len, exp); BUFFER_SIZE(ret, size, len, offset); - ret = __snprintf_address(buf+offset, len, - &exp->expected.tuple[__DIR_ORIG], + ret = __snprintf_address(buf+offset, len, &exp->expected.orig, "src", "dst"); BUFFER_SIZE(ret, size, len, offset); - ret = __snprintf_proto(buf+offset, len, &exp->expected.tuple[__DIR_ORIG]); + ret = __snprintf_proto(buf+offset, len, &exp->expected.orig); BUFFER_SIZE(ret, size, len, offset); - ret = __snprintf_address(buf+offset, len, - &exp->mask.tuple[__DIR_ORIG], + ret = __snprintf_address(buf+offset, len, &exp->mask.orig, "mask-src", "mask-dst"); BUFFER_SIZE(ret, size, len, offset); ret = __snprintf_proto(buf+offset, len, - &exp->mask.tuple[__DIR_ORIG]); + &exp->mask.orig); BUFFER_SIZE(ret, size, len, offset); - ret = __snprintf_address(buf+offset, len, - &exp->master.tuple[__DIR_ORIG], + ret = __snprintf_address(buf+offset, len, &exp->master.orig, "master-src", "master-dst"); BUFFER_SIZE(ret, size, len, offset); ret = __snprintf_proto(buf+offset, len, - &exp->master.tuple[__DIR_ORIG]); + &exp->master.orig); BUFFER_SIZE(ret, size, len, offset); if (test_bit(ATTR_EXP_ZONE, exp->set)) { -- cgit v1.2.3