Commit b6b84d4a authored by Yasuyuki Kozakai's avatar Yasuyuki Kozakai Committed by David S. Miller

[NETFILTER]: nf_nat: merge nf_conn and nf_nat_info

Signed-off-by: default avatarYasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d8a0509a
...@@ -54,16 +54,6 @@ struct nf_nat_multi_range_compat ...@@ -54,16 +54,6 @@ struct nf_nat_multi_range_compat
#include <linux/netfilter/nf_conntrack_pptp.h> #include <linux/netfilter/nf_conntrack_pptp.h>
#include <net/netfilter/nf_conntrack_extend.h> #include <net/netfilter/nf_conntrack_extend.h>
struct nf_conn;
/* The structure embedded in the conntrack structure. */
struct nf_nat_info
{
struct list_head bysource;
struct nf_nat_seq seq[IP_CT_DIR_MAX];
struct nf_conn *ct;
};
/* per conntrack: nat application helper private data */ /* per conntrack: nat application helper private data */
union nf_conntrack_nat_help union nf_conntrack_nat_help
{ {
...@@ -71,9 +61,14 @@ union nf_conntrack_nat_help ...@@ -71,9 +61,14 @@ union nf_conntrack_nat_help
struct nf_nat_pptp nat_pptp_info; struct nf_nat_pptp nat_pptp_info;
}; };
struct nf_conn;
/* The structure embedded in the conntrack structure. */
struct nf_conn_nat struct nf_conn_nat
{ {
struct nf_nat_info info; struct list_head bysource;
struct nf_nat_seq seq[IP_CT_DIR_MAX];
struct nf_conn *ct;
union nf_conntrack_nat_help help; union nf_conntrack_nat_help help;
#if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \
defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE)
......
...@@ -155,8 +155,8 @@ find_appropriate_src(const struct nf_conntrack_tuple *tuple, ...@@ -155,8 +155,8 @@ find_appropriate_src(const struct nf_conntrack_tuple *tuple,
struct nf_conn *ct; struct nf_conn *ct;
read_lock_bh(&nf_nat_lock); read_lock_bh(&nf_nat_lock);
list_for_each_entry(nat, &bysource[h], info.bysource) { list_for_each_entry(nat, &bysource[h], bysource) {
ct = nat->info.ct; ct = nat->ct;
if (same_src(ct, tuple)) { if (same_src(ct, tuple)) {
/* Copy source part from reply tuple. */ /* Copy source part from reply tuple. */
nf_ct_invert_tuplepr(result, nf_ct_invert_tuplepr(result,
...@@ -284,7 +284,6 @@ nf_nat_setup_info(struct nf_conn *ct, ...@@ -284,7 +284,6 @@ nf_nat_setup_info(struct nf_conn *ct,
{ {
struct nf_conntrack_tuple curr_tuple, new_tuple; struct nf_conntrack_tuple curr_tuple, new_tuple;
struct nf_conn_nat *nat; struct nf_conn_nat *nat;
struct nf_nat_info *info;
int have_to_hash = !(ct->status & IPS_NAT_DONE_MASK); int have_to_hash = !(ct->status & IPS_NAT_DONE_MASK);
enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum); enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum);
...@@ -335,9 +334,9 @@ nf_nat_setup_info(struct nf_conn *ct, ...@@ -335,9 +334,9 @@ nf_nat_setup_info(struct nf_conn *ct,
srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
write_lock_bh(&nf_nat_lock); write_lock_bh(&nf_nat_lock);
/* nf_conntrack_alter_reply might re-allocate exntension aera */ /* nf_conntrack_alter_reply might re-allocate exntension aera */
info = &nfct_nat(ct)->info; nat = nfct_nat(ct);
info->ct = ct; nat->ct = ct;
list_add(&info->bysource, &bysource[srchash]); list_add(&nat->bysource, &bysource[srchash]);
write_unlock_bh(&nf_nat_lock); write_unlock_bh(&nf_nat_lock);
} }
...@@ -595,14 +594,14 @@ static void nf_nat_cleanup_conntrack(struct nf_conn *ct) ...@@ -595,14 +594,14 @@ static void nf_nat_cleanup_conntrack(struct nf_conn *ct)
{ {
struct nf_conn_nat *nat = nf_ct_ext_find(ct, NF_CT_EXT_NAT); struct nf_conn_nat *nat = nf_ct_ext_find(ct, NF_CT_EXT_NAT);
if (nat == NULL || nat->info.ct == NULL) if (nat == NULL || nat->ct == NULL)
return; return;
NF_CT_ASSERT(nat->info.ct->status & IPS_NAT_DONE_MASK); NF_CT_ASSERT(nat->ct->status & IPS_NAT_DONE_MASK);
write_lock_bh(&nf_nat_lock); write_lock_bh(&nf_nat_lock);
list_del(&nat->info.bysource); list_del(&nat->bysource);
nat->info.ct = NULL; nat->ct = NULL;
write_unlock_bh(&nf_nat_lock); write_unlock_bh(&nf_nat_lock);
} }
...@@ -610,7 +609,7 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old) ...@@ -610,7 +609,7 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old)
{ {
struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT); struct nf_conn_nat *new_nat = nf_ct_ext_find(conntrack, NF_CT_EXT_NAT);
struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old; struct nf_conn_nat *old_nat = (struct nf_conn_nat *)old;
struct nf_conn *ct = old_nat->info.ct; struct nf_conn *ct = old_nat->ct;
unsigned int srchash; unsigned int srchash;
if (!(ct->status & IPS_NAT_DONE_MASK)) if (!(ct->status & IPS_NAT_DONE_MASK))
...@@ -619,8 +618,8 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old) ...@@ -619,8 +618,8 @@ static void nf_nat_move_storage(struct nf_conn *conntrack, void *old)
srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
write_lock_bh(&nf_nat_lock); write_lock_bh(&nf_nat_lock);
list_replace(&old_nat->info.bysource, &new_nat->info.bysource); list_replace(&old_nat->bysource, &new_nat->bysource);
new_nat->info.ct = ct; new_nat->ct = ct;
write_unlock_bh(&nf_nat_lock); write_unlock_bh(&nf_nat_lock);
} }
......
...@@ -52,8 +52,8 @@ adjust_tcp_sequence(u32 seq, ...@@ -52,8 +52,8 @@ adjust_tcp_sequence(u32 seq,
dir = CTINFO2DIR(ctinfo); dir = CTINFO2DIR(ctinfo);
this_way = &nat->info.seq[dir]; this_way = &nat->seq[dir];
other_way = &nat->info.seq[!dir]; other_way = &nat->seq[!dir];
DEBUGP("nf_nat_resize_packet: Seq_offset before: "); DEBUGP("nf_nat_resize_packet: Seq_offset before: ");
DUMP_OFFSET(this_way); DUMP_OFFSET(this_way);
...@@ -372,8 +372,7 @@ nf_nat_sack_adjust(struct sk_buff **pskb, ...@@ -372,8 +372,7 @@ nf_nat_sack_adjust(struct sk_buff **pskb,
op[1] >= 2+TCPOLEN_SACK_PERBLOCK && op[1] >= 2+TCPOLEN_SACK_PERBLOCK &&
((op[1] - 2) % TCPOLEN_SACK_PERBLOCK) == 0) ((op[1] - 2) % TCPOLEN_SACK_PERBLOCK) == 0)
sack_adjust(*pskb, tcph, optoff+2, sack_adjust(*pskb, tcph, optoff+2,
optoff+op[1], optoff+op[1], &nat->seq[!dir]);
&nat->info.seq[!dir]);
optoff += op[1]; optoff += op[1];
} }
} }
...@@ -394,8 +393,8 @@ nf_nat_seq_adjust(struct sk_buff **pskb, ...@@ -394,8 +393,8 @@ nf_nat_seq_adjust(struct sk_buff **pskb,
dir = CTINFO2DIR(ctinfo); dir = CTINFO2DIR(ctinfo);
this_way = &nat->info.seq[dir]; this_way = &nat->seq[dir];
other_way = &nat->info.seq[!dir]; other_way = &nat->seq[!dir];
if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph))) if (!skb_make_writable(pskb, ip_hdrlen(*pskb) + sizeof(*tcph)))
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment