]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
netfilter: move nat hlist_head to nf_conn
authorFlorian Westphal <fw@strlen.de>
Tue, 5 Jul 2016 10:07:23 +0000 (12:07 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 11 Jul 2016 09:47:50 +0000 (11:47 +0200)
commit7c9664351980aaa6a4b8837a314360b3a4ad382a
treeb3c4b235e53c9576adc9eb7eec5ea9a73d406e9b
parent242922a027176cd260c5adce4ba6bbfa3a05190c
netfilter: move nat hlist_head to nf_conn

The nat extension structure is 32bytes in size on x86_64:

struct nf_conn_nat {
        struct hlist_node          bysource;             /*     0    16 */
        struct nf_conn *           ct;                   /*    16     8 */
        union nf_conntrack_nat_help help;                /*    24     4 */
        int                        masq_index;           /*    28     4 */
        /* size: 32, cachelines: 1, members: 4 */
        /* last cacheline: 32 bytes */
};

The hlist is needed to quickly check for possible tuple collisions
when installing a new nat binding. Storing this in the extension
area has two drawbacks:

1. We need ct backpointer to get the conntrack struct from the extension.
2. When reallocation of extension area occurs we need to fixup the bysource
   hash head via hlist_replace_rcu.

We can avoid both by placing the hlist_head in nf_conn and place nf_conn in
the bysource hash rather than the extenstion.

We can also remove the ->move support; no other extension needs it.

Moving the entire nat extension into nf_conn would be possible as well but
then we have to add yet another callback for deletion from the bysource
hash table rather than just using nat extension ->destroy hook for this.

nf_conn size doesn't increase due to aligment, followup patch replaces
hlist_node with single pointer.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_conntrack.h
include/net/netfilter/nf_conntrack_extend.h
include/net/netfilter/nf_nat.h
net/netfilter/nf_conntrack_extend.c
net/netfilter/nf_nat_core.c