Commit e54cbc1f91dea4f98b6209e693d3b5eae46321bd
Committed by
David S. Miller
1 parent
ceceae1b15
Exists in
master
and in
7 other branches
[NETFILTER]: nf_nat: add reference to conntrack from entry of bysource list
I will split 'struct nf_nat_info' out from conntrack. So I cannot use 'offsetof' to get the pointer to conntrack from it. Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 2 changed files with 6 additions and 3 deletions Side-by-side Diff
include/net/netfilter/nf_nat.h
... | ... | @@ -53,11 +53,14 @@ |
53 | 53 | #include <linux/list.h> |
54 | 54 | #include <linux/netfilter/nf_conntrack_pptp.h> |
55 | 55 | |
56 | +struct nf_conn; | |
57 | + | |
56 | 58 | /* The structure embedded in the conntrack structure. */ |
57 | 59 | struct nf_nat_info |
58 | 60 | { |
59 | 61 | struct list_head bysource; |
60 | 62 | struct nf_nat_seq seq[IP_CT_DIR_MAX]; |
63 | + struct nf_conn *ct; | |
61 | 64 | }; |
62 | 65 | |
63 | 66 | /* per conntrack: nat application helper private data */ |
... | ... | @@ -76,8 +79,6 @@ |
76 | 79 | int masq_index; |
77 | 80 | #endif |
78 | 81 | }; |
79 | - | |
80 | -struct nf_conn; | |
81 | 82 | |
82 | 83 | /* Set up the info structure to map into this range. */ |
83 | 84 | extern unsigned int nf_nat_setup_info(struct nf_conn *ct, |
net/ipv4/netfilter/nf_nat_core.c
... | ... | @@ -97,6 +97,7 @@ |
97 | 97 | nat = nfct_nat(conn); |
98 | 98 | write_lock_bh(&nf_nat_lock); |
99 | 99 | list_del(&nat->info.bysource); |
100 | + nat->info.ct = NULL; | |
100 | 101 | write_unlock_bh(&nf_nat_lock); |
101 | 102 | } |
102 | 103 | |
... | ... | @@ -169,7 +170,7 @@ |
169 | 170 | |
170 | 171 | read_lock_bh(&nf_nat_lock); |
171 | 172 | list_for_each_entry(nat, &bysource[h], info.bysource) { |
172 | - ct = (struct nf_conn *)((char *)nat - offsetof(struct nf_conn, data)); | |
173 | + ct = nat->info.ct; | |
173 | 174 | if (same_src(ct, tuple)) { |
174 | 175 | /* Copy source part from reply tuple. */ |
175 | 176 | nf_ct_invert_tuplepr(result, |
... | ... | @@ -337,6 +338,7 @@ |
337 | 338 | |
338 | 339 | srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); |
339 | 340 | write_lock_bh(&nf_nat_lock); |
341 | + info->ct = ct; | |
340 | 342 | list_add(&info->bysource, &bysource[srchash]); |
341 | 343 | write_unlock_bh(&nf_nat_lock); |
342 | 344 | } |